From f13efc569ab4ffb1d9aefa27ea0a0e81aee2f745 Mon Sep 17 00:00:00 2001
From: Tor-Einar Skog <tor-einar.skog@nibio.no>
Date: Wed, 20 Dec 2023 09:06:17 +0100
Subject: [PATCH] Update docs about legends now defined by Json

---
 examples/PSILARTEMP.map | 259 +++++++++++++++-------------------------
 grid_models.md          | 125 ++++++++++++++++---
 2 files changed, 200 insertions(+), 184 deletions(-)

diff --git a/examples/PSILARTEMP.map b/examples/PSILARTEMP.map
index 8c65434..9bbce20 100644
--- a/examples/PSILARTEMP.map
+++ b/examples/PSILARTEMP.map
@@ -42,53 +42,22 @@ MAP
               
               
               "wms_abstract.nb" "
-              <h2>Modellbeskrivelse</h2>
-              <p>Varslingsmodellen &laquo;Gulrotflue svermetidspunkt&raquo; er basert p&aring; en finsk, temperaturbasert modell (Markkula <em>et al</em>, 1998; Tiilikkala &amp; Ojanen, 1999; Markkula <em>et al</em>, 2000). Modellen beregner tidspunkt for sverming av 1. generasjon og 2. generasjon av gulrotflue basert p&aring; akkumulering av graddager (d&oslash;gngrader) over en basistemperatur p&aring; 5 &deg;C. I VIPS benyttes modellen kun for 1. generasjon.</p>
-              <p>Det er standard lufttemperatur (temperatur m&aring;lt 2 m over bakken) som benyttes i modellen. Graddager er her definert som summen av differansen mellom en basistemperatur p&aring; 5 &deg;C og d&oslash;gnmiddeltemperatur for alle d&oslash;gn med temperatur &gt;5 &deg;C dvs. summen av (d&oslash;gnmiddeltemperatur - 5 &deg;C) fra 1. mars (fra det er telefritt i jorda).</p>
-              <h2>Tolking av varsel</h2>
-              <p>Gr&oslash;nne bokser betyr at svermingen enda ikke har begynt. Akkumulering av d&oslash;gngrader er &lt; 260 graddager (d&oslash;gngrader).</p>
-              <p>Gule bokser betyr svermingen er i startfasen og at man m&aring; v&aelig;re obs p&aring; at det kan komme innflyvere i &aring;keren. Akkumulering av d&oslash;gngrader er &ge; 260 graddager (d&oslash;gngrader).</p>
-              <p>R&oslash;de bokser betyr svermingen er p&aring; sitt mest aktive. Akkumulering av d&oslash;gngrader er &ge; 360 graddager (d&oslash;gngrader).</p>
-              <p>Gr&aring; bokser betyr at svermingen av 1. generasjon er over og varslingen er avsluttet. Akkumulering av d&oslash;gngrader er &ge; 560 graddager (d&oslash;gngrader).</p>
-              <p>V&aelig;r klar over at i omr&aring;der med dekke (plast, enkel og dobbel fiberduk el. lign.) ved tidligproduksjon (enten p&aring; samme jorde eller nabojorder) &aring;ret f&oslash;r, kan svermingen starte tidligere p&aring; grunn av h&oslash;yere jordtemperatur under dekket.</p>
-              <h2>Varslingssesong &ndash; oppstart og avslutning av varsel</h2>
-              <p>Starttidspunkt: Vises i VIPS fra 1. april (startdato for akkumulering av graddager fra det er telefritt) i jorda.</p>
-              <p>Sluttidspunkt: N&aring;r modellen har n&aring;dd kravet til d&oslash;gngrader for avsluttet sverming av 1. generasjon (560 d&oslash;gngrader).</p>
-              <h2>Utpr&oslash;ving og validering av modellen</h2>
-              <h3>Nasjonalt</h3>
-              <p>Modellen har v&aelig;rt testet og evaluert for norske forhold i perioden 2011-2015. Valideringen har vist at modellen stemte ganske bra for de fleste steder for 1. generasjon. Modellen stemte imidlertid d&aring;rlig for 2. generasjon for mange lokaliteter og var direkte feil for J&aelig;ren-distriktet. P&aring; bakgrunn av resultatene fra valideringen har vi derfor valgt &aring; fjerne varsling av 2. generasjon gulrotflue med denne modellen.</p>
-              <h3>Internasjonalt</h3>
-              <p>Modellen er i bruk i Finland. Det er usikkert hvor omfattende modellen er validert i Finland, men det er utf&oslash;rt en validering sommeren 1997. Denne valideringen tilsa at modellen stemte noks&aring; bra, men at terskeltemperatursummen burde reduseres til 255 graddager for svermingsstart (mot 260 graddager i den opprinnelige modellen) og 355 graddager for svermetoppen (mot 360 daggrader i den opprinnelige modellen) (Tiilikkala &amp; Ojanen, 1999).</p>
-              <h2>Referanser</h2>
-              <ul>
-              <li>Markkula, I., H. Ojanen and K. Tiilikkala. 1998. Forecasting and monitoring of the carrot fly (Psila rosae) in Finland. The 1998 Brighton Conference: Pests and Diseases: Conference Proceedings, Volume 2, pages 657-662.</li>
-              <li>Tiilikkala, K. and H. Ojanen. 1999. Use of a geographical information system (GIS) for forecasting the activities of carrot fly and cabbage root fly. IOBC/WPRS Bulletin 22 (5): 15-24.</li>
-              <li>Markkula, I., A. Hannukkala, A. Lehtinen, I. Mattila, H. Ojanen, S. Raisjio, P. Reijonen and K. Tiilikkala. 2000. Pest warnings and forecasts sent as SMS messages from models into &quot;farmer's pocket&quot;. In publication: Pests &amp; Diseases 2000. Proceedings of an international conference held at the Brighton Hilton Metropole Hotel, UK, 13-16 November 2000. BCPC Conference Proceedings pages 285-290.</li>
+              <p>
+              Kartet viser beregnet <a href=\"https://www.vips-landbruk.no/forecasts/models/PSILARTEMP/\" target=\"new\">svermetidspunkt 
+              for gulrotflue 1. generasjon</a>. Varslene beregnes i rutenett a 1x1km basert på reanalyserte data og værvarsler fra 
+              Meteorologisk institutt. Varslene oppdateres en gang per døgn. Modellen for svermetidspunkt for gulrotflue beregnes også 
+              med data fra værstasjoner, hvor mer detaljerte beregninger kan hentes opp via visningen i kartet på VIPS-forsida.
+            </p>
+            <p>
+              Denne kartvisningen av rutenettbaserte varsler er resultat fra prosjektet &quot;Grid-baserte varsler i VIPS&quot;,
+              finansiert av Landbruksdirektoratet gjennom Handlingsplan for bærekraftig bruk av plantevernmidler i 
+              2023.
+            </p>
               "
               "wms_abstract.en"  "
                   <p>The warning system model &laquo;Carrot rust fly temperature&raquo; is based on a Finnish temperature-based model (Markkula <em>et al</em>, 1998; Tiilikkala &amp; Ojanen, 1999; Markkula <em>et al</em>, 2000). The model determines the start of the flight period for the 1st and 2nd generation of carrot rust fly based on accumuleted degree-days (day-degrees) over a base temperature of 5,0 &deg;C. VIPS uses the model for the 1st generation only.</p>
                   <p>Standard air temperature (temperature measured 2 m above ground) is used in the model. Degree-days are defined for this model as the sum of the difference between a base temperature of 5,0 &deg;C and the mean temperature for all days with a temperature &gt;5,0 &deg;C, in other words (daily mean temperature &ndash; 5,0 &deg;C) from 1 March (beginning when the ground has thawed).</p>
