Skip to content

Commit

Permalink
exchange pop with get
Browse files Browse the repository at this point in the history
  • Loading branch information
konstntokas committed Jul 22, 2024
1 parent 2b0cc46 commit 8557eea
Show file tree
Hide file tree
Showing 4 changed files with 238 additions and 38 deletions.
26 changes: 14 additions & 12 deletions test/webapi/ows/stac/demo-collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@
}
},
"xcube:dataset": {
"id": "demo",
"title": "xcube-server Demonstration L2C Cube",
"groupTitle": "Demo",
"tags": [
"demo",
Expand Down Expand Up @@ -785,18 +787,6 @@
}
],
"dimensions": [
{
"name": "time",
"size": 5,
"dtype": "datetime64[ns]",
"coordinates": [
"2017-01-16T10:09:21Z",
"2017-01-25T09:35:51Z",
"2017-01-26T10:50:17Z",
"2017-01-28T09:58:11Z",
"2017-01-30T10:46:34Z"
]
},
{
"name": "lat",
"size": 1000,
Expand Down Expand Up @@ -1804,6 +1794,18 @@
50.00125
]
},
{
"name": "time",
"size": 5,
"dtype": "datetime64[ns]",
"coordinates": [
"2017-01-16T10:09:21Z",
"2017-01-25T09:35:51Z",
"2017-01-26T10:50:17Z",
"2017-01-28T09:58:11Z",
"2017-01-30T10:46:34Z"
]
},
{
"name": "lon",
"size": 2000,
Expand Down
119 changes: 109 additions & 10 deletions test/webapi/ows/stac/stac-datacubes-item.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,111 @@
}
},
"xcube:dataset": {
"id": "demo-1w",
"title": "xcube-server Demonstration L3 Cube",
"groupTitle": "Demo",
"tags": [
"demo",
"zarr",
"computed"
],
"bbox": [
0.0,
50.0,
5.0,
52.5
],
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
0.0,
50.0
],
[
0.0,
50.5
],
[
0.0,
51.0
],
[
0.0,
51.5
],
[
0.0,
52.0
],
[
0.0,
52.5
],
[
1.0,
52.5
],
[
2.0,
52.5
],
[
3.0,
52.5
],
[
4.0,
52.5
],
[
5.0,
52.5
],
[
5.0,
52.0
],
[
5.0,
51.5
],
[
5.0,
51.0
],
[
5.0,
50.5
],
[
5.0,
50.0
],
[
4.0,
50.0
],
[
3.0,
50.0
],
[
2.0,
50.0
],
[
1.0,
50.0
],
[
0.0,
50.0
]
]
]
},
"spatialRef": "EPSG:4326",
"variables": [
{
Expand Down Expand Up @@ -790,16 +889,6 @@
}
],
"dimensions": [
{
"name": "time",
"size": 3,
"dtype": "datetime64[ns]",
"coordinates": [
"2017-01-22T00:00:00Z",
"2017-01-29T00:00:00Z",
"2017-02-05T00:00:00Z"
]
},
{
"name": "lat",
"size": 1000,
Expand Down Expand Up @@ -1807,6 +1896,16 @@
50.00125
]
},
{
"name": "time",
"size": 3,
"dtype": "datetime64[ns]",
"coordinates": [
"2017-01-22T00:00:00Z",
"2017-01-29T00:00:00Z",
"2017-02-05T00:00:00Z"
]
},
{
"name": "lon",
"size": 2000,
Expand Down
121 changes: 110 additions & 11 deletions test/webapi/ows/stac/stac-single-item.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,111 @@
}
},
"xcube:dataset": {
"id": "demo-1w",
"title": "xcube-server Demonstration L3 Cube",
"groupTitle": "Demo",
"tags": [
"demo",
"zarr",
"computed"
],
"bbox": [
0.0,
50.0,
5.0,
52.5
],
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
0.0,
50.0
],
[
0.0,
50.5
],
[
0.0,
51.0
],
[
0.0,
51.5
],
[
0.0,
52.0
],
[
0.0,
52.5
],
[
1.0,
52.5
],
[
2.0,
52.5
],
[
3.0,
52.5
],
[
4.0,
52.5
],
[
5.0,
52.5
],
[
5.0,
52.0
],
[
5.0,
51.5
],
[
5.0,
51.0
],
[
5.0,
50.5
],
[
5.0,
50.0
],
[
4.0,
50.0
],
[
3.0,
50.0
],
[
2.0,
50.0
],
[
1.0,
50.0
],
[
0.0,
50.0
]
]
]
},
"spatialRef": "EPSG:4326",
"variables": [
{
Expand Down Expand Up @@ -790,16 +889,6 @@
}
],
"dimensions": [
{
"name": "time",
"size": 3,
"dtype": "datetime64[ns]",
"coordinates": [
"2017-01-22T00:00:00Z",
"2017-01-29T00:00:00Z",
"2017-02-05T00:00:00Z"
]
},
{
"name": "lat",
"size": 1000,
Expand Down Expand Up @@ -1807,6 +1896,16 @@
50.00125
]
},
{
"name": "time",
"size": 3,
"dtype": "datetime64[ns]",
"coordinates": [
"2017-01-22T00:00:00Z",
"2017-01-29T00:00:00Z",
"2017-02-05T00:00:00Z"
]
},
{
"name": "lon",
"size": 2000,
Expand Down Expand Up @@ -3819,7 +3918,7 @@
"Conventions": "CF-1.7"
},
"attributions": [
"\u00a9 by Brockmann Consult GmbH 2020, contains modified Copernicus Data 2019, processed by ESA"
"© by Brockmann Consult GmbH 2020, contains modified Copernicus Data 2019, processed by ESA"
]
},
"datetime": null,
Expand Down
10 changes: 5 additions & 5 deletions xcube/webapi/ows/stac/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ def _get_single_dataset_collection(
},
"temporal": {"interval": [time_interval], "grid": get_time_grid(dataset)},
},
"id": dataset_dict.pop("id"),
"id": dataset_dict.get("id"),
"keywords": [],
"license": "proprietary",
"links": [
Expand Down Expand Up @@ -805,9 +805,9 @@ def _get_dataset_feature(
"stac_version": STAC_VERSION,
"stac_extensions": STAC_EXTENSIONS,
"type": "Feature",
"id": dataset_dict.pop("id"),
"bbox": dataset_dict.pop("bbox"),
"geometry": dataset_dict.pop("geometry"),
"id": dataset_dict.get("id"),
"bbox": dataset_dict.get("bbox"),
"geometry": dataset_dict.get("geometry"),
"properties": _get_cube_properties(ctx, dataset_id, dataset_dict),
"collection": collection_id,
"links": [
Expand Down Expand Up @@ -840,7 +840,7 @@ def _get_cube_properties(
dataset = ml_dataset.base_dataset

properties = dict()
properties["title"] = dataset_dict.pop("title", dataset_id)
properties["title"] = dataset_dict.get("title", dataset_id)
cube_dimensions = get_datacube_dimensions(dataset, grid_mapping)
properties["cube:dimensions"] = cube_dimensions
properties["cube:variables"] = _get_dc_variables(dataset, cube_dimensions)
Expand Down

0 comments on commit 8557eea

Please sign in to comment.