Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tilejson bounds #41

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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