Skip to content

Commit

Permalink
Merge pull request #160 from stac-utils/feature/deprecated-default-ti…
Browse files Browse the repository at this point in the history
…lematrixset

Deprecate default tilematrixset
  • Loading branch information
vincentsarago authored Mar 25, 2024
2 parents 2d57d2e + 06fdf5e commit ffe0b68
Show file tree
Hide file tree
Showing 10 changed files with 292 additions and 138 deletions.
23 changes: 23 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Release Notes

## 1.3.0 (TBD)

* update titiler requirement to `>=0.18.0,<0.19`
* Add `/colorMaps` endpoints
* **Deprecation** remove default `WebMercatorQuad` tile matrix set in `/tiles`, `/tilesjson.json`, `/map`, `/WMTSCapabilities.xml` and `/assets` endpoints

```
# Before
/tiles/{z}/{x}/{y}
/tilejson.json
/map
/WMTSCapabilities.xml
# Now
/tiles/WebMercatorQuad/{z}/{x}/{y}
/WebMercatorQuad/tilejson.json
/WebMercatorQuad/map
/WebMercatorQuad/WMTSCapabilities.xml
```

* update `titiler.pgstac.model.Link` to match the OGC specification
* use `{tileMatrixSetId}` in templated URL links

## 1.2.3 (2024-03-25)

* add python 3.12 support
Expand Down
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ services:

database:
container_name: stac-db
platform: linux/amd64
image: ghcr.io/stac-utils/pgstac:v${PGSTAC_VERSION-0.8.1}
image: ghcr.io/stac-utils/pgstac:v${PGSTAC_VERSION-0.8.5}
environment:
- POSTGRES_USER=username
- POSTGRES_PASSWORD=password
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ classifiers = [
"Topic :: Scientific/Engineering :: GIS",
]
dependencies = [
"titiler.core>=0.17.0,<0.18",
"titiler.mosaic>=0.17.0,<0.18",
"titiler.core>=0.18.0,<0.19",
"titiler.mosaic>=0.18.0,<0.19",
"geojson-pydantic~=1.0",
"pydantic>=2.4,<3.0",
"pydantic-settings~=2.0",
Expand Down
66 changes: 38 additions & 28 deletions tests/test_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,15 @@ def test_assets_for_point_collections(app):

def test_assets_for_tile_collections(app):
"""Get assets for a Tile."""
response = app.get(f"/collections/{collection_id}/tiles/15/8589/12849/assets")
response = app.get(
f"/collections/{collection_id}/tiles/WebMercatorQuad/15/8589/12849/assets"
)
assert response.status_code == 200
resp = response.json()
assert len(resp) == 1
assert list(resp[0]) == ["id", "bbox", "assets", "collection"]
assert resp[0]["id"] == "20200307aC0853900w361030"

response = app.get(f"/collections/{collection_id}/tiles/15/8601/12849/assets")
assert response.status_code == 200
resp = response.json()
assert len(resp) == 2

response = app.get(
f"/collections/{collection_id}/tiles/WebMercatorQuad/15/8601/12849/assets"
)
Expand All @@ -68,14 +65,9 @@ def test_assets_for_tile_collections(app):
resp = response.json()
assert len(resp) == 4

response = app.get(f"/collections/{collection_id}/tiles/15/8601/12849/assets")
assert response.status_code == 200
resp = response.json()
assert len(resp) == 2

# CollectionId not found
response = app.get(
"/collections/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/tiles/15/8589/12849/assets"
"/collections/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/tiles/WebMercatorQuad/15/8589/12849/assets"
)
assert response.status_code == 404
resp = response.json()
Expand All @@ -84,10 +76,12 @@ def test_assets_for_tile_collections(app):

def test_tilejson_collections(app):
"""Create TileJSON."""
response = app.get(f"/collections/{collection_id}/tilejson.json")
response = app.get(f"/collections/{collection_id}/WebMercatorQuad/tilejson.json")
assert response.status_code == 400

response = app.get(f"/collections/{collection_id}/tilejson.json?assets=cog")
response = app.get(
f"/collections/{collection_id}/WebMercatorQuad/tilejson.json?assets=cog"
)
assert response.headers["content-type"] == "application/json"
assert response.status_code == 200
resp = response.json()
Expand All @@ -98,7 +92,7 @@ def test_tilejson_collections(app):
assert "?assets=cog" in resp["tiles"][0]

response = app.get(
f"/collections/{collection_id}/tilejson.json?assets=cog&scan_limit=100&items_limit=1&time_limit=2&exitwhenfull=False&skipcovered=False"
f"/collections/{collection_id}/WebMercatorQuad/tilejson.json?assets=cog&scan_limit=100&items_limit=1&time_limit=2&exitwhenfull=False&skipcovered=False"
)
assert response.headers["content-type"] == "application/json"
assert response.status_code == 200
Expand All @@ -108,12 +102,16 @@ def test_tilejson_collections(app):
in resp["tiles"][0]
)

response = app.get(f"/collections/{collection_id}/tilejson.json?expression=cog")
response = app.get(
f"/collections/{collection_id}/WebMercatorQuad/tilejson.json?expression=cog"
)
assert response.status_code == 200
resp = response.json()
assert "?expression=cog" in resp["tiles"][0]

