Skip to content

Commit 4e1aa2c

Browse files
committed
STAC: use asset keys if they exist; update native STAC item response media type evaluation
1 parent 745857b commit 4e1aa2c

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

pycsw/core/metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1890,7 +1890,7 @@ def _parse_stac_resource(context, repos, record):
18901890
}
18911891

18921892
if link.get('title') is not None:
1893-
new_link['name'] = link.get('title')
1893+
new_link['name'] = key
18941894
new_link['description'] = link.get('title')
18951895
if link.get('type') is not None:
18961896
new_link['protocol'] = link.get('type')

pycsw/ogc/api/records.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ def record2json(record, url, collection, mode='ogcapi-records'):
11281128
:returns: `dict` of record GeoJSON
11291129
"""
11301130

1131-
if record.metadata_type == 'application/json':
1131+
if record.metadata_type in ['application/json', 'application/geo+json']:
11321132
rec = json.loads(record.metadata)
11331133
if rec.get('stac_version') is not None and rec['type'] == 'Feature' and mode == 'stac-api':
11341134
LOGGER.debug('Returning native STAC representation')

pycsw/stac/api.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,12 @@ def links2stacassets(collection, record):
565565
if 'assets' not in record:
566566
record['assets'] = {}
567567

568-
for count, value in enumerate(links_assets):
569-
record['assets'][count] = value
568+
for count, asset in enumerate(links_assets):
569+
if 'name' in asset:
570+
asset_key = asset.pop('name')
571+
else:
572+
asset_key = count
573+
574+
record['assets'][asset_key] = asset
570575

571576
return record

tests/functionaltests/suites/stac_api/test_stac_api_functional.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ def test_item(config):
247247
assert content['stac_version'] == '1.0.0'
248248
assert content['collection'] == 'S2MSI2A'
249249

250+
assert 'assets' in content
251+
assert 'B02' in content['assets']
252+
assert 'product-metadata' in content['assets']
253+
250254
for link in content['links']:
251255
assert 'href' in link
252256
assert 'rel' in link

0 commit comments

Comments
 (0)