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

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

Merged
merged 4 commits into from
Jan 10, 2024
Merged

Conversation

hrodmn
Copy link
Collaborator

@hrodmn hrodmn commented Jan 2, 2024

I added the capability to query asset values at a point as discussed in #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.

@@ -364,7 +364,9 @@ def _reader(
if "allowed_exceptions" not in kwargs:
kwargs.update({"allowed_exceptions": (PointOutsideBounds,)})

return list(multi_values(mosaic_assets, _reader, lon, lat, **kwargs).items())
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to go away from multi_values because the STAC item metadata was getting set to the dictionary keys and I was getting an unhashable error.

@vincentsarago vincentsarago merged commit 19f7ee9 into stac-utils:main Jan 10, 2024
7 checks passed
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

Successfully merging this pull request may close these issues.

2 participants