response = app.get(f"/collections/{collection_id}/tilejson.json?expression=cog")
response = app.get(
f"/collections/{collection_id}/WebMercatorQuad/tilejson.json?expression=cog"
)
assert response.status_code == 200
resp = response.json()
assert "?expression=cog" in resp["tiles"][0]
Expand All @@ -130,15 +128,15 @@ def test_tilejson_collections(app):
assert "?assets=cog" in resp["tiles"][0]

response = app.get(
f"/collections/{collection_id}/tilejson.json?assets=cog&tile_format=png"
f"/collections/{collection_id}/WebMercatorQuad/tilejson.json?assets=cog&tile_format=png"
)
assert response.status_code == 200
resp = response.json()
assert ".png?assets=cog" in resp["tiles"][0]

# CollectionId not found
response = app.get(
"/collections/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/tilejson.json?assets=cog"
"/collections/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/WebMercatorQuad/tilejson.json?assets=cog"
)
assert response.status_code == 404
resp = response.json()
Expand All @@ -153,26 +151,32 @@ def test_tiles_collections(rio, app):
z, x, y = 15, 8589, 12849

# missing assets
response = app.get(f"/collections/{collection_id}/tiles/{z}/{x}/{y}")
response = app.get(
f"/collections/{collection_id}/tiles/WebMercatorQuad/{z}/{x}/{y}"
)
assert response.status_code == 400

response = app.get(f"/collections/{collection_id}/tiles/{z}/{x}/{y}?assets=cog")
response = app.get(
f"/collections/{collection_id}/tiles/WebMercatorQuad/{z}/{x}/{y}?assets=cog"
)
assert response.status_code == 200
assert response.headers["content-type"] == "image/jpeg"
meta = parse_img(response.content)
assert meta["width"] == 256
assert meta["height"] == 256

response = app.get(
f"/collections/{collection_id}/tiles/{z}/{x}/{y}?assets=cog&buffer=0.5"
f"/collections/{collection_id}/tiles/WebMercatorQuad/{z}/{x}/{y}?assets=cog&buffer=0.5"
)
assert response.status_code == 200
assert response.headers["content-type"] == "image/jpeg"
meta = parse_img(response.content)
assert meta["width"] == 257
assert meta["height"] == 257

response = app.get(f"/collections/{collection_id}/tiles/{z}/{x}/{y}.png?assets=cog")
response = app.get(
f"/collections/{collection_id}/tiles/WebMercatorQuad/{z}/{x}/{y}.png?assets=cog"
)
assert response.status_code == 200
assert response.headers["content-type"] == "image/png"
meta = parse_img(response.content)
Expand Down Expand Up @@ -201,7 +205,7 @@ def test_tiles_collections(rio, app):

# CollectionId not found
response = app.get(
"/collections/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/tiles/0/0/0?assets=cog"
"/collections/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/tiles/WebMercatorQuad/0/0/0?assets=cog"
)
assert response.status_code == 404
resp = response.json()
Expand All @@ -211,14 +215,18 @@ def test_tiles_collections(rio, app):
def test_wmts_collections(app):
"""Create wmts document."""
# missing assets
response = app.get(f"/collections/{collection_id}/WMTSCapabilities.xml")
response = app.get(
f"/collections/{collection_id}/WebMercatorQuad/WMTSCapabilities.xml"
)
assert response.status_code == 400
assert (
response.json()["detail"]
== "assets must be defined either via expression or assets options."
)

response = app.get(f"/collections/{collection_id}/WMTSCapabilities.xml?assets=cog")
response = app.get(
f"/collections/{collection_id}/WebMercatorQuad/WMTSCapabilities.xml?assets=cog"
)
assert response.status_code == 200
assert response.headers["content-type"] == "application/xml"

Expand Down Expand Up @@ -306,10 +314,12 @@ def test_statistics_collections(rio, app):

def test_map_collection(app):
"""test /map endpoint."""
response = app.get(f"/collections/{collection_id}/map")
response = app.get(f"/collections/{collection_id}/WebMercatorQuad/map")
assert response.status_code == 400

response = app.get(f"/collections/{collection_id}/map", params={"assets": "cog"})
response = app.get(
f"/collections/{collection_id}/WebMercatorQuad/map", params={"assets": "cog"}
)
assert response.status_code == 200


Expand Down
6 changes: 3 additions & 3 deletions tests/test_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_stac_items(rio, app):
assert resp["cog"]

response = app.get(
"/collections/noaa-emergency-response/items/20200307aC0853900w361030/tilejson.json",
"/collections/noaa-emergency-response/items/20200307aC0853900w361030/WebMercatorQuad/tilejson.json",
params={
"assets": "cog",
},
Expand All @@ -77,12 +77,12 @@ def test_stac_items(rio, app):
)

response = app.get(
"/collections/noaa-emergency-response/items/20200307aC0853900w361030/map",
"/collections/noaa-emergency-response/items/20200307aC0853900w361030/WebMercatorQuad/map",
)
assert response.status_code == 400

response = app.get(
"/collections/noaa-emergency-response/items/20200307aC0853900w361030/map",
"/collections/noaa-emergency-response/items/20200307aC0853900w361030/WebMercatorQuad/map",
params={
"assets": "cog",
},
Expand Down
Loading

0 comments on commit ffe0b68

Please sign in to comment.