-
Notifications
You must be signed in to change notification settings - Fork 112
WIP connect titiler for custom search tiling #97
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
Conversation
ids: Optional[str] = Query(None) | ||
datetime: Optional[str] = Query(None) | ||
limit: Optional[int] = Query(10) | ||
query: Optional[str] = Query(None) | ||
token: Optional[str] = Query(None) | ||
fields: Optional[str] = Query(None) | ||
sortby: Optional[str] = Query(None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: add title and description for each of these, so it shows up in openapi
Custom extension for sending query results to a titiler DynamicSTAC endpoint | ||
""" | ||
|
||
client: CoreCrudClient = attr.ib(default=attr.Factory(CoreCrudClient)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This uses the base CoreCrudClient
as all it needs is the client.get_search
method. I figured it wasn't necessary to subclass CoreCrudClient
like the TilesClient
does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense. TilesClient
arguably shouldn't subclass CoreCrudClient
either. I think composition is a better pattern here.
""" | ||
dynamic_stac_endpoint = MosaicTilerFactory( | ||
reader=DynamicStacBackend, | ||
reader_options={"client": self.client}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the best way to pass the client
to the MosaicTilerFactory
? I need to access the client in the MosaicBackend.get_assets
method, but it seems like it shouldn't be on the reader_options
. Maybe it's best to subclass the DynamicStacBackend
within this extension so you can attach the client there...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it seems like it shouldn't be on the reader_options.
I think it's ok to use the reader_options here and just pass a backend_options
dict within.
reader_options={"backend_options":{"client": self.client}},
that's how we do for STAC https://github.com/developmentseed/cogeo-mosaic/blob/master/cogeo_mosaic/backends/stac.py#L76
I agree it's not perfect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, in fact you are already creating a custom Mosaic Backend so you can still use reader_options={"client": self.client}
and make client a required parameter for your DynamicStacBackend
backend
|
||
print("feature_collection") | ||
print(feature_collection) | ||
return [default_stac_accessor(f) for f in feature_collection["features"]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't fully understand this... seems like here I'm returning the id of each stac item, rather than the stac items themselves... Seems like it would be better to return feature_collection['features']
and then use the resulting STAC dicts directly.
|
||
|
||
@attr.s | ||
class FakeRequest: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to mock the request
param passed through by default here https://github.com/arturo-ai/arturo-stac-api/blob/7ca0c8790ac64bbd359e88933ef94f25ece5b383/stac_api/api/routes.py#L58-L66
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A way to get around this is to inject a dependency which itself returns a request object. This works because dependencies always have access to the request:
from starlette.requests import Request
def request_dependency(request: Request):
return request
router_prefix="test-dynamic-search", | ||
) | ||
|
||
app.include_router( | ||
dynamic_stac_endpoint.router, prefix="/dynamic-stac", tags=["Dynamic STAC"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems unnecessary to have both of these router prefixes, and it looks like /dynamic-stac
overrides test-dynamic-search
anyways. Also, open to other prefix names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is unnecessary, I think i'd rather include the prefix on the call to include_router
.
To summarize our slack convo: The "all-in-one" approach where we overload a single endpoint to {
"title": "tile-layer",
"type": "image/jpeg",
"href": "http://tile-layer/{z}/{x}/{y}.jpg",
"templated": true,
"rel": "tiles",
} In my mind this has two primary benefits:
My dream for STAC + tiling is exposing In particular I think breaking up this repo into appropriate parts (stac-api / db / extension - ref @vincentsarago) will clear up separation of concerns and make thinking through the implementation a little easier. |
In general I think it makes sense to put
I think this makes sense, but in my mind this PR is essentially intending to serve the "tile a Catalog" problem. For almost any Catalog, like Landsat 8/Sentinel 2, you have way too many images per relevant tile, so you still need a search within the catalog. |
By the way this isn't necessarily in conflict with a |
Makes sense to me. Catalog tiling should happen through
This is a great approach to make this more consumable, let's roll with it. |
FYI, I've started something similar over https://github.com/stac-utils/titiler-pgstac Note: This is not an extension and doesn't add new endpoint to a stac-api but create a new standalone app |
What's the status of this PR? IMO stac-fastapi shouldn't host its own tiler - the titiler-pgstac is a good example of standing up a tiler that uses STAC but a separate service that can be deployed independently. In our implementation of stac-fastapi, we override the pgstac backend core client in order to iterate over collections/items and inject tiler links where appropriate. I think this approach allows stac-fastapi to concentrate on just the STAC API endpoints, but allows customization by users if they want to add titiler or other tiling capability. I could see work done to generalize and implement a link injection mechanism so that other libraries can write hooks into the STAC objects returned by stac-fastapi so that the link/asset injection logic can live in that external project. But I don't think we should create tilers directly in stac-fastapi. |
I agree the code for such an integration should live somewhere else. Closing this PR.
This would be a good feature. |
This is a draft PR to connect titiler with STAC api's search endpoint.
Notes:
tile
endpoint of theMosaicTilerFactory
; I haven't tested anything else.cogeo_mosaic
,morecantile
,rio_tiler
. (Though I guess the STAC API mountstitiler
by default already, so I guess this isn't actually adding any more dependencies?)