Skip to content

Commit

Permalink
added two failing tests for mars crss
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewAnnex committed Oct 15, 2024
1 parent 3fa4e2e commit bd73194
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,7 @@ dmypy.json

# PyCharm:
.idea

# VSCode
.vscode
.vscode/
1 change: 0 additions & 1 deletion morecantile/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]


Expand Down
29 changes: 29 additions & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
[
Expand Down

0 comments on commit bd73194

Please sign in to comment.