Further Fixes for STAC Search#2340
Conversation
2d5f412 to
a33a862
Compare
tomkralidis
left a comment
There was a problem hiding this comment.
See change requests. It would be valuable to clarify the problems the PR attempts to address/fix (and/or feel free to create an issue). Thanks!
| for la in ['links', 'assets']: | ||
| if feature.get(la) is None: | ||
| feature[la] = [] | ||
| if feature.get('links') is None: |
There was a problem hiding this comment.
What is the content model that this update is based on? Is properties.content.links and properties.content.assets part of STAC proper?
There was a problem hiding this comment.
| LOGGER.debug('Attempting to derive temporal from GeoJSON feature') | ||
| LOGGER.debug(feature) | ||
| if feature.get('time') is not None: | ||
| if not value.get('datetime') and feature.get('time') is not None: |
There was a problem hiding this comment.
Can we do if value.get('datetime') is None and feature.get('time') is not None: for readability?
| value['end_datetime'] = feature['time']['interval'][1] | ||
|
|
||
| if feature['properties'].get('created') is not None: | ||
| if not value.get('datetime') \ |
There was a problem hiding this comment.
Can we do if value.get('datetime') is None and feature['properties'].get('created') is not None: for readability?
|
Thank you for taking a quick look! I'll add more context and motivation for the changes, and make the readability improvements today. 🙏 |
This mistakenly used double slashes in the URL which would break the output. A single slash fixes this. Closes geopython#2354
As specified in the STAC spec: https://stacspec.org/en/about/stac-spec/ assets are dicts, not lists. When missing, now they are initialized as the correct empty data structures. Closes geopython#2354
Althought the STAC specification expects links and assets to be top-level items, this is not the case in pgSTAC tables, which store the details in a `contents` JSONB column: https://github.com/stac-utils/pgstac/blob/08ce5991e7840f51993d508c715fad44f889e5e5/src/pgstac/pgstac.sql#L889-L899 In cases where the top-level items are not available, we attempt to source them fromm the pgSTAC-specific source if available. Closes geopython#2355
Previously the `datetime` field was not used to initalize the temporal instant, causing it to be overridden by other approximations. This ensure that the initialization happens correctly, and the overrides only occur in cases when `datetime` is None. Closes geopython#2356
a33a862 to
72e7a7f
Compare
|
Apologies for the long delay in getting back to this. I created cards specifying the individual issues we need to fix: #2354, #2355, #2356. I've also marked this PR as closing those bugs. I've also added more detail to the individual commits, better explaining their relevance and motivation. And I've incorporated your keen recommendations to improve readability. Would appreciate a second look at your convenience. Thank you! |
| if feature.get(la) is None: | ||
| feature[la] = [] | ||
| if feature.get('links') is None: | ||
| feature['links'] = feature\ |
There was a problem hiding this comment.
Thanks. I am seeing:
.get('properties', {})\
.get('content', {})\
.get('links', [])A STAC Item indeed has links and assets, but they are at the root of the STAC item, not in an object called properties.content.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.

Overview
Minor fixes that allow the STAC search endpoint to work correctly. This is in support of the USGS NHGF work.
Related Issue / discussion
This is a continuation of #2153.
Closes #2354
Closes #2355
Closes #2356
Additional information
Dependency policy (RFC2)
Updates to public demo
Contributions and licensing
(as per https://github.com/geopython/pygeoapi/blob/master/CONTRIBUTING.md#contributions-and-licensing)