Skip to content

Commit a051f76

Browse files
committed
add license queryable (#1208)
1 parent 73f1483 commit a051f76

File tree

7 files changed

+16
-6
lines changed

7 files changed

+16
-6
lines changed

pycsw/core/metadata.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,6 +1834,7 @@ def _parse_stac_resource(context, repos, record):
18341834
_set(context, recobj, 'pycsw:CreationDate', record['properties'].get('created'))
18351835
_set(context, recobj, 'pycsw:Modified', record['properties'].get('updated'))
18361836
_set(context, recobj, 'pycsw:Platform', record['properties'].get('platform'))
1837+
_set(context, recobj, 'pycsw:OtherConstraints', record['properties'].get('license'))
18371838
instruments = record['properties'].get('instruments')
18381839
if instruments is not None:
18391840
_set(context, recobj, 'pycsw:Instrument', ','.join(instruments))
@@ -1853,6 +1854,7 @@ def _parse_stac_resource(context, repos, record):
18531854
_set(context, recobj, 'pycsw:CreationDate', record.get('created'))
18541855
_set(context, recobj, 'pycsw:Modified', record.get('updated'))
18551856
_set(context, recobj, 'pycsw:Platform', record.get('platform'))
1857+
_set(context, recobj, 'pycsw:OtherConstraints', record.get('license'))
18561858
instruments = record.get('instruments')
18571859
if instruments is not None:
18581860
_set(context, recobj, 'pycsw:Instrument', ','.join(instruments))
@@ -1876,6 +1878,7 @@ def _parse_stac_resource(context, repos, record):
18761878
_set(context, recobj, 'pycsw:CreationDate', record.get('created'))
18771879
_set(context, recobj, 'pycsw:Modified', record.get('updated'))
18781880
_set(context, recobj, 'pycsw:Platform', record.get('platform'))
1881+
_set(context, recobj, 'pycsw:OtherConstraints', record.get('license'))
18791882
instruments = record.get('instruments')
18801883
if instruments is not None:
18811884
_set(context, recobj, 'pycsw:Instrument', ','.join(instruments))

pycsw/core/repository.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ def __init__(self, database, context, app_root=None, table='records', repo_filte
169169
'instrument': self.dataset.instrument,
170170
'sensortype': self.dataset.sensortype,
171171
'off_nadir': self.dataset.illuminationelevationangle,
172-
'distancevalue': self.dataset.distancevalue
172+
'distancevalue': self.dataset.distancevalue,
173+
'otherconstraints': self.dataset.otherconstraints
173174
}
174175

175176
if self.dbtype == 'postgresql':

tests/functionaltests/suites/oarec/test_oarec_functional.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def test_queryables(config):
108108
assert content['$id'] == 'http://localhost/pycsw/oarec/collections/metadata:main/queryables' # noqa
109109
assert content['$schema'] == 'http://json-schema.org/draft/2019-09/schema'
110110

111-
assert len(content['properties']) == 18
111+
assert len(content['properties']) == 19
112112

113113
assert 'geometry' in content['properties']
114114
assert content['properties']['geometry']['$ref'] == 'https://geojson.org/schema/Polygon.json' # noqa

tests/functionaltests/suites/oarec/test_oarec_virtual_collections_functional.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def test_queryables(config_virtual_collections):
116116
assert content['$id'] == 'http://localhost/pycsw/oarec/collections/metadata:main/queryables' # noqa
117117
assert content['$schema'] == 'http://json-schema.org/draft/2019-09/schema'
118118

119-
assert len(content['properties']) == 18
119+
assert len(content['properties']) == 19
120120

121121
assert 'geometry' in content['properties']
122122
assert content['properties']['geometry']['$ref'] == 'https://geojson.org/schema/Polygon.json' # noqa

tests/functionaltests/suites/stac_api/data/S2A_MSIL2A_20241128T092331_R093_T34SEJ_20241128T122153.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,7 @@
689689
},
690690
"collection": "sentinel-2-l2a",
691691
"properties": {
692+
"license": "other",
692693
"datetime": "2024-11-28T09:23:31.024000Z",
693694
"platform": "Sentinel-2A",
694695
"proj:epsg": 32634,
@@ -730,4 +731,4 @@
730731
"https://stac-extensions.github.io/projection/v1.0.0/schema.json"
731732
],
732733
"stac_version": "1.0.0"
733-
}
734+
}
0 Bytes
Binary file not shown.

tests/functionaltests/suites/stac_api/test_stac_api_functional.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Authors: Tom Kralidis <tomkralidis@gmail.com>
44
# Angelos Tzotsos <gcpp.kalxas@gmail.com>
55
#
6-
# Copyright (c) 2025 Tom Kralidis
6+
# Copyright (c) 2026 Tom Kralidis
77
# Copyright (c) 2022 Angelos Tzotsos
88
#
99
# Permission is hereby granted, free of charge, to any person
@@ -134,7 +134,7 @@ def test_queryables(config):
134134
assert content['$id'] == 'http://localhost/pycsw/oarec/stac/collections/metadata:main/queryables' # noqa
135135
assert content['$schema'] == 'http://json-schema.org/draft/2019-09/schema'
136136

137-
assert len(content['properties']) == 18
137+
assert len(content['properties']) == 19
138138

139139
assert 'geometry' in content['properties']
140140
assert content['properties']['geometry']['$ref'] == 'https://geojson.org/schema/Polygon.json' # noqa
@@ -191,6 +191,11 @@ def test_items(config):
191191
assert content['numberMatched'] == 26
192192
assert content['features'][6]['properties']['title'] == 'S2B_MSIL1C_20190910T095029_N0208_R079_T33UWQ_20190910T120910.SAFE' # noqa
193193

194+
content = json.loads(api.items({}, None, {'otherconstraints': 'other'})[2])
195+
196+
assert content['numberMatched'] == 1
197+
assert content['features'][0]['properties']['license'] == 'other'
198+
194199
content = json.loads(api.items({}, None, {'sortby': '-title'})[2])
195200

196201
assert content['numberMatched'] == 26

0 commit comments

Comments
 (0)