changeset 3457:870812d8f247

client: spuc05: implemented new data format (csv) for diagrams on map
author Markus Kottlaender <markus@intevation.de>
date Fri, 24 May 2019 15:32:47 +0200
parents ca395be62023
children aa3c83fb7018
files client/src/components/map/layers.js client/src/components/map/styles.js client/src/store/fairwayavailability.js
diffstat 3 files changed, 23 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/map/layers.js	Fri May 24 14:24:24 2019 +0200
+++ b/client/src/components/map/layers.js	Fri May 24 15:32:47 2019 +0200
@@ -485,7 +485,7 @@
                 } else {
                   let date = new Date();
                   data = await store.dispatch(
-                    "fairwayavailability/loadAvailableFairwayDepthLNWL",
+                    "fairwayavailability/loadAvailableFairwayDepthLNWLForMap",
                     {
                       feature: f,
                       from: date.toISOString().split("T")[0],
--- a/client/src/components/map/styles.js	Fri May 24 14:24:24 2019 +0200
+++ b/client/src/components/map/styles.js	Fri May 24 15:32:47 2019 +0200
@@ -194,20 +194,10 @@
       resolution > 15
     ) {
       let data = feature.get("fa_data");
-      let lnwlHeight =
-        (80 / 100) * data.ldc.find(d => d.hasOwnProperty("from")).percent;
-      let belowThresholdHeight =
-        (80 / 100) *
-        data.afd.find(d => d.hasOwnProperty("to") && !d.hasOwnProperty("from"))
-          .percent;
-      let betweenThresholdHeight =
-        (80 / 100) *
-        data.afd.find(d => d.hasOwnProperty("to") && d.hasOwnProperty("from"))
-          .percent;
-      let aboveThresholdHeight =
-        (80 / 100) *
-        data.afd.find(d => !d.hasOwnProperty("to") && d.hasOwnProperty("from"))
-          .percent;
+      let lnwlHeight = (80 / 100) * data.ldc;
+      let belowThresholdHeight = (80 / 100) * data.below;
+      let betweenThresholdHeight = (80 / 100) * data.between;
+      let aboveThresholdHeight = (80 / 100) * data.above;
 
       let frame = `<rect x='0' y='0' width='32' height='84' stroke-width='0' fill='white'/>`;
       let lnwl = `<rect x='2' y='${80 -
--- a/client/src/store/fairwayavailability.js	Fri May 24 14:24:24 2019 +0200
+++ b/client/src/store/fairwayavailability.js	Fri May 24 15:32:47 2019 +0200
@@ -360,6 +360,24 @@
         // transformAFDLNWL
         commit("setFwLNWLData", data);
       });
+    },
+    loadAvailableFairwayDepthLNWLForMap: ({ dispatch }, options) => {
+      return dispatch("loadAvailableFairwayDepthLNWL", options).then(
+        response => {
+          let data = response.split("\n").filter(d => d);
+          data.shift(); // remove header line
+          data = data.map(d => {
+            let columns = d.split(",");
+            return {
+              ldc: columns[2],
+              below: columns[3],
+              between: columns[4],
+              above: columns[5]
+            };
+          });
+          return data[0];
+        }
+      );
     }
   }
 };