From dcab537a19f73acc5073d6c03eb0191a8aa85159 Mon Sep 17 00:00:00 2001 From: Fabian Schindler Date: Fri, 29 Nov 2024 18:33:55 +0100 Subject: [PATCH] feat(heatmap): make default heatmap style configurable --- eoxserver/contrib/mapserver.py | 1 + eoxserver/render/mapserver/config.py | 3 +++ eoxserver/render/mapserver/factories.py | 8 +++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/eoxserver/contrib/mapserver.py b/eoxserver/contrib/mapserver.py index 94756c6a0..37e0d6b02 100644 --- a/eoxserver/contrib/mapserver.py +++ b/eoxserver/contrib/mapserver.py @@ -297,6 +297,7 @@ def set_env(map_obj, env, fail_on_override=False, return_old=False): return old_values + @contextlib.contextmanager def config_env(map_obj, env, fail_on_override=False, reset_old=True): old_env = set_env(env, fail_on_override, reset_old) diff --git a/eoxserver/render/mapserver/config.py b/eoxserver/render/mapserver/config.py index 156a1e37f..38b474e9b 100644 --- a/eoxserver/render/mapserver/config.py +++ b/eoxserver/render/mapserver/config.py @@ -42,3 +42,6 @@ # render requests DEFAULT_EOXS_MAPSERVER_HEATMAP_RANGE_DEFAULT = (0, 10) + +# default for EOXS_MAPSERVER_HEATMAP_STYLE_DEFAULT +DEFAULT_EOXS_MAPSERVER_HEATMAP_STYLE_DEFAULT = "plasma" diff --git a/eoxserver/render/mapserver/factories.py b/eoxserver/render/mapserver/factories.py index 515132356..eef7d3f3c 100644 --- a/eoxserver/render/mapserver/factories.py +++ b/eoxserver/render/mapserver/factories.py @@ -56,6 +56,7 @@ from eoxserver.render.coverage.objects import Coverage, Field from eoxserver.render.mapserver.config import ( DEFAULT_EOXS_MAPSERVER_HEATMAP_RANGE_DEFAULT, + DEFAULT_EOXS_MAPSERVER_HEATMAP_STYLE_DEFAULT, DEFAULT_EOXS_MAPSERVER_LAYER_FACTORIES, ) from eoxserver.render.colors import BASE_COLORS, COLOR_SCALES, OFFSITE_COLORS @@ -763,9 +764,14 @@ def create(self, map_obj: ms.mapObj, layer: Layer): DEFAULT_EOXS_MAPSERVER_HEATMAP_RANGE_DEFAULT ) + default_style = getattr( + settings, 'EOXS_MAPSERVER_HEATMAP_STYLE_DEFAULT', + DEFAULT_EOXS_MAPSERVER_HEATMAP_STYLE_DEFAULT + ) + range_ = layer.range or default_range _create_raster_style( - DEFAULT_RASTER_STYLES[layer.style or "plasma"], + DEFAULT_RASTER_STYLES[layer.style or default_style], layer_obj, range_[0], range_[1],