Skip to content

Commit

Permalink
feat: allow overriding of color_formula, expression and colormap from…
Browse files Browse the repository at this point in the history
… url params
  • Loading branch information
jverrydt committed Jun 12, 2024
1 parent 49f0f6a commit 47917b2
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion titiler/stacapi/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,11 @@ def get_tile( # noqa: C901
] = f"{start_datetime.strftime('%Y-%m-%dT%H:%M:%SZ')}/{end_datetime.strftime('%Y-%m-%dT%H:%M:%SZ')}"

query_params = layer.get("render") or {}
if "color_formula" in req:
query_params["color_formula"] = req["color_formula"]
if "expression" in req:
query_params["expression"] = req["expression"]

layer_params = get_dependency_params(
dependency=self.layer_dependency,
query_params=query_params,
Expand Down Expand Up @@ -955,6 +960,26 @@ def register_routes(self): # noqa: C901
"name": "TileCol",
"in": "query",
},
{
"required": False,
"schema": {
"title": "Color Formula",
"description": "rio-color formula (info: https://github.com/mapbox/rio-color)",
"type": "string",
},
"name": "color_formula",
"in": "query",
},
{
"required": False,
"schema": {
"title": "Colormap name",
"description": "JSON encoded custom Colormap",
"type": "string",
},
"name": "colormap",
"in": "query",
},
################
# GetFeatureInfo
# InfoFormat
Expand Down Expand Up @@ -1122,7 +1147,7 @@ def web_map_tile_service( # noqa: C901

colormap = get_dependency_params(
dependency=self.colormap_dependency,
query_params=layer.get("render") or {},
query_params={"colormap": req["colormap"]} if "colormap" in req else layer.get("render") or {},
)

content, media_type = render_image(
Expand Down

0 comments on commit 47917b2

Please sign in to comment.