Skip to content
Snippets Groups Projects
template.j2 6.88 KiB
MAP

# This mapfile is generated using Jinja2 templates
# 
# Copyright (C) 2023 NIBIO <https://www.nibio.no/>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

NAME "VIPS.SEPTREFHUM"

# WGS84
EXTENT {{mapserver_extent}}
UNITS DD

CONFIG "MS_ERRORFILE" "{{mapserver_log_file}}" 

PROJECTION 
    "init=epsg:4326"
END


WEB
    IMAGEPATH "{{mapserver_image_path}}"
    IMAGEURL "/tmp/"
    # List of standard metadata: https://mapserver.org/ogc/wms_server.html#web-object-metadata
    # i18n support: https://mapserver.org/ogc/inspire.html#inspire-multi-language-support  
    METADATA
            "wms_keywordlist" "VIPS model Septoria Reference Humidity Model (SEPTREFHUM)"
            {% if languages %}
            "wms_inspire_capabilities" "embed"
            "wms_languages" "{{ language_codes|join(",")}}" # The first is the default
            {% endif %}
            "wms_abstract"  "<div>
              <p>
              This map indicates the risk of splash-borne foliar diseases of wheat (septoria leaf blotch, 
              glume blotch and tan spot) based only on the number of 'wet hours' in a 72 hour period (yesterday, 
              today and tomorrow). It is a simplified -- weather-based only -- version of the more detailed Septoria 
              Humidity Model which you can configure and run for your farm after logging in to the platform.
              </p>
              <p>
              The risk criteria were developed in Denmark as the <a href='https://dca.au.dk/en/current-news/news/show/artikel/risikomodeller-kan-reducere-brugen-af-fungicider-mod-septoria-1' target='new'>Septoria Reference Humidity Model</a>.
              </p>
              <p>
              The risk map can be used to assist (not replace) decisions by experienced crop managers, taking into account all relevant local risk factors. If a risk is indicated
              in your area, please login and set up the complete Septoria Humidity Model for your farm, and check its outputs for a more in-depth assessment.
              </p>
              <h3>Explanation of parameters</h3>
              <ul>
              <li>WHS = <span itemprop=\"WHS\">Wet hour sum</span></li>
              </ul>
            </div>
            "
        "wms_enable_request"  "*"
        "wms_title.en"     "Septoria Humidity Model (Simplified)"
        "wms_title.nb"     "Septoria-fuktmodell (Forenklet)"
        "wms_getfeatureinfo_formatlist" "text/plain,text/html,text/xml"
        "wms_accessconstraints" "none"
        "wms_addresstype" ""
        "wms_address" "Høgskoleveien 7"
        "wms_city" "Ås"
        "wms_stateorprovince" "Ås"
        "wms_postcode" "1430"
        "wms_country" "Norway"
        "wms_contactelectronicmailaddress" "vips@nibio.no"
        "wms_feature_info_mime_type" "text/html"
        "wms_contactperson" "Berit Nordskog"
        "wms_contactposition" "owner"
        "wms_contactorganization" "Norsk institutt for bioøkonomi (NIBIO)"
    END
END #web

############################# Start of legend #########################################################
# The legend configuration uses the CLASSITEM information in each layer to generate colour icons and labels
LEGEND
    STATUS ON
    KEYSIZE 16 12
    LABEL
        TYPE TRUETYPE
        SIZE 10
        COLOR 0 0 0
        OFFSET 0 -3
    END
END

{% for timestep_date in timestep_dates %}
LAYER
    NAME "{{model_id}}.WARNING_STATUS.{{ timestep_date }}"
    DATA "{{mapserver_data_dir}}result_WARNING_STATUS_{{ timestep_date }}.tif"
    TEMPLATE "{{mapserver_mapfile_dir}}query_template.xml" TOLERANCE 1 TOLERANCEUNITS PIXELS
    TYPE RASTER
    PROCESSING "BANDS=1" # WARNING_STATUS band on top (others invisible, but band values are available in the query template)
    PROCESSING "NODATA=-1"
   
    
    STATUS ON
    METADATA
      "wms_title"     "Reference humidity model {{ timestep_date }}"  
      {% for language in languages %}
      "wms_abstract.{{language.language_code}}" "
      {
          \"isWarningStatus\": true,
          \"legendItems\": [
          {
            \"classification\": 2,
            \"legendLabel\": \"{{ language.low_risk }}\",
            \"legendIconCSS\": \"width: 25px; background-color: #3ac47d;\"
          },
          {
            \"classification\": 3,
            \"legendLabel\": \"{{ language.medium_risk }}\",
            \"legendIconCSS\": \"width: 25px; background-color: #f7b924;\"
          },
          {
            \"classification\": 4,
            \"legendLabel\": \"{{ language.high_risk }}\",
            \"legendIconCSS\": \"width: 25px; background-color: #d92550;\"
          }
        ]
      }
      "
      {% endfor %}
    END  
      CLASSITEM "[pixel]"
  
    # class using simple string comparison, equivalent to ([pixel] = 0)
  
    CLASS
      NAME "Low infection risk"
      EXPRESSION ([pixel] >= 2 AND [pixel] < 3) 
      STYLE
          COLOR 58 196 125
      END
    END
    CLASS
      NAME "Medium infection risk"
      EXPRESSION ([pixel] >= 3 AND [pixel] < 4) 
      STYLE
          COLOR 247 185 36
      END
    END
    CLASS
      NAME "High infection risk"
      EXPRESSION ([pixel] >= 4) 
      STYLE
          COLOR  217 37 80
      END
    END
END # Layer
  
LAYER
     NAME "{{model_id}}.WHS.{{ timestep_date }}"
     DATA "{{mapserver_data_dir}}result_{{ timestep_date }}.tif"
     TEMPLATE "{{mapserver_mapfile_dir}}query_template_WHS.xml" TOLERANCE 1 TOLERANCEUNITS PIXELS
     TYPE RASTER
     #PROCESSING "BANDS=1" # WHS band on top (others invisible, but band values are available in the query template)
     #PROCESSING "SCALE=AUTO"
     #PROCESSING "NODATA=-1"
   
   
     STATUS ON
     METADATA
       "wms_title"     "Reference humidity model WHS {{ timestep_date }}"
       {% for language in languages %}
      "wms_abstract.{{language.language_code}}" "
      {
          \"isWarningStatus\": false,
          \"legendItems\": [
          {
            \"legendLabel\": \"{{ language.whs }}\",
            \"legendIconCSS\": \"width: 25px; background: linear-gradient(to right, #FFFF00, #0000FF);\"
          }
        ]
      }
      "
      {% endfor %}
     END
    CLASSITEM "[pixel]"
    CLASS
      NAME "Wet hour sum (yesterday + today + tomorrow) [0-72]"
      EXPRESSION ([pixel] >= 0 AND [pixel] <= 72)
      STYLE
        DATARANGE 0 72
        COLORRANGE 255 255 0 0 0 255
      END
    END
   
END # Layer

{% endfor %}
  
END #map