Skip to content

OARec: output values if they exist #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions pygeometa/schemas/ogcapi_records/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def write(self, mcf: dict, stringify: str = True) -> Union[dict, str]:
record = {
'id': mcf['metadata']['identifier'],
'conformsTo': [
'http://www.opengis.net/spec/ogcapi-records-1/1.0/req/record-core', # noqa
'http://www.opengis.net/spec/ogcapi-records-1/1.0/conf/record-core', # noqa
],
'type': 'Feature',
'geometry': {
Expand All @@ -116,14 +116,16 @@ def write(self, mcf: dict, stringify: str = True) -> Union[dict, str]:
'title': title[0],
'description': description[0],
'themes': [],
'language': {
'code': self.lang1
},
'type': mcf['metadata']['hierarchylevel'],
},
'links': []
}

if self.lang1 is not None:
record['properties']['language'] = {
'code': self.lang1
}

LOGGER.debug('Checking for temporal')
try:
begin = mcf['identification']['extents']['temporal'][0]['begin']
Expand All @@ -141,6 +143,8 @@ def write(self, mcf: dict, stringify: str = True) -> Union[dict, str]:

if [begin, end] == [None, None]:
record['time'] = None
elif [begin, end] == ['..', '..']:
pass
else:
record['time'] = {
'interval': [begin, end]
Expand Down Expand Up @@ -214,6 +218,9 @@ def write(self, mcf: dict, stringify: str = True) -> Union[dict, str]:
if all_keywords:
record['properties']['keywords'] = all_keywords

if not record['properties']['themes']:
_ = record['properties'].pop('themes', None)

LOGGER.debug('Checking for licensing')
if mcf['identification'].get('license') is not None:
license = mcf['identification']['license']
Expand Down Expand Up @@ -388,10 +395,12 @@ def generate_link(self, distribution: dict) -> dict:
name = get_charstring(distribution.get('name'), self.lang1, self.lang2)

link = {
'href': distribution['url'],
'type': distribution['type']
'href': distribution['url']
}

if distribution.get('type') is not None:
link['type'] = distribution['type']

reltype = distribution.get('rel') or distribution.get('function')
if reltype is not None:
link['rel'] = reltype
Expand Down