Mercurial > gemma
changeset 4336:45307cf4931a
Review of fairway dimensions
In order to review fairway dimensions, the ids from the summary are used to retrieve
the according features from the geoserver. Then instances of the type Feature are
generated with the information given from the geoserver. These are then added
to the VectorSource layer and should be displayed.
Currently the display doesn't work.
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Thu, 05 Sep 2019 15:52:43 +0200 |
parents | 2f212f520a04 |
children | 086640dc0fba |
files | client/src/components/importoverview/FairwayDimensionDetail.vue client/src/components/importoverview/LogDetail.vue client/src/components/map/layers.js |
diffstat | 3 files changed, 76 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/importoverview/FairwayDimensionDetail.vue Thu Sep 05 15:02:06 2019 +0200 +++ b/client/src/components/importoverview/FairwayDimensionDetail.vue Thu Sep 05 15:52:43 2019 +0200 @@ -16,5 +16,70 @@ * Author(s): * Thomas Junk <thomas.junk@intevation.de> */ -export default {}; +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"; + +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); + }); + }); +}; + +export default { + props: ["summary"], + mounted() { + const ids = this.fairWayDimensionIDs.map(id => { + return equalToFilter("id", id); + }); + getFromWFS("fairway_dimensions", orFilter(...ids)).then(response => { + let { features } = response.data; + const fairwaydimensionLayer = this.openLayersMap().getLayer( + "FDREVIEWLAYER" + ); + features = features.map(f => { + let result = new Feature({ + geometry: new Polygon(f.geometry.coordinates) + }); + result.setId(f.id); + return result; + }); + fairwaydimensionLayer.setVisible(true); + fairwaydimensionLayer.getSource().addFeatures(features); + }); + }, + computed: { + ...mapGetters("map", ["openLayersMap"]), + fairWayDimensionIDs() { + return this.summary["fd-area"].map(e => e.id); + } + } +}; </script>
--- a/client/src/components/importoverview/LogDetail.vue Thu Sep 05 15:02:06 2019 +0200 +++ b/client/src/components/importoverview/LogDetail.vue Thu Sep 05 15:52:43 2019 +0200 @@ -35,7 +35,7 @@ v-if="entry.id === showAdditional && isPending && (isFD || isAGM || isBN)" class="d-flex border-bottom" > - <FairwayDimensionDetail v-if="isFD" /> + <FairwayDimensionDetail :summary="details.summary" v-if="isFD" /> <ApprovedGaugeMeasurementDetail v-if="isAGM" /> <BottleneckDetail :entry="entry" v-if="isBN" /> </div>
--- a/client/src/components/map/layers.js Thu Sep 05 15:02:06 2019 +0200 +++ b/client/src/components/map/layers.js Thu Sep 05 15:52:43 2019 +0200 @@ -180,6 +180,13 @@ // Shared feature source for layers: // BOTTLENECKS, BOTTLENECKSTATUS and BOTTLENECKFAIRWAYAVAILABILITY // Reduces bottlenecks_geoserver requests and number of stored feature objects. + const FDREVIEWLAYER = new VectorLayer({ + id: "FDREVIEWLAYER", + label: "Review", + visible: true, + source: new VectorSource(), + style: styles.sections + }); const bottlenecksSource = new VectorSource({ strategy: bboxStrategy }); bottlenecksSource.setLoader( buildVectorLoader( @@ -637,7 +644,8 @@ }); })(), DRAWLAYER, - CUTLAYER + CUTLAYER, + FDREVIEWLAYER ]; layerConfigs[mapId] = config;