Mercurial > gemma
annotate client/src/store/map.js @ 3006:44493664d40e
client: refactored layers config
Layers are not stored in the vuex store anymore but instead they are served from a factory function, so that
different maps can haved individual layer objects
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Thu, 11 Apr 2019 11:44:11 +0200 |
parents | 707e1bc24d93 |
children | 81c2e561fe03 |
rev | line source |
---|---|
1362
ca33ad696594
remove the first empyty lines
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1361
diff
changeset
|
1 /* This is Free Software under GNU Affero General Public License v >= 3.0 |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
975
diff
changeset
|
2 * without warranty, see README.md and license for details. |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1313
diff
changeset
|
3 * |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
975
diff
changeset
|
4 * SPDX-License-Identifier: AGPL-3.0-or-later |
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
975
diff
changeset
|
5 * License-Filename: LICENSES/AGPL-3.0.txt |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1313
diff
changeset
|
6 * |
1927
5a37ee321651
client: make isolines legend graphic internally availableo
Bernhard Reiter <bernhard@intevation.de>
parents:
1879
diff
changeset
|
7 * Copyright (C) 2018, 2019 by via donau |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
975
diff
changeset
|
8 * – Österreichische Wasserstraßen-Gesellschaft mbH |
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
975
diff
changeset
|
9 * Software engineering by Intevation GmbH |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1313
diff
changeset
|
10 * |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
975
diff
changeset
|
11 * Author(s): |
1927
5a37ee321651
client: make isolines legend graphic internally availableo
Bernhard Reiter <bernhard@intevation.de>
parents:
1879
diff
changeset
|
12 * * Bernhard Reiter <bernhard.reiter@intevation.de> |
5a37ee321651
client: make isolines legend graphic internally availableo
Bernhard Reiter <bernhard@intevation.de>
parents:
1879
diff
changeset
|
13 * * Markus Kottländer <markus@intevation.de> |
5a37ee321651
client: make isolines legend graphic internally availableo
Bernhard Reiter <bernhard@intevation.de>
parents:
1879
diff
changeset
|
14 * * Thomas Junk <thomas.junk@intevation.de> |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
975
diff
changeset
|
15 */ |
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
975
diff
changeset
|
16 |
2985
1b8bb4f89227
client: removed .js and .vue extention from imports
Markus Kottlaender <markus@intevation.de>
parents:
2957
diff
changeset
|
17 import Draw from "ol/interaction/Draw"; |
3006
44493664d40e
client: refactored layers config
Markus Kottlaender <markus@intevation.de>
parents:
2997
diff
changeset
|
18 import { Stroke, Style, Fill, Circle } from "ol/style"; |
1158
da75faa8043f
added central moveMap method to pan and zoom the map on certain events
Markus Kottlaender <markus@intevation.de>
parents:
1144
diff
changeset
|
19 import { fromLonLat } from "ol/proj"; |
2985
1b8bb4f89227
client: removed .js and .vue extention from imports
Markus Kottlaender <markus@intevation.de>
parents:
2957
diff
changeset
|
20 import { getLength, getArea } from "ol/sphere"; |
1435
7fa030127b05
fixed panning problem
Markus Kottlaender <markus@intevation.de>
parents:
1395
diff
changeset
|
21 import { unByKey } from "ol/Observable"; |
7fa030127b05
fixed panning problem
Markus Kottlaender <markus@intevation.de>
parents:
1395
diff
changeset
|
22 import { getCenter } from "ol/extent"; |
2985
1b8bb4f89227
client: removed .js and .vue extention from imports
Markus Kottlaender <markus@intevation.de>
parents:
2957
diff
changeset
|
23 import { transformExtent } from "ol/proj"; |
2132
7a2eedc182f7
staging: zoomable stretches. zoomToExtent etd
Thomas Junk <thomas.junk@intevation.de>
parents:
2125
diff
changeset
|
24 import bbox from "@turf/bbox"; |
2947
a6eea3002e6e
client: cleanup import paths
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2932
diff
changeset
|
25 import app from "@/main"; |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
26 |
2186
d0498088894f
map_store: extracted moveMap, etd moveToBoundingBox, refactored moveToExtent
Thomas Junk <thomas.junk@intevation.de>
parents:
2166
diff
changeset
|
27 const moveMap = ({ view, extent, zoom, preventZoomOut }) => { |
d0498088894f
map_store: extracted moveMap, etd moveToBoundingBox, refactored moveToExtent
Thomas Junk <thomas.junk@intevation.de>
parents:
2166
diff
changeset
|
28 const currentZoom = view.getZoom(); |
2713
b79f5c5404c2
client: made zoom optional in moveMap/moveToExtent
Markus Kottlaender <markus@intevation.de>
parents:
2643
diff
changeset
|
29 zoom = zoom || currentZoom; |
2186
d0498088894f
map_store: extracted moveMap, etd moveToBoundingBox, refactored moveToExtent
Thomas Junk <thomas.junk@intevation.de>
parents:
2166
diff
changeset
|
30 view.fit(extent, { |
d0498088894f
map_store: extracted moveMap, etd moveToBoundingBox, refactored moveToExtent
Thomas Junk <thomas.junk@intevation.de>
parents:
2166
diff
changeset
|
31 maxZoom: preventZoomOut ? Math.max(zoom, currentZoom) : zoom, |
d0498088894f
map_store: extracted moveMap, etd moveToBoundingBox, refactored moveToExtent
Thomas Junk <thomas.junk@intevation.de>
parents:
2166
diff
changeset
|
32 duration: 700 |
d0498088894f
map_store: extracted moveMap, etd moveToBoundingBox, refactored moveToExtent
Thomas Junk <thomas.junk@intevation.de>
parents:
2166
diff
changeset
|
33 }); |
d0498088894f
map_store: extracted moveMap, etd moveToBoundingBox, refactored moveToExtent
Thomas Junk <thomas.junk@intevation.de>
parents:
2166
diff
changeset
|
34 }; |
d0498088894f
map_store: extracted moveMap, etd moveToBoundingBox, refactored moveToExtent
Thomas Junk <thomas.junk@intevation.de>
parents:
2166
diff
changeset
|
35 |
1296
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
36 // initial state |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
37 const init = () => { |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
38 return { |
783
ab9604a46075
client: add move after clicking search result
Bernhard Reiter <bernhard@intevation.de>
parents:
782
diff
changeset
|
39 openLayersMap: null, |
2310
92b21df288e2
client: use user specific extent only on initial load
Markus Kottlaender <markus@intevation.de>
parents:
2309
diff
changeset
|
40 initialLoad: true, |
1313
e4e35fb2d995
save map extent (center/zoom) in store, to not lose it when switching between map and admin area
Markus Kottlaender <markus@intevation.de>
parents:
1296
diff
changeset
|
41 extent: { |
e4e35fb2d995
save map extent (center/zoom) in store, to not lose it when switching between map and admin area
Markus Kottlaender <markus@intevation.de>
parents:
1296
diff
changeset
|
42 lat: 6155376, |
e4e35fb2d995
save map extent (center/zoom) in store, to not lose it when switching between map and admin area
Markus Kottlaender <markus@intevation.de>
parents:
1296
diff
changeset
|
43 lon: 1819178, |
e4e35fb2d995
save map extent (center/zoom) in store, to not lose it when switching between map and admin area
Markus Kottlaender <markus@intevation.de>
parents:
1296
diff
changeset
|
44 zoom: 11 |
e4e35fb2d995
save map extent (center/zoom) in store, to not lose it when switching between map and admin area
Markus Kottlaender <markus@intevation.de>
parents:
1296
diff
changeset
|
45 }, |
1435
7fa030127b05
fixed panning problem
Markus Kottlaender <markus@intevation.de>
parents:
1395
diff
changeset
|
46 identifyTool: null, // event binding (singleclick, dblclick) |
1140
2e06bc53b002
separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents:
1122
diff
changeset
|
47 identifiedFeatures: [], // map features identified by clicking on the map |
1247
c14353e2cdb9
repositioning of buttons (issue225)
Markus Kottlaender <markus@intevation.de>
parents:
1237
diff
changeset
|
48 currentMeasurement: null, // distance or area from line-/polygon-/cutTool |
1237
74562dc29e10
refactored drawtool
Markus Kottlaender <markus@intevation.de>
parents:
1197
diff
changeset
|
49 lineTool: null, // open layers interaction object (Draw) |
74562dc29e10
refactored drawtool
Markus Kottlaender <markus@intevation.de>
parents:
1197
diff
changeset
|
50 polygonTool: null, // open layers interaction object (Draw) |
1140
2e06bc53b002
separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents:
1122
diff
changeset
|
51 cutTool: null, // open layers interaction object (Draw) |
1927
5a37ee321651
client: make isolines legend graphic internally availableo
Bernhard Reiter <bernhard@intevation.de>
parents:
1879
diff
changeset
|
52 isolinesLegendImgDataURL: "", |
3006
44493664d40e
client: refactored layers config
Markus Kottlaender <markus@intevation.de>
parents:
2997
diff
changeset
|
53 differencesLegendImgDataURL: "" |
1296
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
54 }; |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
55 }; |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
56 |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
57 export default { |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
58 init, |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
59 namespaced: true, |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
60 state: init(), |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
61 getters: { |
2370
7fe2f5d334dc
client: improved identify tool readability
Markus Kottlaender <markus@intevation.de>
parents:
2314
diff
changeset
|
62 filteredIdentifiedFeatures: state => { |
7fe2f5d334dc
client: improved identify tool readability
Markus Kottlaender <markus@intevation.de>
parents:
2314
diff
changeset
|
63 return state.identifiedFeatures.filter(f => f.getId()); |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
64 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
65 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
66 mutations: { |
2310
92b21df288e2
client: use user specific extent only on initial load
Markus Kottlaender <markus@intevation.de>
parents:
2309
diff
changeset
|
67 initialLoad: (state, initialLoad) => { |
92b21df288e2
client: use user specific extent only on initial load
Markus Kottlaender <markus@intevation.de>
parents:
2309
diff
changeset
|
68 state.initialLoad = initialLoad; |
92b21df288e2
client: use user specific extent only on initial load
Markus Kottlaender <markus@intevation.de>
parents:
2309
diff
changeset
|
69 }, |
1313
e4e35fb2d995
save map extent (center/zoom) in store, to not lose it when switching between map and admin area
Markus Kottlaender <markus@intevation.de>
parents:
1296
diff
changeset
|
70 extent: (state, extent) => { |
e4e35fb2d995
save map extent (center/zoom) in store, to not lose it when switching between map and admin area
Markus Kottlaender <markus@intevation.de>
parents:
1296
diff
changeset
|
71 state.extent = extent; |
e4e35fb2d995
save map extent (center/zoom) in store, to not lose it when switching between map and admin area
Markus Kottlaender <markus@intevation.de>
parents:
1296
diff
changeset
|
72 }, |
1296
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
73 openLayersMap: (state, map) => { |
783
ab9604a46075
client: add move after clicking search result
Bernhard Reiter <bernhard@intevation.de>
parents:
782
diff
changeset
|
74 state.openLayersMap = map; |
1112
2c3d32322126
moved identifystore properties to mapstore
Markus Kottlaender <markus@intevation.de>
parents:
1099
diff
changeset
|
75 }, |
1435
7fa030127b05
fixed panning problem
Markus Kottlaender <markus@intevation.de>
parents:
1395
diff
changeset
|
76 identifyTool: (state, events) => { |
7fa030127b05
fixed panning problem
Markus Kottlaender <markus@intevation.de>
parents:
1395
diff
changeset
|
77 state.identifyTool = events; |
7fa030127b05
fixed panning problem
Markus Kottlaender <markus@intevation.de>
parents:
1395
diff
changeset
|
78 }, |
1112
2c3d32322126
moved identifystore properties to mapstore
Markus Kottlaender <markus@intevation.de>
parents:
1099
diff
changeset
|
79 setIdentifiedFeatures: (state, identifiedFeatures) => { |
2c3d32322126
moved identifystore properties to mapstore
Markus Kottlaender <markus@intevation.de>
parents:
1099
diff
changeset
|
80 state.identifiedFeatures = identifiedFeatures; |
2c3d32322126
moved identifystore properties to mapstore
Markus Kottlaender <markus@intevation.de>
parents:
1099
diff
changeset
|
81 }, |
2c3d32322126
moved identifystore properties to mapstore
Markus Kottlaender <markus@intevation.de>
parents:
1099
diff
changeset
|
82 setCurrentMeasurement: (state, measurement) => { |
2c3d32322126
moved identifystore properties to mapstore
Markus Kottlaender <markus@intevation.de>
parents:
1099
diff
changeset
|
83 state.currentMeasurement = measurement; |
1115
1b160eda22cf
moved drawMode to map store
Markus Kottlaender <markus@intevation.de>
parents:
1114
diff
changeset
|
84 }, |
1237
74562dc29e10
refactored drawtool
Markus Kottlaender <markus@intevation.de>
parents:
1197
diff
changeset
|
85 lineTool: (state, lineTool) => { |
74562dc29e10
refactored drawtool
Markus Kottlaender <markus@intevation.de>
parents:
1197
diff
changeset
|
86 state.lineTool = lineTool; |
1140
2e06bc53b002
separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents:
1122
diff
changeset
|
87 }, |
1237
74562dc29e10
refactored drawtool
Markus Kottlaender <markus@intevation.de>
parents:
1197
diff
changeset
|
88 polygonTool: (state, polygonTool) => { |
74562dc29e10
refactored drawtool
Markus Kottlaender <markus@intevation.de>
parents:
1197
diff
changeset
|
89 state.polygonTool = polygonTool; |
1140
2e06bc53b002
separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents:
1122
diff
changeset
|
90 }, |
2e06bc53b002
separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents:
1122
diff
changeset
|
91 cutTool: (state, cutTool) => { |
2e06bc53b002
separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents:
1122
diff
changeset
|
92 state.cutTool = cutTool; |
1158
da75faa8043f
added central moveMap method to pan and zoom the map on certain events
Markus Kottlaender <markus@intevation.de>
parents:
1144
diff
changeset
|
93 }, |
2186
d0498088894f
map_store: extracted moveMap, etd moveToBoundingBox, refactored moveToExtent
Thomas Junk <thomas.junk@intevation.de>
parents:
2166
diff
changeset
|
94 moveToBoundingBox: (state, { boundingBox, zoom, preventZoomOut }) => { |
d0498088894f
map_store: extracted moveMap, etd moveToBoundingBox, refactored moveToExtent
Thomas Junk <thomas.junk@intevation.de>
parents:
2166
diff
changeset
|
95 const extent = transformExtent(boundingBox, "EPSG:4326", "EPSG:3857"); |
d0498088894f
map_store: extracted moveMap, etd moveToBoundingBox, refactored moveToExtent
Thomas Junk <thomas.junk@intevation.de>
parents:
2166
diff
changeset
|
96 let view = state.openLayersMap.getView(); |
d0498088894f
map_store: extracted moveMap, etd moveToBoundingBox, refactored moveToExtent
Thomas Junk <thomas.junk@intevation.de>
parents:
2166
diff
changeset
|
97 moveMap({ view, extent, zoom, preventZoomOut }); |
d0498088894f
map_store: extracted moveMap, etd moveToBoundingBox, refactored moveToExtent
Thomas Junk <thomas.junk@intevation.de>
parents:
2166
diff
changeset
|
98 }, |
2132
7a2eedc182f7
staging: zoomable stretches. zoomToExtent etd
Thomas Junk <thomas.junk@intevation.de>
parents:
2125
diff
changeset
|
99 moveToExtent: (state, { feature, zoom, preventZoomOut }) => { |
7a2eedc182f7
staging: zoomable stretches. zoomToExtent etd
Thomas Junk <thomas.junk@intevation.de>
parents:
2125
diff
changeset
|
100 const boundingBox = bbox(feature.geometry); |
7a2eedc182f7
staging: zoomable stretches. zoomToExtent etd
Thomas Junk <thomas.junk@intevation.de>
parents:
2125
diff
changeset
|
101 const extent = transformExtent(boundingBox, "EPSG:4326", "EPSG:3857"); |
2108
cac5d2fba591
bbox tool from turfjs added. zoomToExtent function added to map.js
Thomas Junk <thomas.junk@intevation.de>
parents:
2101
diff
changeset
|
102 let view = state.openLayersMap.getView(); |
2186
d0498088894f
map_store: extracted moveMap, etd moveToBoundingBox, refactored moveToExtent
Thomas Junk <thomas.junk@intevation.de>
parents:
2166
diff
changeset
|
103 moveMap({ view, extent, zoom, preventZoomOut }); |
2108
cac5d2fba591
bbox tool from turfjs added. zoomToExtent function added to map.js
Thomas Junk <thomas.junk@intevation.de>
parents:
2101
diff
changeset
|
104 }, |
1158
da75faa8043f
added central moveMap method to pan and zoom the map on certain events
Markus Kottlaender <markus@intevation.de>
parents:
1144
diff
changeset
|
105 moveMap: (state, { coordinates, zoom, preventZoomOut }) => { |
da75faa8043f
added central moveMap method to pan and zoom the map on certain events
Markus Kottlaender <markus@intevation.de>
parents:
1144
diff
changeset
|
106 let view = state.openLayersMap.getView(); |
da75faa8043f
added central moveMap method to pan and zoom the map on certain events
Markus Kottlaender <markus@intevation.de>
parents:
1144
diff
changeset
|
107 const currentZoom = view.getZoom(); |
2713
b79f5c5404c2
client: made zoom optional in moveMap/moveToExtent
Markus Kottlaender <markus@intevation.de>
parents:
2643
diff
changeset
|
108 zoom = zoom || currentZoom; |
1158
da75faa8043f
added central moveMap method to pan and zoom the map on certain events
Markus Kottlaender <markus@intevation.de>
parents:
1144
diff
changeset
|
109 view.animate({ |
da75faa8043f
added central moveMap method to pan and zoom the map on certain events
Markus Kottlaender <markus@intevation.de>
parents:
1144
diff
changeset
|
110 zoom: preventZoomOut ? Math.max(zoom, currentZoom) : zoom, |
da75faa8043f
added central moveMap method to pan and zoom the map on certain events
Markus Kottlaender <markus@intevation.de>
parents:
1144
diff
changeset
|
111 center: fromLonLat(coordinates, view.getProjection()), |
da75faa8043f
added central moveMap method to pan and zoom the map on certain events
Markus Kottlaender <markus@intevation.de>
parents:
1144
diff
changeset
|
112 duration: 700 |
da75faa8043f
added central moveMap method to pan and zoom the map on certain events
Markus Kottlaender <markus@intevation.de>
parents:
1144
diff
changeset
|
113 }); |
1927
5a37ee321651
client: make isolines legend graphic internally availableo
Bernhard Reiter <bernhard@intevation.de>
parents:
1879
diff
changeset
|
114 }, |
5a37ee321651
client: make isolines legend graphic internally availableo
Bernhard Reiter <bernhard@intevation.de>
parents:
1879
diff
changeset
|
115 isolinesLegendImgDataURL: (state, isolinesLegendImgDataURL) => { |
5a37ee321651
client: make isolines legend graphic internally availableo
Bernhard Reiter <bernhard@intevation.de>
parents:
1879
diff
changeset
|
116 state.isolinesLegendImgDataURL = isolinesLegendImgDataURL; |
2932
173ce013a021
layers: difference layer now contains legend
Thomas Junk <thomas.junk@intevation.de>
parents:
2910
diff
changeset
|
117 }, |
173ce013a021
layers: difference layer now contains legend
Thomas Junk <thomas.junk@intevation.de>
parents:
2910
diff
changeset
|
118 differencesLegendImgDataURL: (state, differencesLegendImgDataURL) => { |
173ce013a021
layers: difference layer now contains legend
Thomas Junk <thomas.junk@intevation.de>
parents:
2910
diff
changeset
|
119 state.differencesLegendImgDataURL = differencesLegendImgDataURL; |
1144 | 120 } |
1296
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
121 }, |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
122 actions: { |
3006
44493664d40e
client: refactored layers config
Markus Kottlaender <markus@intevation.de>
parents:
2997
diff
changeset
|
123 openLayersMap({ commit, dispatch }, map) { |
44493664d40e
client: refactored layers config
Markus Kottlaender <markus@intevation.de>
parents:
2997
diff
changeset
|
124 const drawVectorSrc = map.getLayer("DRAWTOOL").getSource(); |
44493664d40e
client: refactored layers config
Markus Kottlaender <markus@intevation.de>
parents:
2997
diff
changeset
|
125 const cutVectorSrc = map.getLayer("CUTTOOL").getSource(); |
1296
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
126 |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
127 // init line tool |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
128 const lineTool = new Draw({ |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
129 source: drawVectorSrc, |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
130 type: "LineString", |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
131 maxPoints: 2 |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
132 }); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
133 lineTool.setActive(false); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
134 lineTool.on("drawstart", () => { |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
135 drawVectorSrc.clear(); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
136 commit("setCurrentMeasurement", null); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
137 }); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
138 lineTool.on("drawend", event => { |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
139 commit("setCurrentMeasurement", { |
1524
a0a16577261a
Translation: mark some strings for translation
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1438
diff
changeset
|
140 quantity: app.$gettext("Length"), |
1296
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
141 unitSymbol: "m", |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
142 value: Math.round(getLength(event.feature.getGeometry()) * 10) / 10 |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
143 }); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
144 commit("application/showIdentify", true, { root: true }); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
145 }); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
146 |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
147 // init polygon tool |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
148 const polygonTool = new Draw({ |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
149 source: drawVectorSrc, |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
150 type: "Polygon", |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
151 maxPoints: 50 |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
152 }); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
153 polygonTool.setActive(false); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
154 polygonTool.on("drawstart", () => { |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
155 drawVectorSrc.clear(); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
156 commit("setCurrentMeasurement", null); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
157 }); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
158 polygonTool.on("drawend", event => { |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
159 const areaSize = getArea(event.feature.getGeometry()); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
160 commit("setCurrentMeasurement", { |
1524
a0a16577261a
Translation: mark some strings for translation
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1438
diff
changeset
|
161 quantity: app.$gettext("Area"), |
1296
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
162 unitSymbol: areaSize > 100000 ? "km²" : "m²", |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
163 value: |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
164 areaSize > 100000 |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
165 ? Math.round(areaSize / 1000) / 1000 // convert into 1 km² == 1000*1000 m² and round to 1000 m² |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
166 : Math.round(areaSize) |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
167 }); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
168 commit("application/showIdentify", true, { root: true }); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
169 }); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
170 |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
171 // init cut tool |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
172 const cutTool = new Draw({ |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
173 source: cutVectorSrc, |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
174 type: "LineString", |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
175 maxPoints: 2, |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
176 style: new Style({ |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
177 stroke: new Stroke({ |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
178 color: "#444", |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
179 width: 2, |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
180 lineDash: [7, 7] |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
181 }), |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
182 image: new Circle({ |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
183 fill: new Fill({ color: "#333" }), |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
184 stroke: new Stroke({ color: "#fff", width: 1.5 }), |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
185 radius: 6 |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
186 }) |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
187 }) |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
188 }); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
189 cutTool.setActive(false); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
190 cutTool.on("drawstart", () => { |
1437
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
191 dispatch("disableIdentifyTool"); |
1296
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
192 cutVectorSrc.clear(); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
193 }); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
194 cutTool.on("drawend", event => { |
1395
210e9f16f8a0
delete cross profiles from localstorage
Markus Kottlaender <markus@intevation.de>
parents:
1363
diff
changeset
|
195 commit("fairwayprofile/selectedCut", null, { root: true }); |
1437
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
196 dispatch("fairwayprofile/cut", event.feature, { root: true }).then(() => |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
197 // This setTimeout is an ugly workaround. If we would enable the |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
198 // identifyTool here immediately then the click event from ending the |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
199 // cut will trigger it. We don't want that. |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
200 setTimeout(() => dispatch("enableIdentifyTool"), 1000) |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
201 ); |
1296
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
202 }); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
203 |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
204 map.addInteraction(lineTool); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
205 map.addInteraction(cutTool); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
206 map.addInteraction(polygonTool); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
207 |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
208 commit("lineTool", lineTool); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
209 commit("polygonTool", polygonTool); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
210 commit("cutTool", cutTool); |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
211 commit("openLayersMap", map); |
1435
7fa030127b05
fixed panning problem
Markus Kottlaender <markus@intevation.de>
parents:
1395
diff
changeset
|
212 }, |
7fa030127b05
fixed panning problem
Markus Kottlaender <markus@intevation.de>
parents:
1395
diff
changeset
|
213 disableIdentifyTool({ state }) { |
7fa030127b05
fixed panning problem
Markus Kottlaender <markus@intevation.de>
parents:
1395
diff
changeset
|
214 unByKey(state.identifyTool); |
1437
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
215 state.identifyTool = null; |
1435
7fa030127b05
fixed panning problem
Markus Kottlaender <markus@intevation.de>
parents:
1395
diff
changeset
|
216 }, |
2957
b74ebeb2bdc8
client: layers: improved structure of layer configuration
Markus Kottlaender <markus@intevation.de>
parents:
2951
diff
changeset
|
217 enableIdentifyTool({ state, rootState, commit, dispatch }) { |
1437
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
218 if (!state.identifyTool) { |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
219 state.identifyTool = state.openLayersMap.on( |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
220 ["singleclick", "dblclick"], |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
221 event => { |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
222 commit("setIdentifiedFeatures", []); |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
223 // checking our WFS layers |
2166
69c49301d689
map.js: GetFeaturesAtPixel added hitTolerance:7.
Bjoern Schilberg <bjoern@intevation.de>
parents:
2157
diff
changeset
|
224 var features = state.openLayersMap.getFeaturesAtPixel(event.pixel, { |
69c49301d689
map.js: GetFeaturesAtPixel added hitTolerance:7.
Bjoern Schilberg <bjoern@intevation.de>
parents:
2157
diff
changeset
|
225 hitTolerance: 7 |
69c49301d689
map.js: GetFeaturesAtPixel added hitTolerance:7.
Bjoern Schilberg <bjoern@intevation.de>
parents:
2157
diff
changeset
|
226 }); |
1437
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
227 if (features) { |
2510
f2758dafe390
client: identify tool: avoid identifying the same feature twice
Markus Kottlaender <markus@intevation.de>
parents:
2506
diff
changeset
|
228 let identifiedFeatures = []; |
1435
7fa030127b05
fixed panning problem
Markus Kottlaender <markus@intevation.de>
parents:
1395
diff
changeset
|
229 |
1437
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
230 for (let feature of features) { |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
231 let id = feature.getId(); |
2511
e958104be9a9
removed console.log, added comment
Markus Kottlaender <markus@intevation.de>
parents:
2510
diff
changeset
|
232 // avoid identifying the same feature twice |
2510
f2758dafe390
client: identify tool: avoid identifying the same feature twice
Markus Kottlaender <markus@intevation.de>
parents:
2506
diff
changeset
|
233 if ( |
f2758dafe390
client: identify tool: avoid identifying the same feature twice
Markus Kottlaender <markus@intevation.de>
parents:
2506
diff
changeset
|
234 identifiedFeatures.findIndex( |
f2758dafe390
client: identify tool: avoid identifying the same feature twice
Markus Kottlaender <markus@intevation.de>
parents:
2506
diff
changeset
|
235 f => f.getId() === feature.getId() |
f2758dafe390
client: identify tool: avoid identifying the same feature twice
Markus Kottlaender <markus@intevation.de>
parents:
2506
diff
changeset
|
236 ) === -1 |
f2758dafe390
client: identify tool: avoid identifying the same feature twice
Markus Kottlaender <markus@intevation.de>
parents:
2506
diff
changeset
|
237 ) { |
f2758dafe390
client: identify tool: avoid identifying the same feature twice
Markus Kottlaender <markus@intevation.de>
parents:
2506
diff
changeset
|
238 identifiedFeatures.push(feature); |
f2758dafe390
client: identify tool: avoid identifying the same feature twice
Markus Kottlaender <markus@intevation.de>
parents:
2506
diff
changeset
|
239 } |
f2758dafe390
client: identify tool: avoid identifying the same feature twice
Markus Kottlaender <markus@intevation.de>
parents:
2506
diff
changeset
|
240 |
f2758dafe390
client: identify tool: avoid identifying the same feature twice
Markus Kottlaender <markus@intevation.de>
parents:
2506
diff
changeset
|
241 // get selected bottleneck |
1437
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
242 // RegExp.prototype.test() works with number, str and undefined |
2133
602c2096c078
fix: bottleneckselection via identifytool
Thomas Junk <thomas.junk@intevation.de>
parents:
2132
diff
changeset
|
243 if (/^bottlenecks/.test(id)) { |
1438
71eb96690f91
avoid unnecessary setSelectedBottleneck call
Markus Kottlaender <markus@intevation.de>
parents:
1437
diff
changeset
|
244 if ( |
71eb96690f91
avoid unnecessary setSelectedBottleneck call
Markus Kottlaender <markus@intevation.de>
parents:
1437
diff
changeset
|
245 rootState.bottlenecks.selectedBottleneck != |
71eb96690f91
avoid unnecessary setSelectedBottleneck call
Markus Kottlaender <markus@intevation.de>
parents:
1437
diff
changeset
|
246 feature.get("objnam") |
71eb96690f91
avoid unnecessary setSelectedBottleneck call
Markus Kottlaender <markus@intevation.de>
parents:
1437
diff
changeset
|
247 ) { |
71eb96690f91
avoid unnecessary setSelectedBottleneck call
Markus Kottlaender <markus@intevation.de>
parents:
1437
diff
changeset
|
248 dispatch( |
71eb96690f91
avoid unnecessary setSelectedBottleneck call
Markus Kottlaender <markus@intevation.de>
parents:
1437
diff
changeset
|
249 "bottlenecks/setSelectedBottleneck", |
71eb96690f91
avoid unnecessary setSelectedBottleneck call
Markus Kottlaender <markus@intevation.de>
parents:
1437
diff
changeset
|
250 feature.get("objnam"), |
71eb96690f91
avoid unnecessary setSelectedBottleneck call
Markus Kottlaender <markus@intevation.de>
parents:
1437
diff
changeset
|
251 { root: true } |
1565
faa045ebdf0c
select first surveydate after identification of bottleneck
Thomas Junk <thomas.junk@intevation.de>
parents:
1524
diff
changeset
|
252 ).then(() => { |
faa045ebdf0c
select first surveydate after identification of bottleneck
Thomas Junk <thomas.junk@intevation.de>
parents:
1524
diff
changeset
|
253 this.commit("bottlenecks/setFirstSurveySelected"); |
faa045ebdf0c
select first surveydate after identification of bottleneck
Thomas Junk <thomas.junk@intevation.de>
parents:
1524
diff
changeset
|
254 }); |
1438
71eb96690f91
avoid unnecessary setSelectedBottleneck call
Markus Kottlaender <markus@intevation.de>
parents:
1437
diff
changeset
|
255 commit("moveMap", { |
71eb96690f91
avoid unnecessary setSelectedBottleneck call
Markus Kottlaender <markus@intevation.de>
parents:
1437
diff
changeset
|
256 coordinates: getCenter( |
71eb96690f91
avoid unnecessary setSelectedBottleneck call
Markus Kottlaender <markus@intevation.de>
parents:
1437
diff
changeset
|
257 feature |
71eb96690f91
avoid unnecessary setSelectedBottleneck call
Markus Kottlaender <markus@intevation.de>
parents:
1437
diff
changeset
|
258 .getGeometry() |
71eb96690f91
avoid unnecessary setSelectedBottleneck call
Markus Kottlaender <markus@intevation.de>
parents:
1437
diff
changeset
|
259 .clone() |
71eb96690f91
avoid unnecessary setSelectedBottleneck call
Markus Kottlaender <markus@intevation.de>
parents:
1437
diff
changeset
|
260 .transform("EPSG:3857", "EPSG:4326") |
71eb96690f91
avoid unnecessary setSelectedBottleneck call
Markus Kottlaender <markus@intevation.de>
parents:
1437
diff
changeset
|
261 .getExtent() |
71eb96690f91
avoid unnecessary setSelectedBottleneck call
Markus Kottlaender <markus@intevation.de>
parents:
1437
diff
changeset
|
262 ), |
71eb96690f91
avoid unnecessary setSelectedBottleneck call
Markus Kottlaender <markus@intevation.de>
parents:
1437
diff
changeset
|
263 zoom: 17, |
71eb96690f91
avoid unnecessary setSelectedBottleneck call
Markus Kottlaender <markus@intevation.de>
parents:
1437
diff
changeset
|
264 preventZoomOut: true |
71eb96690f91
avoid unnecessary setSelectedBottleneck call
Markus Kottlaender <markus@intevation.de>
parents:
1437
diff
changeset
|
265 }); |
71eb96690f91
avoid unnecessary setSelectedBottleneck call
Markus Kottlaender <markus@intevation.de>
parents:
1437
diff
changeset
|
266 } |
1437
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
267 } |
2590
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
2568
diff
changeset
|
268 |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
2568
diff
changeset
|
269 // get selected gauge |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
2568
diff
changeset
|
270 if (/^gauges/.test(id)) { |
2596
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
271 if ( |
2643
27933e66e848
client: gauges: use isrs_code as unique id for gauges
Markus Kottlaender <markus@intevation.de>
parents:
2604
diff
changeset
|
272 rootState.gauges.selectedGaugeISRS !== |
27933e66e848
client: gauges: use isrs_code as unique id for gauges
Markus Kottlaender <markus@intevation.de>
parents:
2604
diff
changeset
|
273 feature.get("isrs_code") |
2596
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
274 ) { |
2604
85f9bf4a6eba
client: gauge waterlevel diagram: draw reference waterlevels
Markus Kottlaender <markus@intevation.de>
parents:
2596
diff
changeset
|
275 dispatch( |
2643
27933e66e848
client: gauges: use isrs_code as unique id for gauges
Markus Kottlaender <markus@intevation.de>
parents:
2604
diff
changeset
|
276 "gauges/selectedGaugeISRS", |
27933e66e848
client: gauges: use isrs_code as unique id for gauges
Markus Kottlaender <markus@intevation.de>
parents:
2604
diff
changeset
|
277 feature.get("isrs_code"), |
2604
85f9bf4a6eba
client: gauge waterlevel diagram: draw reference waterlevels
Markus Kottlaender <markus@intevation.de>
parents:
2596
diff
changeset
|
278 { |
85f9bf4a6eba
client: gauge waterlevel diagram: draw reference waterlevels
Markus Kottlaender <markus@intevation.de>
parents:
2596
diff
changeset
|
279 root: true |
85f9bf4a6eba
client: gauge waterlevel diagram: draw reference waterlevels
Markus Kottlaender <markus@intevation.de>
parents:
2596
diff
changeset
|
280 } |
85f9bf4a6eba
client: gauge waterlevel diagram: draw reference waterlevels
Markus Kottlaender <markus@intevation.de>
parents:
2596
diff
changeset
|
281 ); |
2590
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
2568
diff
changeset
|
282 commit("moveMap", { |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
2568
diff
changeset
|
283 coordinates: getCenter( |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
2568
diff
changeset
|
284 feature |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
2568
diff
changeset
|
285 .getGeometry() |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
2568
diff
changeset
|
286 .clone() |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
2568
diff
changeset
|
287 .transform("EPSG:3857", "EPSG:4326") |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
2568
diff
changeset
|
288 .getExtent() |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
2568
diff
changeset
|
289 ), |
2713
b79f5c5404c2
client: made zoom optional in moveMap/moveToExtent
Markus Kottlaender <markus@intevation.de>
parents:
2643
diff
changeset
|
290 zoom: null, |
2590
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
2568
diff
changeset
|
291 preventZoomOut: true |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
2568
diff
changeset
|
292 }); |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
2568
diff
changeset
|
293 } |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
2568
diff
changeset
|
294 } |
2910
c8c7122047a2
client: stretches: select/unselect stretches by clicking on them on the map
Markus Kottlaender <markus@intevation.de>
parents:
2909
diff
changeset
|
295 |
c8c7122047a2
client: stretches: select/unselect stretches by clicking on them on the map
Markus Kottlaender <markus@intevation.de>
parents:
2909
diff
changeset
|
296 // get selected stretch |
c8c7122047a2
client: stretches: select/unselect stretches by clicking on them on the map
Markus Kottlaender <markus@intevation.de>
parents:
2909
diff
changeset
|
297 if (/^stretches/.test(id)) { |
c8c7122047a2
client: stretches: select/unselect stretches by clicking on them on the map
Markus Kottlaender <markus@intevation.de>
parents:
2909
diff
changeset
|
298 if (rootState.imports.selectedStretchId === feature.getId()) { |
c8c7122047a2
client: stretches: select/unselect stretches by clicking on them on the map
Markus Kottlaender <markus@intevation.de>
parents:
2909
diff
changeset
|
299 commit("imports/selectedStretchId", null, { root: true }); |
c8c7122047a2
client: stretches: select/unselect stretches by clicking on them on the map
Markus Kottlaender <markus@intevation.de>
parents:
2909
diff
changeset
|
300 } else { |
c8c7122047a2
client: stretches: select/unselect stretches by clicking on them on the map
Markus Kottlaender <markus@intevation.de>
parents:
2909
diff
changeset
|
301 commit("imports/selectedStretchId", feature.getId(), { |
c8c7122047a2
client: stretches: select/unselect stretches by clicking on them on the map
Markus Kottlaender <markus@intevation.de>
parents:
2909
diff
changeset
|
302 root: true |
c8c7122047a2
client: stretches: select/unselect stretches by clicking on them on the map
Markus Kottlaender <markus@intevation.de>
parents:
2909
diff
changeset
|
303 }); |
c8c7122047a2
client: stretches: select/unselect stretches by clicking on them on the map
Markus Kottlaender <markus@intevation.de>
parents:
2909
diff
changeset
|
304 commit("moveMap", { |
c8c7122047a2
client: stretches: select/unselect stretches by clicking on them on the map
Markus Kottlaender <markus@intevation.de>
parents:
2909
diff
changeset
|
305 coordinates: getCenter( |
c8c7122047a2
client: stretches: select/unselect stretches by clicking on them on the map
Markus Kottlaender <markus@intevation.de>
parents:
2909
diff
changeset
|
306 feature |
c8c7122047a2
client: stretches: select/unselect stretches by clicking on them on the map
Markus Kottlaender <markus@intevation.de>
parents:
2909
diff
changeset
|
307 .getGeometry() |
c8c7122047a2
client: stretches: select/unselect stretches by clicking on them on the map
Markus Kottlaender <markus@intevation.de>
parents:
2909
diff
changeset
|
308 .clone() |
c8c7122047a2
client: stretches: select/unselect stretches by clicking on them on the map
Markus Kottlaender <markus@intevation.de>
parents:
2909
diff
changeset
|
309 .transform("EPSG:3857", "EPSG:4326") |
c8c7122047a2
client: stretches: select/unselect stretches by clicking on them on the map
Markus Kottlaender <markus@intevation.de>
parents:
2909
diff
changeset
|
310 .getExtent() |
c8c7122047a2
client: stretches: select/unselect stretches by clicking on them on the map
Markus Kottlaender <markus@intevation.de>
parents:
2909
diff
changeset
|
311 ), |
c8c7122047a2
client: stretches: select/unselect stretches by clicking on them on the map
Markus Kottlaender <markus@intevation.de>
parents:
2909
diff
changeset
|
312 zoom: null, |
c8c7122047a2
client: stretches: select/unselect stretches by clicking on them on the map
Markus Kottlaender <markus@intevation.de>
parents:
2909
diff
changeset
|
313 preventZoomOut: true |
c8c7122047a2
client: stretches: select/unselect stretches by clicking on them on the map
Markus Kottlaender <markus@intevation.de>
parents:
2909
diff
changeset
|
314 }); |
c8c7122047a2
client: stretches: select/unselect stretches by clicking on them on the map
Markus Kottlaender <markus@intevation.de>
parents:
2909
diff
changeset
|
315 } |
c8c7122047a2
client: stretches: select/unselect stretches by clicking on them on the map
Markus Kottlaender <markus@intevation.de>
parents:
2909
diff
changeset
|
316 } |
1435
7fa030127b05
fixed panning problem
Markus Kottlaender <markus@intevation.de>
parents:
1395
diff
changeset
|
317 } |
2510
f2758dafe390
client: identify tool: avoid identifying the same feature twice
Markus Kottlaender <markus@intevation.de>
parents:
2506
diff
changeset
|
318 |
f2758dafe390
client: identify tool: avoid identifying the same feature twice
Markus Kottlaender <markus@intevation.de>
parents:
2506
diff
changeset
|
319 commit("setIdentifiedFeatures", identifiedFeatures); |
1435
7fa030127b05
fixed panning problem
Markus Kottlaender <markus@intevation.de>
parents:
1395
diff
changeset
|
320 } |
1437
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
321 |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
322 // DEBUG output and example how to remove the GeometryName |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
323 /* |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
324 for (let feature of features) { |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
325 console.log("Identified:", feature.getId()); |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
326 for (let key of feature.getKeys()) { |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
327 if (key != feature.getGeometryName()) { |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
328 console.log(key, feature.get(key)); |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
329 } |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
330 } |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
331 } |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
332 */ |
1435
7fa030127b05
fixed panning problem
Markus Kottlaender <markus@intevation.de>
parents:
1395
diff
changeset
|
333 |
1437
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
334 // trying the GetFeatureInfo way for WMS |
3006
44493664d40e
client: refactored layers config
Markus Kottlaender <markus@intevation.de>
parents:
2997
diff
changeset
|
335 var wmsSource = state.openLayersMap |
44493664d40e
client: refactored layers config
Markus Kottlaender <markus@intevation.de>
parents:
2997
diff
changeset
|
336 .getLayer("INLANDECDIS") |
44493664d40e
client: refactored layers config
Markus Kottlaender <markus@intevation.de>
parents:
2997
diff
changeset
|
337 .getSource(); |
1437
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
338 var url = wmsSource.getGetFeatureInfoUrl( |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
339 event.coordinate, |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
340 100 /* resolution */, |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
341 "EPSG:3857", |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
342 // { INFO_FORMAT: "application/vnd.ogc.gml" } // not allowed by d4d |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
343 { INFO_FORMAT: "text/plain" } |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
344 ); |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
345 |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
346 if (url) { |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
347 // cannot directly query here because of SOP |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
348 console.log("GetFeatureInfo url:", url); |
1435
7fa030127b05
fixed panning problem
Markus Kottlaender <markus@intevation.de>
parents:
1395
diff
changeset
|
349 } |
7fa030127b05
fixed panning problem
Markus Kottlaender <markus@intevation.de>
parents:
1395
diff
changeset
|
350 } |
1437
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
351 ); |
1cd1549aab47
fixed panning problem when drawing cross cuts
Markus Kottlaender <markus@intevation.de>
parents:
1435
diff
changeset
|
352 } |
1296
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
353 } |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
354 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
355 }; |