-
-
Notifications
You must be signed in to change notification settings - Fork 317
Further Fixes for STAC Search #2340
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -284,7 +284,7 @@ def landing_page(api: API, | |
| 'rel': 'search', | ||
| 'type': FORMAT_TYPES[F_JSON], | ||
| 'title': l10n.translate('STAC API search', request.locale), | ||
| 'href': f"{api.base_url}/stac-api//search?f={F_JSON}" | ||
| 'href': f"{api.base_url}/stac-api/search?f={F_JSON}" | ||
| }] | ||
|
|
||
| return headers, status, to_json(content, api.pretty_print) | ||
|
|
@@ -379,9 +379,17 @@ def search(api: API, request: Union[APIRequest, Any]) -> Tuple[dict, int, str]: | |
| geom = from_geojson(json.dumps(feature['geometry'])) | ||
| feature['bbox'] = geom.bounds | ||
|
|
||
| for la in ['links', 'assets']: | ||
| if feature.get(la) is None: | ||
| feature[la] = [] | ||
| if feature.get('links') is None: | ||
| feature['links'] = feature\ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. I am seeing: .get('properties', {})\
.get('content', {})\
.get('links', [])A STAC Item indeed has
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed. This is quirk of the pgSTAC back-end. Please see #2355 for a more detailed explanation. I can also add a comment here pointing to that to keep the context near the code. Also open to alternative approaches to address this discrepancy.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case, I would suggest removing this given it is backend specific. You can work around this by adding your own feature provider plugin which reads PgSTAC and returns items such that the STAC code in pygeoapi is reading content on the absence of a backend specific data model. |
||
| .get('properties', {})\ | ||
| .get('content', {})\ | ||
| .get('links', []) | ||
|
|
||
| if feature.get('assets') is None: | ||
| feature['assets'] = feature\ | ||
| .get('properties', {})\ | ||
| .get('content', {})\ | ||
| .get('assets', {}) | ||
|
|
||
| stac_api_response['numberReturned'] = len(stac_api_response['features']) | ||
|
|
||
|
|
@@ -488,18 +496,20 @@ def get_temporal(feature: dict) -> dict: | |
| if datetime_ is None and None not in [start_datetime, end_datetime]: | ||
| LOGGER.debug('Temporal range partially exists') | ||
| elif datetime_ is not None: | ||
| value['datetime'] = datetime_ | ||
| LOGGER.debug('Temporal instant exists') | ||
|
|
||
| LOGGER.debug('Attempting to derive temporal from GeoJSON feature') | ||
| LOGGER.debug(feature) | ||
| if feature.get('time') is not None: | ||
| if value.get('datetime') is None and feature.get('time') is not None: | ||
| if feature['time'].get('timestamp') is not None: | ||
| value['datetime'] = feature['time']['timestamp'] | ||
| if feature['time'].get('interval') is not None: | ||
| value['start_datetime'] = feature['time']['interval'][0] | ||
| value['end_datetime'] = feature['time']['interval'][1] | ||
|
|
||
| if feature['properties'].get('created') is not None: | ||
| if value.get('datetime') is None \ | ||
| and feature['properties'].get('created') is not None: | ||
| value['datetime'] = feature['properties']['created'] | ||
|
|
||
| if not value: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the content model that this update is based on? Is
properties.content.linksandproperties.content.assetspart of STAC proper?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. As can be seen in the STAC Spec:
linksis a list, andassetsis a dict.