Skip to content

Commit

Permalink
Fix tilejson bounds (#41)
Browse files Browse the repository at this point in the history
* add tilejson tests

* fix tilejson endpoint
  • Loading branch information
hrodmn authored Nov 26, 2024
1 parent 00b73aa commit c75fa56
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
38 changes: 38 additions & 0 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,25 @@ def test_conformance(app):
assert "Conformance" in response.text


@pytest.mark.vcr
def test_rasterio_tilejson(app, rasterio_query_params):
"""Test /tilejson.json endpoint for rasterio backend"""

response = app.get(
"/WebMercatorQuad/tilejson.json",
params={
**rasterio_query_params,
"datetime": "2024-10-11T00:00:00Z/2024-10-12T23:59:59Z",
},
)

assert response.status_code == 200
assert response.headers["content-type"] == "application/json"

tilejson = response.json()
assert tilejson["bounds"] == [-180.0, -90.0, 180.0, 90.0]


@pytest.mark.vcr
def test_rasterio_statistics(app, mock_cmr_get_assets, mn_geojson):
"""Test /statistics endpoint for a polygon that straddles the boundary between two HLS granules"""
Expand Down Expand Up @@ -182,6 +201,25 @@ def test_rasterio_part(
assert response.headers["content-type"] == "image/tiff; application=geotiff"


@pytest.mark.vcr
def test_xarray_tilejson(app, xarray_query_params):
"""Test /tilejson.json endpoint for xarray backend"""

response = app.get(
"/WebMercatorQuad/tilejson.json",
params={
**xarray_query_params,
"datetime": "2024-10-11T00:00:00Z/2024-10-12T23:59:59Z",
},
)

assert response.status_code == 200
assert response.headers["content-type"] == "application/json"

tilejson = response.json()
assert tilejson["bounds"] == [-180.0, -90.0, 180.0, 90.0]


@pytest.mark.vcr
def test_xarray_statistics(
app, mock_cmr_get_assets, xarray_query_params, arctic_geojson
Expand Down
3 changes: 2 additions & 1 deletion titiler/cmr/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,8 @@ def tilejson_endpoint( # type: ignore
auth=request.app.state.cmr_auth,
) as src_dst:
minx, miny, maxx, maxy = zip(
[-180, -90, 180, 90], list(src_dst.geographic_bounds)
[-180, -90, 180, 90],
src_dst.get_geographic_bounds(crs=src_dst.geographic_crs),
)
bounds = [max(minx), max(miny), min(maxx), min(maxy)]

Expand Down

0 comments on commit c75fa56

Please sign in to comment.