Skip to content

Commit

Permalink
add record links to ogc-api records item (geopython#880)
Browse files Browse the repository at this point in the history
* add record links to ogc-api records item

* Update records.py

---------

Co-authored-by: Genuchten <paul.vangenuchten@wur.nl>
Co-authored-by: Tom Kralidis <tomkralidis@gmail.com>
  • Loading branch information
3 people authored Aug 11, 2023
1 parent 94673d0 commit a007cac
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pycsw/ogc/api/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import json
import logging
import os
from urllib.parse import urlencode
from urllib.parse import urlencode, quote

from pygeofilter.parsers.ecql import parse as parse_ecql
from pygeofilter.parsers.cql2_json import parse as parse_cql2_json
Expand Down Expand Up @@ -1129,6 +1129,19 @@ def record2json(record, url, collection, stac_item=False):

rdl.append(link2)

for lnk in [record.parentidentifier, record.relation]:
if lnk and len(lnk.strip()) > 0:
if not lnk.startswith('http'):
lnk = f"{url}/collections/{collection}/items/{quote(lnk)}"
record_dict['links'].append({
'rel': 'related',
'href': lnk,
'name': 'related record',
'description': 'related record',
'type': 'application/json'
})


record_dict['links'].append({
'rel': 'collection',
'type': 'application/json',
Expand Down

0 comments on commit a007cac

Please sign in to comment.