Beispiel #1
0
def test_datum_from_name__auth_type(auth_name):
    dd = Datum.from_name(
        "WGS_1984_Geoid",
        auth_name=auth_name,
        datum_type=DatumType.VERTICAL_REFERENCE_FRAME,
    )
    assert dd.name == "WGS_1984_Geoid"
Beispiel #2
0
def test_datum__from_epsg():
    if PROJ_GTE_82:
        datum_wkt = (
            'ENSEMBLE["World Geodetic System 1984 ensemble",'
            'MEMBER["World Geodetic System 1984 (Transit)",ID["EPSG",1166]],'
            'MEMBER["World Geodetic System 1984 (G730)",ID["EPSG",1152]],'
            'MEMBER["World Geodetic System 1984 (G873)",ID["EPSG",1153]],'
            'MEMBER["World Geodetic System 1984 (G1150)",ID["EPSG",1154]],'
            'MEMBER["World Geodetic System 1984 (G1674)",ID["EPSG",1155]],'
            'MEMBER["World Geodetic System 1984 (G1762)",ID["EPSG",1156]],'
            'MEMBER["World Geodetic System 1984 (G2139)",ID["EPSG",1309]],'
            'ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1],'
            'ID["EPSG",7030]],ENSEMBLEACCURACY[2.0],ID["EPSG",6326]]'
        )
    else:
        datum_wkt = (
            'ENSEMBLE["World Geodetic System 1984 ensemble",'
            'MEMBER["World Geodetic System 1984 (Transit)",ID["EPSG",1166]],'
            'MEMBER["World Geodetic System 1984 (G730)",ID["EPSG",1152]],'
            'MEMBER["World Geodetic System 1984 (G873)",ID["EPSG",1153]],'
            'MEMBER["World Geodetic System 1984 (G1150)",ID["EPSG",1154]],'
            'MEMBER["World Geodetic System 1984 (G1674)",ID["EPSG",1155]],'
            'MEMBER["World Geodetic System 1984 (G1762)",ID["EPSG",1156]],'
            'ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1],'
            'ID["EPSG",7030]],ENSEMBLEACCURACY[2.0],ID["EPSG",6326]]'
        )
    assert Datum.from_epsg("6326").to_wkt() == datum_wkt
Beispiel #3
0
def test_datum__from_string(input_str):
    dd = Datum.from_string(input_str)
    if PROJ_GTE_8:
        assert dd.name == "World Geodetic System 1984 ensemble"
        assert dd.type_name == "Datum Ensemble"
    else:
        assert dd.name == "World Geodetic System 1984"
        assert dd.type_name == "Geodetic Reference Frame"
Beispiel #4
0
def test_datum__from_authority__invalid():
    with pytest.raises(CRSError, match="Invalid authority"):
        Datum.from_authority("BOB", 1)
Beispiel #5
0
def test_datum__from_epsg__invalid():
    with pytest.raises(CRSError, match="Invalid authority"):
        Datum.from_epsg(1)
Beispiel #6
0
def test_datum__from_epsg__empty():
    Datum.from_epsg(1) is None
Beispiel #7
0
def test_datum__from_name__invalid_type():
    with pytest.raises(CRSError, match="Invalid datum name: WGS84"):
        Datum.from_name("WGS84", datum_type="VERTICAL_REFERENCE_FRAME")
Beispiel #8
0
def test_datum_from_name__any_type():
    dd = Datum.from_name("WGS_1984_Geoid")
    assert dd.name == "WGS_1984_Geoid"
    assert dd.type_name == "Vertical Reference Frame"
Beispiel #9
0
def test_datum__from_string__type_name(input_str, type_name):
    dd = Datum.from_string(input_str)
    assert dd.type_name == type_name
Beispiel #10
0
def test_datum_equals():
    datum = Datum.from_epsg(6326)
    assert datum == 6326
    assert not datum != 6326
    assert datum != "invalid"
