diff client/src/components/identify/Identify.vue @ 4269:837f90680d4c

identify: complete helper methods for legend
author Thomas Junk <thomas.junk@intevation.de>
date Tue, 27 Aug 2019 15:51:05 +0200
parents c5642480eb9b
children e4d6c6339cb4
line wrap: on
line diff
--- a/client/src/components/identify/Identify.vue	Tue Aug 27 14:37:53 2019 +0200
+++ b/client/src/components/identify/Identify.vue	Tue Aug 27 15:51:05 2019 +0200
@@ -162,10 +162,10 @@
 import { styleFactory } from "@/components/map/styles";
 
 const {
-  recencyColorCodes
-  // gmAvailabilityColorCodes,
-  // forecastAccuracyColorCodes,
-  // forecastVsRealityColorCodes
+  recencyColorCodes,
+  gmAvailabilityColorCodes,
+  forecastAccuracyColorCodes,
+  forecastVsRealityColorCodes
 } = styleFactory();
 
 export default {
@@ -183,15 +183,64 @@
     }
   },
   methods: {
+    gmAvailability(feature) {
+      const latestInHours = this.config.gm_latest_hours;
+      const measurementsIn14D = this.config.gm_min_values_14d;
+      const messagesPerState = {
+        OK:
+          this.$gettext("Last measurement <") +
+          ` ${latestInHours} (${measurementsIn14D} in 14d)`,
+        WARNING:
+          this.$gettext("Below treshold") + `: ${measurementsIn14D} in 14d`,
+        DANGER:
+          this.$gettext("Latest measurement older than") + ` ${latestInHours} d`
+      };
+      return messagesPerState[[classifications.gmAvailability(feature)]];
+    },
+    gmAvailabilityColor(feature) {
+      return gmAvailabilityColorCodes[classifications.gmAvailability(feature)];
+    },
+    forecastAccuracy(feature) {
+      const offset24 = this.config.gm_forecast_offset_24h;
+      const offset72 = this.config.gm_forecast_offset_72h;
+      const messagesPerState = {
+        OK:
+          this.$gettext("Highest confidence") +
+          ` <${offset24} cm/24h, <${offset72} cm/72h`,
+        WARNING: this.$gettext("Confidence per 72h") + ` > ${offset72} cm`,
+        DANGER: this.$gettext("Confidence per 24h") + ` > ${offset24} cm`
+      };
+      return messagesPerState[[classifications.forecastAccuracy(feature)]];
+    },
+    forecastAccuracyColor(feature) {
+      return forecastAccuracyColorCodes[
+        classifications.forecastAccuracy(feature)
+      ];
+    },
+    forecastVsReality(feature) {
+      const nsc24 = this.config.gm_forecast_vs_reality_nsc_24h;
+      const nsc72 = this.config.gm_forecast_vs_reality_nsc_72h;
+      const messagesPerState = {
+        OK: this.$gettext("Nash-Sutcliffe") + `>${nsc24} /24h >${nsc72} / 72h`,
+        WARNING: this.$gettext("Nash-Sutcliffe") + ` < ${nsc72}`,
+        DANGER: this.$gettext("Nash-Sutcliffe") + ` < ${nsc24}`
+      };
+      return messagesPerState[[classifications.forecastVsReality(feature)]];
+    },
+    forecastVsRealityColor(feature) {
+      return forecastVsRealityColorCodes[
+        classifications.forecastVsReality(feature)
+      ];
+    },
     recency(feature) {
       const revisitingFactor = this.config.bn_revtime_multiplier;
       const messagesPerState = {
         OK: this.$gettext("Data within the revisiting time"),
         WARNING:
-          this.$gettext("Data within revisiting treshold ") +
-          `(${revisitingFactor})`,
+          this.$gettext("Data within revisiting treshold") +
+          ` (${revisitingFactor})`,
         DANGER:
-          this.$gettext("Data too old. Treshold: ") + `(${revisitingFactor})`
+          this.$gettext("Data too old. Treshold:") + ` (${revisitingFactor})`
       };
       return messagesPerState[classifications.surveyCurrency(feature)];
     },