changeset 828:4e093c5560c3

Merged
author Sascha Wilde <wilde@intevation.de>
date Thu, 27 Sep 2018 23:25:44 +0200
parents f3adc0f3a20a (current diff) 90a601884ff2 (diff)
children 56fa02c93766
files
diffstat 5 files changed, 126 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/App.vue	Thu Sep 27 23:24:40 2018 +0200
+++ b/client/src/App.vue	Thu Sep 27 23:25:44 2018 +0200
@@ -22,7 +22,7 @@
             </div>
         </div>
         <div class="d-flex flex-column">
-            <router-view />
+            <router-view/>
         </div>
     </div>
 </template>
@@ -90,6 +90,7 @@
 import { mapGetters } from "vuex";
 import Userbar from "./application/Userbar";
 import Linetool from "./application/Linetool";
+import Morphtool from "./application/Morphtool";
 
 export default {
   name: "app",
@@ -104,7 +105,8 @@
     Sidebar,
     Topbar,
     Userbar,
-    Linetool
+    Linetool,
+    Morphtool
   }
 };
 </script>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/client/src/application/Morphtool.vue	Thu Sep 27 23:25:44 2018 +0200
@@ -0,0 +1,117 @@
+<template>
+  <div v-if="selectedBottleneck">
+    <div v-if="surveyList" class="ui-element card card-body shadow">
+      <div class="headline">
+        <h5>{{selectedBottleneck.get("objnam")}}</h5>
+      </div>
+      <ul class="list-group">
+        <li v-for="survey of surveyList.surveys" :key="survey.data_info"
+            class="list-group-item" @click.prevent="selectSurvey(survey)">
+          <a href="#" @click.prevent=""
+             >{{survey.date_info}}</a>
+        </li>
+      </ul>
+      <div @click="clearSelection"
+           class="float-left ui-element d-flex shadow morphtoolminus">
+        <i class="fa fa-minus morphtoolsminus"></i>
+      </div>
+    </div>
+    <div v-else @click="clearSelection" class="float-right ui-element d-flex shadow morphtool">
+        <i class="fa fa-object-ungroup"></i>
+    </div>
+  </div>
+</template>
+
+<style lang="scss">
+.morphtool {
+  position: relative;
+  background-color: white;
+  padding: $small-offset;
+  border-radius: $border-radius;
+  margin-left: $offset;
+  height: $icon-width;
+  width: $icon-height;
+  margin-bottom: $offset;
+  margin-right: $offset;
+  z-index: 2;
+}
+.morphtoolminus {
+  position: relative;
+  background-color: white;
+  padding: $small-offset;
+  border-radius: $border-radius;
+  height: $icon-width;
+  width: $icon-height;
+  z-index: 2;
+}
+</style>
+
+<script>
+import { mapGetters, mapState } from "vuex";
+
+import { displayError } from "../application/lib/errors.js";
+import { HTTP } from "../application/lib/http";
+
+export default {
+  name: "morphtool",
+  data() {
+    return {
+      surveyList: null
+    };
+  },
+  computed: {
+    ...mapGetters("application", ["drawMode"]),
+    ...mapState("mapstore", ["identifiedFeatures", "selectedMorph"]),
+    selectedBottleneck: function() {
+      if (this.identifiedFeatures) {
+        for (let feature of this.identifiedFeatures) {
+          if (feature.getId().replace(/[.][^.]*$/, "") === "bottlenecks") {
+            return feature;
+          }
+        }
+      }
+      return null;
+    }
+  },
+  watch: {
+    selectedBottleneck: function(bottleneckFeature) {
+      if (bottleneckFeature) {
+        let bottleneckName = bottleneckFeature.get("objnam");
+        if (bottleneckName) {
+          this.queryBottleneck(bottleneckName);
+        }
+      }
+    }
+  },
+  methods: {
+    queryBottleneck(name) {
+      HTTP.get("/surveys/" + name, {
+        headers: {
+          "X-Gemma-Auth": localStorage.getItem("token"),
+          "Content-type": "text/xml; charset=UTF-8"
+        }
+      })
+        .then(response => {
+          this.surveyList = response.data;
+        })
+        .catch(error => {
+          this.surveyList = null;
+          const { status, data } = error.response;
+          displayError({
+            title: "Backend Error",
+            message: `${status}: ${data.message || data}`
+          });
+        });
+    },
+    selectSurvey(survey) {
+      this.$store.commit("mapstore/setSelectedMorph", survey);
+      this.surveyList = null;
+    },
+    clearSelection() {
+      this.$store.commit("mapstore/setIdentifiedFeatures", []);
+      this.$store.commit("mapstore/setSelectedMorph", null);
+      this.surveyList = null;
+    }
+  }
+};
+</script>
--- a/client/src/map/store.js	Thu Sep 27 23:24:40 2018 +0200
+++ b/client/src/map/store.js	Thu Sep 27 23:25:44 2018 +0200
@@ -195,7 +195,7 @@
     setCurrentMeasurement: (state, measurement) => {
       state.currentMeasurement = measurement;
     },
-    setSelectedMorpth: (state, selectedMorph) => {
+    setSelectedMorph: (state, selectedMorph) => {
       state.selectedMorph = selectedMorph;
     }
   }
--- a/pkg/controllers/surveys.go	Thu Sep 27 23:24:40 2018 +0200
+++ b/pkg/controllers/surveys.go	Thu Sep 27 23:25:44 2018 +0200
@@ -44,6 +44,10 @@
 		surveys = append(surveys, survey)
 	}
 
+	if err = rows.Err(); err != nil {
+		return
+	}
+
 	jr = JSONResult{
 		Result: struct {
 			Surveys []models.Survey `json:"surveys"`
--- a/pkg/octree/vertex.go	Thu Sep 27 23:24:40 2018 +0200
+++ b/pkg/octree/vertex.go	Thu Sep 27 23:25:44 2018 +0200
@@ -427,10 +427,6 @@
 
 func onPlane(x float64) bool { return math.Abs(x) < epsPlane }
 
-func dist(x1, y1, x2, y2 float64) float64 {
-	return math.Sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2))
-}
-
 func relative(v1, v2 Vertex) func(x, y float64) float64 {
 	ls := linearScale(v1.X, v1.Y, v2.X, v2.Y)
 	return func(x, y float64) float64 {