-                  <h3>Interpretation of the warning</h3>
-                  <p>Green rectangles indicate that the flight period has not yet begun. The accumulated day-degrees are &lt; 260 degree-days (day-degrees).</p>
-                  <p>Yellow rectangles indicate that the flight period is beginning and that flies can be coming into the field. The accumulated day-degrees are &ge; 260 degree-days (day-degrees).</p>
-                  <p>Red rectangles indicate peak flight period. The accumulated day-degrees are &ge; 360 degree-days (day-degrees).</p>
-                  <p>Grey rectangles indicate that the flight period of the 1st generation is over. The accumulated day-degrees are &ge; 560 degree-days (day-degrees).</p>
-                  <p>Be aware that in areas with field covers (plastic, single or double non-woven covers, etc.) with early crops the preceding season (either on the current field or neighboring fields), the flight period can start earlier due to higher soil temperature under the covers.</p>
-                  <p>The graphic presentation shows the progress of the day-degree calculation that is the basis for the green, yellow and red warnings (the line: &laquo;Accumulated day-degrees with the base temperature of 5 degrees C&raquo;). The graph show straight horizontal lines for the threshold values. &laquo;Day-degree threshold for low likelihood of attack&raquo; corresponds to when the warning changes from green to yellow (260 day-degrees). &laquo;Day-degree threshold for high likelihood of attack &raquo; corresponds to when the warning changes from yellow to red (360 day-degrees). &laquo;Day-degree threshold for end of flight period&raquo; corresponds to when the warning changes from red to grey (560 day-degrees) and the flight period for the 1st generation is considered to be over. When the line &laquo; Accumulated day-degrees with the base temperature of 5 degrees C&raquo; intersects one of the lines for the day-degree threshold, the warning will advance to the next level and the color of the warning rectangle will change. The graph also shows the daily mean temperature for the relevant weather station. The graph is dynamic and the user can choose which parameters that are shown by clicking on the explanation below the graph.</p>
-                  <h3>Warning season &ndash; start and end of the warning</h3>
-                  <p>Starting time: Shown in VIPS from 1 April (starting date for accumulation of degree-days beginning from when the ground has thawed).<br /> Ending time: When the model has reached the requirement for the end of the flight period for the 1st generation (560 day-degrees).</p>
-                  <h3>Testing and validation of the model</h3>
-                  <h4>National</h4>
-                  <p>The model has been tested for Norwegian conditions in the period of 2011-2015. Validation has shown that the model was accurate for most locations for the 1st generation. The model was, however, inaccurate for the 2nd generation for many locations and was totally incorrect for the district of J&aelig;ren. Based on the validation results, we have therefore chosen to remove warning of the 2nd generation of carrot rust fly from this model.</p>
-                  <h4>International</h4>
-                  <p>The model is in use in Finland. The extent to which the model has been validated in Finland is uncertain, but a validation was done in the summer of 1997. This validation showed that the model was quite accurate, but that the threshold temperature sm should be lowered to 255 day-degrees for the start of the flight period (as opposed to 260 degree-days in the original model) and 355 degree-days forthe peak flight period (as opposed to 360 degree-days in the original model) (Tiilikkala &amp; Ojanen, 1999).</p>
-                  <h3>Literature</h3>
-                  <p>Markkula, I., H. Ojanen and K. Tiilikkala. 1998. Forecasting and monitoring of the carrot fly (<em>Psila rosae</em>) in Finland. The 1998 Brighton Conference: Pests and Diseases: Conference Proceedings, Volume 2, pages 657-662.</p>
-                  <p>Tiilikkala, K. and H. Ojanen. 1999. Use of a geographical information system (GIS) for forecasting the activities of carrot fly and cabbage root fly. IOBC/WPRS Bulletin 22 (5): 15-24.</p>
-                  <p>Markkula, I., A. Hannukkala, A. Lehtinen, I. Mattila, H. Ojanen, S. Raisjio, P. Reijonen and K. Tiilikkala. 2000. Pest warnings and forecasts sent as SMS messages from models into \"farmer's pocket\". In publication: Pests &amp; Diseases 2000. Proceedings of an international conference held at the Brighton Hilton Metropole Hotel, UK, 13-16 November 2000. BCPC Conference Proceedings pages 285-290.</p>
-                  <p>&nbsp;</p>
-                  <p><strong>Contacts</strong></p>
-                  <p>Annette Folkedal Schj&oslash;ll <a href=\"mailto:annette.folkedal.schjoll@nibio.no\">annette.folkedal.schjoll@nibio.no</a><br />Tor J. Johansen <a href=\"mailto:tor.johansen@nibio.no\">tor.johansen@nibio.no</a></p>
+                  <p><a href=\"https://www.vips-landbruk.no/forecasts/models/PSILARTEMP/\" target=\"new\">Complete model description</a></p>
               "
           "wms_enable_request"  "*"
           "wms_title.en"     "Carrot rust fly (Psila rosae) temperature model"
