Skip to content
Closed
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
2 changes: 1 addition & 1 deletion pygeoapi/templates/stac/item.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ <h4>{% trans %}Assets{% endtrans %}</h4>
}
));

var bbox = gen_safe_bbox({{ data['extent']['spatial']['bbox'][0] }});
var bbox = gen_safe_bbox({{ data['bbox'] }});

var bbox_layer = L.polygon([
[bbox[1], bbox[0]],
Expand Down
34 changes: 33 additions & 1 deletion tests/api/test_stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

import pytest

from pygeoapi.api.stac import search, landing_page
from pygeoapi.api.stac import get_stac_path, landing_page, search
from pygeoapi.formats import FORMAT_TYPES, F_JSON
from pygeoapi.util import yaml_load

Expand Down Expand Up @@ -66,6 +66,38 @@ def test_landing_page(config, api_):
assert response['description'] == 'pygeoapi provides an API to geospatial data' # noqa


def test_get_stac_item_html(config, api_, monkeypatch):
item = {
'id': 'test-item',
'type': 'Feature',
'bbox': [-10, -5, 10, 5],
'geometry': None,
'properties': {},
'links': [],
'assets': {
'default': {
'href': 'test-item.tif',
'created': '2026-09-18T00:00:00Z',
'file:size': 1024
}
}
}

class ItemProvider:
def get_data_path(self, base_url, path, relative_path):
return item

monkeypatch.setattr('pygeoapi.api.stac.load_plugin',
lambda *args: ItemProvider())

request = mock_api_request({'f': 'html'})
_, code, response = get_stac_path(api_, request,
'test-data/test-item.tif')

assert code == 200
assert 'var bbox = gen_safe_bbox([-10, -5, 10, 5]);' in response


@pytest.mark.parametrize('params,matched,returned', [
({}, 10, 10),
({'bbox': '-142,52,-140,55'}, 6, 6),
Expand Down