# HG changeset patch # User Markus Kottlaender # Date 1543497376 -3600 # Node ID 4afbc615cfc2f953d3c91b0d8dba06a01d9c870a # Parent 40f5ec2839b86669d725da436d8131b3fce9745e little code cleanup diff -r 40f5ec2839b8 -r 4afbc615cfc2 client/src/components/map/Maplayer.vue --- 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()); }); diff -r 40f5ec2839b8 -r 4afbc615cfc2 client/src/components/map/fairway/Fairwayprofile.vue --- 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", [ diff -r 40f5ec2839b8 -r 4afbc615cfc2 client/src/components/map/toolbar/Linetool.vue --- 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(); } } }; diff -r 40f5ec2839b8 -r 4afbc615cfc2 client/src/components/map/toolbar/Polygontool.vue --- 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(); } } }; diff -r 40f5ec2839b8 -r 4afbc615cfc2 client/src/components/map/toolbar/Toolbar.vue --- 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(); } }); } diff -r 40f5ec2839b8 -r 4afbc615cfc2 client/src/store/fairway.js --- 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) {