Mercurial > gemma
changeset 4374:ad2bf9580696
importoverview: review of fairwaydimensions improved
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Wed, 11 Sep 2019 15:51:15 +0200 |
parents | aa249a25f0ec |
children | 6ebd2d7756d5 |
files | client/src/components/Contextbox.vue client/src/components/importoverview/FairwayDimensionDetail.vue client/src/components/importoverview/ImportOverview.vue client/src/components/layers/Layers.vue client/src/components/map/layers.js |
diffstat | 5 files changed, 42 insertions(+), 64 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/Contextbox.vue Wed Sep 11 12:35:07 2019 +0200 +++ b/client/src/components/Contextbox.vue Wed Sep 11 15:51:15 2019 +0200 @@ -59,6 +59,7 @@ this.$store.commit("map/mapPopupEnabled", true); this.$store.commit("application/searchQuery", ""); this.$store.commit("application/showContextBox", false); + this.$store.commit("map/reviewActive", false); this.$store.commit( "application/showSearchbar", this.showSearchbarLastState
--- a/client/src/components/importoverview/FairwayDimensionDetail.vue Wed Sep 11 12:35:07 2019 +0200 +++ b/client/src/components/importoverview/FairwayDimensionDetail.vue Wed Sep 11 15:51:15 2019 +0200 @@ -26,43 +26,12 @@ * Author(s): * Thomas Junk <thomas.junk@intevation.de> */ -import { HTTP } from "@/lib/http"; -import { WFS } from "ol/format"; import { or as orFilter, equalTo as equalToFilter } from "ol/format/filter"; //import { displayError } from "@/lib/errors"; import { mapGetters } from "vuex"; -import Feature from "ol/Feature"; -import Polygon from "ol/geom/Polygon"; -import { transform } from "ol/proj"; - -const getFromWFS = (type, filter) => { - return new Promise((resolve, reject) => { - var featureCollectionRequest = new WFS().writeGetFeature({ - srsName: "EPSG:4326", - featureNS: "gemma", - featurePrefix: "gemma", - featureTypes: [type], - outputFormat: "application/json", - filter: filter - }); - HTTP.post( - "/internal/wfs", - new XMLSerializer().serializeToString(featureCollectionRequest), - { - headers: { - "X-Gemma-Auth": localStorage.getItem("token"), - "Content-type": "text/xml; charset=UTF-8" - } - } - ) - .then(response => { - resolve(response); - }) - .catch(error => { - reject(error); - }); - }); -}; +import VectorSource from "ol/source/Vector"; +import { buildVectorLoader } from "@/components/map/layers.js"; +import { bbox as bboxStrategy } from "ol/loadingstrategy"; export default { props: ["summary"], @@ -76,34 +45,30 @@ const ids = this.fairWayDimensionIDs.map(id => { return equalToFilter("id", id); }); - getFromWFS("fairway_dimensions", orFilter(...ids)).then(response => { - let { features } = response.data; - if (features.length < 0) { - const { - level_of_service, - source_organization - } = features[0].properties; - this.LOS = level_of_service; - this.organization = source_organization; - const fairwaydimensionLayer = this.openLayersMap().getLayer( - "FDREVIEWLAYER" - ); - features = features.map(f => { - let result = new Feature({ - geometry: new Polygon([ - f.geometry.coordinates[0].map(c => - transform(c, "EPSG:4326", "EPSG:3857") - ) - ]) - }); - result.setId(f.id); - return result; - }); - this.$store.commit("map/reviewActive", true); - fairwaydimensionLayer.setVisible(true); - fairwaydimensionLayer.getSource().addFeatures(features); - } - }); + const fairwaydimensionLayer = this.openLayersMap().getLayer( + "FDREVIEWLAYER" + ); + const source = new VectorSource({ strategy: bboxStrategy }); + this.$store.commit("map/reviewActive", true); + fairwaydimensionLayer.setVisible(true); + source.setLoader( + buildVectorLoader( + { + geometryName: "area", + featureTypes: ["fairway_dimensions"], + filter: orFilter(...ids) + }, + source, + false + ) + ); + fairwaydimensionLayer.setSource(source); + // this.$store.dispatch("map/moveToBoundingBox", { + // boundingBox: , + // zoom: 17, + // preventZoomOut: true, + // duration: 0 + // }); }, computed: { ...mapGetters("map", ["openLayersMap"]),
--- a/client/src/components/importoverview/ImportOverview.vue Wed Sep 11 12:35:07 2019 +0200 +++ b/client/src/components/importoverview/ImportOverview.vue Wed Sep 11 15:51:15 2019 +0200 @@ -419,6 +419,7 @@ this.$store.dispatch("imports/loadStagingNotifications"); this.$store.dispatch("imports/loadStretches"); this.$store.dispatch("imports/loadSections"); + this.$store.commit("map/reviewActive", false); const messages = response.data .map(x => { if (x.message) return x.message;
--- a/client/src/components/layers/Layers.vue Wed Sep 11 12:35:07 2019 +0200 +++ b/client/src/components/layers/Layers.vue Wed Sep 11 15:51:15 2019 +0200 @@ -59,7 +59,7 @@ * Thomas Junk <thomas.junk@intevation.de> * Markus Kottländer <markus.kottlaender@intevation.de> */ -import { mapState } from "vuex"; +import { mapState, mapGetters } from "vuex"; export default { components: { @@ -68,6 +68,7 @@ computed: { ...mapState("application", ["showLayers"]), ...mapState("map", ["openLayersMaps", "reviewActive"]), + ...mapGetters("map", ["openLayersMap"]), label() { return this.$gettext("Map Layers"); }, @@ -82,6 +83,16 @@ return counter; } }, + watch: { + reviewActive() { + if (!this.reviewActive) { + const fairwaydimensionLayer = this.openLayersMap().getLayer( + "FDREVIEWLAYER" + ); + fairwaydimensionLayer.setVisible(false); + } + } + }, methods: { close() { this.$store.commit("application/showLayers", false);
--- a/client/src/components/map/layers.js Wed Sep 11 12:35:07 2019 +0200 +++ b/client/src/components/map/layers.js Wed Sep 11 15:51:15 2019 +0200 @@ -16,7 +16,7 @@ import { styleFactory } from "./styles"; import store from "@/store/index"; -const buildVectorLoader = ( +export const buildVectorLoader = ( featureRequestOptions, vectorSource, bboxStrategyDisabled,