annotate client/src/map/Maplayer.vue @ 802:327aa4a18a1c

Fairway profile WIP
author Thomas Junk <thomas.junk@intevation.de>
date Thu, 27 Sep 2018 13:36:43 +0200
parents 644172f201e8
children 68a39aea942a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
1 <template>
621
b17a4482d07d feat: UI adaptation of 4 slots
Thomas Junk <thomas.junk@intevation.de>
parents: 620
diff changeset
2 <div id="map" :class="mapStyle"></div>
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
3 </template>
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
4
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
5 <style lang="scss">
593
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
6 .mapsplit {
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
7 height: 50vh;
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
8 }
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
9
593
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
10 .mapfull {
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
11 height: 100vh;
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
12 }
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
13 </style>
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
14
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
15 <script>
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
16 import { HTTP } from "../application/lib/http";
783
ab9604a46075 client: add move after clicking search result
Bernhard Reiter <bernhard@intevation.de>
parents: 782
diff changeset
17 import { mapGetters, mapState } from "vuex";
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
18 import "ol/ol.css";
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
19 import { Map, View } from "ol";
709
35fd15711e9e client: prepare to send profile cut to backend
Bernhard Reiter <bernhard@intevation.de>
parents: 706
diff changeset
20 import Feature from "ol/Feature";
715
23b68cd4bed3 client: re-enable loading of full river bank marks
Bernhard Reiter <bernhard@intevation.de>
parents: 714
diff changeset
21 // import { bbox as bboxFilter } from "ol/format/filter.js";
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
22 import { WFS, GeoJSON } from "ol/format.js";
754
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
23 // import GeometryType from "ol/geom/GeometryType.js";
709
35fd15711e9e client: prepare to send profile cut to backend
Bernhard Reiter <bernhard@intevation.de>
parents: 706
diff changeset
24 import LineString from "ol/geom/LineString.js";
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
25 import Draw from "ol/interaction/Draw.js";
709
35fd15711e9e client: prepare to send profile cut to backend
Bernhard Reiter <bernhard@intevation.de>
parents: 706
diff changeset
26 import { Vector as VectorLayer } from "ol/layer.js";
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
27 import { Vector as VectorSource } from "ol/source.js";
793
073394629ec6 client: add measurement and improve identify
Bernhard Reiter <bernhard@intevation.de>
parents: 790
diff changeset
28 import { getLength } from "ol/sphere.js";
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
29
738
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
30 import distance from "@turf/distance";
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
31 import {
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
32 lineString as turfLineString,
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
33 polygon as turfPolygon
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
34 } from "@turf/helpers";
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
35 //import { lineIntersect as turfLineIntersect } from "@turf/line-intersect";
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
36 import lineIntersect from "@turf/line-intersect";
767
dedf252b3e01 feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents: 765
diff changeset
37 import { displayError } from "../application/lib/errors.js";
738
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
38
802
327aa4a18a1c Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 797
diff changeset
39 const DEMODATA = 2.5;
327aa4a18a1c Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 797
diff changeset
40
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
41 export default {
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
42 name: "maplayer",
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
43 props: ["drawMode", "lat", "long", "zoom", "split"],
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
44 data() {
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
45 return {
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
46 projection: "EPSG:3857",
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
47 interaction: null,
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
48 vectorLayer: null,
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
49 vectorSource: null
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
50 };
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
51 },
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
52 computed: {
783
ab9604a46075 client: add move after clicking search result
Bernhard Reiter <bernhard@intevation.de>
parents: 782
diff changeset
53 ...mapGetters("mapstore", ["layers", "getLayerByName"]),
ab9604a46075 client: add move after clicking search result
Bernhard Reiter <bernhard@intevation.de>
parents: 782
diff changeset
54 ...mapState("mapstore", ["openLayersMap"]),
593
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
55 mapStyle() {
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
56 return {
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
57 mapfull: !this.split,
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
58 mapsplit: this.split
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
59 };
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
60 },
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
61 layerData() {
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
62 const l = this.layers.map(x => {
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
63 return x.data;
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
64 });
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
65 return [...l, this.vectorLayer];
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
66 }
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
67 },
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
68 methods: {
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
69 createVectorSource() {
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
70 this.vectorSource = new VectorSource({ wrapX: false });
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
71 },
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
72 createVectorLayer() {
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
73 this.vectorLayer = new VectorLayer({
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
74 source: this.vectorSource
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
75 });
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
76 },
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
77 removeCurrentInteraction() {
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
78 this.openLayersMap.removeInteraction(this.interaction);
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
79 this.interaction = null;
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
80 },
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
81 createInteraction() {
752
f09cbe80a864 refac: small improvements
Thomas Junk <thomas.junk@intevation.de>
parents: 745
diff changeset
82 this.vectorSource.clear();
705
6aa09d12157f client: add detection of drawend
Bernhard Reiter <bernhard@intevation.de>
parents: 703
diff changeset
83 var draw = new Draw({
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
84 source: this.vectorSource,
752
f09cbe80a864 refac: small improvements
Thomas Junk <thomas.junk@intevation.de>
parents: 745
diff changeset
85 type: this.drawMode,
f09cbe80a864 refac: small improvements
Thomas Junk <thomas.junk@intevation.de>
parents: 745
diff changeset
86 maxPoints: 2
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
87 });
793
073394629ec6 client: add measurement and improve identify
Bernhard Reiter <bernhard@intevation.de>
parents: 790
diff changeset
88 draw.on("drawstart", event => {
752
f09cbe80a864 refac: small improvements
Thomas Junk <thomas.junk@intevation.de>
parents: 745
diff changeset
89 this.vectorSource.clear();
793
073394629ec6 client: add measurement and improve identify
Bernhard Reiter <bernhard@intevation.de>
parents: 790
diff changeset
90 this.$store.commit("mapstore/setCurrentMeasurement", null);
073394629ec6 client: add measurement and improve identify
Bernhard Reiter <bernhard@intevation.de>
parents: 790
diff changeset
91 event.feature.setId("drawn.1"); // unique id for new feature
706
d47fa556a3e8 client: improve draw behaviour
Bernhard Reiter <bernhard@intevation.de>
parents: 705
diff changeset
92 });
705
6aa09d12157f client: add detection of drawend
Bernhard Reiter <bernhard@intevation.de>
parents: 703
diff changeset
93 draw.on("drawend", this.drawEnd);
6aa09d12157f client: add detection of drawend
Bernhard Reiter <bernhard@intevation.de>
parents: 703
diff changeset
94 return draw;
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
95 },
754
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
96 findFeature(profileLine) {
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
97 return new Feature({
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
98 geometry: profileLine,
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
99 // FIXME: hardcoded bottleneck and survey date
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
100 bottleneck: "AT_Bottleneck_44",
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
101 date: "2017-11-20"
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
102 });
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
103 },
706
d47fa556a3e8 client: improve draw behaviour
Bernhard Reiter <bernhard@intevation.de>
parents: 705
diff changeset
104 drawEnd(event) {
793
073394629ec6 client: add measurement and improve identify
Bernhard Reiter <bernhard@intevation.de>
parents: 790
diff changeset
105 const length = getLength(event.feature.getGeometry());
073394629ec6 client: add measurement and improve identify
Bernhard Reiter <bernhard@intevation.de>
parents: 790
diff changeset
106 this.$store.commit("mapstore/setCurrentMeasurement", length);
073394629ec6 client: add measurement and improve identify
Bernhard Reiter <bernhard@intevation.de>
parents: 790
diff changeset
107 // also place the a rounded length in a property, so identify can show it
073394629ec6 client: add measurement and improve identify
Bernhard Reiter <bernhard@intevation.de>
parents: 790
diff changeset
108 event.feature.set("length", Math.round(length * 10) / 10);
073394629ec6 client: add measurement and improve identify
Bernhard Reiter <bernhard@intevation.de>
parents: 790
diff changeset
109
073394629ec6 client: add measurement and improve identify
Bernhard Reiter <bernhard@intevation.de>
parents: 790
diff changeset
110 // prepare to send the first line seqment to the server as GeoJSON
754
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
111 const inputLineString = event.feature.getGeometry().clone();
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
112 inputLineString.transform("EPSG:3857", "EPSG:4326");
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
113 const [start, end] = inputLineString.getCoordinates();
767
dedf252b3e01 feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents: 765
diff changeset
114 this.$store.commit("fairwayprofile/setStartPoint", start);
dedf252b3e01 feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents: 765
diff changeset
115 this.$store.commit("fairwayprofile/setEndPoint", end);
754
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
116 const profileLine = new LineString([start, end]);
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
117 const feature = this.findFeature(profileLine);
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
118 const geoJSON = new GeoJSON({ geometryName: "geometry" }).writeFeature(
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
119 feature
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
120 );
767
dedf252b3e01 feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents: 765
diff changeset
121 this.$store
dedf252b3e01 feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents: 765
diff changeset
122 .dispatch("fairwayprofile/loadProfile", geoJSON)
797
644172f201e8 Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 793
diff changeset
123 .then(() => {
644172f201e8 Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 793
diff changeset
124 var vectorSource = this.getLayerByName(
644172f201e8 Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 793
diff changeset
125 "Fairway Dimensions"
644172f201e8 Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 793
diff changeset
126 ).data.getSource();
644172f201e8 Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 793
diff changeset
127 vectorSource.forEachFeatureIntersectingExtent(
644172f201e8 Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 793
diff changeset
128 // need to use EPSG:3857 which is the proj of vectorSource
644172f201e8 Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 793
diff changeset
129 profileLine
644172f201e8 Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 793
diff changeset
130 .clone()
644172f201e8 Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 793
diff changeset
131 .transform("EPSG:4326", "EPSG:3857")
644172f201e8 Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 793
diff changeset
132 .getExtent(),
644172f201e8 Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 793
diff changeset
133 feature => {
644172f201e8 Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 793
diff changeset
134 // transform back to prepare for usage
644172f201e8 Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 793
diff changeset
135 var intersectingPolygon = feature
644172f201e8 Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 793
diff changeset
136 .getGeometry()
644172f201e8 Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 793
diff changeset
137 .clone()
644172f201e8 Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 793
diff changeset
138 .transform("EPSG:3857", "EPSG:4326");
644172f201e8 Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 793
diff changeset
139 this.addToFairwayRectangle(
644172f201e8 Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 793
diff changeset
140 profileLine,
644172f201e8 Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 793
diff changeset
141 intersectingPolygon,
802
327aa4a18a1c Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 797
diff changeset
142 DEMODATA
797
644172f201e8 Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 793
diff changeset
143 );
644172f201e8 Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 793
diff changeset
144 }
644172f201e8 Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 793
diff changeset
145 );
644172f201e8 Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 793
diff changeset
146 })
767
dedf252b3e01 feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents: 765
diff changeset
147 .catch(error => {
dedf252b3e01 feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents: 765
diff changeset
148 const { status, data } = error.response;
dedf252b3e01 feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents: 765
diff changeset
149 displayError({
dedf252b3e01 feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents: 765
diff changeset
150 title: "Backend Error",
dedf252b3e01 feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents: 765
diff changeset
151 message: `${status}: ${data.message || data}`
dedf252b3e01 feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents: 765
diff changeset
152 });
dedf252b3e01 feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents: 765
diff changeset
153 });
706
d47fa556a3e8 client: improve draw behaviour
Bernhard Reiter <bernhard@intevation.de>
parents: 705
diff changeset
154 },
802
327aa4a18a1c Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 797
diff changeset
155 addToFairwayRectangle(profileLine, fairwayGeometry, depth) {
734
1581ba78a360 client: prepare for fairway intersection for profile
Bernhard Reiter <bernhard@intevation.de>
parents: 733
diff changeset
156 // both geometries have to be in EPSG:4326
738
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
157 // uses turfjs distance() function
802
327aa4a18a1c Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 797
diff changeset
158 let fairwayCoordinates = [];
738
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
159 var line = turfLineString(profileLine.getCoordinates());
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
160 var polygon = turfPolygon(fairwayGeometry.getCoordinates());
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
161 var intersects = lineIntersect(line, polygon);
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
162 var l = intersects.features.length;
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
163 if (l % 2 != 0) {
772
990a9d85ac6c client: readd diagnosis output for fairway rectangle calc
Bernhard Reiter <bernhard@intevation.de>
parents: 770
diff changeset
164 console.log("Ignoring fairway because profile only intersects once.");
738
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
165 } else {
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
166 for (let i = 0; i < l; i += 2) {
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
167 let pStartPoint = profileLine.getCoordinates()[0];
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
168 let fStartPoint = intersects.features[i].geometry.coordinates;
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
169 let fEndPoint = intersects.features[i + 1].geometry.coordinates;
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
170 let opts = { units: "kilometers" };
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
171
802
327aa4a18a1c Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 797
diff changeset
172 fairwayCoordinates.push([
738
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
173 distance(pStartPoint, fStartPoint, opts) * 1000,
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
174 distance(pStartPoint, fEndPoint, opts) * 1000,
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
175 depth
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
176 ]);
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
177 }
d7530644dde3 client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents: 734
diff changeset
178 }
802
327aa4a18a1c Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 797
diff changeset
179 this.$store.commit(
327aa4a18a1c Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 797
diff changeset
180 "fairwayprofile/setFairwayCoordinates",
327aa4a18a1c Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 797
diff changeset
181 fairwayCoordinates
327aa4a18a1c Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 797
diff changeset
182 );
734
1581ba78a360 client: prepare for fairway intersection for profile
Bernhard Reiter <bernhard@intevation.de>
parents: 733
diff changeset
183 },
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
184 activateInteraction() {
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
185 const interaction = this.createInteraction(this.drawMode);
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
186 this.interaction = interaction;
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
187 this.openLayersMap.addInteraction(interaction);
701
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
188 },
764
a6a8fe89eb84 client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents: 754
diff changeset
189 activateIdentifyMode() {
a6a8fe89eb84 client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents: 754
diff changeset
190 this.openLayersMap.on("singleclick", event => {
a6a8fe89eb84 client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents: 754
diff changeset
191 // console.log("single click on map:", event);
765
c1baaff348b0 client: add code to identify WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 764
diff changeset
192 this.identify(event.coordinate, event.pixel);
764
a6a8fe89eb84 client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents: 754
diff changeset
193 });
a6a8fe89eb84 client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents: 754
diff changeset
194 },
765
c1baaff348b0 client: add code to identify WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 764
diff changeset
195 identify(coordinate, pixel) {
770
c12ec7fde3f2 client: add simple identify top area box
Bernhard Reiter <bernhard@intevation.de>
parents: 767
diff changeset
196 this.$store.commit("mapstore/setIdentifiedFeatures", []);
765
c1baaff348b0 client: add code to identify WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 764
diff changeset
197 // checking our WFS layers
c1baaff348b0 client: add code to identify WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 764
diff changeset
198 var features = this.openLayersMap.getFeaturesAtPixel(pixel);
770
c12ec7fde3f2 client: add simple identify top area box
Bernhard Reiter <bernhard@intevation.de>
parents: 767
diff changeset
199 this.$store.commit("mapstore/setIdentifiedFeatures", features);
c12ec7fde3f2 client: add simple identify top area box
Bernhard Reiter <bernhard@intevation.de>
parents: 767
diff changeset
200
c12ec7fde3f2 client: add simple identify top area box
Bernhard Reiter <bernhard@intevation.de>
parents: 767
diff changeset
201 // DEBUG output and example how to remove the GeometryName
c12ec7fde3f2 client: add simple identify top area box
Bernhard Reiter <bernhard@intevation.de>
parents: 767
diff changeset
202 /*
765
c1baaff348b0 client: add code to identify WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 764
diff changeset
203 for (let feature of features) {
c1baaff348b0 client: add code to identify WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 764
diff changeset
204 console.log("Identified:", feature.getId());
c1baaff348b0 client: add code to identify WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 764
diff changeset
205 for (let key of feature.getKeys()) {
c1baaff348b0 client: add code to identify WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 764
diff changeset
206 if (key != feature.getGeometryName()) {
c1baaff348b0 client: add code to identify WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 764
diff changeset
207 console.log(key, feature.get(key));
c1baaff348b0 client: add code to identify WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 764
diff changeset
208 }
c1baaff348b0 client: add code to identify WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 764
diff changeset
209 }
c1baaff348b0 client: add code to identify WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 764
diff changeset
210 }
770
c12ec7fde3f2 client: add simple identify top area box
Bernhard Reiter <bernhard@intevation.de>
parents: 767
diff changeset
211 */
765
c1baaff348b0 client: add code to identify WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 764
diff changeset
212
c1baaff348b0 client: add code to identify WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 764
diff changeset
213 // trying the GetFeatureInfo way for WMS
c1baaff348b0 client: add code to identify WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 764
diff changeset
214 var wmsSource = this.getLayerByName(
c1baaff348b0 client: add code to identify WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 764
diff changeset
215 "Inland ECDIS chart Danube"
c1baaff348b0 client: add code to identify WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 764
diff changeset
216 ).data.getSource();
764
a6a8fe89eb84 client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents: 754
diff changeset
217 var url = wmsSource.getGetFeatureInfoUrl(
a6a8fe89eb84 client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents: 754
diff changeset
218 coordinate,
765
c1baaff348b0 client: add code to identify WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 764
diff changeset
219 100 /* resolution */,
764
a6a8fe89eb84 client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents: 754
diff changeset
220 "EPSG:3857",
a6a8fe89eb84 client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents: 754
diff changeset
221 // { INFO_FORMAT: "application/vnd.ogc.gml" } // not allowed by d4d
a6a8fe89eb84 client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents: 754
diff changeset
222 { INFO_FORMAT: "text/plain" }
a6a8fe89eb84 client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents: 754
diff changeset
223 );
a6a8fe89eb84 client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents: 754
diff changeset
224
a6a8fe89eb84 client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents: 754
diff changeset
225 if (url) {
a6a8fe89eb84 client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents: 754
diff changeset
226 // cannot directly query here because of SOP
765
c1baaff348b0 client: add code to identify WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 764
diff changeset
227 console.log("GetFeatureInfo url:", url);
764
a6a8fe89eb84 client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents: 754
diff changeset
228 }
a6a8fe89eb84 client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents: 754
diff changeset
229 },
701
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
230 buildVectorLoader(featureRequestOptions, endpoint, vectorSource) {
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
231 // build a function to be used for VectorSource.setLoader()
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
232 // make use of WFS().writeGetFeature to build the request
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
233 // and use our HTTP library to actually do it
703
e9c28c42c927 client: improve WFS loader
Bernhard Reiter <bernhard@intevation.de>
parents: 702
diff changeset
234 // NOTE: a) the geometryName has to be given in featureRequestOptions,
e9c28c42c927 client: improve WFS loader
Bernhard Reiter <bernhard@intevation.de>
parents: 702
diff changeset
235 // because we want to load depending on the bbox
e9c28c42c927 client: improve WFS loader
Bernhard Reiter <bernhard@intevation.de>
parents: 702
diff changeset
236 // b) the VectorSource has to have the option strategy: bbox
701
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
237 featureRequestOptions["outputFormat"] = "application/json";
702
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
238 var loader = function(extent, resolution, projection) {
701
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
239 featureRequestOptions["bbox"] = extent;
702
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
240 featureRequestOptions["srsName"] = projection.getCode();
701
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
241 var featureRequest = new WFS().writeGetFeature(featureRequestOptions);
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
242 // DEBUG console.log(featureRequest);
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
243 HTTP.post(
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
244 endpoint,
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
245 new XMLSerializer().serializeToString(featureRequest),
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
246 {
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
247 headers: {
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
248 "X-Gemma-Auth": localStorage.getItem("token"),
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
249 "Content-type": "text/xml; charset=UTF-8"
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
250 }
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
251 }
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
252 )
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
253 .then(response => {
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
254 var features = new GeoJSON().readFeatures(
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
255 JSON.stringify(response.data)
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
256 );
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
257 vectorSource.addFeatures(features);
754
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
258 // console.log(
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
259 // "loaded",
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
260 // features.length,
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
261 // featureRequestOptions.featureTypes,
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
262 // "features"
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
263 // );
701
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
264 // DEBUG console.log("loaded ", features, "for", vectorSource);
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
265 // eslint-disable-next-line
713
badbc0207418 feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents: 709
diff changeset
266 })
badbc0207418 feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents: 709
diff changeset
267 .catch(() => {
701
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
268 vectorSource.removeLoadedExtent(extent);
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
269 });
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
270 };
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
271 return loader;
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
272 }
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
273 },
593
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
274 watch: {
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
275 drawMode() {
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
276 if (this.interaction) {
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
277 this.removeCurrentInteraction();
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
278 } else {
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
279 this.activateInteraction();
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
280 }
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
281 },
593
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
282 split() {
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
283 const map = this.openLayersMap;
594
6987b5c926b8 fix: leveraging vue.nexttick instead of timeout
Thomas Junk <thomas.junk@intevation.de>
parents: 593
diff changeset
284 this.$nextTick(() => {
593
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
285 map.updateSize();
594
6987b5c926b8 fix: leveraging vue.nexttick instead of timeout
Thomas Junk <thomas.junk@intevation.de>
parents: 593
diff changeset
286 });
593
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
287 }
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
288 },
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
289 mounted() {
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
290 this.createVectorSource();
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
291 this.createVectorLayer();
783
ab9604a46075 client: add move after clicking search result
Bernhard Reiter <bernhard@intevation.de>
parents: 782
diff changeset
292 let map = new Map({
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
293 layers: this.layerData,
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
294 target: "map",
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
295 controls: [],
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
296 view: new View({
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
297 center: [this.long, this.lat],
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
298 zoom: this.zoom,
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
299 projection: this.projection
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
300 })
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
301 });
783
ab9604a46075 client: add move after clicking search result
Bernhard Reiter <bernhard@intevation.de>
parents: 782
diff changeset
302 this.$store.commit("mapstore/setOpenLayersMap", map);
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
303
733
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
304 // TODO make display of layers more dynamic, e.g. from a list
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
305
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
306 // loading the full WFS layer, by not setting the loader function
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
307 // and without bboxStrategy
628
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
308 var featureRequest2 = new WFS().writeGetFeature({
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
309 srsName: "EPSG:3857",
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
310 featureNS: "gemma",
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
311 featurePrefix: "gemma",
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
312 featureTypes: ["fairway_dimensions"],
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
313 outputFormat: "application/json"
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
314 });
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
315
733
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
316 // NOTE: loading the full fairway_dimensions makes sure
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
317 // that all are available for the intersection with the profile
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
318 HTTP.post(
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
319 "/internal/wfs",
628
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
320 new XMLSerializer().serializeToString(featureRequest2),
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
321 {
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
322 headers: {
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
323 "X-Gemma-Auth": localStorage.getItem("token"),
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
324 "Content-type": "text/xml; charset=UTF-8"
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
325 }
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
326 }
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
327 ).then(response => {
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
328 var features = new GeoJSON().readFeatures(JSON.stringify(response.data));
733
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
329 var vectorSrc = this.getLayerByName(
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
330 "Fairway Dimensions"
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
331 ).data.getSource();
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
332 vectorSrc.addFeatures(features);
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
333 // would scale to the extend of all resulting features
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
334 // this.openLayersMap.getView().fit(vectorSrc.getExtent());
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
335 });
620
ef00684e021f client: add showing special buoys
Bernhard Reiter <bernhard@intevation.de>
parents: 594
diff changeset
336
733
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
337 // load following layers with bboxStrategy (using our request builder)
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
338 var layer = null;
620
ef00684e021f client: add showing special buoys
Bernhard Reiter <bernhard@intevation.de>
parents: 594
diff changeset
339
733
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
340 layer = this.getLayerByName("Waterway Area");
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
341 layer.data.getSource().setLoader(
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
342 this.buildVectorLoader(
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
343 {
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
344 featurePrefix: "ws-wamos",
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
345 featureTypes: ["ienc_wtware"],
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
346 geometryName: "geom"
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
347 },
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
348 "/external/d4d",
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
349 layer.data.getSource()
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
350 )
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
351 );
628
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
352
733
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
353 layer = this.getLayerByName("Waterway Axis");
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
354 layer.data.getSource().setLoader(
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
355 this.buildVectorLoader(
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
356 {
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
357 featurePrefix: "ws-wamos",
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
358 featureTypes: ["ienc_wtwaxs"],
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
359 geometryName: "geom"
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
360 },
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
361 "/external/d4d",
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
362 layer.data.getSource()
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
363 )
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
364 );
628
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
365
733
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
366 layer = this.getLayerByName("Distance marks");
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
367 layer.data.getSource().setLoader(
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
368 this.buildVectorLoader(
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
369 {
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
370 featurePrefix: "ws-wamos",
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
371 featureTypes: ["ienc_dismar"],
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
372 geometryName: "geom" //,
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
373 /* restrict loading approximately to extend of danube in Austria */
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
374 // filter: bboxFilter("geom", [13.3, 48.0, 17.1, 48.6], "EPSG:4326")
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
375 },
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
376 "/external/d4d",
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
377 layer.data.getSource()
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
378 )
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
379 );
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
380 layer.data.setVisible(layer.isVisible);
628
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
381
733
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
382 layer = this.getLayerByName("Distance marks, Axis");
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
383 layer.data.getSource().setLoader(
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
384 this.buildVectorLoader(
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
385 {
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
386 featureNS: "gemma",
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
387 featurePrefix: "gemma",
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
388 featureTypes: ["distance_marks_geoserver"],
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
389 geometryName: "geom"
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
390 },
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
391 "/internal/wfs",
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
392 layer.data.getSource()
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
393 )
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
394 );
745
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
395
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
396 layer = this.getLayerByName("Waterway Area, named");
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
397 layer.data.getSource().setLoader(
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
398 this.buildVectorLoader(
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
399 {
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
400 featureNS: "gemma",
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
401 featurePrefix: "gemma",
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
402 featureTypes: ["hydro_seaare"],
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
403 geometryName: "geom"
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
404 },
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
405 "/external/d4d",
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
406 layer.data.getSource()
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
407 )
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
408 );
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
409 layer.data.setVisible(layer.isVisible);
764
a6a8fe89eb84 client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents: 754
diff changeset
410
790
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
411 layer = this.getLayerByName("Bottlenecks");
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
412 layer.data.getSource().setLoader(
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
413 this.buildVectorLoader(
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
414 {
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
415 featureNS: "gemma",
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
416 featurePrefix: "gemma",
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
417 featureTypes: ["bottlenecks"],
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
418 geometryName: "area"
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
419 },
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
420 "/internal/wfs",
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
421 layer.data.getSource()
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
422 )
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
423 );
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
424
764
a6a8fe89eb84 client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents: 754
diff changeset
425 this.activateIdentifyMode();
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
426 }
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
427 };
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
428 </script>