Skip to content
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

Links returned by search queries don't contain custom fields #247

Open
pedro-cf opened this issue May 6, 2024 · 2 comments
Open

Links returned by search queries don't contain custom fields #247

pedro-cf opened this issue May 6, 2024 · 2 comments

Comments

@pedro-cf
Copy link
Collaborator

pedro-cf commented May 6, 2024

Describe the bug
Links returned by search queries don't contain custom fields.

To Reproduce

  1. Run app docker-compose up
  2. Create test collection
curl --request POST \
  --url http://localhost:8080/collections \
  --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
  --header 'Content-Type: application/json' \
  --data '{"id":"test-collection","stac_extensions":["https://stac-extensions.github.io/eo/v1.0.0/schema.json"],"type":"Collection","description":"Landat 8 imagery radiometrically calibrated and orthorectified using gound points and Digital Elevation Model (DEM) data to correct relief displacement.","stac_version":"1.0.0","summaries":{"platform":["landsat-8"],"instruments":["oli","tirs"],"gsd":[30]},"extent":{"spatial":{"bbox":[[-180,-90,180,90]]},"temporal":{"interval":[["2013-06-01",null]]}},"links":[{"href":"http://localhost:8081/collections/landsat-8-l1","rel":"self","type":"application/json"},{"href":"http://localhost:8081/","rel":"parent","type":"application/json"},{"href":"http://localhost:8081/collections/landsat-8-l1/items","rel":"item","type":"application/geo+json"},{"href":"http://localhost:8081/","rel":"root","type":"application/json"}],"title":"Landsat 8 L1","keywords":["landsat","earth observation","usgs"]}'
  1. Create item with custom links (example from https://github.com/stac-extensions/web-map-links):
curl --request POST \
  --url http://localhost:8080/collections/test-collection/items \
  --header 'Content-Type: application/json' \
  --data '{"stac_version":"1.0.0","collection":"test-collection","stac_extensions":["https://stac-extensions.github.io/web-map-links/v1.2.0/schema.json"],"type":"Feature","id":"item","bbox":[172.9,1.3,173,1.4],"geometry":{"type":"Polygon","coordinates":[[[172.9,1.3],[173,1.3],[173,1.4],[172.9,1.4],[172.9,1.3]]]},"properties":{"datetime":"2020-12-11T22:38:32Z"},"attribution":"© 2022 The Example Corp.","links":[{"href":"https://example.com/examples/item.json","rel":"self"},{"href":"https://maps.example.com/wmts","rel":"wmts","type":"image/png","title":"RGB composite visualized through a WMTS","wmts:layer":["streets","satellite"]},{"href":"https://maps.example.com/wms","rel":"wms","type":"image/png","title":"RGB composite visualized through a WMS","wms:layers":["rgb"],"wms:transparent":true},{"href":"https://maps.example.com/xyz/{z}/{x}/{y}.jpg","rel":"xyz","type":"image/jpeg","title":"RGB composite visualized through a XYZ"},{"href":"https://maps.example.com/item/tilejson.json","rel":"tilejson","title":"TileJSON","type":"application/json"},{"href":"https://storage.googleapis.com/open-cogs/planet-stac/cocabamba-peru/3d-geofox.ai/3DTiles/tileset.json","rel":"3d-tiles","title":"3D Tiles","type":"application/json"},{"href":"https://maps.example.com/item/example.pmtiles","rel":"pmtiles","title":"PMTiles","type":"application/vnd.pmtiles","pmtiles:layers":["streets"]}],"assets":{}}'
  1. Search for all items:
curl --request POST \
  --url http://localhost:8080/search \
  --header 'Content-Type: application/json' \
  --data '{}'
  1. Response will will include links as follows:
"links": [
{
	"href": "https://maps.example.com/wms",
	"rel": "wms",
	"type": "image/png",
	"title": "RGB composite visualized through a WMS"
}

Expected behavior
Web Map Links should include custom fields like:

{
      "href": "https://maps.example.com/wms",
      "rel": "wms",
      "type": "image/png",
      "title": "RGB composite visualized through a WMS",
      "wms:layers": [
        "rgb"
      ],
      "wms:transparent": true
}

Additional context

stac_pydantic.Item(**feat).json(**filter_kwargs, exclude_unset=True)

Issue seems to be the version of stac_pydantic==2.0.*, I believe this will be fixed if upgraded to stac_pydantic==3.0.0 with stac-fastapi.api==3.0.0

@jonhealy1
Copy link
Collaborator

This may be fixed in the new version of stac-fastapi - 3.0 - but let's write a test for this before we close the issue.

@jonhealy1
Copy link
Collaborator

This is not working as of #234. This should work according to the item spec: https://schemas.stacspec.org/v1.0.0/item-spec/json-schema/item.json. I think we should start an issue in stac-pydantic.

jonhealy1 added a commit that referenced this issue May 10, 2024
**Related Issue(s):**

- #238 
- #247 
- #249 
- stac-utils/stac-fastapi-pgstac#108
- stac-utils/stac-fastapi#685
- stac-utils/stac-fastapi#687
- stac-utils/stac-fastapi#690
- 

**Description:**

Update stac-fastapi parent libraries to v3.0.0a. There are quite a few
changes made in this pr.

**PR Checklist:**

- [x] Code is formatted and linted (run `pre-commit run --all-files`)
- [x] Tests pass (run `make test`)
- [x] Documentation has been updated to reflect changes, if applicable
- [x] Changes are added to the changelog

---------

Co-authored-by: pedro-cf <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants