Mercurial > gemma
annotate client/src/map/Maplayer.vue @ 764:a6a8fe89eb84
client: add hooks for identify mode
* Add hooks for single mouse click if the interaction is not enabled.
For example get the d4d WMS url for getfeatureinfo and display it.
author | Bernhard Reiter <bernhard@intevation.de> |
---|---|
date | Tue, 25 Sep 2018 15:23:15 +0200 |
parents | 105c421f99b1 |
children | c1baaff348b0 |
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"; |
709
35fd15711e9e
client: prepare to send profile cut to backend
Bernhard Reiter <bernhard@intevation.de>
parents:
706
diff
changeset
|
17 import { mapGetters } 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"; |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
28 |
738
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
29 import distance from "@turf/distance"; |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
30 import { |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
31 lineString as turfLineString, |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
32 polygon as turfPolygon |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
33 } from "@turf/helpers"; |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
34 //import { lineIntersect as turfLineIntersect } from "@turf/line-intersect"; |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
35 import lineIntersect from "@turf/line-intersect"; |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
36 |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
37 export default { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
38 name: "maplayer", |
649
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
39 props: ["drawMode", "lat", "long", "zoom", "split"], |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
40 data() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
41 return { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
42 projection: "EPSG:3857", |
649
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
43 openLayersMap: null, |
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
44 interaction: null, |
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
45 vectorLayer: null, |
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
46 vectorSource: null |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
47 }; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
48 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
49 computed: { |
754
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
50 ...mapGetters("mapstore", ["layers", "getLayerByName"]), |
593
c4a4dc612191
feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
51 mapStyle() { |
c4a4dc612191
feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
52 return { |
c4a4dc612191
feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
53 mapfull: !this.split, |
c4a4dc612191
feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
54 mapsplit: this.split |
c4a4dc612191
feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
55 }; |
c4a4dc612191
feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
56 }, |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
57 layerData() { |
649
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
58 const l = this.layers.map(x => { |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
59 return x.data; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
60 }); |
649
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
61 return [...l, this.vectorLayer]; |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
62 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
63 }, |
649
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
64 methods: { |
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
65 createVectorSource() { |
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
66 this.vectorSource = new VectorSource({ wrapX: false }); |
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
67 }, |
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
68 createVectorLayer() { |
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
69 this.vectorLayer = new VectorLayer({ |
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
70 source: this.vectorSource |
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 }, |
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
73 removeCurrentInteraction() { |
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
74 this.openLayersMap.removeInteraction(this.interaction); |
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
75 this.interaction = null; |
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 createInteraction() { |
752
f09cbe80a864
refac: small improvements
Thomas Junk <thomas.junk@intevation.de>
parents:
745
diff
changeset
|
78 this.vectorSource.clear(); |
705
6aa09d12157f
client: add detection of drawend
Bernhard Reiter <bernhard@intevation.de>
parents:
703
diff
changeset
|
79 var draw = new Draw({ |
649
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
80 source: this.vectorSource, |
752
f09cbe80a864
refac: small improvements
Thomas Junk <thomas.junk@intevation.de>
parents:
745
diff
changeset
|
81 type: this.drawMode, |
f09cbe80a864
refac: small improvements
Thomas Junk <thomas.junk@intevation.de>
parents:
745
diff
changeset
|
82 maxPoints: 2 |
649
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
83 }); |
752
f09cbe80a864
refac: small improvements
Thomas Junk <thomas.junk@intevation.de>
parents:
745
diff
changeset
|
84 draw.on("drawstart", () => { |
f09cbe80a864
refac: small improvements
Thomas Junk <thomas.junk@intevation.de>
parents:
745
diff
changeset
|
85 this.vectorSource.clear(); |
706
d47fa556a3e8
client: improve draw behaviour
Bernhard Reiter <bernhard@intevation.de>
parents:
705
diff
changeset
|
86 }); |
705
6aa09d12157f
client: add detection of drawend
Bernhard Reiter <bernhard@intevation.de>
parents:
703
diff
changeset
|
87 draw.on("drawend", this.drawEnd); |
6aa09d12157f
client: add detection of drawend
Bernhard Reiter <bernhard@intevation.de>
parents:
703
diff
changeset
|
88 return draw; |
649
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
89 }, |
754
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
90 findFeature(profileLine) { |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
91 return new Feature({ |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
92 geometry: profileLine, |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
93 // FIXME: hardcoded bottleneck and survey date |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
94 bottleneck: "AT_Bottleneck_44", |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
95 date: "2017-11-20" |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
96 }); |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
97 }, |
706
d47fa556a3e8
client: improve draw behaviour
Bernhard Reiter <bernhard@intevation.de>
parents:
705
diff
changeset
|
98 drawEnd(event) { |
754
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
99 const inputLineString = event.feature.getGeometry().clone(); |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
100 // prepare to send the first line seqment to the server as GeoJSON |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
101 inputLineString.transform("EPSG:3857", "EPSG:4326"); |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
102 const [start, end] = inputLineString.getCoordinates(); |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
103 const profileLine = new LineString([start, end]); |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
104 const feature = this.findFeature(profileLine); |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
105 const geoJSON = new GeoJSON({ geometryName: "geometry" }).writeFeature( |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
106 feature |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
107 ); |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
108 console.log("Feature: ", feature); |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
109 console.log("geoJSON", geoJSON); |
734
1581ba78a360
client: prepare for fairway intersection for profile
Bernhard Reiter <bernhard@intevation.de>
parents:
733
diff
changeset
|
110 |
754
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
111 // // FIXME: assuming that we have the fairway dimensions loaded |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
112 // var vectorSource = this.getLayerByName( |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
113 // "Fairway Dimensions" |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
114 // ).data.getSource(); |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
115 // console.log(vectorSource); |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
116 |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
117 // var diagStack = []; |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
118 // vectorSource.forEachFeatureIntersectingExtent( |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
119 // // need to use EPSG:3857 which is the proj of vectorSource |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
120 // profileLine |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
121 // .clone() |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
122 // .transform("EPSG:4326", "EPSG:3857") |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
123 // .getExtent(), |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
124 // feature => { |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
125 // // transform back to prepare for usage |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
126 // var intersectingPolygon = feature |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
127 // .getGeometry() |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
128 // .clone() |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
129 // .transform("EPSG:3857", "EPSG:4326"); |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
130 // console.log("intersecting:", intersectingPolygon); |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
131 // this.addToFairwayRectangle( |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
132 // profileLine, |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
133 // intersectingPolygon, |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
134 // 2.5, // FIXME use real fairway depth value for this feature |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
135 // diagStack |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
136 // ); |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
137 // } |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
138 // ); |
706
d47fa556a3e8
client: improve draw behaviour
Bernhard Reiter <bernhard@intevation.de>
parents:
705
diff
changeset
|
139 }, |
738
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
140 addToFairwayRectangle(profileLine, fairwayGeometry, depth, diagStack) { |
734
1581ba78a360
client: prepare for fairway intersection for profile
Bernhard Reiter <bernhard@intevation.de>
parents:
733
diff
changeset
|
141 // 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
|
142 // uses turfjs distance() function |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
143 // pushes pairs of diagram points into diagStack |
754
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
144 // console.log( |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
145 // "addToFairwayRectangle(", |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
146 // profileLine, |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
147 // fairwayGeometry, |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
148 // depth, |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
149 // diagStack, |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
150 // ")" |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
151 // ); |
738
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
152 var line = turfLineString(profileLine.getCoordinates()); |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
153 var polygon = turfPolygon(fairwayGeometry.getCoordinates()); |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
154 var intersects = lineIntersect(line, polygon); |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
155 console.log(intersects.features); |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
156 |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
157 var l = intersects.features.length; |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
158 if (l % 2 != 0) { |
754
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
159 //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
|
160 } else { |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
161 for (let i = 0; i < l; i += 2) { |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
162 let pStartPoint = profileLine.getCoordinates()[0]; |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
163 let fStartPoint = intersects.features[i].geometry.coordinates; |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
164 let fEndPoint = intersects.features[i + 1].geometry.coordinates; |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
165 let opts = { units: "kilometers" }; |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
166 |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
167 diagStack.push([ |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
168 distance(pStartPoint, fStartPoint, opts) * 1000, |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
169 distance(pStartPoint, fEndPoint, opts) * 1000, |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
170 depth |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
171 ]); |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
172 } |
d7530644dde3
client: add calculation of fairway rectangles
Bernhard Reiter <bernhard@intevation.de>
parents:
734
diff
changeset
|
173 } |
754
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
174 //console.log("Resulting diagStack:", diagStack); |
734
1581ba78a360
client: prepare for fairway intersection for profile
Bernhard Reiter <bernhard@intevation.de>
parents:
733
diff
changeset
|
175 }, |
649
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
176 activateInteraction() { |
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
177 const interaction = this.createInteraction(this.drawMode); |
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
178 this.interaction = interaction; |
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
179 this.openLayersMap.addInteraction(interaction); |
701
8149772c62d6
client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents:
690
diff
changeset
|
180 }, |
764
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
181 activateIdentifyMode() { |
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
182 this.openLayersMap.on("singleclick", event => { |
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
183 // console.log("single click on map:", event); |
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
184 this.identify( |
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
185 event.coordinate, |
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
186 this.getLayerByName("Inland ECDIS chart Danube").data.getSource() |
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
187 ); |
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
188 }); |
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
189 }, |
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
190 identify(coordinate, wmsSource) { |
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
191 // console.log(coordinate, wmsSource); |
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
192 //var viewResolution = this.openLayersMap.view.getResolution(); |
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
193 var url = wmsSource.getGetFeatureInfoUrl( |
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
194 coordinate, |
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
195 100, |
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
196 "EPSG:3857", |
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
197 // { 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
|
198 { INFO_FORMAT: "text/plain" } |
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
199 ); |
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
200 |
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
201 if (url) { |
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
202 // cannot directly query here because of SOP |
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
203 console.log(url); |
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
204 } |
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
205 }, |
701
8149772c62d6
client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents:
690
diff
changeset
|
206 buildVectorLoader(featureRequestOptions, endpoint, vectorSource) { |
8149772c62d6
client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents:
690
diff
changeset
|
207 // 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
|
208 // 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
|
209 // and use our HTTP library to actually do it |
703
e9c28c42c927
client: improve WFS loader
Bernhard Reiter <bernhard@intevation.de>
parents:
702
diff
changeset
|
210 // NOTE: a) the geometryName has to be given in featureRequestOptions, |
e9c28c42c927
client: improve WFS loader
Bernhard Reiter <bernhard@intevation.de>
parents:
702
diff
changeset
|
211 // because we want to load depending on the bbox |
e9c28c42c927
client: improve WFS loader
Bernhard Reiter <bernhard@intevation.de>
parents:
702
diff
changeset
|
212 // 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
|
213 featureRequestOptions["outputFormat"] = "application/json"; |
702
aaf5dbfb9512
client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents:
701
diff
changeset
|
214 var loader = function(extent, resolution, projection) { |
701
8149772c62d6
client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents:
690
diff
changeset
|
215 featureRequestOptions["bbox"] = extent; |
702
aaf5dbfb9512
client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents:
701
diff
changeset
|
216 featureRequestOptions["srsName"] = projection.getCode(); |
701
8149772c62d6
client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents:
690
diff
changeset
|
217 var featureRequest = new WFS().writeGetFeature(featureRequestOptions); |
8149772c62d6
client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents:
690
diff
changeset
|
218 // DEBUG console.log(featureRequest); |
8149772c62d6
client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents:
690
diff
changeset
|
219 HTTP.post( |
8149772c62d6
client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents:
690
diff
changeset
|
220 endpoint, |
8149772c62d6
client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents:
690
diff
changeset
|
221 new XMLSerializer().serializeToString(featureRequest), |
8149772c62d6
client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents:
690
diff
changeset
|
222 { |
8149772c62d6
client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents:
690
diff
changeset
|
223 headers: { |
8149772c62d6
client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents:
690
diff
changeset
|
224 "X-Gemma-Auth": localStorage.getItem("token"), |
8149772c62d6
client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents:
690
diff
changeset
|
225 "Content-type": "text/xml; charset=UTF-8" |
8149772c62d6
client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents:
690
diff
changeset
|
226 } |
8149772c62d6
client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents:
690
diff
changeset
|
227 } |
8149772c62d6
client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents:
690
diff
changeset
|
228 ) |
8149772c62d6
client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents:
690
diff
changeset
|
229 .then(response => { |
8149772c62d6
client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents:
690
diff
changeset
|
230 var features = new GeoJSON().readFeatures( |
8149772c62d6
client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents:
690
diff
changeset
|
231 JSON.stringify(response.data) |
8149772c62d6
client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents:
690
diff
changeset
|
232 ); |
8149772c62d6
client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents:
690
diff
changeset
|
233 vectorSource.addFeatures(features); |
754
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
234 // console.log( |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
235 // "loaded", |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
236 // features.length, |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
237 // featureRequestOptions.featureTypes, |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
238 // "features" |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
752
diff
changeset
|
239 // ); |
701
8149772c62d6
client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents:
690
diff
changeset
|
240 // DEBUG console.log("loaded ", features, "for", vectorSource); |
8149772c62d6
client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents:
690
diff
changeset
|
241 // eslint-disable-next-line |
713
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
709
diff
changeset
|
242 }) |
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
709
diff
changeset
|
243 .catch(() => { |
701
8149772c62d6
client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents:
690
diff
changeset
|
244 vectorSource.removeLoadedExtent(extent); |
8149772c62d6
client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents:
690
diff
changeset
|
245 }); |
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 return loader; |
649
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
248 } |
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
249 }, |
593
c4a4dc612191
feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
250 watch: { |
649
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
251 drawMode() { |
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
252 if (this.interaction) { |
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
253 this.removeCurrentInteraction(); |
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
254 } else { |
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
255 this.activateInteraction(); |
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
256 } |
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
257 }, |
593
c4a4dc612191
feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
258 split() { |
c4a4dc612191
feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
259 const map = this.openLayersMap; |
594
6987b5c926b8
fix: leveraging vue.nexttick instead of timeout
Thomas Junk <thomas.junk@intevation.de>
parents:
593
diff
changeset
|
260 this.$nextTick(() => { |
593
c4a4dc612191
feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
261 map.updateSize(); |
594
6987b5c926b8
fix: leveraging vue.nexttick instead of timeout
Thomas Junk <thomas.junk@intevation.de>
parents:
593
diff
changeset
|
262 }); |
593
c4a4dc612191
feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
263 } |
c4a4dc612191
feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
264 }, |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
265 mounted() { |
649
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
266 this.createVectorSource(); |
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
267 this.createVectorLayer(); |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
268 this.openLayersMap = new Map({ |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
269 layers: this.layerData, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
270 target: "map", |
649
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
271 controls: [], |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
272 view: new View({ |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
273 center: [this.long, this.lat], |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
274 zoom: this.zoom, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
275 projection: this.projection |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
276 }) |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
277 }); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
278 |
733
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
279 // 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
|
280 |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
281 // 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
|
282 // and without bboxStrategy |
628
ef9c733cc6aa
client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents:
626
diff
changeset
|
283 var featureRequest2 = new WFS().writeGetFeature({ |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
284 srsName: "EPSG:3857", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
285 featureNS: "gemma", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
286 featurePrefix: "gemma", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
287 featureTypes: ["fairway_dimensions"], |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
288 outputFormat: "application/json" |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
289 }); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
290 |
733
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
291 // NOTE: loading the full fairway_dimensions makes sure |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
292 // 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
|
293 HTTP.post( |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
294 "/internal/wfs", |
628
ef9c733cc6aa
client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents:
626
diff
changeset
|
295 new XMLSerializer().serializeToString(featureRequest2), |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
296 { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
297 headers: { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
298 "X-Gemma-Auth": localStorage.getItem("token"), |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
299 "Content-type": "text/xml; charset=UTF-8" |
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 } |
649
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
302 ).then(response => { |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
303 var features = new GeoJSON().readFeatures(JSON.stringify(response.data)); |
733
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
304 var vectorSrc = this.getLayerByName( |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
305 "Fairway Dimensions" |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
306 ).data.getSource(); |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
307 vectorSrc.addFeatures(features); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
308 // would scale to the extend of all resulting features |
649
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
630
diff
changeset
|
309 // this.openLayersMap.getView().fit(vectorSrc.getExtent()); |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
310 }); |
620
ef00684e021f
client: add showing special buoys
Bernhard Reiter <bernhard@intevation.de>
parents:
594
diff
changeset
|
311 |
733
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
312 // load following layers with bboxStrategy (using our request builder) |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
313 var layer = null; |
620
ef00684e021f
client: add showing special buoys
Bernhard Reiter <bernhard@intevation.de>
parents:
594
diff
changeset
|
314 |
733
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
315 layer = this.getLayerByName("Waterway Area"); |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
316 layer.data.getSource().setLoader( |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
317 this.buildVectorLoader( |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
318 { |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
319 featurePrefix: "ws-wamos", |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
320 featureTypes: ["ienc_wtware"], |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
321 geometryName: "geom" |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
322 }, |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
323 "/external/d4d", |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
324 layer.data.getSource() |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
325 ) |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
326 ); |
628
ef9c733cc6aa
client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents:
626
diff
changeset
|
327 |
733
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
328 layer = this.getLayerByName("Waterway Axis"); |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
329 layer.data.getSource().setLoader( |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
330 this.buildVectorLoader( |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
331 { |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
332 featurePrefix: "ws-wamos", |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
333 featureTypes: ["ienc_wtwaxs"], |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
334 geometryName: "geom" |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
335 }, |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
336 "/external/d4d", |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
337 layer.data.getSource() |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
338 ) |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
339 ); |
628
ef9c733cc6aa
client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents:
626
diff
changeset
|
340 |
733
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
341 layer = this.getLayerByName("Distance marks"); |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
342 layer.data.getSource().setLoader( |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
343 this.buildVectorLoader( |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
344 { |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
345 featurePrefix: "ws-wamos", |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
346 featureTypes: ["ienc_dismar"], |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
347 geometryName: "geom" //, |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
348 /* restrict loading approximately to extend of danube in Austria */ |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
349 // 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
|
350 }, |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
351 "/external/d4d", |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
352 layer.data.getSource() |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
353 ) |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
354 ); |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
355 layer.data.setVisible(layer.isVisible); |
628
ef9c733cc6aa
client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents:
626
diff
changeset
|
356 |
733
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
357 layer = this.getLayerByName("Distance marks, Axis"); |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
358 layer.data.getSource().setLoader( |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
359 this.buildVectorLoader( |
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 featureNS: "gemma", |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
362 featurePrefix: "gemma", |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
363 featureTypes: ["distance_marks_geoserver"], |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
364 geometryName: "geom" |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
365 }, |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
366 "/internal/wfs", |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
367 layer.data.getSource() |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
368 ) |
e57955c1996f
client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents:
716
diff
changeset
|
369 ); |
745
f2691e0d4970
client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents:
738
diff
changeset
|
370 |
f2691e0d4970
client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents:
738
diff
changeset
|
371 layer = this.getLayerByName("Waterway Area, named"); |
f2691e0d4970
client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents:
738
diff
changeset
|
372 layer.data.getSource().setLoader( |
f2691e0d4970
client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents:
738
diff
changeset
|
373 this.buildVectorLoader( |
f2691e0d4970
client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents:
738
diff
changeset
|
374 { |
f2691e0d4970
client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents:
738
diff
changeset
|
375 featureNS: "gemma", |
f2691e0d4970
client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents:
738
diff
changeset
|
376 featurePrefix: "gemma", |
f2691e0d4970
client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents:
738
diff
changeset
|
377 featureTypes: ["hydro_seaare"], |
f2691e0d4970
client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents:
738
diff
changeset
|
378 geometryName: "geom" |
f2691e0d4970
client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents:
738
diff
changeset
|
379 }, |
f2691e0d4970
client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents:
738
diff
changeset
|
380 "/external/d4d", |
f2691e0d4970
client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents:
738
diff
changeset
|
381 layer.data.getSource() |
f2691e0d4970
client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents:
738
diff
changeset
|
382 ) |
f2691e0d4970
client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents:
738
diff
changeset
|
383 ); |
f2691e0d4970
client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents:
738
diff
changeset
|
384 layer.data.setVisible(layer.isVisible); |
764
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
385 |
a6a8fe89eb84
client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents:
754
diff
changeset
|
386 this.activateIdentifyMode(); |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
387 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
388 }; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
389 </script> |