From 7f841b118726521b97c398c4bda32ada0e3f1c3f Mon Sep 17 00:00:00 2001
From: Tor-Einar Skog <tor-einar.skog@nibio.no>
Date: Wed, 28 Feb 2024 08:47:19 +0100
Subject: [PATCH] Rename weather param 1001 to 1002 if provided, to adapt to
 HAPDMA

---
 ipmd/templates/ipmd/saddlegallmidgeform.html | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ipmd/templates/ipmd/saddlegallmidgeform.html b/ipmd/templates/ipmd/saddlegallmidgeform.html
index 077d49f2..ad0cf420 100644
--- a/ipmd/templates/ipmd/saddlegallmidgeform.html
+++ b/ipmd/templates/ipmd/saddlegallmidgeform.html
@@ -524,6 +524,11 @@
             }
             if(weatherData != null)
             {
+                // HAPDMA only accepts average temp (code 1002), so we need to change the temp code if it's 1001
+                if(!weatherData.weatherParameters.includes(1002) && weatherData.weatherParameters.includes(1001))
+                {
+                    weatherData.weatherParameters[weatherData.weatherParameters.indexOf(1001)] = 1002;                
+                }
                 inputData["weatherData"] = weatherData;
             }
             else
-- 
GitLab