Skip to content

Commit 27dd522

Browse files
Merge pull request #211 from developmentseed/feature/remove-deprecated-and-move-endpoints
remove deprecated endpoints and add /tiles prefix for tilejson and stylejson
2 parents 0b7b8b0 + 11661a8 commit 27dd522

6 files changed

+94
-86
lines changed

CHANGES.md

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ Note: Minor version `0.X.0` update might break the API, It's recommended to pin
3939
) -> None:
4040
```
4141
* fix URL in HTML templates when behind proxy
42+
* remove **deprecated** tiles endpoint with default TileMatrixSet
43+
* renamed tilejson endpoint from `/collections/{collectionId}/{tileMatrixSetId}/tilejson.json` to `/collections/{collectionId}/tiles/{tileMatrixSetId}/tilejson.json` **breaking change**
44+
* renamed stylejson endpoint from `/collections/{collectionId}/{tileMatrixSetId}/style.json` to `/collections/{collectionId}/tiles/{tileMatrixSetId}/style.json` **breaking change**
4245

4346
## [0.11.0] - TBD
4447

tests/routes/test_geography.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ def test_geography_column(app):
2424
assert body["numberReturned"] == 6
2525
assert body["features"][0]["geometry"]["type"] == "Polygon"
2626

27-
response = app.get("/collections/public.my_data_geo/tilejson.json")
27+
response = app.get(
28+
"/collections/public.my_data_geo/tiles/WebMercatorQuad/tilejson.json"
29+
)
2830
assert response.status_code == 200
2931
resp_json = response.json()
3032
assert resp_json["name"] == "public.my_data_geo"
@@ -34,7 +36,7 @@ def test_geography_column(app):
3436
resp_json["bounds"], [-47.5356, 74.8049, -8.97407, 81.8555]
3537
)
3638

37-
response = app.get("/collections/public.my_data_geo/tiles/5/11/5")
39+
response = app.get("/collections/public.my_data_geo/tiles/WebMercatorQuad/5/11/5")
3840
assert response.status_code == 200
3941
decoded = mapbox_vector_tile.decode(response.content)
4042
assert len(decoded["default"]["features"])

tests/routes/test_tiles.py

+33-15
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
def test_tilejson(app):
1010
"""Test TileJSON endpoint."""
11-
response = app.get("/collections/public.landsat_wrs/tilejson.json")
11+
response = app.get(
12+
"/collections/public.landsat_wrs/tiles/WebMercatorQuad/tilejson.json"
13+
)
1214
assert response.status_code == 200
1315

1416
resp_json = response.json()
@@ -22,7 +24,9 @@ def test_tilejson(app):
2224
resp_json["bounds"], [-180.0, -82.6401, 180.0, 82.6401], decimal=4
2325
)
2426

25-
response = app.get("/collections/public.landsat_wrs/WGS1984Quad/tilejson.json")
27+
response = app.get(
28+
"/collections/public.landsat_wrs/tiles/WGS1984Quad/tilejson.json"
29+
)
2630
assert response.status_code == 200
2731

2832
resp_json = response.json()
@@ -38,7 +42,7 @@ def test_tilejson(app):
3842
)
3943

4044
response = app.get(
41-
"/collections/public.landsat_wrs/tilejson.json?minzoom=1&maxzoom=2"
45+
"/collections/public.landsat_wrs/tiles/WebMercatorQuad/tilejson.json?minzoom=1&maxzoom=2"
4246
)
4347
assert response.status_code == 200
4448

@@ -48,7 +52,7 @@ def test_tilejson(app):
4852
assert resp_json["maxzoom"] == 2
4953

5054
response = app.get(
51-
"/collections/public.landsat_wrs/tilejson.json?minzoom=1&maxzoom=2&limit=1000"
55+
"/collections/public.landsat_wrs/tiles/WebMercatorQuad/tilejson.json?minzoom=1&maxzoom=2&limit=1000"
5256
)
5357
assert response.status_code == 200
5458

@@ -59,7 +63,9 @@ def test_tilejson(app):
5963
assert "?limit=1000" in resp_json["tiles"][0]
6064

6165
# Make sure that a non-4326 collection still returns the bounds in 4326
62-
response = app.get("/collections/public.minnesota/tilejson.json")
66+
response = app.get(
67+
"/collections/public.minnesota/tiles/WebMercatorQuad/tilejson.json"
68+
)
6369
assert response.status_code == 200
6470

6571
resp_json = response.json()
@@ -77,13 +83,15 @@ def test_tile(app):
7783
mvt_settings.set_mvt_layername = False
7884

7985
name = "landsat_wrs"
80-
response = app.get(f"/collections/public.{name}/tiles/0/0/0")
86+
response = app.get(f"/collections/public.{name}/tiles/WebMercatorQuad/0/0/0")
8187
assert response.status_code == 200
8288
decoded = mapbox_vector_tile.decode(response.content)
8389
assert "default" in decoded.keys()
8490
assert len(decoded["default"]["features"]) == 10000
8591

86-
response = app.get(f"/collections/public.{name}/tiles/0/0/0?limit=1000")
92+
response = app.get(
93+
f"/collections/public.{name}/tiles/WebMercatorQuad/0/0/0?limit=1000"
94+
)
8795
assert response.status_code == 200
8896
decoded = mapbox_vector_tile.decode(response.content)
8997
assert len(decoded["default"]["features"]) == 1000
@@ -92,21 +100,25 @@ def test_tile(app):
92100
)
93101

94102
response = app.get(
95-
f"/collections/public.{name}/tiles/0/0/0?limit=1&properties=pr,row,path"
103+
f"/collections/public.{name}/tiles/WebMercatorQuad/0/0/0?limit=1&properties=pr,row,path"
96104
)
97105
assert response.status_code == 200
98106
decoded = mapbox_vector_tile.decode(response.content)
99107
assert sorted(["pr", "row", "path"]) == sorted(
100108
decoded["default"]["features"][0]["properties"]
101109
)
102110

103-
response = app.get(f"/collections/public.{name}/tiles/0/0/0?geom-column=geom")
111+
response = app.get(
112+
f"/collections/public.{name}/tiles/WebMercatorQuad/0/0/0?geom-column=geom"
113+
)
104114
assert response.status_code == 200
105115
decoded = mapbox_vector_tile.decode(response.content)
106116
assert len(decoded["default"]["features"]) == 10000
107117

108118
# invalid geometry column name
109-
response = app.get(f"/collections/public.{name}/tiles/0/0/0?geom-column=the_geom")
119+
response = app.get(
120+
f"/collections/public.{name}/tiles/WebMercatorQuad/0/0/0?geom-column=the_geom"
121+
)
110122
assert response.status_code == 404
111123

112124
mvt_settings.set_mvt_layername = init_value
@@ -118,7 +130,7 @@ def test_tile_custom_name(app):
118130
mvt_settings.set_mvt_layername = True
119131

120132
name = "landsat_wrs"
121-
response = app.get(f"/collections/public.{name}/tiles/0/0/0")
133+
response = app.get(f"/collections/public.{name}/tiles/WebMercatorQuad/0/0/0")
122134
assert response.status_code == 200
123135
decoded = mapbox_vector_tile.decode(response.content)
124136
assert name in decoded.keys()
@@ -178,7 +190,9 @@ def test_tile_tms_custom_name(app):
178190

179191
def test_stylejson(app):
180192
"""Test StyleJSON endpoint."""
181-
response = app.get("/collections/public.landsat_wrs/style.json")
193+
response = app.get(
194+
"/collections/public.landsat_wrs/tiles/WebMercatorQuad/style.json"
195+
)
182196
assert response.status_code == 200
183197

184198
resp_json = response.json()
@@ -197,7 +211,7 @@ def test_stylejson(app):
197211
np.around(source["bounds"], 4), [-180.0, -82.6401, 180.0, 82.6401]
198212
)
199213

200-
response = app.get("/collections/public.landsat_wrs/WGS1984Quad/style.json")
214+
response = app.get("/collections/public.landsat_wrs/tiles/WGS1984Quad/style.json")
201215
assert response.status_code == 200
202216

203217
resp_json = response.json()
@@ -217,7 +231,9 @@ def test_stylejson(app):
217231
np.around(source["bounds"], 4), [-180.0, -82.6401, 180.0, 82.6401]
218232
)
219233

220-
response = app.get("/collections/public.landsat_wrs/style.json?minzoom=1&maxzoom=2")
234+
response = app.get(
235+
"/collections/public.landsat_wrs/tiles/WebMercatorQuad/style.json?minzoom=1&maxzoom=2"
236+
)
221237
assert response.status_code == 200
222238

223239
resp_json = response.json()
@@ -227,5 +243,7 @@ def test_stylejson(app):
227243
assert "minzoom" not in source["tiles"][0]
228244
assert "maxzoom" not in source["tiles"][0]
229245

230-
response = app.get("/collections/public.landsat/style.json?geom-column=centroid")
246+
response = app.get(
247+
"/collections/public.landsat/tiles/WebMercatorQuad/style.json?geom-column=centroid"
248+
)
231249
assert response.status_code == 200

tests/test_factories.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def test_tiles_factory():
116116
endpoints = OGCTilesFactory()
117117
assert endpoints.with_common
118118
assert endpoints.title == "OGC API"
119-
assert len(endpoints.router.routes) == 15
119+
assert len(endpoints.router.routes) == 10
120120
assert len(endpoints.conforms_to) == 5
121121

122122
app = FastAPI()
@@ -150,7 +150,7 @@ def test_tiles_factory():
150150
assert endpoints.router_prefix == "/map"
151151
assert endpoints.with_common
152152
assert endpoints.title == "OGC Tiles API"
153-
assert len(endpoints.router.routes) == 15
153+
assert len(endpoints.router.routes) == 10
154154

155155
app = FastAPI()
156156
app.include_router(endpoints.router, prefix="/map")
@@ -180,7 +180,7 @@ def test_tiles_factory():
180180
endpoints = OGCTilesFactory(title="OGC Tiles API", with_common=False)
181181
assert not endpoints.with_common
182182
assert endpoints.title == "OGC Tiles API"
183-
assert len(endpoints.router.routes) == 13
183+
assert len(endpoints.router.routes) == 8
184184
assert len(endpoints.conforms_to) == 5
185185

186186
app = FastAPI()
@@ -203,7 +203,7 @@ def test_endpoints_factory():
203203
endpoints = Endpoints()
204204
assert endpoints.with_common
205205
assert endpoints.title == "OGC API"
206-
assert len(endpoints.router.routes) == 20
206+
assert len(endpoints.router.routes) == 15
207207
assert len(endpoints.conforms_to) == 11 # 5 from tiles + 6 from features
208208

209209
app = FastAPI()
@@ -244,7 +244,7 @@ def test_endpoints_factory():
244244
assert endpoints.router_prefix == "/ogc"
245245
assert endpoints.with_common
246246
assert endpoints.title == "OGC Full API"
247-
assert len(endpoints.router.routes) == 20
247+
assert len(endpoints.router.routes) == 15
248248
assert not endpoints.ogc_features.with_common
249249
assert endpoints.ogc_features.router_prefix == "/ogc"
250250
assert not endpoints.ogc_tiles.with_common
@@ -288,7 +288,7 @@ def test_endpoints_factory():
288288
endpoints = Endpoints(title="Tiles and Features API", with_common=False)
289289
assert not endpoints.with_common
290290
assert endpoints.title == "Tiles and Features API"
291-
assert len(endpoints.router.routes) == 18 # 11 from tiles + 5 from features
291+
assert len(endpoints.router.routes) == 13 # 8 from tiles + 5 from features
292292
assert len(endpoints.conforms_to) == 11 # 4 from tiles + 6 from features
293293

294294
app = FastAPI()

tests/test_sql_functions.py

+28-10
Original file line numberDiff line numberDiff line change
@@ -138,22 +138,26 @@ def test_items_function(app_functions):
138138

139139
def test_tiles_functions(app_functions):
140140
"""Test Tiles endpoint."""
141-
response = app_functions.get("/collections/pg_temp.landsat_centroids/tilejson.json")
141+
response = app_functions.get(
142+
"/collections/pg_temp.landsat_centroids/tiles/WebMercatorQuad/tilejson.json"
143+
)
142144
assert response.status_code == 200
143145
body = response.json()
144146
assert body["name"] == "pg_temp.landsat_centroids"
145147
assert body["minzoom"] == 5
146148
assert body["maxzoom"] == 12
147149

148-
response = app_functions.get("/collections/pg_temp.hexagons/tilejson.json")
150+
response = app_functions.get(
151+
"/collections/pg_temp.hexagons/tiles/WebMercatorQuad/tilejson.json"
152+
)
149153
assert response.status_code == 200
150154
body = response.json()
151155
assert body["name"] == "pg_temp.hexagons"
152156
assert body["minzoom"] == 5
153157
assert body["maxzoom"] == 12
154158

155159
response = app_functions.get(
156-
"/collections/pg_temp.hexagons/tilejson.json?minzoom=1&maxzoom=2&size=4"
160+
"/collections/pg_temp.hexagons/tiles/WebMercatorQuad/tilejson.json?minzoom=1&maxzoom=2&size=4"
157161
)
158162
assert response.status_code == 200
159163
body = response.json()
@@ -193,43 +197,57 @@ def test_tiles_functions(app_functions):
193197

194198
# tiles
195199
# Check default's function are used
196-
response = app_functions.get("/collections/pg_temp.squares/tiles/3/3/3")
200+
response = app_functions.get(
201+
"/collections/pg_temp.squares/tiles/WebMercatorQuad/3/3/3"
202+
)
197203
assert response.status_code == 200
198204
decoded = mapbox_vector_tile.decode(response.content)
199205
assert len(decoded["default"]["features"]) == 25
200206

201207
# Check default's function are used
202-
response = app_functions.get("/collections/pg_temp.squares/tiles/3/3/3?size=2")
208+
response = app_functions.get(
209+
"/collections/pg_temp.squares/tiles/WebMercatorQuad/3/3/3?size=2"
210+
)
203211
assert response.status_code == 200
204212
decoded = mapbox_vector_tile.decode(response.content)
205213
assert len(decoded["default"]["features"]) == 483
206214

207215
# Check any geometry input column will work
208-
response = app_functions.get("/collections/pg_temp.hexagons/tiles/3/3/3")
216+
response = app_functions.get(
217+
"/collections/pg_temp.hexagons/tiles/WebMercatorQuad/3/3/3"
218+
)
209219
assert response.status_code == 200
210220
decoded = mapbox_vector_tile.decode(response.content)
211221
assert len(decoded["default"]["features"]) == 12
212222

213-
response = app_functions.get("/collections/pg_temp.hexagons_g/tiles/3/3/3")
223+
response = app_functions.get(
224+
"/collections/pg_temp.hexagons_g/tiles/WebMercatorQuad/3/3/3"
225+
)
214226
assert response.status_code == 200
215227
decoded = mapbox_vector_tile.decode(response.content)
216228
assert len(decoded["default"]["features"]) == 12
217229

218230
# Check function with x/y/z input
219-
response = app_functions.get("/collections/pg_temp.landsat/tiles/0/0/0?p=13")
231+
response = app_functions.get(
232+
"/collections/pg_temp.landsat/tiles/WebMercatorQuad/0/0/0?p=13"
233+
)
220234
assert response.status_code == 200
221235
decoded = mapbox_vector_tile.decode(response.content)
222236
assert len(decoded["default"]["features"]) == 104
223237
assert decoded["default"]["features"][0]["properties"]["grid_path"] == 13
224238

225239
# No features with p=0
226-
response = app_functions.get("/collections/pg_temp.landsat/tiles/0/0/0?p=0")
240+
response = app_functions.get(
241+
"/collections/pg_temp.landsat/tiles/WebMercatorQuad/0/0/0?p=0"
242+
)
227243
assert response.status_code == 200
228244
decoded = mapbox_vector_tile.decode(response.content)
229245
assert not decoded
230246

231247
# default p=0 so it should return nothing
232-
response = app_functions.get("/collections/pg_temp.landsat/tiles/0/0/0")
248+
response = app_functions.get(
249+
"/collections/pg_temp.landsat/tiles/WebMercatorQuad/0/0/0"
250+
)
233251
assert response.status_code == 200
234252
decoded = mapbox_vector_tile.decode(response.content)
235253
assert not decoded

0 commit comments

Comments
 (0)