Skip to content

Commit

Permalink
load_stac: useful proj: metadata is not returned by default
Browse files Browse the repository at this point in the history
  • Loading branch information
bossie committed May 27, 2024
1 parent ac8b180 commit 9723d20
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
3 changes: 2 additions & 1 deletion openeogeotrellis/load_stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ def operator_value(criterion: Dict[str, object]) -> (str, object):
fields = None
else:
# standard behavior seems to be to include only a minimal subset e.g. https://stac.openeo.vito.be/
fields = [f"properties.{property_name}" for property_name in all_properties.keys()]
fields = [f"properties.{property_name}" for property_name in
{"proj:epsg", "proj:bbox", "proj:shape"}.union(all_properties.keys())]

search_request = client.search(
method="GET",
Expand Down
18 changes: 15 additions & 3 deletions tests/test_api_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -3934,12 +3934,15 @@ def test_load_stac_from_spatiotemporal_netcdf_job_results(self, api110, urllib_m
"https://stac.test",
"https://tamn.snapplanet.io",
])
def test_stac_api_property_filter(self, api110, urllib_mock, requests_mock, catalog_url):
def test_stac_api_property_filter(self, api110, urllib_mock, requests_mock, catalog_url, tmp_path):
def feature_collection(request, _) -> dict:
if catalog_url == "https://tamn.snapplanet.io":
assert "fields" not in request.qs
else:
assert request.qs["fields"] == ["+properties.season"]
# a GET request has a single "fields" param with values separated by commas
assert set(request.qs["fields"][0].split(",")) == {"+properties.proj:epsg", "+properties.proj:bbox",
"+properties.proj:shape", "+properties.season",
}

def item(path) -> dict:
return json.loads(
Expand Down Expand Up @@ -4003,7 +4006,16 @@ def item(path) -> dict:
.replace("$CATALOG_URL", catalog_url))
requests_mock.get(f"{catalog_url}/search", json=feature_collection)

api110.result(process_graph).assert_status_code(200)
res = api110.result(process_graph).assert_status_code(200)

res_path = tmp_path / "res.tif"
res_path.write_bytes(res.data)

# output asset should match input asset
with rasterio.open(res_path) as ds:
assert ds.crs.to_epsg() == 4326
assert ds.shape == (10, 10)
assert tuple(ds.bounds) == (5.0, 50.0, 6.0, 51.0)

def test_load_stac_from_unsigned_job_results_respects_proj_metadata(self, api110, urllib_mock, tmp_path,
batch_job_output_root, zk_job_registry):
Expand Down

0 comments on commit 9723d20

Please sign in to comment.