@@ -124,8 +93,8 @@ MAP
   
   
   LAYER
-      NAME "PSILARTEMP.WARNING_STATUS.2023-04-01"
-      DATA "/disks/data01/mapserver/data/PSILARTEMP/result_WARNING_STATUS_2023-04-01.tif"
+      NAME "PSILARTEMP.WARNING_STATUS.2023-06-01"
+      DATA "/disks/data01/mapserver/data/PSILARTEMP/result_WARNING_STATUS_2023-06-01.tif"
       TEMPLATE "/disks/data01/mapserver/wms/PSILARTEMP/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)
@@ -134,125 +103,68 @@ MAP
       
       STATUS ON
       METADATA
-        "wms_title"     "Carrot rust fly (Psila rosae) temperature model 2023-04-01"
+        "wms_title"     "Carrot rust fly (Psila rosae) temperature model 2023-06-01"
         
         "wms_abstract.en" "
-        <ul style=\"list-style: none; padding: 0;\">
-        <li style=\"margin-bottom: 5px;\"><span style=\"background-color: #707070;\">&nbsp;&nbsp;&nbsp;</span> No forecast</li>
-        <li style=\"margin-bottom: 5px;\"><span style=\"background-color: #00B457;\">&nbsp;&nbsp;&nbsp;</span> No risk</li>
-        <li style=\"margin-bottom: 5px;\"><span style=\"background-color: #FFCC00;\">&nbsp;&nbsp;&nbsp;</span> Possible risk</li>
-        <li><span style=\"background-color: #FF0000;\">&nbsp;&nbsp;&nbsp;</span> High risk</li>
-        </ul>
-        "
-        
-        "wms_abstract.nb" "
-        <ul style=\"list-style: none; padding: 0;\">
-        <li style=\"margin-bottom: 5px;\"><span style=\"background-color: #707070;\">&nbsp;&nbsp;&nbsp;</span> Varsel beregnes ikke</li>
-        <li style=\"margin-bottom: 5px;\"><span style=\"background-color: #00B457;\">&nbsp;&nbsp;&nbsp;</span> Ingen infeksjonsrisikok</li>
-        <li style=\"margin-bottom: 5px;\"><span style=\"background-color: #FFCC00;\">&nbsp;&nbsp;&nbsp;</span> Mulig fare for angrep</li>
-        <li><span style=\"background-color: #FF0000;\">&nbsp;&nbsp;&nbsp;</span> Høy fare for angrep</li>
-        </ul>
-        "
-        
-      END  
-        CLASSITEM "[pixel]"
-    
-      # class using simple string comparison, equivalent to ([pixel] = 0)
-    
-      CLASS
-        NAME "Model not running"
-        EXPRESSION ([pixel] >= 0 AND [pixel] < 2) 
-        STYLE
-            COLOR 112 112 112
-        END
-      END
-      CLASS
-        NAME "No infection risk"
-        EXPRESSION ([pixel] >= 2 AND [pixel] < 3) 
-        STYLE
-            COLOR 0 180 87
-        END
-      END
-      CLASS
-        NAME "Possible infection risk"
-        EXPRESSION ([pixel] >= 3 AND [pixel] < 4) 
-        STYLE
-            COLOR 255 204 0
-        END
-      END
-      CLASS
-        NAME "High infection risk"
-        EXPRESSION ([pixel] >= 4) 
-        STYLE
-            COLOR  255 0 0
-        END
-      END
-  END # Layer
-    
-  LAYER
-       NAME "PSILARTEMP.DD.2023-04-01"
-       DATA "/disks/data01/mapserver/data/PSILARTEMP/result_2023-04-01.tif"
-       TEMPLATE "/disks/data01/mapserver/wms/PSILARTEMP/query_template_DD.xml" TOLERANCE 1 TOLERANCEUNITS PIXELS
-       TYPE RASTER
-       STATUS ON
-       METADATA
-         "wms_title"     "Carrot rust fly (Psila rosae) temperature model Day Degrees 2023-04-01"
-         
-        "wms_abstract.en" "
-        <ul style=\"list-style: none; padding: 0;\">
-        <li style=\"margin-bottom: 5px;\"><span style=\"display: inline-block; width: 25px; background: linear-gradient(to right, #0000FF, #FF0000);\">&nbsp;</span> Day degrees</li>
-        </ul>
+        {
+          \"legendItems\": [
+            {
+              \"isWarningStatus\": true,
+              \"classification\": 0,
+              \"legendLabel\": \"Flight period ended\",
+              \"legendIconCSS\": \"width: 25px; background-color: #707070;\"
+            },
+            {
+              \"isWarningStatus\": true,
+              \"classification\": 2,
+              \"legendLabel\": \"Flight period not started\",
+              \"legendIconCSS\": \"width: 25px; background-color: #00B457;\"
+            },
+            {
+              \"isWarningStatus\": true,
+              \"classification\": 3,
+              \"legendLabel\": \"Flight period starting\",
+              \"legendIconCSS\": \"width: 25px; background-color: #FFCC00;\"
+            },
+            {
+              \"isWarningStatus\": true,
+              \"classification\": 4,
+              \"legendLabel\": \"Peak flight activity\",
+              \"legendIconCSS\": \"width: 25px; background-color: #FF0000;\"
+            }
+          ]
+        }
         "
         
         "wms_abstract.nb" "
