From bd73194d824a6cc80344f48d58daba203eed422a Mon Sep 17 00:00:00 2001 From: Andrew Annex Date: Tue, 15 Oct 2024 13:20:38 -0700 Subject: [PATCH] added two failing tests for mars crss --- .gitignore | 4 ++++ morecantile/models.py | 1 - tests/test_models.py | 29 +++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 23077b4..788139f 100644 --- a/.gitignore +++ b/.gitignore @@ -130,3 +130,7 @@ dmypy.json # PyCharm: .idea + +# VSCode +.vscode +.vscode/ diff --git a/morecantile/models.py b/morecantile/models.py index c43349c..e5052b0 100644 --- a/morecantile/models.py +++ b/morecantile/models.py @@ -40,7 +40,6 @@ NumType = Union[float, int] BoundsType = Tuple[NumType, NumType] LL_EPSILON = 1e-11 -WGS84_CRS = pyproj.CRS.from_epsg(4326) axesInfo = Annotated[List[str], Field(min_length=2, max_length=2)] diff --git a/tests/test_models.py b/tests/test_models.py index a62078b..d2afb31 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -395,6 +395,35 @@ def test_mars_local_tms(): assert bbox == syrtis_tms.bbox +def test_mars_tms_construction(): + mars_sphere_crs = pyproj.CRS.from_user_input("IAU_2015:49900") + extent = [-90, -180, 90, 180] + mars_tms = morecantile.TileMatrixSet.custom( + extent, mars_sphere_crs, id="MarsGeographicCRS" + ) + assert "4326" not in mars_tms.geographic_crs.to_wkt() + assert "4326" not in mars_tms.rasterio_geographic_crs.to_wkt() + assert mars_tms.xy_bbox.left == pytest.approx(-90.0) + assert mars_tms.xy_bbox.right == pytest.approx(180.0) + assert mars_tms.xy_bbox.bottom == pytest.approx(180.0) + assert mars_tms.xy_bbox.top == pytest.approx(90.0) + + +def test_mars_web_mercator_long_lat(): + wkt_mars_web_mercator = 'PROJCRS["Mars (2015) - Sphere XY / Pseudo-Mercator",BASEGEOGCRS["Mars (2015) - Sphere",DATUM["Mars (2015) - Sphere",ELLIPSOID["Mars (2015) - Sphere",3396190,0,LENGTHUNIT["metre",1,ID["EPSG",9001]]],ANCHOR["Viking 1 lander : 47.95137 W"]],PRIMEM["Reference Meridian",0,ANGLEUNIT["degree",0.0174532925199433,ID["EPSG",9122]]]],CONVERSION["Popular Visualisation Pseudo-Mercator",METHOD["Popular Visualisation Pseudo Mercator",ID["EPSG",1024]],PARAMETER["Latitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8801]],PARAMETER["Longitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["False easting",0,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["easting (X)",east,ORDER[1],LENGTHUNIT["metre",1,ID["EPSG",9001]]],AXIS["northing (Y)",north,ORDER[2],LENGTHUNIT["metre",1,ID["EPSG",9001]]],USAGE[SCOPE["Web mapping and visualisation."],AREA["World between 85.06 S and 85.06 N."],BBOX[-85.850511287,-180,85.0511287,180]],REMARK["Use semi-major radius as sphere radius for interoperability. Source of IAU Coordinate systems: doi:10.1007/s10569-017-9805-5"]]' + crs_mars_web_mercator = pyproj.CRS.from_wkt(wkt_mars_web_mercator) + extent_wm = [-85.850511287, -180, 85.0511287, 180] + mars_tms_wm = morecantile.TileMatrixSet.custom( + extent_wm, crs_mars_web_mercator, id="MarsWebMercator" + ) + assert "4326" not in mars_tms_wm.geographic_crs.to_wkt() + assert "4326" not in mars_tms_wm.rasterio_geographic_crs.to_wkt() + assert mars_tms_wm.bbox.left == pytest.approx(-180.0) + assert mars_tms_wm.bbox.right == pytest.approx(180.0) + assert mars_tms_wm.bbox.bottom == pytest.approx(-85.850511287) + assert mars_tms_wm.bbox.top == pytest.approx(85.850511287) + + @pytest.mark.parametrize( "identifier, file, crs", [