Skip to content

Commit c75fa56

Browse files
authored
Fix tilejson bounds (#41)
* add tilejson tests * fix tilejson endpoint
1 parent 00b73aa commit c75fa56

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

tests/test_app.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,25 @@ def test_conformance(app):
101101
assert "Conformance" in response.text
102102

103103

104+
@pytest.mark.vcr
105+
def test_rasterio_tilejson(app, rasterio_query_params):
106+
"""Test /tilejson.json endpoint for rasterio backend"""
107+
108+
response = app.get(
109+
"/WebMercatorQuad/tilejson.json",
110+
params={
111+
**rasterio_query_params,
112+
"datetime": "2024-10-11T00:00:00Z/2024-10-12T23:59:59Z",
113+
},
114+
)
115+
116+
assert response.status_code == 200
117+
assert response.headers["content-type"] == "application/json"
118+
119+
tilejson = response.json()
120+
assert tilejson["bounds"] == [-180.0, -90.0, 180.0, 90.0]
121+
122+
104123
@pytest.mark.vcr
105124
def test_rasterio_statistics(app, mock_cmr_get_assets, mn_geojson):
106125
"""Test /statistics endpoint for a polygon that straddles the boundary between two HLS granules"""
@@ -182,6 +201,25 @@ def test_rasterio_part(
182201
assert response.headers["content-type"] == "image/tiff; application=geotiff"
183202

184203

204+
@pytest.mark.vcr
205+
def test_xarray_tilejson(app, xarray_query_params):
206+
"""Test /tilejson.json endpoint for xarray backend"""
207+
208+
response = app.get(
209+
"/WebMercatorQuad/tilejson.json",
210+
params={
211+
**xarray_query_params,
212+
"datetime": "2024-10-11T00:00:00Z/2024-10-12T23:59:59Z",
213+
},
214+
)
215+
216+
assert response.status_code == 200
217+
assert response.headers["content-type"] == "application/json"
218+
219+
tilejson = response.json()
220+
assert tilejson["bounds"] == [-180.0, -90.0, 180.0, 90.0]
221+
222+
185223
@pytest.mark.vcr
186224
def test_xarray_statistics(
187225
app, mock_cmr_get_assets, xarray_query_params, arctic_geojson

titiler/cmr/factory.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,8 @@ def tilejson_endpoint( # type: ignore
636636
auth=request.app.state.cmr_auth,
637637
) as src_dst:
638638
minx, miny, maxx, maxy = zip(
639-
[-180, -90, 180, 90], list(src_dst.geographic_bounds)
639+
[-180, -90, 180, 90],
640+
src_dst.get_geographic_bounds(crs=src_dst.geographic_crs),
640641
)
641642
bounds = [max(minx), max(miny), min(maxx), min(maxy)]
642643

0 commit comments

Comments
 (0)