Skip to content

Commit 95d5fbd

Browse files
committed
ODataToSTAC template for cadip and auxip
1 parent 6f51f00 commit 95d5fbd

File tree

4 files changed

+7
-15
lines changed

4 files changed

+7
-15
lines changed

services/adgs/config/ODataToSTAC_template.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"stac_version": "1.0.0",
33
"stac_extensions": [
4-
"https://stac-extensions.github.io/file/v2.1.0/schema.json"
4+
"https://stac-extensions.github.io/file/v2.1.0/schema.json",
5+
"https://stac-extensions.github.io/timestamps/v1.1.0/schema.json"
56
],
67
"type": "Feature",
78
"id": "PLACEHOLDER",

services/adgs/rs_server_adgs/adgs_utils.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
ADGS_CONFIG = Path(osp.realpath(osp.dirname(__file__))).parent / "config"
3333
search_yaml = ADGS_CONFIG / "adgs_search_config.yaml"
34-
TIMESTAMPS_EXTENSION_1_1_0 = "https://stac-extensions.github.io/timestamps/v1.1.0/schema.json"
3534

3635

3736
@lru_cache()
@@ -60,27 +59,17 @@ def stac_to_odata(stac_params: dict) -> dict:
6059

6160

6261
def serialize_adgs_asset(feature_collection, products):
63-
"""Update ADGS asset with proper href and format {asset_name: asset_body},
64-
and ensure the timestamps extension is included when a 'published' field is present."""
65-
62+
"""Used to update adgs asset with propper href and format {asset_name: asset_body}."""
6663
for feature in feature_collection.features:
67-
props = feature.properties.dict()
68-
auxip_id = props["auxip:id"]
69-
64+
auxip_id = feature.properties.dict()["auxip:id"]
7065
# Find matching product by id and update feature href
7166
try:
7267
matched_product = next((p for p in products if p.properties["id"] == auxip_id), None)
7368
except StopIteration as exc:
7469
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=f"Unable to map {feature.id}") from exc
7570
if matched_product:
7671
feature.assets["file"].href = re.sub(r"\([^\)]*\)", f"({auxip_id})", matched_product.properties["href"])
77-
78-
# Check for the 'published' field; if present, ensure the timestamps extension is added.
79-
if "published" in props:
80-
if TIMESTAMPS_EXTENSION_1_1_0 not in feature.stac_extensions:
81-
feature.stac_extensions.append(TIMESTAMPS_EXTENSION_1_1_0)
82-
83-
# Rename the "file" asset key to feature.id
72+
# Rename "file" asset to feature.id
8473
feature.assets[feature.id] = feature.assets.pop("file")
8574

8675
return feature_collection

services/cadip/config/cadip_session_ODataToSTAC_template.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"stac_version": "1.0.0",
33
"stac_extensions": [
4+
"https://stac-extensions.github.io/file/v2.1.0/schema.json",
45
"https://stac-extensions.github.io/timestamps/v1.1.0/schema.json"
56
],
67
"type": "Feature",

tests/resources/endpoints/cadip_feature.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
}
8383
],
8484
"stac_extensions": [
85+
"https://stac-extensions.github.io/file/v2.1.0/schema.json",
8586
"https://stac-extensions.github.io/timestamps/v1.1.0/schema.json"
8687
],
8788
"collection": "cadip_session_by_id"

0 commit comments

Comments
 (0)