def test_coordinate_system__from_string(): cs = CoordinateSystem.from_string( '{"$schema":"https://proj.org/schemas/v0.2/projjson.schema.json",' '"type":"CoordinateSystem","subtype":"ellipsoidal",' '"axis":[{"name":"Geodetic latitude","abbreviation":"Lat",' '"direction":"north","unit":"degree"},' '{"name":"Geodetic longitude","abbreviation":"Lon",' '"direction":"east","unit":"degree"}],' '"id":{"authority":"EPSG","code":6422}}') assert cs.name == "ellipsoidal"
def test_coordinate_system__from_user_input__invalid(user_input): with pytest.raises(CRSError, match="Invalid"): CoordinateSystem.from_user_input(user_input)
def test_coordinate_system__from_user_input(user_input): assert CoordinateSystem.from_user_input( user_input) == CoordinateSystem.from_json_dict(CS_JSON_DICT)
def test_coordinate_system__from_string__invalid(invalid_cs_string): with pytest.raises(CRSError, match="Invalid coordinate system string"): CoordinateSystem.from_string(invalid_cs_string)
def test_coordinate_system__from_string(): cs = CoordinateSystem.from_string(_COORDINATE_SYSTEM_STR) assert cs.name == "ellipsoidal"
def test_coordinate_system__equals(): cs = CoordinateSystem.from_string(_COORDINATE_SYSTEM_STR) assert cs == _COORDINATE_SYSTEM_STR assert not cs != _COORDINATE_SYSTEM_STR assert cs != "invalid"
{ "name": "Northing", "abbreviation": "N", "direction": "north", "unit": "metre", }, ], } @pytest.mark.parametrize( "user_input", [ CS_JSON_DICT, json.dumps(CS_JSON_DICT), CoordinateSystem.from_json_dict(CS_JSON_DICT), ], ) def test_coordinate_system__from_user_input(user_input): assert CoordinateSystem.from_user_input( user_input) == CoordinateSystem.from_json_dict(CS_JSON_DICT) @pytest.mark.parametrize( "user_input", [ 7001, ("EPSG", 7001), "urn:ogc:def:ellipsoid:EPSG::7001", Ellipsoid.from_epsg(7001), Ellipsoid.from_epsg(7001).to_json_dict(),
def test_coordinate_system_from_json(): # separate test from other properties due to # https://github.com/OSGeo/PROJ/issues/1818 aeqd_cs = CRS(proj="aeqd", lon_0=-80, lat_0=40.5).coordinate_system assert CoordinateSystem.from_json(aeqd_cs.to_json()) == aeqd_cs