changeset 3512:30a47d9fc667 waterlevel-in-crossprofile

client: fairway profiles: removed some old code
author Markus Kottlaender <markus@intevation.de>
date Tue, 28 May 2019 18:27:21 +0200
parents c50d955372b9
children ca9590be1da2
files client/src/components/fairway/Fairwayprofile.vue client/src/components/fairway/Profiles.vue client/src/store/fairwayprofile.js
diffstat 3 files changed, 15 insertions(+), 67 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/fairway/Fairwayprofile.vue	Tue May 28 17:14:52 2019 +0200
+++ b/client/src/components/fairway/Fairwayprofile.vue	Tue May 28 18:27:21 2019 +0200
@@ -149,9 +149,7 @@
       "endPoint",
       "fairwayData",
       "maxAlt",
-      "referenceWaterLevel",
-      "selectedWaterLevel",
-      "waterLevels"
+      "selectedWaterLevel"
     ]),
     ...mapState("application", ["paneSetup"]),
     title() {
@@ -173,9 +171,6 @@
       }
     },
     ...mapState("bottlenecks", ["selectedSurvey"]),
-    relativeWaterLevelDelta() {
-      return this.selectedWaterLevel.value - this.referenceWaterLevel;
-    },
     currentData() {
       if (
         !this.selectedSurvey ||
@@ -191,16 +186,6 @@
       )
         return [];
       return this.currentProfile[this.additionalSurvey.date_info].points;
-    },
-    xScale() {
-      return [0, this.totalLength];
-    },
-    yScaleRight() {
-      //ToDO calcReleativeDepth(this.maxAlt) to get the
-      // maximum depth according to the actual waterlevel
-      // additionally: take the one which is higher reference or current waterlevel
-      const DELTA = this.maxAlt * 1.1 - this.maxAlt;
-      return [this.maxAlt * 1 + DELTA, -DELTA];
     }
   },
   watch: {
@@ -429,25 +414,6 @@
       this.pdf.doc.circle(x, y + 10, 2, "FD");
       this.pdf.doc.text(x + 3, y + 11, "Ground");
     },
-    calcRelativeDepth(depth) {
-      /* takes a depth value and substracts the delta of the relative waterlevel
-       * say the reference level is above the current level, the ground is nearer,
-       * thus, the depth is lower.
-       *
-       * E.g.:
-       *
-       * Reference waterlevel 5m, current 4m => delta = -1m
-       * If the distance to the ground was 3m from the 5m mark
-       * it is now only 2m from the current waterlevel.
-       *
-       *  Vice versa:
-       *
-       *  If the reference level is 5m and the current 6m => delta = +1m
-       *  The ground is one meter farer away from the current waterlevel
-       *
-       */
-      return depth - this.relativeWaterLevelDelta;
-    },
     drawDiagram() {
       d3.select(".diagram-container svg").remove();
       this.scaleFairwayProfile();
@@ -458,7 +424,7 @@
       const height = this.height - this.margin.top - 2 * this.margin.bottom;
       const currentData = this.currentData;
       const additionalData = this.additionalData;
-      const { xScale, yScaleRight, graph } = this.generateCoordinates(
+      const { xScale, yScaleRight, graph } = this.generateScalesAndGraph(
         svg,
         height,
         width
@@ -540,20 +506,18 @@
         ])
         .text("Width [m]");
     },
-    generateCoordinates(svg, height, width) {
+    generateScalesAndGraph(svg, height, width) {
       let xScale = d3
         .scaleLinear()
-        .domain(this.xScale)
+        .domain([0, this.totalLength])
         .rangeRound([0, width]);
 
-      xScale.ticks(5);
-
       let yScaleRight = d3
         .scaleLinear()
-        .domain(this.yScaleRight)
+        .domain([this.maxAlt * 1.1, -(this.maxAlt * 0.1)])
         .rangeRound([height, 0]);
 
-      let xAxis = d3.axisBottom(xScale);
+      let xAxis = d3.axisBottom(xScale).ticks(5);
       let yAxis2 = d3.axisRight(yScaleRight);
       let graph = svg
         .append("g")
@@ -564,7 +528,7 @@
       graph
         .append("g")
         .attr("transform", "translate(0," + height + ")")
-        .call(xAxis.ticks(5))
+        .call(xAxis)
         .selectAll(".tick text")
         .attr("fill", "black")
         .select(function() {
--- a/client/src/components/fairway/Profiles.vue	Tue May 28 17:14:52 2019 +0200
+++ b/client/src/components/fairway/Profiles.vue	Tue May 28 18:27:21 2019 +0200
@@ -45,15 +45,11 @@
                 v-model="selectedWaterLevel"
                 class="form-control form-control-sm small"
               >
-                <option value="" v-if="Object.keys(waterLevels).length === 0">
-                  <translate>Current</translate>
+                <option value="LDC">
+                  <translate>LDC</translate>
                 </option>
-                <option
-                  v-for="wl in Object.keys(waterLevels)"
-                  :key="wl"
-                  :value="wl"
-                >
-                  {{ wl | surveyDate }}
+                <option value="current">
+                  <translate>Current</translate>
                 </option>
               </select>
             </div>
@@ -327,7 +323,7 @@
     },
     selectedWaterLevel: {
       get() {
-        return this.$store.state.fairwayprofile.selectedWaterLevel.date || "";
+        return this.$store.state.fairwayprofile.selectedWaterLevel;
       },
       set(value) {
         this.$store.commit("fairwayprofile/setSelectedWaterLevel", value);
--- a/client/src/store/fairwayprofile.js	Tue May 28 17:14:52 2019 +0200
+++ b/client/src/store/fairwayprofile.js	Tue May 28 18:27:21 2019 +0200
@@ -28,9 +28,7 @@
     minAlt: 0,
     maxAlt: 0,
     currentProfile: {},
-    referenceWaterLevel: null,
-    waterLevels: {},
-    selectedWaterLevel: "",
+    selectedWaterLevel: "LDC",
     fairwayData: [],
     startPoint: null,
     endPoint: null,
@@ -61,7 +59,7 @@
       state.additionalSurvey = additionalSurvey;
     },
     setSelectedWaterLevel: (state, level) => {
-      state.selectedWaterLevel = state.waterLevels[level];
+      state.selectedWaterLevel = level;
     },
     setDifferencesLoading: (state, value) => {
       state.differencesLoading = value;
@@ -69,8 +67,6 @@
     profileLoaded: (state, answer) => {
       const { response, surveyDate } = answer;
       const { data } = response;
-      const { waterlevel } = response.data.properties;
-      const { value, when } = waterlevel;
       const coordinates = data.geometry.coordinates;
       if (!coordinates) return;
       const startPoint = state.startPoint;
@@ -79,12 +75,6 @@
       const result = prepareProfile({ geoJSON, startPoint, endPoint });
       // Use Vue.set() to make new object properties rective
       // https://vuejs.org/v2/guide/reactivity.html#Change-Detection-Caveats
-      const entry = {
-        date: when,
-        value: value
-      };
-      state.waterLevels = { [when]: entry };
-      state.selectedWaterLevel = entry;
       Vue.set(state.currentProfile, surveyDate, {
         points: result.points,
         length: result.lengthPolyLine
@@ -116,9 +106,7 @@
       state.fairwayData = [];
       state.startPoint = null;
       state.endPoint = null;
-      state.referenceWaterLevel = null;
-      state.waterLevels = {};
-      state.selectedWaterLevel = "";
+      state.selectedWaterLevel = "LDC";
     },
     previousCuts: (state, previousCuts) => {
       state.previousCuts = previousCuts;