changeset 1424:4afbc615cfc2

little code cleanup
author Markus Kottlaender <markus@intevation.de>
date Thu, 29 Nov 2018 14:16:16 +0100
parents 40f5ec2839b8
children c8fe86d1c270
files client/src/components/map/Maplayer.vue client/src/components/map/fairway/Fairwayprofile.vue client/src/components/map/toolbar/Linetool.vue client/src/components/map/toolbar/Polygontool.vue client/src/components/map/toolbar/Toolbar.vue client/src/store/fairway.js
diffstat 6 files changed, 15 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/map/Maplayer.vue	Thu Nov 29 13:06:14 2018 +0100
+++ b/client/src/components/map/Maplayer.vue	Thu Nov 29 14:16:16 2018 +0100
@@ -55,7 +55,7 @@
     };
   },
   computed: {
-    ...mapGetters("map", ["getLayerByName"]),
+    ...mapGetters("map", ["getLayerByName", "getVSourceByName"]),
     ...mapState("map", [
       "extent",
       "layers",
@@ -127,9 +127,7 @@
         */
 
         // trying the GetFeatureInfo way for WMS
-        var wmsSource = this.getLayerByName(
-          "Inland ECDIS chart Danube"
-        ).data.getSource();
+        var wmsSource = this.getVSourceByName("Inland ECDIS chart Danube");
         var url = wmsSource.getGetFeatureInfoUrl(
           coordinate,
           100 /* resolution */,
@@ -189,10 +187,11 @@
     },
     updateBottleneckFilter(bottleneck_id, datestr) {
       console.log("updating filter with", bottleneck_id, datestr);
-      var layer = this.getLayerByName("Bottleneck isolines");
-      var wmsSrc = layer.data.getSource();
+      const layer = this.getLayerByName("Bottleneck isolines");
+      const wmsSrc = layer.data.getSource();
+      const exists = bottleneck_id != "does_not_exist";
 
-      if (bottleneck_id != "does_not_exist") {
+      if (exists) {
         wmsSrc.updateParams({
           cql_filter:
             "date_info='" +
@@ -201,12 +200,9 @@
             bottleneck_id +
             "'"
         });
-        layer.isVisible = true;
-        layer.data.setVisible(true);
-      } else {
-        layer.isVisible = false;
-        layer.data.setVisible(false);
       }
+      layer.isVisible = exists;
+      layer.data.setVisible(exists);
     },
     onBeforePrint(/* evt */) {
       // console.log("onBeforePrint(", evt ,")");
@@ -300,11 +296,9 @@
         }
       }
     ).then(response => {
-      var features = new GeoJSON().readFeatures(JSON.stringify(response.data));
-      var vectorSrc = this.getLayerByName(
-        "Fairway Dimensions"
-      ).data.getSource();
-      vectorSrc.addFeatures(features);
+      this.getVSourceByName("Fairway Dimensions").addFeatures(
+        new GeoJSON().readFeatures(JSON.stringify(response.data))
+      );
       // would scale to the extend of all resulting features
       // this.openLayersMap.getView().fit(vectorSrc.getExtent());
     });
--- a/client/src/components/map/fairway/Fairwayprofile.vue	Thu Nov 29 13:06:14 2018 +0100
+++ b/client/src/components/map/fairway/Fairwayprofile.vue	Thu Nov 29 14:16:16 2018 +0100
@@ -109,7 +109,6 @@
     };
   },
   computed: {
-    ...mapGetters("map", ["getLayerByName"]),
     ...mapGetters("fairwayprofile", ["totalLength"]),
     ...mapState("application", ["showSplitscreen"]),
     ...mapState("fairwayprofile", [
@@ -122,7 +121,6 @@
       "fairwayCoordinates",
       "waterLevels",
       "selectedWaterLevel",
-      "previousCuts",
       "profileLoading"
     ]),
     ...mapState("bottlenecks", [
--- a/client/src/components/map/toolbar/Linetool.vue	Thu Nov 29 13:06:14 2018 +0100
+++ b/client/src/components/map/toolbar/Linetool.vue	Thu Nov 29 14:16:16 2018 +0100
@@ -32,9 +32,7 @@
       this.polygonTool.setActive(false);
       this.cutTool.setActive(false);
       this.$store.commit("map/setCurrentMeasurement", null);
-      this.getLayerByName("Draw Tool")
-        .data.getSource()
-        .clear();
+      this.getVSourceByName("Draw Tool").clear();
     }
   }
 };
--- a/client/src/components/map/toolbar/Polygontool.vue	Thu Nov 29 13:06:14 2018 +0100
+++ b/client/src/components/map/toolbar/Polygontool.vue	Thu Nov 29 14:16:16 2018 +0100
@@ -32,9 +32,7 @@
       this.lineTool.setActive(false);
       this.cutTool.setActive(false);
       this.$store.commit("map/setCurrentMeasurement", null);
-      this.getLayerByName("Draw Tool")
-        .data.getSource()
-        .clear();
+      this.getVSourceByName("Draw Tool").clear();
     }
   }
 };
--- a/client/src/components/map/toolbar/Toolbar.vue	Thu Nov 29 13:06:14 2018 +0100
+++ b/client/src/components/map/toolbar/Toolbar.vue	Thu Nov 29 14:16:16 2018 +0100
@@ -107,9 +107,7 @@
         this.polygonTool.setActive(false);
         this.cutTool.setActive(false);
         this.$store.commit("map/setCurrentMeasurement", null);
-        this.getLayerByName("Draw Tool")
-          .data.getSource()
-          .clear();
+        this.getVSourceByName("Draw Tool").clear();
       }
     });
   }
--- a/client/src/store/fairway.js	Thu Nov 29 13:06:14 2018 +0100
+++ b/client/src/store/fairway.js	Thu Nov 29 14:16:16 2018 +0100
@@ -121,9 +121,7 @@
       commit("clearCurrentProfile");
       commit("application/showSplitscreen", false, { root: true });
       rootState.map.cutTool.setActive(false);
-      rootGetters["map/getLayerByName"]("Cut Tool")
-        .data.getSource()
-        .clear();
+      rootGetters["map/getVSourceByName"]("Cut Tool").clear();
     },
     loadProfile({ commit, state }, survey) {
       if (state.startPoint && state.endPoint) {