-        <ul style=\"list-style: none; padding: 0;\">
-        <li style=\"margin-bottom: 5px;\"><span style=\"display: inline-block; width: 25px; background: linear-gradient(to right, #0000FF, #FF0000);\">&nbsp;</span> Døgngrader</li>
-        </ul>
-        "
-        
-       END
-  
-      CLASSITEM "[pixel]"
-      CLASS
-        NAME "Day degrees"
-        STYLE
-          DATARANGE 0 1000
-          COLORRANGE 0 0 255 255 0 0
-        END
-      END
-     
-  END # Layer
-  
-  
-  LAYER
-      NAME "PSILARTEMP.WARNING_STATUS.2023-04-02"
-      DATA "/disks/data01/mapserver/data/PSILARTEMP/result_WARNING_STATUS_2023-04-02.tif"
-      TEMPLATE "/disks/data01/mapserver/wms/PSILARTEMP/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"     "Carrot rust fly (Psila rosae) temperature model 2023-04-02"
-        
-        "wms_abstract.en" "
-        <ul style=\"list-style: none; padding: 0;\">
-        <li style=\"margin-bottom: 5px;\"><span style=\"background-color: #707070;\">&nbsp;&nbsp;&nbsp;</span> No forecast</li>
-        <li style=\"margin-bottom: 5px;\"><span style=\"background-color: #00B457;\">&nbsp;&nbsp;&nbsp;</span> No risk</li>
-        <li style=\"margin-bottom: 5px;\"><span style=\"background-color: #FFCC00;\">&nbsp;&nbsp;&nbsp;</span> Possible risk</li>
-        <li><span style=\"background-color: #FF0000;\">&nbsp;&nbsp;&nbsp;</span> High risk</li>
-        </ul>
-        "
-        
-        "wms_abstract.nb" "
-        <ul style=\"list-style: none; padding: 0;\">
-        <li style=\"margin-bottom: 5px;\"><span style=\"background-color: #707070;\">&nbsp;&nbsp;&nbsp;</span> Varsel beregnes ikke</li>
-        <li style=\"margin-bottom: 5px;\"><span style=\"background-color: #00B457;\">&nbsp;&nbsp;&nbsp;</span> Ingen infeksjonsrisikok</li>
-        <li style=\"margin-bottom: 5px;\"><span style=\"background-color: #FFCC00;\">&nbsp;&nbsp;&nbsp;</span> Mulig fare for angrep</li>
-        <li><span style=\"background-color: #FF0000;\">&nbsp;&nbsp;&nbsp;</span> Høy fare for angrep</li>
-        </ul>
+        {
+          \"legendItems\": [
+            {
+              \"isWarningStatus\": true,
+              \"classification\": 0,
+              \"legendLabel\": \"Sverming avsluttet\",
+              \"legendIconCSS\": \"width: 25px; background-color: #707070;\"
+            },
+            {
+              \"isWarningStatus\": true,
+              \"classification\": 2,
+              \"legendLabel\": \"Sverming har ikke begynt\",
+              \"legendIconCSS\": \"width: 25px; background-color: #00B457;\"
+            },
+            {
+              \"isWarningStatus\": true,
+              \"classification\": 3,
+              \"legendLabel\": \"Sverming i startfasen\",
+              \"legendIconCSS\": \"width: 25px; background-color: #FFCC00;\"
+            },
+            {
+              \"isWarningStatus\": true,
+              \"classification\": 4,
+              \"legendLabel\": \"Sverming på sitt mest aktive\",
+              \"legendIconCSS\": \"width: 25px; background-color: #FF0000;\"
+            }
+          ]
+        }
         "
         
       END  
