Skip to content

Commit

Permalink
should be working but seeing very odd behavior locally, may need to r…
Browse files Browse the repository at this point in the history
…estart computer...
  • Loading branch information
AndrewAnnex committed Oct 1, 2024
1 parent d65131d commit a9369a5
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cogeo_mosaic/scripts/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def info(input, to_json, tms):
}

geo = {
"TileMatrixSet": mosaic.tms.id, # TODO this may require deeper and more changes
"TileMatrixSet": mosaic.tms.id,
"BoundingBox": mosaic.mosaic_def.bounds,
"Center": mosaic.mosaic_def.center,
"Min Zoom": mosaic.mosaic_def.minzoom,
Expand Down
48 changes: 48 additions & 0 deletions tests/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

from cogeo_mosaic.errors import MultipleDataTypeError
from cogeo_mosaic.mosaic import MosaicJSON, default_filter
from cogeo_mosaic.backends import MosaicBackend
from cogeo_mosaic.backends.file import FileBackend

tms_3857 = morecantile.tms.get("WebMercatorQuad")
tms_4326 = morecantile.tms.get("WorldCRS84Quad")
Expand Down Expand Up @@ -155,3 +157,49 @@ def test_mosaic_create_additional_metadata():
assert mosaic.data_type == "uint16"
assert mosaic.layers["true-color"]
assert mosaic.tiles["0302301"] == ["/cog1.tif", "/cog2.tif"]


def test_mars_mosaic_create():
# first define the tilematrixset manually
MARS2000_SPHERE = pyproj.CRS.from_user_input("IAU_2015:49900")
MARS_MERCATOR = pyproj.CRS.from_user_input("IAU_2015:49990")
# same boundaries as Earth mercator
mars_tms = morecantile.TileMatrixSet.custom(
[
-179.9999999999996,
-85.05112877980656,
179.9999999999996,
85.05112877980656,
],
MARS_MERCATOR,
extent_crs=MARS2000_SPHERE,
title="Web Mercator Mars",
geographic_crs=MARS2000_SPHERE,
)
# load the mars_ctx_stac_assset.json file
with open(mars_ctx_asset, 'r') as f:
stac_asset = json.load(f)
# these stac item has multiple assets so grab the DTM
stac_asset['properties']['path'] = stac_asset['assets']['dtm']['href']
# now construct the mosaicjson object
mosaic_json = MosaicJSON.from_features(
[stac_asset,],
minzoom=7,
maxzoom=30,
tilematrixset=mars_tms,
)
assert mosaic_json is not None
assert mosaic_json.tilematrixset == mars_tms
assert len(mosaic_json.tiles) > 0
# now test the mosaic backend
with MosaicBackend("mosaic.json", mosaic_def=mosaic_json, tms=mars_tms) as mosaic:
assert isinstance(mosaic, FileBackend)
assert mosaic.tms == mars_tms
assert mosaic.crs == mars_tms.rasterio_geographic_crs
assert mosaic.geographic_crs == mars_tms.rasterio_geographic_crs
assert len(mosaic.assets_for_point(77.28, 18, mars_tms.geographic_crs)) > 0
assert len(mosaic.assets_for_bbox(77.2, 17.5, 77.4, 18.5, mars_tms.geographic_crs)) > 0
assert len(mosaic.assets_for_point(77.28, 18, mars_tms.rasterio_geographic_crs)) > 0
assert len(mosaic.assets_for_bbox(77.2, 17.5, 77.4, 18.5, mars_tms.rasterio_geographic_crs)) > 0
assert len(mosaic.assets_for_point(77.25, 18.0)) > 0
assert len(mosaic.assets_for_bbox(77.2, 17.5, 77.4, 18.5)) > 0

0 comments on commit a9369a5

Please sign in to comment.