stac-fastapi icon indicating copy to clipboard operation
stac-fastapi copied to clipboard

Collection bbox filtering from stac-browser

Open carderne opened this issue 2 years ago • 2 comments

The collection-level filter in stac-browser makes a request that looks like:

/collections{collection_id}/items?bbox=1,2,3,4

But the bbox query param is ignore in that route in stac-fastapi.pgstac. Eg this request to the MS PC API, which returns an Item nowhere near the requested bbox.

The route called doesn't do anything with the bbox: https://github.com/stac-utils/stac-fastapi/blob/fbdd9931721a73fbbf54646f853ef720dfb25268/stac_fastapi/pgstac/stac_fastapi/pgstac/core.py#L270-L273

As far as I can tell this is not an issue on stac-browser's side. Would appreciate some help understanding how this is supposed to work, because it seems like there's more going on that just adding bbox to the queries passed to _search_base? If not I'm happy to work on a PR to do that...

carderne avatar Oct 06 '22 14:10 carderne

Same as #380

The bbox and datetime query parameters on the /items endpoint are part of OGC API - Features (OAF) and not currently supported by stac-fastapi. Note that STAC extends OAF, but they are two different specifications. It would be really nice to support them though because this has caused some confusion (as mentioned in #380 ). PRs are more than welcome! 😄

In order to implement this:

  • This class defines the query parameters accepted by the /items endpoint. Add bbox and datetime.
  • Update the abstract base classes (here and here) to accept optional bbox and datetime arguments. This will allow the backend clients to accept these query parameters.
  • Update the backend implementations to implement the two new parameters.
    • The sqlalchemy backend will support this, I'd recommend starting there.
    • This may require a change to pgstac, @bitner @vincentsarago would know more.

You can find more information about how bbox and datetime should be implemented here:

  • The STAC OpenAPI fragments - https://github.com/radiantearth/stac-api-spec/blob/main/ogcapi-features/openapi.yaml#L119-L144
  • The OGC API - Features specification - https://docs.opengeospatial.org/is/17-069r4/17-069r4.html#_features_rootcollectionscollectioniditems

geospatial-jeff avatar Oct 06 '22 14:10 geospatial-jeff

Thanks I didn’t find that duplicate issue somehow. Will dig into this tomorrow.

carderne avatar Oct 06 '22 15:10 carderne