@@ -291,21 +203,41 @@ MAP
   END # Layer
     
   LAYER
-       NAME "PSILARTEMP.DD.2023-04-02"
-       DATA "/disks/data01/mapserver/data/PSILARTEMP/result_2023-04-02.tif"
+       NAME "PSILARTEMP.DD.2023-06-01"
+       DATA "/disks/data01/mapserver/data/PSILARTEMP/result_2023-06-01.tif"
        TEMPLATE "/disks/data01/mapserver/wms/PSILARTEMP/query_template_DD.xml" TOLERANCE 1 TOLERANCEUNITS PIXELS
        TYPE RASTER
        STATUS ON
        METADATA
-         "wms_title"     "Carrot rust fly (Psila rosae) temperature model Day Degrees 2023-04-02"
+         "wms_title"     "Carrot rust fly (Psila rosae) temperature model Day Degrees 2023-06-01"
          
         "wms_abstract.en" "
+        {
+          \"legendItems\": [
+            {
+              \"isWarningStatus\": false,
+              \"classification\": 0,
+              \"legendLabel\": \"Day degrees\",
+              \"legendIconCSS\": \"width: 25px; background: linear-gradient(to right, #0000FF, #FF0000);\"
+            }
+          ]
+        }
         <ul style=\"list-style: none; padding: 0;\">
         <li style=\"margin-bottom: 5px;\"><span style=\"display: inline-block; width: 25px; background: linear-gradient(to right, #0000FF, #FF0000);\">&nbsp;</span> Day degrees</li>
         </ul>
         "
         
         "wms_abstract.nb" "
