|
56 | 56 | ) |
57 | 57 | from pygeoapi.util import ( |
58 | 58 | filter_dict_by_key_value, get_current_datetime, get_provider_by_type, |
59 | | - render_j2_template, to_json |
| 59 | + render_j2_template, to_json, get_base_url |
60 | 60 | ) |
61 | 61 |
|
62 | 62 | from . import APIRequest, API, FORMAT_TYPES, F_JSON, F_HTML |
@@ -200,6 +200,8 @@ def get_stac_path(api: API, request: APIRequest, |
200 | 200 | content['links'].extend( |
201 | 201 | stac_collections[dataset].get('links', [])) |
202 | 202 |
|
| 203 | + linked_data = api.config['resources'][dataset].get('linked-data') |
| 204 | + |
203 | 205 | if request.format == F_HTML: # render |
204 | 206 | content['path'] = path |
205 | 207 | if 'assets' in content: # item view |
@@ -227,6 +229,18 @@ def get_stac_path(api: API, request: APIRequest, |
227 | 229 |
|
228 | 230 | return headers, HTTPStatus.OK, content |
229 | 231 |
|
| 232 | + elif (linked_data |
| 233 | + and all(linked_data.get(k) |
| 234 | + for k in ('context', 'inject_verbatim_context'))): |
| 235 | + content = { |
| 236 | + '@context': linked_data['context'], |
| 237 | + **content |
| 238 | + } |
| 239 | + if replace_id_field := linked_data.get('replace_id_field'): |
| 240 | + content[replace_id_field] = (f"{get_base_url(api.config)}" |
| 241 | + f"/stac/{path}") |
| 242 | + pass |
| 243 | + |
230 | 244 | return headers, HTTPStatus.OK, to_json(content, api.pretty_print) |
231 | 245 |
|
232 | 246 | else: # send back file |
|
0 commit comments