|
31 | 31 |
|
32 | 32 | ADGS_CONFIG = Path(osp.realpath(osp.dirname(__file__))).parent / "config" |
33 | 33 | 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" |
35 | 34 |
|
36 | 35 |
|
37 | 36 | @lru_cache() |
@@ -60,27 +59,17 @@ def stac_to_odata(stac_params: dict) -> dict: |
60 | 59 |
|
61 | 60 |
|
62 | 61 | 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}.""" |
66 | 63 | 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"] |
70 | 65 | # Find matching product by id and update feature href |
71 | 66 | try: |
72 | 67 | matched_product = next((p for p in products if p.properties["id"] == auxip_id), None) |
73 | 68 | except StopIteration as exc: |
74 | 69 | raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=f"Unable to map {feature.id}") from exc |
75 | 70 | if matched_product: |
76 | 71 | 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 |
84 | 73 | feature.assets[feature.id] = feature.assets.pop("file") |
85 | 74 |
|
86 | 75 | return feature_collection |
|
0 commit comments