+        {
+          \"legendItems\": [
+            {
+              \"isWarningStatus\": false,
+              \"classification\": 0,
+              \"legendLabel\": \"Døgngrader\",
+              \"legendIconCSS\": \"width: 25px; background: linear-gradient(to right, #0000FF, #FF0000);\"
+            }
+          ]
+        }
         <ul style=\"list-style: none; padding: 0;\">
         <li style=\"margin-bottom: 5px;\"><span style=\"display: inline-block; width: 25px; background: linear-gradient(to right, #0000FF, #FF0000);\">&nbsp;</span> Døgngrader</li>
         </ul>
@@ -324,9 +256,6 @@ MAP
      
   END # Layer
   
-  
-  
-    
   END #map
     
     
\ No newline at end of file
diff --git a/grid_models.md b/grid_models.md
index 3dc2f35..3e57dbc 100644
--- a/grid_models.md
+++ b/grid_models.md
@@ -4,7 +4,7 @@
 
 Tor-Einar Skog, Senior developer, NIBIO
 
-Updated: 2023-11-17
+Updated: 2023-12-20
 
 ## What you will learn
 This document describes how to set up a VIPS compatible gridded DSS model, such as in the screenshot below. It also describes briefly [how to set up a client to a VIPS compatible DSS gridded model](#vips-grid-model-client).
@@ -255,33 +255,120 @@ We have hacked this by using the `"wms_abstract"` metadata option for each layer
     NAME "PSILARTEMP.WARNING_STATUS.2023-04-01"
     [...]
     METADATA
+      "wms_title"     "Reference humidity model 2023-10-28"  
       "wms_abstract.en" "
-        <ul style=\"list-style: none; padding: 0;\">
-        <li style=\"margin-bottom: 5px;\"><span style=\"background-color: #707070;\">&nbsp;&nbsp;&nbsp;</span> No forecast</li>
-        <li style=\"margin-bottom: 5px;\"><span style=\"background-color: #00B457;\">&nbsp;&nbsp;&nbsp;</span> No risk</li>
-        <li style=\"margin-bottom: 5px;\"><span style=\"background-color: #FFCC00;\">&nbsp;&nbsp;&nbsp;</span> Possible risk</li>
-        <li><span style=\"background-color: #FF0000;\">&nbsp;&nbsp;&nbsp;</span> High risk</li>
-        </ul>
-        "
-        
-        "wms_abstract.nb" "
-        <ul style=\"list-style: none; padding: 0;\">
-        <li style=\"margin-bottom: 5px;\"><span style=\"background-color: #707070;\">&nbsp;&nbsp;&nbsp;</span> Varsel beregnes ikke</li>
-        <li style=\"margin-bottom: 5px;\"><span style=\"background-color: #00B457;\">&nbsp;&nbsp;&nbsp;</span> Ingen infeksjonsrisikok</li>
-        <li style=\"margin-bottom: 5px;\"><span style=\"background-color: #FFCC00;\">&nbsp;&nbsp;&nbsp;</span> Mulig fare for angrep</li>
-        <li><span style=\"background-color: #FF0000;\">&nbsp;&nbsp;&nbsp;</span> Høy fare for angrep</li>
-        </ul>
-        "
-    END
+      {
+          \"isWarningStatus\": true,
+          \"legendItems\": [
+          {
+            \"classification\": 0,
+            \"legendLabel\": \"No infection risk\",
+            \"legendIconCSS\": \"width: 25px; background-color: #707070;\"
+          },
+          {
+            \"classification\": 2,
+            \"legendLabel\": \"Low infection risk\",
+            \"legendIconCSS\": \"width: 25px; background-color: #FFCC00;\"
+          },
+          {
+            \"classification\": 3,
+            \"legendLabel\": \"Medium infection risk\",
+            \"legendIconCSS\": \"width: 25px; background-color: #FFCC99;\"
+          },
+          {
+            \"classification\": 4,
+            \"legendLabel\": \"High infection risk\",
+            \"legendIconCSS\": \"width: 25px; background-color: #FF0000;\"
+          }
+        ]
+      }
+      "
+      
+      "wms_abstract.nb" "
+      {
+          \"isWarningStatus\": true,
+          \"legendItems\": [
+          {
+            \"classification\": 0,
+            \"legendLabel\": \"Ingen infeksjonsrisiko\",
+            \"legendIconCSS\": \"width: 25px; background-color: #707070;\"
+          },
+          {
+            \"classification\": 2,
+            \"legendLabel\": \"Lav infeksjonsrisiko\",
+            \"legendIconCSS\": \"width: 25px; background-color: #FFCC00;\"
+          },
+          {
+            \"classification\": 3,
+            \"legendLabel\": \"Middels infeksjonsrisiko\",
+            \"legendIconCSS\": \"width: 25px; background-color: #FFCC99;\"
+          },
+          {
+            \"classification\": 4,
+            \"legendLabel\": \"Høy infeksjonsrisiko\",
+            \"legendIconCSS\": \"width: 25px; background-color: #FF0000;\"
+          }
+        ]
+      }
+      "
+      
+    END  
   END
 ```
 
+The Json schema for the legend is as follows: (TODO: place on a URI)
+```json
+{
+  "title": "Layer legend",
+  "type": "object",
+  "required": [
+    "legendItems"
+  ],
+  "properties": {
+    "isWarningStatus": {
+      "type": "boolean",
+      "title": "Legend type is warning status?",
+      "default": false
+    },
+    "legendItems": {
+      "type": "array",
+      "title": "Legend items",
+      "description": "The lengend items in their preferred order",
+      "items": {
+        "required": [
+          "legendLabel"
+        ],
+        "type": "object",
+        "title": "Legend item",
+        "properties": {
+          "classification": {
+            "type": "number",
+            "title": "Classification"
+          },
+          "legendLabel": {
+            "type": "string",
+            "title": "Legend label"
+          },
+          "legendIconCSS": {
+            "type": "string",
+            "title": "Legend icon CSS"
+          }
+        }
+      }
+    }
+  }
+}
+```
+
+Use this schema e.g. in [Json-editor](https://json-editor.github.io/json-editor/) and create the legend without coding. Remember to escape all double quotes before adding it to a mapfile.
+
 The client must then check if the layer abstract exists in the requested language. If not, default to the auto generated legend. For example like this (using OpenLayers):
 ```javascript
 // See if there is a language specific legend available
 if(currentLayer.Abstract != undefined)
 {
-    document.getElementById("layerLegend").innerHTML=currentLayer.Abstract;
+  // You need to generate and return HTML from the Json in the getLegendHTML function
+    document.getElementById("layerLegend").innerHTML=getLegendHTML(currentLayer.Abstract);
 }
 else // Fallback to auto generated legend
 {
-- 
GitLab