Skip to content
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
28 changes: 14 additions & 14 deletions openeo_driver/backend_/_geopyspark.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,21 +480,7 @@ def jsonable_nodata(nodata: Optional[float]) -> Union[None, float, str]:
)
for band in bands
]

raster_bands = result_dict.get("raster:bands")
if raster_bands is None:
if nodata_value is not None or data_type_value is not None:
result_dict["raster:bands"] = [
dict_no_none(data_type=data_type_value, nodata=nodata_value) for _ in bands
]
else:
for raster_band in raster_bands:
if "nodata" not in raster_band and nodata_value is not None:
raster_band["nodata"] = nodata_value
if "data_type" not in raster_band and data_type_value is not None:
raster_band["data_type"] = data_type_value
else:

def raster_bands(band_index) -> dict:
rb = asset_metadata.get("raster:bands", [])
return rb[band_index] if band_index < len(rb) else {}
Expand All @@ -513,6 +499,20 @@ def raster_bands(band_index) -> dict:
for (i, band) in enumerate(bands)
]

if not stac11:
raster_bands = result_dict.get("raster:bands")
if raster_bands is None and bands:
if nodata_value is not None or data_type_value is not None:
result_dict["raster:bands"] = [
dict_no_none(data_type=data_type_value, nodata=nodata_value) for _ in bands
]
elif raster_bands is not None:
for raster_band in raster_bands:
if "nodata" not in raster_band and nodata_value is not None:
raster_band["nodata"] = nodata_value
if "data_type" not in raster_band and data_type_value is not None:
raster_band["data_type"] = data_type_value

asset_proj_epsg = asset_metadata.get("proj:epsg", job_info.epsg)
result_dict.update(
dict_no_none(
Expand Down
1 change: 1 addition & 0 deletions openeo_driver/dummy/dummy_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,7 @@ def get_result_assets(self, job_id: str, user_id: str) -> Dict[str, dict]:
"roles": ["data"],
"type": "application/x-netcdf",
"nodata": -1,
"raster:bands": [{}],
},
"vectorcube.geojson": {
"output_dir": f"{self._output_root()}/{job_id}",
Expand Down
8 changes: 8 additions & 0 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1919,6 +1919,7 @@ def test_get_job_results_100(self, api100):
"roles": ["data"],
"title": "output.nc",
"type": "application/x-netcdf",
"raster:bands": [{"nodata": -1}],
},
"randomforest.model": {
"href": "http://oeo.net/openeo/1.0.0/jobs/07024ee9-7847-4b8a-b260-6c879a2b3cdc/results/assets/randomforest.model",
Expand Down Expand Up @@ -1996,6 +1997,7 @@ def test_get_job_results_100(self, api100):
"proj:epsg": 4326,
"proj:code": "EPSG:4326",
"proj:shape": [300, 600],
"raster:bands": [{"nodata": -1}],
},
"randomforest.model": {
"href": "http://oeo.net/openeo/1.0.0/jobs/53c71345-09b4-46b4-b6b0-03fd6fe1f199/results/assets/randomforest.model",
Expand Down Expand Up @@ -2095,6 +2097,7 @@ def test_get_job_results_110(self, api110):
"roles": ["data"],
"title": "output.nc",
"type": "application/x-netcdf",
"raster:bands": [{"nodata": -1}],
},
"randomforest.model": {
"href": "http://oeo.net/openeo/1.1.0/jobs/07024ee9-7847-4b8a-b260-6c879a2b3cdc/results/assets/randomforest.model",
Expand Down Expand Up @@ -2184,6 +2187,7 @@ def test_get_job_results_110(self, api110):
"proj:epsg": 4326,
"proj:code": "EPSG:4326",
"proj:shape": [300, 600],
"raster:bands": [{"nodata": -1}],
},
"randomforest.model": {
"href": "http://oeo.net/openeo/1.1.0/jobs/53c71345-09b4-46b4-b6b0-03fd6fe1f199/results/assets/randomforest.model",
Expand Down Expand Up @@ -2367,6 +2371,7 @@ def test_get_job_results_signed_100(self, api100, flask_app, backend_config_over
"roles": ["data"],
"title": "output.nc",
"type": "application/x-netcdf",
"raster:bands": [{"nodata": -1}],
},
"randomforest.model": {
"href": "http://oeo.net/openeo/1.0.0/jobs/07024ee9-7847-4b8a-b260-6c879a2b3cdc/results/assets/TXIuVGVzdA==/741cfd7379a9eda4bc1c8b0c5155bfe9/randomforest.model",
Expand Down Expand Up @@ -2515,6 +2520,7 @@ def test_get_job_results_signed_110(self, api110, flask_app, backend_config_over
"roles": ["data"],
"title": "output.nc",
"type": "application/x-netcdf",
"raster:bands": [{"nodata": -1}],
},
"randomforest.model": {
"href": "http://oeo.net/openeo/1.1.0/jobs/07024ee9-7847-4b8a-b260-6c879a2b3cdc/results/assets/TXIuVGVzdA==/741cfd7379a9eda4bc1c8b0c5155bfe9/randomforest.model",
Expand Down Expand Up @@ -2665,6 +2671,7 @@ def test_get_job_results_signed_with_expiration_100(self, api100, flask_app, bac
"roles": ["data"],
"title": "output.nc",
"type": "application/x-netcdf",
"raster:bands": [{"nodata": -1}],
},
"randomforest.model": {
"href": "http://oeo.net/openeo/1.0.0/jobs/07024ee9-7847-4b8a-b260-6c879a2b3cdc/results/assets/TXIuVGVzdA==/22b76413158c59acaccc74e74841a473/randomforest.model?expires=2234",
Expand Down Expand Up @@ -2864,6 +2871,7 @@ def test_get_job_results_signed_with_expiration_110(self, api110, flask_app, bac
"proj:epsg": 4326,
"proj:code": "EPSG:4326",
"proj:shape": [300, 600],
"raster:bands": [{"nodata": -1}],
},
"randomforest.model": {
"href": "http://oeo.net/openeo/1.1.0/jobs/53c71345-09b4-46b4-b6b0-03fd6fe1f199/results/assets/TXIuVGVzdA==/18fd2346c52945c0caba7b13246f5a63/randomforest.model?expires=2234",
Expand Down
Loading