Skip to content

Commit 47917b2

Browse files
committed
feat: allow overriding of color_formula, expression and colormap from url params
1 parent 49f0f6a commit 47917b2

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

titiler/stacapi/factory.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,11 @@ def get_tile( # noqa: C901
781781
] = f"{start_datetime.strftime('%Y-%m-%dT%H:%M:%SZ')}/{end_datetime.strftime('%Y-%m-%dT%H:%M:%SZ')}"
782782

783783
query_params = layer.get("render") or {}
784+
if "color_formula" in req:
785+
query_params["color_formula"] = req["color_formula"]
786+
if "expression" in req:
787+
query_params["expression"] = req["expression"]
788+
784789
layer_params = get_dependency_params(
785790
dependency=self.layer_dependency,
786791
query_params=query_params,
@@ -955,6 +960,26 @@ def register_routes(self): # noqa: C901
955960
"name": "TileCol",
956961
"in": "query",
957962
},
963+
{
964+
"required": False,
965+
"schema": {
966+
"title": "Color Formula",
967+
"description": "rio-color formula (info: https://github.com/mapbox/rio-color)",
968+
"type": "string",
969+
},
970+
"name": "color_formula",
971+
"in": "query",
972+
},
973+
{
974+
"required": False,
975+
"schema": {
976+
"title": "Colormap name",
977+
"description": "JSON encoded custom Colormap",
978+
"type": "string",
979+
},
980+
"name": "colormap",
981+
"in": "query",
982+
},
958983
################
959984
# GetFeatureInfo
960985
# InfoFormat
@@ -1122,7 +1147,7 @@ def web_map_tile_service( # noqa: C901
11221147

11231148
colormap = get_dependency_params(
11241149
dependency=self.colormap_dependency,
1125-
query_params=layer.get("render") or {},
1150+
query_params={"colormap": req["colormap"]} if "colormap" in req else layer.get("render") or {},
11261151
)
11271152

11281153
content, media_type = render_image(

0 commit comments

Comments
 (0)