def test_vertical_perspective(): crs = ProjectedCRS( conversion=VerticalPerspectiveConversion(50, 0, 1, 0, 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": "vertical_perspective", "perspective_point_height": 50.0, "latitude_of_projection_origin": 0.0, "longitude_of_projection_origin": 1.0, "false_easting": 2.0, "false_northing": 3.0, "geographic_crs_name": "undefined", "projected_crs_name": "undefined", } 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[")
def test_vertical_perspective_operation__defaults(): aeaop = VerticalPerspectiveConversion(viewpoint_height=10) assert aeaop.name == "unknown" assert aeaop.method_name == "Vertical Perspective" assert _to_dict(aeaop) == { "Latitude of topocentric origin": 0.0, "Longitude of topocentric origin": 0.0, "Ellipsoidal height of topocentric origin": 0.0, "Viewpoint height": 10.0, "False easting": 0.0, "False northing": 0.0, }
def _vertical_perspective(cf_params): """ http://cfconventions.org/cf-conventions/cf-conventions.html#vertical-perspective """ return VerticalPerspectiveConversion( viewpoint_height=cf_params["perspective_point_height"], latitude_topocentric_origin=cf_params.get( "latitude_of_projection_origin", 0.0), longitude_topocentric_origin=cf_params.get( "longitude_of_projection_origin", 0.0), false_easting=cf_params.get("false_easting", 0.0), false_northing=cf_params.get("false_northing", 0.0), )
def test_vertical_perspective_operation(): aeaop = VerticalPerspectiveConversion( viewpoint_height=10, latitude_topocentric_origin=1, longitude_topocentric_origin=2, false_easting=3, false_northing=4, ellipsoidal_height_topocentric_origin=5, ) assert aeaop.name == "unknown" assert aeaop.method_name == "Vertical Perspective" assert _to_dict(aeaop) == { "Latitude of topocentric origin": 1.0, "Longitude of topocentric origin": 2.0, "Ellipsoidal height of topocentric origin": 5.0, "Viewpoint height": 10.0, "False easting": 3.0, "False northing": 4.0, }