diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fb19da0..a321f29f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +## [2022.1.2] + +### Fixed + +- Fixed renderconfigs for item tile links [#41](https://github.com/microsoft/planetary-computer-apis/pull/41) +- Fixes hostname setting for URLs used in item links + ## [2022.1.1] ### Fixed @@ -44,4 +51,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated search limit constraints to avoid 500s [#15](https://github.com/microsoft/planetary-computer-apis/pull/15) - Fixed STAC `describedby` and `preview` links [#33](https://github.com/microsoft/planetary-computer-apis/pull/33) - Default search limit restored to 250 [#36](https://github.com/microsoft/planetary-computer-apis/pull/36) -- Work around issue with LandPage stac_extensions [#37](https://github.com/microsoft/planetary-computer-apis/pull/37) \ No newline at end of file +- Work around issue with LandPage stac_extensions [#37](https://github.com/microsoft/planetary-computer-apis/pull/37) diff --git a/pccommon/render.py b/pccommon/render.py index 1ea6dd29..417bebcf 100644 --- a/pccommon/render.py +++ b/pccommon/render.py @@ -18,9 +18,9 @@ class DefaultRenderConfig: normal human vision, parameters will likely encode this rendering. """ - assets: List[str] render_params: Dict[str, Any] minzoom: int + assets: Optional[List[str]] = None maxzoom: Optional[int] = 18 create_links: bool = True has_mosaic: bool = False @@ -29,8 +29,14 @@ class DefaultRenderConfig: requires_token: bool = False hidden: bool = False # Hide from API - def get_assets_param(self) -> str: - return ",".join(self.assets) + def get_assets_params(self) -> str: + if self.assets is None: + return "" + + if len(self.assets) == 1: + return f"&assets={self.assets[0]}" + + return "&assets=".join(self.assets) def get_render_params(self) -> str: return get_param_str(self.render_params) @@ -72,7 +78,7 @@ def should_add_item_links(self) -> bool: ), "aster-l1t": DefaultRenderConfig( assets=["VNIR"], - render_params={"bidx": [2, 3, 1], "nodata": 0}, + render_params={"asset_bidx": "VNIR|2,3,1", "nodata": 0}, mosaic_preview_zoom=9, mosaic_preview_coords=[37.2141, -104.2947], minzoom=9, @@ -111,9 +117,8 @@ def should_add_item_links(self) -> bool: minzoom=5, ), "gnatsgo-rasters": DefaultRenderConfig( - create_links=False, assets=["aws0_100"], - render_params={"colormap_name": "cividis"}, + render_params={"colormap_name": "cividis", "rescale": [0, 600]}, mosaic_preview_zoom=6, mosaic_preview_coords=[44.1454, -112.6404], requires_token=True, @@ -130,7 +135,6 @@ def should_add_item_links(self) -> bool: ), "goes-cmi": DefaultRenderConfig( create_links=True, - assets=["data"], render_params={ "expression": ( "C02_2km_wm," @@ -212,7 +216,7 @@ def should_add_item_links(self) -> bool: ), "naip": DefaultRenderConfig( assets=["image"], - render_params={"bidx": [1, 2, 3]}, + render_params={"asset_bidx": "image|1,2,3"}, mosaic_preview_zoom=13, mosaic_preview_coords=[36.0891, -111.8577], minzoom=11, @@ -235,7 +239,7 @@ def should_add_item_links(self) -> bool: ), "sentinel-2-l2a": DefaultRenderConfig( assets=["visual"], - render_params={"bidx": [1, 2, 3], "nodata": 0}, + render_params={"asset_bidx": "visual|1,2,3", "nodata": 0}, mosaic_preview_zoom=9, mosaic_preview_coords=[-16.4940, 124.0274], requires_token=True, diff --git a/pcstac/pcstac/tiles.py b/pcstac/pcstac/tiles.py index 460ce90b..01ac28a5 100644 --- a/pcstac/pcstac/tiles.py +++ b/pcstac/pcstac/tiles.py @@ -58,7 +58,7 @@ def _get_collection_tilejson_asset(self) -> Dict[str, Any]: ( "collection/tilejson.json?" f"collection={self.collection_id}" - f"&assets={self.render_config.get_assets_param()}" + f"{self.render_config.get_assets_params()}" f"{render_params_part}" ), ) @@ -91,8 +91,8 @@ def _get_item_preview_asset(self, item_id: str) -> Dict[str, Any]: ( f"item/preview.png?" f"collection={self.collection_id}" - f"&items={item_id}" - f"&assets={self.render_config.get_assets_param()}" + f"&item={item_id}" + f"{self.render_config.get_assets_params()}" f"{render_params_part}" ), ) @@ -113,8 +113,8 @@ def _get_item_tilejson_asset(self, item_id: str) -> Dict[str, Any]: ( "item/tilejson.json?" f"collection={self.collection_id}" - f"&items={item_id}" - f"&assets={self.render_config.get_assets_param()}" + f"&item={item_id}" + f"{self.render_config.get_assets_params()}" f"{render_params_part}" ), ) diff --git a/pctiler/pctiler/endpoints/item.py b/pctiler/pctiler/endpoints/item.py index a6b382f3..bef61b9d 100644 --- a/pctiler/pctiler/endpoints/item.py +++ b/pctiler/pctiler/endpoints/item.py @@ -51,12 +51,15 @@ def map( content=f"No item map available for collection {collection}", ) - tilejson_params = get_param_str( - { - "collection": collection, - "item": item, - "assets": ",".join(render_config.assets), - } + tilejson_params = ( + get_param_str( + { + "collection": collection, + "item": item, + } + ) + + render_config.get_assets_params() + + f"&{render_config.get_render_params()}" ) tilejson_url = pc_tile_factory.url_for(request, "tilejson") @@ -75,6 +78,5 @@ def map( "collectionId": collection, "itemId": item, "itemUrl": item_url, - "renderParams": get_param_str(render_config.render_params), }, ) diff --git a/pctiler/templates/item_preview.html b/pctiler/templates/item_preview.html index e4cf04bc..00942f64 100644 --- a/pctiler/templates/item_preview.html +++ b/pctiler/templates/item_preview.html @@ -28,10 +28,6 @@ ).addTo(map); var tiles = tileJson.tiles[0]; - var renderParams = "{{ renderParams }}"; - if (renderParams) { - tiles += "&" + renderParams; - } var tileLayer = L.tileLayer(tiles, { minZoom: tileJson.minzoon,