def test_make_geographic_3d_crs(): gcrs = GeographicCRS(ellipsoidal_cs=Ellipsoidal3DCS()) assert gcrs.type_name == "Geographic 3D CRS" expected_authority = ("IGNF", "WGS84GEODD") if PROJ_GTE_901: expected_authority = ("OGC", "CRS84h") assert gcrs.to_authority() == expected_authority
def test_compund_crs(): vertcrs = VerticalCRS( name="NAVD88 height", datum="North American Vertical Datum 1988", vertical_cs=VerticalCS(), geoid_model="GEOID12B", ) projcrs = ProjectedCRS( name="NAD83 / Pennsylvania South", conversion=LambertConformalConic2SPConversion( latitude_false_origin=39.3333333333333, longitude_false_origin=-77.75, latitude_first_parallel=40.9666666666667, latitude_second_parallel=39.9333333333333, easting_false_origin=600000, northing_false_origin=0, ), geodetic_crs=GeographicCRS(datum="North American Datum 1983"), cartesian_cs=Cartesian2DCS(), ) compcrs = CompoundCRS( name="NAD83 / Pennsylvania South + NAVD88 height", components=[projcrs, vertcrs] ) assert compcrs.name == "NAD83 / Pennsylvania South + NAVD88 height" assert compcrs.type_name == "Compound CRS" assert compcrs.sub_crs_list[0].type_name == "Projected CRS" assert compcrs.sub_crs_list[1].type_name == "Vertical CRS"
def test_bound_crs__example(): proj_crs = ProjectedCRS( conversion=TransverseMercatorConversion( latitude_natural_origin=0, longitude_natural_origin=15, false_easting=2520000, false_northing=0, scale_factor_natural_origin=0.9996, ), geodetic_crs=GeographicCRS( datum=CustomDatum(ellipsoid="International 1909 (Hayford)") ), ) bound_crs = BoundCRS( source_crs=proj_crs, target_crs="WGS 84", transformation=ToWGS84Transformation( proj_crs.geodetic_crs, -122.74, -34.27, -22.83, -1.884, -3.4, -3.03, -15.62 ), ) with pytest.warns(UserWarning): assert bound_crs.to_dict() == { "ellps": "intl", "k": 0.9996, "lat_0": 0, "lon_0": 15, "no_defs": None, "proj": "tmerc", "towgs84": [-122.74, -34.27, -22.83, -1.884, -3.4, -3.03, -15.62], "type": "crs", "units": "m", "x_0": 2520000, "y_0": 0, }
def test_make_derived_geographic_crs(tmp_path): conversion = RotatedLatitudeLongitudeConversion(o_lat_p=0, o_lon_p=0) dgc = DerivedGeographicCRS(base_crs=GeographicCRS(), conversion=conversion) assert dgc.name == "undefined" assert dgc.type_name == "Derived Geographic 2D CRS" assert dgc.coordinate_operation == conversion assert dgc.is_derived assert_can_pickle(dgc, tmp_path)
def test_geographic_crs__from_methods(): assert_maker_inheritance_valid(GeographicCRS.from_epsg(4326), GeographicCRS) assert_maker_inheritance_valid(GeographicCRS.from_string("EPSG:4326"), GeographicCRS) assert_maker_inheritance_valid(GeographicCRS.from_proj4("+proj=latlon"), GeographicCRS) assert_maker_inheritance_valid( GeographicCRS.from_user_input(GeographicCRS.from_string("EPSG:4326")), GeographicCRS, ) assert_maker_inheritance_valid( GeographicCRS.from_json(CRS(4326).to_json()), GeographicCRS) assert_maker_inheritance_valid( GeographicCRS.from_json_dict(CRS(4326).to_json_dict()), GeographicCRS) with pytest.raises(CRSError, match="Invalid type"): GeographicCRS.from_epsg(6933)
def test_towgs84_transformation__defaults(): transformation = ToWGS84Transformation(GeographicCRS()) assert transformation.towgs84 == [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] assert _to_dict(transformation) == { "Scale difference": 0.0, "X-axis rotation": 0.0, "X-axis translation": 0.0, "Y-axis rotation": 0.0, "Y-axis translation": 0.0, "Z-axis rotation": 0.0, "Z-axis translation": 0.0, }
def test_towgs84_transformation(): transformation = ToWGS84Transformation(GeographicCRS(), 1, 2, 3, 4, 5, 6, 7) assert transformation.towgs84 == [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0] assert _to_dict(transformation) == { "Scale difference": 7.0, "X-axis rotation": 4.0, "X-axis translation": 1.0, "Y-axis rotation": 5.0, "Y-axis translation": 2.0, "Z-axis rotation": 6.0, "Z-axis translation": 3.0, }
def test_make_geographic_3d_crs(): gcrs = GeographicCRS(ellipsoidal_cs=Ellipsoidal3DCS()) assert gcrs.type_name == "Geographic 3D CRS" assert gcrs.to_authority() == ("IGNF", "WGS84GEODD")
def test_make_geographic_crs(): gc = GeographicCRS(name="WGS 84") assert gc.name == "WGS 84" assert gc.type_name == "Geographic 2D CRS" assert gc.to_authority() == ("OGC", "CRS84")
def test_make_geographic_crs(tmp_path): gc = GeographicCRS(name="WGS 84") assert gc.name == "WGS 84" assert gc.type_name == "Geographic 2D CRS" assert gc.to_authority() == ("OGC", "CRS84") assert_can_pickle(gc, tmp_path)