diff --git a/CHANGES.md b/CHANGES.md index bb209c2b8..284fc21df 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Release Notes +## 0.10.1 (2022-12-15) + +* update `/map` endpoint and template to support multiple TMS (https://github.com/developmentseed/titiler/pull/560) + ## 0.10.0 (2022-12-09) **breaking change** diff --git a/docs/src/endpoints/cog.md b/docs/src/endpoints/cog.md index c682b2c90..5f1a98743 100644 --- a/docs/src/endpoints/cog.md +++ b/docs/src/endpoints/cog.md @@ -237,7 +237,7 @@ Example: `:endpoint:/cog[/{TileMatrixSetId}]/map` Simple viewer - PathParams: - - **TileMatrixSetId**: TileMatrixSet name (only `WebMercatorQuad` is supported). **Optional** + - **TileMatrixSetId**: TileMatrixSet name, default is `WebMercatorQuad`. **Optional** - QueryParams: - **url** (str): Cloud Optimized GeoTIFF URL. **Required** diff --git a/docs/src/endpoints/stac.md b/docs/src/endpoints/stac.md index 2608286fa..f33e5c72f 100644 --- a/docs/src/endpoints/stac.md +++ b/docs/src/endpoints/stac.md @@ -260,7 +260,7 @@ Example: `:endpoint:/stac[/{TileMatrixSetId}]/map` Simple viewer - PathParams: - - **TileMatrixSetId**: TileMatrixSet name (only `WebMercatorQuad` is supported). **Optional** + - **TileMatrixSetId**: TileMatrixSet name, default is `WebMercatorQuad`. **Optional** - QueryParams: - **url** (str): STAC Item URL. **Required** diff --git a/src/titiler/core/titiler/core/factory.py b/src/titiler/core/titiler/core/factory.py index 91bb90c10..7253efbc6 100644 --- a/src/titiler/core/titiler/core/factory.py +++ b/src/titiler/core/titiler/core/factory.py @@ -633,9 +633,9 @@ def map_viewer(self): # noqa: C901 def map_viewer( request: Request, src_path=Depends(self.path_dependency), - TileMatrixSetId: Literal["WebMercatorQuad"] = Query( - "WebMercatorQuad", - description="TileMatrixSet Name (default: 'WebMercatorQuad')", + TileMatrixSetId: Literal[tuple(self.supported_tms.list())] = Query( + self.default_tms, + description=f"TileMatrixSet Name (default: '{self.default_tms}')", ), # noqa tile_format: Optional[ImageType] = Query( None, description="Output image type. Default is auto." @@ -672,15 +672,20 @@ def map_viewer( env=Depends(self.environment_dependency), # noqa ): """Return TileJSON document for a dataset.""" - tilejson_url = self.url_for(request, "tilejson") + tilejson_url = self.url_for( + request, "tilejson", TileMatrixSetId=TileMatrixSetId + ) if request.query_params._list: tilejson_url += f"?{urlencode(request.query_params._list)}" + tms = self.supported_tms.get(TileMatrixSetId) return templates.TemplateResponse( name="index.html", context={ "request": request, "tilejson_endpoint": tilejson_url, + "tms": tms, + "resolutions": [tms._resolution(matrix) for matrix in tms], }, media_type="text/html", ) diff --git a/src/titiler/core/titiler/core/templates/index.html b/src/titiler/core/titiler/core/templates/index.html index 05ac41484..3d74bfce0 100644 --- a/src/titiler/core/titiler/core/templates/index.html +++ b/src/titiler/core/titiler/core/templates/index.html @@ -4,53 +4,20 @@ TiTiler Map Viewer - - - + + + + -
-
Zoom:
-
- - diff --git a/src/titiler/mosaic/titiler/mosaic/factory.py b/src/titiler/mosaic/titiler/mosaic/factory.py index 0803fd26f..97845bb64 100644 --- a/src/titiler/mosaic/titiler/mosaic/factory.py +++ b/src/titiler/mosaic/titiler/mosaic/factory.py @@ -428,15 +428,15 @@ def tilejson( def map_viewer(self): # noqa: C901 """Register /map endpoint.""" - @self.router.get("/{TileMatrixSetId}/map", response_class=HTMLResponse) @self.router.get("/map", response_class=HTMLResponse) + @self.router.get("/{TileMatrixSetId}/map", response_class=HTMLResponse) def map_viewer( request: Request, src_path=Depends(self.path_dependency), - TileMatrixSetId: Literal["WebMercatorQuad"] = Query( - "WebMercatorQuad", - description="TileMatrixSet Name (default: 'WebMercatorQuad')", - ), # noqa + TileMatrixSetId: Literal[tuple(self.supported_tms.list())] = Query( + self.default_tms, + description=f"TileMatrixSet Name (default: '{self.default_tms}')", + ), tile_format: Optional[ImageType] = Query( None, description="Output image type. Default is auto." ), @@ -473,15 +473,20 @@ def map_viewer( env=Depends(self.environment_dependency), # noqa ): """Return TileJSON document for a dataset.""" - tilejson_url = self.url_for(request, "tilejson") + tilejson_url = self.url_for( + request, "tilejson", TileMatrixSetId=TileMatrixSetId + ) if request.query_params._list: tilejson_url += f"?{urlencode(request.query_params._list)}" + tms = self.supported_tms.get(TileMatrixSetId) return templates.TemplateResponse( name="index.html", context={ "request": request, "tilejson_endpoint": tilejson_url, + "tms": tms, + "resolutions": [tms._resolution(matrix) for matrix in tms], }, media_type="text/html", )