-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add queryables * bump pgstac version * add tests for queryables * make id refer to current url * update content type, add changelog
- Loading branch information
Showing
8 changed files
with
77 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
stac_fastapi/pgstac/stac_fastapi/pgstac/extensions/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
"""pgstac extension customisations.""" | ||
|
||
from .filter import FiltersClient | ||
from .query import QueryExtension | ||
|
||
__all__ = ["QueryExtension"] | ||
__all__ = ["QueryExtension", "FiltersClient"] |
37 changes: 37 additions & 0 deletions
37
stac_fastapi/pgstac/stac_fastapi/pgstac/extensions/filter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"""Get Queryables.""" | ||
from typing import Any, Optional | ||
|
||
from buildpg import render | ||
from fastapi import Request | ||
from fastapi.responses import JSONResponse | ||
|
||
from stac_fastapi.types.core import AsyncBaseFiltersClient | ||
|
||
|
||
class FiltersClient(AsyncBaseFiltersClient): | ||
"""Defines a pattern for implementing the STAC filter extension.""" | ||
|
||
async def get_queryables( | ||
self, request: Request, collection_id: Optional[str] = None, **kwargs: Any | ||
) -> JSONResponse: | ||
"""Get the queryables available for the given collection_id. | ||
If collection_id is None, returns the intersection of all | ||
queryables over all collections. | ||
This base implementation returns a blank queryable schema. This is not allowed | ||
under OGC CQL but it is allowed by the STAC API Filter Extension | ||
https://github.com/radiantearth/stac-api-spec/tree/master/fragments/filter#queryables | ||
""" | ||
pool = request.app.state.readpool | ||
|
||
async with pool.acquire() as conn: | ||
q, p = render( | ||
""" | ||
SELECT * FROM get_queryables(:collection::text); | ||
""", | ||
collection=collection_id, | ||
) | ||
queryables = await conn.fetchval(q, *p) | ||
queryables["$id"] = str(request.url) | ||
headers = {"Content-Type": "application/schema+json"} | ||
return JSONResponse(queryables, headers=headers) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters