stac-utils / titiler-pgstac

TiTiler + PgSTAC
https://stac-utils.github.io/titiler-pgstac/
MIT License
80 stars 29 forks source link

add /{lon},{lat}/values endpoints #146

Closed hrodmn closed 10 months ago

hrodmn commented 10 months ago

I added the capability to query asset values at a point as discussed in https://github.com/stac-utils/titiler-pgstac/discussions/144.

Rather than a dedicated /point endpoint, I followed the pattern for querying assets at a lon/lat pair ({lon}/{lat}/assets).

I tried to mimic the response class from the analagous titiler endpoint, the only difference is that the assets object comes back as a list. It looks like this:

{
  'coordinates': [-85.5, 36.1624],
  'values': [
    [
      ['https://noaa-eri-pds.s3.us-east-1.amazonaws.com/2020_Nashville_Tornado/20200307a_RGB/20200307aC0853130w361030n.tif'],
      [27.0, 34.0, 42.0],
      ['cog_b1', 'cog_b2', 'cog_b3']
    ],
    [
      ['https://noaa-eri-pds.s3.us-east-1.amazonaws.com/2020_Nashville_Tornado/20200307a_RGB/20200307aC0853000w361030n.tif'],
      [30.0, 34.0, 43.0],
      ['cog_b1', 'cog_b2', 'cog_b3']
    ]
  ]
}

The other odd thing is that if you send a query for a point that doesn't intersect any assets, you get a 204 instead of a 200 with an empty values list.