@@ -89,4 +89,95 @@ The model outputs GeoTIFF files, two per day in the season/period of calculation
* 4 = High risk (red)
*`result_[YYYY-MM-DD].tif`, which contains the accumulated day degrees (`DD`) - which is the sum of daily average temperatures with a base temperature of 5 °C
A [Jinja2](https://pypi.org/project/Jinja2/) template mapfile (for [Mapserver](https://mapserver.org/)) with separate layers (WARNING_STATUS and WHS) for each date is found in the `mapfile/` folder.
\ No newline at end of file
A [Jinja2](https://pypi.org/project/Jinja2/) template mapfile (for [Mapserver](https://mapserver.org/)) with separate layers (WARNING_STATUS and WHS) for each date is found in the `mapfile/` folder.
## Multi language support
Mapserver supports the &language=[language code] query parameter. Read more about the specifics [here](https://mapserver.org/ogc/inspire.html). Through this, we have been able to add language specific titles and abstracts. See an example below
```mapserver
MAP
[...]
WEB
METADATA
[...]
"wms_inspire_capabilities" "embed"
"wms_title.en" "Carrot rust fly (Psila rosae) temperature model"
"wms_title.nb" "Gulrotflue svermetidspunktmodell"
END
END
END
```
### Hacking i18n of mapserver generated legends
The auto generated legends from these mapserver sections do not support internationalization:
```mapserver
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
```
We have hacked this by using the `"wms_abstract"` metadata option for each layer. For example:
```mapserver
LAYER
NAME "PSILARTEMP.WARNING_STATUS.2023-04-01"
[...]
METADATA
"wms_abstract.en" "
<ul style=\"list-style: none; padding: 0;\">
<li style=\"margin-bottom: 5px;\"><span style=\"background-color: #707070;\"> </span> No forecast</li>
<li style=\"margin-bottom: 5px;\"><span style=\"background-color: #00B457;\"> </span> No risk</li>
<li style=\"margin-bottom: 5px;\"><span style=\"background-color: #FFCC00;\"> </span> Possible risk</li>
<li><span style=\"background-color: #FF0000;\"> </span> High risk</li>
<li style=\"margin-bottom: 5px;\"><span style=\"background-color: #00B457;\"> </span> Ingen infeksjonsrisikok</li>
<li style=\"margin-bottom: 5px;\"><span style=\"background-color: #FFCC00;\"> </span> Mulig fare for angrep</li>
<li><span style=\"background-color: #FF0000;\"> </span> Høy fare for angrep</li>
</ul>
"
END
END
```
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