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

Render Extension #1034

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id":"bs_to_save","bbox":[-120.61338752166166,38.54940283865057,-119.91905658168675,38.90577651328637],"type":"Feature","links":[{"rel":"collection","type":"application/json","href":"https://openveda.cloud/api/stac/collections/caldor-fire-burn-severity"},{"rel":"parent","type":"application/json","href":"https://openveda.cloud/api/stac/collections/caldor-fire-burn-severity"},{"rel":"root","type":"application/json","href":"https://openveda.cloud/api/stac/"},{"rel":"self","type":"application/geo+json","href":"https://openveda.cloud/api/stac/collections/caldor-fire-burn-severity/items/bs_to_save"},{"title":"Map of Item","href":"https://openveda.cloud/api/raster/collections/caldor-fire-burn-severity/items/bs_to_save/map?assets=cog_default&rescale=0%2C5&colormap_name=inferno_r","rel":"preview","type":"text/html"}],"assets":{"cog_default":{"href":"s3://veda-data-store/caldor-fire-burn-severity/bs_to_save.tif","type":"image/tiff; application=geotiff","roles":["data","layer"],"title":"Default COG Layer","proj:bbox":[-120.61338752166166,38.54940283865057,-119.91905658168675,38.90577651328637],"proj:epsg":4326,"proj:wkt2":"GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]","proj:shape":[1103,2149],"description":"Cloud optimized default layer to display on map","raster:bands":[{"scale":1.0,"nodata":-100.0,"offset":0.0,"sampling":"area","data_type":"float64","histogram":{"max":4.0,"min":1.0,"count":11,"buckets":[10233,0,0,67409,0,0,71518,0,0,24232]},"statistics":{"mean":2.63295307741995,"stddev":0.7936384596443959,"maximum":4.0,"minimum":1.0,"valid_percent":32.191658745247146}}],"proj:geometry":{"type":"Polygon","coordinates":[[[-120.61338752166166,38.54940283865057],[-119.91905658168675,38.54940283865057],[-119.91905658168675,38.90577651328637],[-120.61338752166166,38.90577651328637],[-120.61338752166166,38.54940283865057]]]},"proj:projjson":{"id":{"code":4326,"authority":"EPSG"},"name":"WGS 84","type":"GeographicCRS","datum":{"name":"World Geodetic System 1984","type":"GeodeticReferenceFrame","ellipsoid":{"name":"WGS 84","semi_major_axis":6378137,"inverse_flattening":298.257223563}},"$schema":"https://proj.org/schemas/v0.4/projjson.schema.json","coordinate_system":{"axis":[{"name":"Geodetic latitude","unit":"degree","direction":"north","abbreviation":"Lat"},{"name":"Geodetic longitude","unit":"degree","direction":"east","abbreviation":"Lon"}],"subtype":"ellipsoidal"}},"proj:transform":[0.0003230948999417961,0.0,-120.61338752166166,0.0,-0.00032309489994179427,38.90577651328637,0.0,0.0,1.0]},"rendered_preview":{"title":"Rendered preview","href":"https://openveda.cloud/api/raster/collections/caldor-fire-burn-severity/items/bs_to_save/preview.png?assets=cog_default&rescale=0%2C5&colormap_name=inferno_r","rel":"preview","roles":["overview"],"type":"image/png"}},"geometry":{"type":"Polygon","coordinates":[[[-120.61338752166166,38.54940283865057],[-119.91905658168675,38.54940283865057],[-119.91905658168675,38.90577651328637],[-120.61338752166166,38.90577651328637],[-120.61338752166166,38.54940283865057]]]},"collection":"caldor-fire-burn-severity","properties":{"end_datetime":"2021-10-21T12:00:00+00:00","start_datetime":"2021-08-15T00:00:00+00:00"},"stac_version":"1.0.0","stac_extensions":["https://stac-extensions.github.io/raster/v1.1.0/schema.json","https://stac-extensions.github.io/projection/v1.1.0/schema.json"]}
2 changes: 2 additions & 0 deletions src/titiler/application/titiler/application/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
cogViewerExtension,
stacExtension,
stacViewerExtension,
renderExtension,
)
from titiler.mosaic.errors import MOSAIC_STATUS_CODES
from titiler.mosaic.factory import MosaicTilerFactory
Expand Down Expand Up @@ -122,6 +123,7 @@ def validate_access_token(access_token: str = Security(api_key_query)):
router_prefix="/stac",
extensions=[
stacViewerExtension(),
renderExtension(),
],
)

Expand Down
1 change: 1 addition & 0 deletions src/titiler/extensions/titiler/extensions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
from .stac import stacExtension # noqa
from .viewer import cogViewerExtension, stacViewerExtension # noqa
from .wms import wmsExtension # noqa
from .render import renderExtension # noqa
34 changes: 34 additions & 0 deletions src/titiler/extensions/titiler/extensions/render.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""render Extension."""

from typing import Any, Dict, List, Literal, Optional

from attrs import define
from fastapi import Depends

from titiler.core.factory import FactoryExtension, MultiBaseTilerFactory

import pystac


@define
class renderExtension(FactoryExtension):
"""Add /stac endpoint to a COG TilerFactory."""

'''
'''
def register(self, factory: MultiBaseTilerFactory):
"""Register endpoint to the tiler factory."""

@factory.router.get("/renders", response_model=Dict, name="List STAC renders")
def show_renders(
src_path=Depends(factory.path_dependency)
):
with factory.reader(src_path) as src:
renders = {}
# if hasattr(src.item, "ext") and src.item.ext.has("renders"):
# renders = src.item.ext.renders

if src.item.properties.get("renders"):
renders = src.item.properties.get("renders")

return {"renders": renders}
Loading