Skip to content

Commit

Permalink
feat(heatmap): make default heatmap style configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
constantinius committed Nov 29, 2024
1 parent 2218f5c commit dcab537
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions eoxserver/contrib/mapserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions eoxserver/render/mapserver/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
8 changes: 7 additions & 1 deletion eoxserver/render/mapserver/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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],
Expand Down

0 comments on commit dcab537

Please sign in to comment.