diff --git a/VIPSWeb/local_settings_sample.py b/VIPSWeb/local_settings_sample.py index fee12ee535aa95325b945d17fa722fd4e1522528..466a2c166494e8bb09326682fc199d5ef5e3a4f2 100755 --- a/VIPSWeb/local_settings_sample.py +++ b/VIPSWeb/local_settings_sample.py @@ -143,8 +143,9 @@ SITE_OWNER_URL = "http://www.example.com/" # Grid models settings WMS_SERVER_URL = "https://gridweb.vips.nibio.no/cgi-bin/" AVAILABLE_GRID_MODELS = [ - {"model_id":"SEPTREFHUM", "model_name": {"nb":"Septoria referansefuktmodell", "en":"Septoria reference humidity model"}}, - {"model_id":"PSILARTEMP", "model_name": {"nb":"Gulrotflue svermetidspunktmodell", "en":"Carrot rust fly (Psila rosae) temperature model"}} + {"model_id":"SEPTREFHUM", "model_name": {"nb":"Septoria referansefuktmodell", "en":"Septoria reference humidity model"}, "url": "%sSEPTREFHUM" % WMS_SERVER_URL}, + {"model_id":"PSILARTEMP", "model_name": {"nb":"Gulrotflue svermetidspunktmodell", "en":"Carrot rust fly (Psila rosae) temperature model"}, "url": "%sPSILARTEMP" % WMS_SERVER_URL}, + {"model_id":"NAERSTADMO", "model_name": {"nb":"Nærstads modell", "en":"Nærstad's potato blight model"}, "url": "%sNAERSTADMO" % WMS_SERVER_URL} ] # OpenLayers Map (map on front page) initial configuration diff --git a/spatial/static/spatial/js/gridmap.js b/spatial/static/spatial/js/gridmap.js index 21feeaaa988601b88c8795af40d76ce66d22b241..f339ee59ea110eb24f66b630a694e39f1d5b70e1 100644 --- a/spatial/static/spatial/js/gridmap.js +++ b/spatial/static/spatial/js/gridmap.js @@ -27,7 +27,7 @@ proj4.defs( let layers = []; -let mapserverURL=settings.WMS_SERVER_URL +//let mapserverURL=settings.WMS_SERVER_URL let modelId = undefined; let today = getSystemTime().format("YYYY-MM-DD"); let todayLayerIndex = undefined; @@ -165,7 +165,7 @@ function getLayersForCurrentTimestamp() * @param {*} inputModelId model Id, e.g. PSILARTEMP * @param {*} mapAttribution background map source information (displayed in the map) */ -async function initGridMap(inputModelId, mapAttribution) { +async function initGridMap(inputModelId, wmsURL, mapAttribution) { modelId = inputModelId; var backgroundLayer = new ol.layer.Tile({ source: new ol.source.OSM({ @@ -180,7 +180,7 @@ async function initGridMap(inputModelId, mapAttribution) { // Get layers from WMS service let parser = new ol.format.WMSCapabilities(); //console.info(mapserverURL + modelId + "?service=WMS&version=1.3.0&request=GetCapabilities"); - let response = await fetch(mapserverURL + modelId + "?service=WMS&version=1.3.0&request=GetCapabilities&language=" + settings.currentLanguage); + let response = await fetch(wmsURL + "?service=WMS&version=1.3.0&request=GetCapabilities&language=" + settings.currentLanguage); //console.info(response.status); // Response is 200 even if a model doesn't exist on the mapserver let txt = await response.text(); @@ -256,7 +256,7 @@ async function initGridMap(inputModelId, mapAttribution) { layers.push( new ol.layer.Image({ source: new ol.source.ImageWMS({ - url: mapserverURL + modelId, + url: wmsURL, params: { "LAYERS": modelId + "." + currentLayerParam + "." + dateStr, "TRANSPARENT": "TRUE" }, serverType: "mapserver", ratio: 1, diff --git a/spatial/templates/spatial/gridmap.html b/spatial/templates/spatial/gridmap.html index 851502e224f5210e701e9ed4ea614f44bcb3e969..c929bcfdd71e142f37e43d638a589fd9543896ba 100644 --- a/spatial/templates/spatial/gridmap.html +++ b/spatial/templates/spatial/gridmap.html @@ -25,7 +25,7 @@ var longitude = {{settings.MAP_CENTER_LONGITUDE|unlocalize}}; var latitude = {{settings.MAP_CENTER_LATITUDE|unlocalize}}; var zoomLevel = {{settings.MAP_ZOOMLEVEL}}; - initGridMap("{{model_id}}","{{settings.MAP_ATTRIBUTION|safe}}"); + initGridMap("{{model_id}}","{{url}}", "{{settings.MAP_ATTRIBUTION|safe}}"); }); </script> {% endblock %} diff --git a/spatial/views.py b/spatial/views.py index eea91a82abbfafcf3c08a5263b080c2beb45fec7..6f043a3457fe31be26e6e6fbc8a4583abfd761a8 100644 --- a/spatial/views.py +++ b/spatial/views.py @@ -35,7 +35,7 @@ def gridmap(request, model_id=None): try: for model in settings.AVAILABLE_GRID_MODELS: if model_id == model["model_id"]: - context = {"model_id": model_id} + context = {"model_id": model_id, "url": model["url"]} return render(request, 'spatial/gridmap.html', context) except AttributeError: pass