From fc15d931c7232b812c376de1a0f052444fbd8d2f Mon Sep 17 00:00:00 2001 From: Trygve Aspenes Date: Thu, 10 Oct 2024 12:57:06 +0200 Subject: [PATCH] add missing parameters in request --- mapgen/modules/helpers.py | 12 ++++++++++-- setup.cfg | 2 -- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/mapgen/modules/helpers.py b/mapgen/modules/helpers.py index 2e27522..c892681 100644 --- a/mapgen/modules/helpers.py +++ b/mapgen/modules/helpers.py @@ -116,6 +116,10 @@ def handle_request(map_object, full_request): logger.error(f"status_code=500, failed to handle query parameters: {str(full_request)}, with error: {str(e)}") raise HTTPError(response_code='500', response=f"failed to handle query parameters: {str(full_request)}, with error: {str(e)}") + if 'request=getlegendgraphic' in full_request_string.lower(): + if not 'sld_version' in full_request_string.lower(): + logger.warning("requst is getlegendgraphic, but no sld_version is given. Add SLD_VERSION=1.1.0 to query.") + full_request_string += '&SLD_VERSION=1.1.0' try: ows_req.loadParamsFromURL(full_request_string) except mapscript.MapServerError: @@ -805,7 +809,11 @@ def _generate_layer(layer, ds, grid_mapping_cache, netcdf_file, qp, map_obj, pro try: style = qp['styles'] except KeyError: - style = qp['style'] + try: + style = qp['style'] + except KeyError: + logger.warning("Style is not in the request. This is mandatory, but I will set it to raster. This is maybe not what you want.") + style = 'raster' if (variable.endswith("_vector") or variable.endswith("_vector_from_direction_and_speed")) and style == "": logger.debug("Empty style. Force wind barbs.") style = "Wind_barbs" @@ -1271,7 +1279,7 @@ def _generate_layer(layer, ds, grid_mapping_cache, netcdf_file, qp, map_obj, pro _style.maxcolor = mapscript.colorObj(red=255, green=255, blue=255) _style.minvalue = float(min_val) _style.maxvalue = float(max_val) - logger.debug(f"After comolrmap min max {min_val} {max_val}") + logger.debug(f"After colormap min max {min_val} {max_val}") return actual_variable diff --git a/setup.cfg b/setup.cfg index 6e3f8e0..af3af49 100644 --- a/setup.cfg +++ b/setup.cfg @@ -33,8 +33,6 @@ install_requires = requests>=2.27.1 pyyaml>=5.4.1 jinja2>=3.1.1 - uvicorn>=0.17.6 - fastapi>=0.75.2 [bdist_wheel] universal = 0