annotate client/src/components/importoverview/FairwayDimensionDetail.vue @ 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 edc2633c3cc6
children e9d2573329da
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2917
edc2633c3cc6 client: importsoverview: cleaned up html, removed unnecessary component
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
1 <template>
edc2633c3cc6 client: importsoverview: cleaned up html, removed unnecessary component
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
2 <div>Fairwaydimension</div>
edc2633c3cc6 client: importsoverview: cleaned up html, removed unnecessary component
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
3 </template>
edc2633c3cc6 client: importsoverview: cleaned up html, removed unnecessary component
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
4
edc2633c3cc6 client: importsoverview: cleaned up html, removed unnecessary component
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
5 <script>
edc2633c3cc6 client: importsoverview: cleaned up html, removed unnecessary component
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
6 /* This is Free Software under GNU Affero General Public License v >= 3.0
edc2633c3cc6 client: importsoverview: cleaned up html, removed unnecessary component
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
7 * without warranty, see README.md and license for details.
edc2633c3cc6 client: importsoverview: cleaned up html, removed unnecessary component
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
8 *
edc2633c3cc6 client: importsoverview: cleaned up html, removed unnecessary component
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
9 * SPDX-License-Identifier: AGPL-3.0-or-later
edc2633c3cc6 client: importsoverview: cleaned up html, removed unnecessary component
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
10 * License-Filename: LICENSES/AGPL-3.0.txt
edc2633c3cc6 client: importsoverview: cleaned up html, removed unnecessary component
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
11 *
edc2633c3cc6 client: importsoverview: cleaned up html, removed unnecessary component
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
12 * Copyright (C) 2018 by via donau
edc2633c3cc6 client: importsoverview: cleaned up html, removed unnecessary component
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
13 * – Österreichische Wasserstraßen-Gesellschaft mbH
edc2633c3cc6 client: importsoverview: cleaned up html, removed unnecessary component
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
14 * Software engineering by Intevation GmbH
edc2633c3cc6 client: importsoverview: cleaned up html, removed unnecessary component
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
15 *
edc2633c3cc6 client: importsoverview: cleaned up html, removed unnecessary component
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
16 * Author(s):
edc2633c3cc6 client: importsoverview: cleaned up html, removed unnecessary component
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
17 * Thomas Junk <thomas.junk@intevation.de>
edc2633c3cc6 client: importsoverview: cleaned up html, removed unnecessary component
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
18 */
4336
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
19 import { HTTP } from "@/lib/http";
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
20 import { WFS } from "ol/format";
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
21 import { or as orFilter, equalTo as equalToFilter } from "ol/format/filter";
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
22 //import { displayError } from "@/lib/errors";
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
23 import { mapGetters } from "vuex";
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
24 import Feature from "ol/Feature";
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
25 import Polygon from "ol/geom/Polygon";
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
26
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
27 const getFromWFS = (type, filter) => {
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
28 return new Promise((resolve, reject) => {
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
29 var featureCollectionRequest = new WFS().writeGetFeature({
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
30 srsName: "EPSG:4326",
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
31 featureNS: "gemma",
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
32 featurePrefix: "gemma",
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
33 featureTypes: [type],
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
34 outputFormat: "application/json",
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
35 filter: filter
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
36 });
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
37 HTTP.post(
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
38 "/internal/wfs",
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
39 new XMLSerializer().serializeToString(featureCollectionRequest),
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
40 {
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
41 headers: {
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
42 "X-Gemma-Auth": localStorage.getItem("token"),
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
43 "Content-type": "text/xml; charset=UTF-8"
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
44 }
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
45 }
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
46 )
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
47 .then(response => {
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
48 resolve(response);
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
49 })
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
50 .catch(error => {
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
51 reject(error);
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
52 });
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
53 });
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
54 };
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
55
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
56 export default {
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
57 props: ["summary"],
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
58 mounted() {
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
59 const ids = this.fairWayDimensionIDs.map(id => {
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
60 return equalToFilter("id", id);
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
61 });
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
62 getFromWFS("fairway_dimensions", orFilter(...ids)).then(response => {
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
63 let { features } = response.data;
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
64 const fairwaydimensionLayer = this.openLayersMap().getLayer(
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
65 "FDREVIEWLAYER"
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
66 );
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
67 features = features.map(f => {
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
68 let result = new Feature({
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
69 geometry: new Polygon(f.geometry.coordinates)
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
70 });
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
71 result.setId(f.id);
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
72 return result;
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
73 });
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
74 fairwaydimensionLayer.setVisible(true);
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
75 fairwaydimensionLayer.getSource().addFeatures(features);
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
76 });
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
77 },
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
78 computed: {
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
79 ...mapGetters("map", ["openLayersMap"]),
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
80 fairWayDimensionIDs() {
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
81 return this.summary["fd-area"].map(e => e.id);
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
82 }
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
83 }
45307cf4931a Review of fairway dimensions
Thomas Junk <thomas.junk@intevation.de>
parents: 2917
diff changeset
84 };
2917
edc2633c3cc6 client: importsoverview: cleaned up html, removed unnecessary component
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
85 </script>