def test_polar_stereographic_b_operation__defaults(): aeop = PolarStereographicBConversion() assert aeop.name == "unknown" assert aeop.method_name == "Polar Stereographic (variant B)" assert _to_dict(aeop) == { "Latitude of standard parallel": 0.0, "Longitude of origin": 0.0, "False easting": 0.0, "False northing": 0.0, }
def test_polar_stereographic_b_operation(): aeop = PolarStereographicBConversion( latitude_standard_parallel=1, longitude_origin=2, false_easting=3, false_northing=4, ) assert aeop.name == "unknown" assert aeop.method_name == "Polar Stereographic (variant B)" assert _to_dict(aeop) == { "Latitude of standard parallel": 1.0, "Longitude of origin": 2.0, "False easting": 3.0, "False northing": 4.0, }
def _polar_stereographic(cf_params): """ http://cfconventions.org/cf-conventions/cf-conventions.html#polar-stereographic """ if "standard_parallel" in cf_params: return PolarStereographicBConversion( latitude_standard_parallel=cf_params["standard_parallel"], longitude_origin=cf_params["straight_vertical_longitude_from_pole"], false_easting=cf_params.get("false_easting", 0.0), false_northing=cf_params.get("false_northing", 0.0), ) return PolarStereographicAConversion( latitude_natural_origin=cf_params["latitude_of_projection_origin"], longitude_natural_origin=cf_params["straight_vertical_longitude_from_pole"], false_easting=cf_params.get("false_easting", 0.0), false_northing=cf_params.get("false_northing", 0.0), scale_factor_natural_origin=cf_params.get( "scale_factor_at_projection_origin", 1.0 ), )
def test_polar_stereographic_b(): crs = ProjectedCRS(conversion=PolarStereographicBConversion(0, 1, 2, 3)) expected_cf = { "semi_major_axis": 6378137.0, "semi_minor_axis": crs.ellipsoid.semi_minor_metre, "inverse_flattening": crs.ellipsoid.inverse_flattening, "reference_ellipsoid_name": "WGS 84", "longitude_of_prime_meridian": 0.0, "prime_meridian_name": "Greenwich", "horizontal_datum_name": "World Geodetic System 1984", "grid_mapping_name": "polar_stereographic", "standard_parallel": 0.0, "straight_vertical_longitude_from_pole": 1.0, "false_easting": 2.0, "false_northing": 3.0, } cf_dict = crs.to_cf() assert cf_dict.pop("crs_wkt").startswith("PROJCRS[") assert cf_dict == expected_cf # test roundtrip _test_roundtrip(expected_cf, "PROJCRS[")