Closed DanielJDufour closed 3 years ago
IMO this is quite a custom feature which could easily be fixed by a custom STACReader on your side (and then used in titiler)
import attr
import pystac
from rio_tiler.io import STACReader
@attr.s
class MyCustomSTACReader(STACReader)
def __attrs_post_init__(self):
if self.filepath and self.filepath.startswith("data:"):
self.items = pystac.Item(json.loads(base64decode(self.filepath.split("data:")[1]))
self.filepath = None
super(). __attrs_post_init__()
@DanielJDufour Are we good here?
FYI, I've played a bit with the idea and here is what I'm using
import json
from base64 import b64decode
import attr
import pystac
from rio_tiler.io import STACReader
@attr.s
class MyCustomSTACReader(STACReader):
"""Custom STACReader."""
def __attrs_post_init__(self):
"""Decode data: urls."""
if self.filepath and self.filepath.startswith("stac://"):
self.item = pystac.Item.from_dict(
json.loads(
b64decode(
self.filepath.replace("stac://", "")
)
)
)
self.filepath = None
super(). __attrs_post_init__()
I added this in a titiler demo. You'll note that I'm using stac://
instead of data:application/json;base64,
because I had weird URL parking issue.
closing for now
Hello. I was wondering if you would be open to a pull request adding support to the fetch function in stac.py for
data:
URLs. The use case is I would like a to be able to pass STAC data directly to the /stac/... endpoints in titiler without having to send a normal URL. And I believe titiler uses this library for this use case. Happy to discuss more and apologies if I'm mistaken.Here would be an example URL:
which decodes to