Beispiel #11
0
def test_datum__from_string__invalid():
    with pytest.raises(CRSError, match="Invalid datum string"):
        Datum.from_string("3-598y5-98y")
    with pytest.raises(CRSError, match="Invalid datum string"):
        Datum.from_string("urn:ogc:def:ellipsoid:EPSG::7001")
Beispiel #12
0
def test_datum__from_string():
    dd = Datum.from_string("urn:ogc:def:datum:EPSG::6326")
    assert dd.name == "World Geodetic System 1984"
Beispiel #13
0
def test_datum__from_epsg():
    assert Datum.from_epsg("6326").to_wkt() == (
        'DATUM["World Geodetic System 1984",'
        'ELLIPSOID["WGS 84",6378137,298.257223563,'
        'LENGTHUNIT["metre",1]],ID["EPSG",6326]]')
Beispiel #14
0
def test_datum__from_string(input_str):
    dd = Datum.from_string(input_str)
    assert dd.name == "World Geodetic System 1984"
    assert dd.type_name == "Geodetic Reference Frame"
Beispiel #15
0
def test_datum__from_string(input_str):
    dd = Datum.from_string(input_str)
    assert dd.name == "World Geodetic System 1984"
Beispiel #16
0
def test_datum__from_user_input(user_input):
    assert Datum.from_user_input(user_input) == Datum.from_epsg(6326)
Beispiel #17
0
def test_datum__from_user_input__invalid():
    with pytest.raises(CRSError, match="Invalid datum"):
        Datum.from_user_input({})
Beispiel #18
0
def test_datum__from_authority():
    dt = Datum.from_authority("EPSG", 6326)
    assert dt.name == "World Geodetic System 1984 ensemble"
Beispiel #19
0
def test_datum__from_string(input_str):
    dd = Datum.from_string(input_str)
    assert dd.name == "World Geodetic System 1984 ensemble"
    assert dd.type_name == "Datum Ensemble"
Beispiel #20
0
def test_datum__from_name(input_name):
    dd = Datum.from_name(input_name)
    assert dd.name == "World Geodetic System 1984 ensemble"
Beispiel #21
0
def test_datum__from_name(input_name):
    dd = Datum.from_name(input_name)
    assert dd.name == get_wgs84_datum_name()
Beispiel #22
0
        Datum.from_epsg(1)


def test_datum__from_authority__invalid():
    with pytest.raises(CRSError, match="Invalid authority"):
        Datum.from_authority("BOB", 1)


@pytest.mark.parametrize(
    "user_input",
    [
        6326,
        ("EPSG", 6326),
        "urn:ogc:def:ensemble:EPSG::6326"
        if PROJ_GTE_8 else "urn:ogc:def:datum:EPSG::6326",
        Datum.from_epsg(6326),
        Datum.from_epsg(6326).to_json_dict(),
        "World Geodetic System 1984",
    ],
)
def test_datum__from_user_input(user_input):
    assert Datum.from_user_input(user_input) == Datum.from_epsg(6326)


def test_datum__from_user_input__invalid():
    with pytest.raises(CRSError, match="Invalid datum"):
        Datum.from_user_input({})


def test_prime_meridian__from_epsg():
    assert PrimeMeridian.from_epsg(8903).to_wkt() == (
Beispiel #23
0
def test_datum__from_name__invalid(invalid_str):
    with pytest.raises(CRSError, match="Invalid datum name:"):
        Datum.from_name(invalid_str)
Beispiel #24
0
def test_datum__from_authority():
    dt = Datum.from_authority("EPSG", 6326)
    assert dt.name == get_wgs84_datum_name()
Beispiel #25
0
def test_datum__from_string__invalid(invalid_str):
    with pytest.raises(CRSError, match="Invalid datum string"):
        Datum.from_string(invalid_str)
Beispiel #26
0
def test_datum__from_epsg():
    assert Datum.from_epsg("6326").to_wkt() == (
        'DATUM["World Geodetic System 1984",'
        'ELLIPSOID["WGS 84",6378137,298.257223563,'
        'LENGTHUNIT["metre",1]],ID["EPSG",6326]]'
    )