changeset 1025:a55f20dc8d8d

refac: store profiles by date
author Thomas Junk <thomas.junk@intevation.de>
date Wed, 24 Oct 2018 13:09:54 +0200
parents 96ea805d44b9
children 3de54d7b7d30
files client/src/application/Main.vue client/src/fairway/store.js client/src/map/Maplayer.vue
diffstat 3 files changed, 36 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/application/Main.vue	Wed Oct 24 12:29:25 2018 +0200
+++ b/client/src/application/Main.vue	Wed Oct 24 13:09:54 2018 +0200
@@ -1,8 +1,29 @@
 <template>
     <div class="main d-flex flex-column">
-        <Maplayer :drawMode="drawMode" :split="isSplitscreen" :lat="6155376" :long="1819178" :zoom="11"></Maplayer>
+        <Maplayer
+            :drawMode="drawMode"
+            :split="isSplitscreen"
+            :lat="6155376"
+            :long="1819178"
+            :zoom="11"
+        ></Maplayer>
         <div v-if="isSplitscreen" class="profile d-flex flex-row">
-            <FairwayProfile :additionalSurveys="additionalSurveys" :minAlt="minAlt" maxAlt="maxAlt" :selectedWaterLevel="selectedWaterLevel" :fairwayCoordinates="fairwayCoordinates" :waterLevels="waterLevels" :data="currentProfile" :height="height" :width="width" :xScale="xAxis" :yScaleLeft="yAxisLeft" :yScaleRight="yAxisRight" :margin="margins" :totalLength="totalLength"></FairwayProfile>
+            <FairwayProfile
+                :additionalSurveys="additionalSurveys"
+                :minAlt="minAlt"
+                maxAlt="maxAlt"
+                :selectedWaterLevel="selectedWaterLevel"
+                :fairwayCoordinates="fairwayCoordinates"
+                :waterLevels="waterLevels"
+                :data="coordinates"
+                :height="height"
+                :width="width"
+                :xScale="xAxis"
+                :yScaleLeft="yAxisLeft"
+                :yScaleRight="yAxisRight"
+                :margin="margins"
+                :totalLength="totalLength"
+            ></FairwayProfile>
         </div>
     </div>
 </template>
@@ -66,6 +87,10 @@
       "availableSurveys"
     ]),
     ...mapState("morphstore", ["selectedMorph"]),
+    coordinates() {
+      const currentSurveyDate = this.selectedMorph.date_info;
+      return this.currentProfile[currentSurveyDate];
+    },
     additionalSurveys() {
       if (!this.availableSurveys) return [];
       return this.availableSurveys.surveys.filter(x => {
--- a/client/src/fairway/store.js	Wed Oct 24 12:29:25 2018 +0200
+++ b/client/src/fairway/store.js	Wed Oct 24 13:09:54 2018 +0200
@@ -24,7 +24,7 @@
     totalLength: 0,
     minAlt: 0,
     maxAlt: 0,
-    currentProfile: [],
+    currentProfile: {},
     waterLevels: [{ year: "2016", level: DEMOLEVEL, color: "#005DFF" }],
     selectedWaterLevel: DEMOLEVEL,
     fairwayCoordinates: [],
@@ -43,7 +43,8 @@
     setSelectedWaterLevel: (state, level) => {
       state.selectedWaterLevel = level;
     },
-    profileLoaded: (state, response) => {
+    profileLoaded: (state, answer) => {
+      const { response, surveyDate } = answer;
       const { data } = response;
       const coordinates = data.geometry.coordinates;
       if (!coordinates) return;
@@ -51,7 +52,7 @@
       const endPoint = state.endPoint;
       const geoJSON = data;
       const result = prepareProfile({ geoJSON, startPoint, endPoint });
-      state.currentProfile = result.points;
+      state.currentProfile[surveyDate] = result.points;
       state.minAlt = result.minAlt;
       state.maxAlt = result.maxAlt;
       state.totalLength = result.lengthPolyLine;
@@ -66,7 +67,7 @@
       state.fairwayCoordinates = coordinates;
     },
     clearCurrentProfile: state => {
-      state.currentProfile = [];
+      state.currentProfile = {};
     }
   }
 };
--- a/client/src/map/Maplayer.vue	Wed Oct 24 12:29:25 2018 +0200
+++ b/client/src/map/Maplayer.vue	Wed Oct 24 13:09:54 2018 +0200
@@ -188,7 +188,10 @@
         headers: { "X-Gemma-Auth": localStorage.getItem("token") }
       })
         .then(response => {
-          this.$store.commit("fairwayprofile/profileLoaded", response);
+          this.$store.commit("fairwayprofile/profileLoaded", {
+            response: response,
+            surveyDate: survey.date_info
+          });
         })
         .then(() => {
           var vectorSource = this.getLayerByName(