Skip to content

Commit

Permalink
Assets for tile (developmentseed#352)
Browse files Browse the repository at this point in the history
* get assets from Tile instead of Quadkey

* update changes
  • Loading branch information
vincentsarago authored Aug 10, 2021
1 parent fc382d2 commit 2168c92
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### titiler.mosaic

* add `/{quadkey}/assets`, `/{lon},{lat}/assets`, `/{minx},{miny},{maxx},{maxy}/assets` GET endpoints to return a list of assets that intersect a given geometry (author @mackdelany, https://github.com/developmentseed/titiler/pull/351)
* add `/{z}/{x}/{y}/assets`, `/{lon},{lat}/assets`, `/{minx},{miny},{maxx},{maxy}/assets` GET endpoints to return a list of assets that intersect a given geometry (author @mackdelany, https://github.com/developmentseed/titiler/pull/351)

## 0.3.4 (2021-08-02)

Expand Down
2 changes: 1 addition & 1 deletion docs/advanced/tiler_factories.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ app.include_router(cog.router, tags=["Landsat"])
| `GET` | `/[{TileMatrixSetId}]/tilejson.json` | JSON | return a Mapbox TileJSON document
| `GET` | `/{TileMatrixSetId}/WMTSCapabilities.xml` | XML | return OGC WMTS Get Capabilities
| `GET` | `/point/{lon},{lat}` | JSON | return pixel value from a MosaicJSON dataset
| `GET` | `/{quadkey}/assets` | JSON | return list of assets intersecting a quadkey
| `GET` | `/{z}/{x}/{y}/assets` | JSON | return list of assets intersecting a XYZ tile
| `GET` | `/{lon},{lat}/assets` | JSON | return list of assets intersecting a point
| `GET` | `/{minx},{miny},{maxx},{maxy}/assets` | JSON | return list of assets intersecting a bounding box

Expand Down
2 changes: 1 addition & 1 deletion docs/endpoints/mosaic.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Read Mosaic Info/Metadata and create Web map Tiles from a multiple COG. The `mos
| `GET` | `/mosaicjson/[{TileMatrixSetId}]/tilejson.json` | JSON | return a Mapbox TileJSON document
| `GET` | `/mosaicjson/{TileMatrixSetId}/WMTSCapabilities.xml` | XML | return OGC WMTS Get Capabilities
| `GET` | `/mosaicjson/point/{lon},{lat}` | JSON | return pixel value from a MosaicJSON dataset
| `GET` | `/mosaicjson/{quadkey}/assets` | JSON | return list of assets intersecting a quadkey
| `GET` | `/mosaicjson/{z}/{x}/{y}/assets` | JSON | return list of assets intersecting a XYZ tile
| `GET` | `/mosaicjson/{lon},{lat}/assets` | JSON | return list of assets intersecting a point
| `GET` | `/mosaicjson/{minx},{miny},{maxx},{maxy}/assets` | JSON | return list of assets intersecting a bounding box

Expand Down
2 changes: 1 addition & 1 deletion src/titiler/mosaic/tests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def test_MosaicTilerFactory():
)
assert response.status_code == 200

response = client.get("/mosaic/0302302/assets", params={"url": mosaic_file},)
response = client.get("/mosaic/7/36/45/assets", params={"url": mosaic_file},)
assert response.status_code == 200
assert all(
filepath.split("/")[-1] in ["cog1.tif"] for filepath in response.json()
Expand Down
16 changes: 9 additions & 7 deletions src/titiler/mosaic/titiler/mosaic/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def assets(self):
r"/{minx},{miny},{maxx},{maxy}/assets",
responses={200: {"description": "Return list of COGs in bounding box"}},
)
def bbox(
def assets_for_bbox(
src_path=Depends(self.path_dependency),
minx: float = Query(None, description="Left side of bounding box"),
miny: float = Query(None, description="Bottom of bounding box"),
Expand Down Expand Up @@ -524,7 +524,7 @@ def bbox(
r"/{lng},{lat}/assets",
responses={200: {"description": "Return list of COGs"}},
)
def lonlat(
def assets_for_lon_lat(
src_path=Depends(self.path_dependency),
lng: float = Query(None, description="Longitude"),
lat: float = Query(None, description="Latitude"),
Expand All @@ -536,15 +536,17 @@ def lonlat(
return assets

@self.router.get(
r"/{quadkey}/assets",
r"/{z}/{x}/{y}/assets",
responses={200: {"description": "Return list of COGs"}},
)
def quadkey(
def assets_for_tile(
z: int = Path(..., ge=0, le=30, description="Mercator tiles's zoom level"),
x: int = Path(..., description="Mercator tiles's column"),
y: int = Path(..., description="Mercator tiles's row"),
src_path=Depends(self.path_dependency),
quadkey: str = Query(None, description="Quadkey to return COGS for."),
):
"""Return a list of assets which overlap a given quadkey"""
"""Return a list of assets which overlap a given tile"""
with self.reader(src_path, **self.backend_options) as mosaic:
assets = mosaic.assets_for_tile(*mercantile.quadkey_to_tile(quadkey))
assets = mosaic.assets_for_tile(x, y, z)

return assets

0 comments on commit 2168c92

Please sign in to comment.