Mercurial > gemma
annotate client/src/store/fairway.js @ 1372:553aadd97087
new cross profile workflow (WIP)
Needs fixing of some bugs and not so nice looks.
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Tue, 27 Nov 2018 12:59:26 +0100 |
parents | ca33ad696594 |
children | fa7d647f8d77 |
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:
1015
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:
1296
diff
changeset
|
3 * |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
1015
diff
changeset
|
4 * SPDX-License-Identifier: AGPL-3.0-or-later |
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
1015
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:
1296
diff
changeset
|
6 * |
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1296
diff
changeset
|
7 * Copyright (C) 2018 by via donau |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
1015
diff
changeset
|
8 * – Österreichische Wasserstraßen-Gesellschaft mbH |
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
1015
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:
1296
diff
changeset
|
10 * |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
1015
diff
changeset
|
11 * Author(s): |
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
1015
diff
changeset
|
12 * Thomas Junk <thomas.junk@intevation.de> |
1044
f8a4ec146d47
fixed Vue reactivity issue (splitscreen button)
Markus Kottlaender <markus@intevation.de>
parents:
1038
diff
changeset
|
13 * Markus Kottländer <markuks.kottlaender@intevation.de> |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
1015
diff
changeset
|
14 */ |
1044
f8a4ec146d47
fixed Vue reactivity issue (splitscreen button)
Markus Kottlaender <markus@intevation.de>
parents:
1038
diff
changeset
|
15 import Vue from "vue"; |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
1237
diff
changeset
|
16 import { HTTP } from "../lib/http"; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
1237
diff
changeset
|
17 import { prepareProfile } from "../lib/geo"; |
1028
dd67e46366ef
refac: loading of profile data via fairwayprofile store
Thomas Junk <thomas.junk@intevation.de>
parents:
1027
diff
changeset
|
18 import LineString from "ol/geom/LineString.js"; |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
1237
diff
changeset
|
19 import { generateFeatureRequest } from "../lib/geo.js"; |
1165
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
20 import { getLength } from "ol/sphere.js"; |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
1237
diff
changeset
|
21 import { calculateFairwayCoordinates } from "../lib/geo.js"; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
1237
diff
changeset
|
22 import { displayError } from "../lib/errors.js"; |
646
4450f2ab41e0
refac: Fairwawprofile view adapted
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
23 |
849 | 24 const DEMOLEVEL = 149.345; |
1165
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
25 const DEMODATA = 2.5; |
849 | 26 |
1296
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
27 // initial state |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
28 const init = () => { |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
29 return { |
1056
28eb62f7c676
additional survey as dynamic property
Thomas Junk <thomas.junk@intevation.de>
parents:
1044
diff
changeset
|
30 additionalSurvey: "", |
767
dedf252b3e01
feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents:
646
diff
changeset
|
31 totalLength: 0, |
dedf252b3e01
feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents:
646
diff
changeset
|
32 minAlt: 0, |
dedf252b3e01
feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents:
646
diff
changeset
|
33 maxAlt: 0, |
1025
a55f20dc8d8d
refac: store profiles by date
Thomas Junk <thomas.junk@intevation.de>
parents:
1020
diff
changeset
|
34 currentProfile: {}, |
896
b9aaa093a9fb
fix: splitbutton only visible when result is visible
Thomas Junk <thomas.junk@intevation.de>
parents:
849
diff
changeset
|
35 waterLevels: [{ year: "2016", level: DEMOLEVEL, color: "#005DFF" }], |
849 | 36 selectedWaterLevel: DEMOLEVEL, |
802
327aa4a18a1c
Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents:
786
diff
changeset
|
37 fairwayCoordinates: [], |
767
dedf252b3e01
feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents:
646
diff
changeset
|
38 startPoint: null, |
1177
48ae4458710d
save cross profiles to local storage to restore them from a dropdown
Markus Kottlaender <markus@intevation.de>
parents:
1165
diff
changeset
|
39 endPoint: null, |
1372
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
40 previousCuts: [], |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
41 profileLoading: false |
1296
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
42 }; |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
43 }; |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
44 |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
45 export default { |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
46 init, |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
47 namespaced: true, |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
48 state: init(), |
646
4450f2ab41e0
refac: Fairwawprofile view adapted
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
49 getters: { |
767
dedf252b3e01
feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents:
646
diff
changeset
|
50 length: state => { |
dedf252b3e01
feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents:
646
diff
changeset
|
51 return state.totalLength; |
1056
28eb62f7c676
additional survey as dynamic property
Thomas Junk <thomas.junk@intevation.de>
parents:
1044
diff
changeset
|
52 }, |
28eb62f7c676
additional survey as dynamic property
Thomas Junk <thomas.junk@intevation.de>
parents:
1044
diff
changeset
|
53 additionalSurvey: state => { |
28eb62f7c676
additional survey as dynamic property
Thomas Junk <thomas.junk@intevation.de>
parents:
1044
diff
changeset
|
54 return state.additionalSurvey; |
646
4450f2ab41e0
refac: Fairwawprofile view adapted
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
55 } |
4450f2ab41e0
refac: Fairwawprofile view adapted
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
56 }, |
767
dedf252b3e01
feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents:
646
diff
changeset
|
57 mutations: { |
1056
28eb62f7c676
additional survey as dynamic property
Thomas Junk <thomas.junk@intevation.de>
parents:
1044
diff
changeset
|
58 setAdditionalSurvey: (state, additionalSurvey) => { |
28eb62f7c676
additional survey as dynamic property
Thomas Junk <thomas.junk@intevation.de>
parents:
1044
diff
changeset
|
59 state.additionalSurvey = additionalSurvey; |
28eb62f7c676
additional survey as dynamic property
Thomas Junk <thomas.junk@intevation.de>
parents:
1044
diff
changeset
|
60 }, |
841 | 61 setSelectedWaterLevel: (state, level) => { |
62 state.selectedWaterLevel = level; | |
63 }, | |
1025
a55f20dc8d8d
refac: store profiles by date
Thomas Junk <thomas.junk@intevation.de>
parents:
1020
diff
changeset
|
64 profileLoaded: (state, answer) => { |
a55f20dc8d8d
refac: store profiles by date
Thomas Junk <thomas.junk@intevation.de>
parents:
1020
diff
changeset
|
65 const { response, surveyDate } = answer; |
767
dedf252b3e01
feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents:
646
diff
changeset
|
66 const { data } = response; |
dedf252b3e01
feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents:
646
diff
changeset
|
67 const coordinates = data.geometry.coordinates; |
dedf252b3e01
feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents:
646
diff
changeset
|
68 if (!coordinates) return; |
dedf252b3e01
feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents:
646
diff
changeset
|
69 const startPoint = state.startPoint; |
dedf252b3e01
feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents:
646
diff
changeset
|
70 const endPoint = state.endPoint; |
dedf252b3e01
feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents:
646
diff
changeset
|
71 const geoJSON = data; |
dedf252b3e01
feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents:
646
diff
changeset
|
72 const result = prepareProfile({ geoJSON, startPoint, endPoint }); |
1044
f8a4ec146d47
fixed Vue reactivity issue (splitscreen button)
Markus Kottlaender <markus@intevation.de>
parents:
1038
diff
changeset
|
73 // Use Vue.set() to make new object properties rective |
f8a4ec146d47
fixed Vue reactivity issue (splitscreen button)
Markus Kottlaender <markus@intevation.de>
parents:
1038
diff
changeset
|
74 // https://vuejs.org/v2/guide/reactivity.html#Change-Detection-Caveats |
f8a4ec146d47
fixed Vue reactivity issue (splitscreen button)
Markus Kottlaender <markus@intevation.de>
parents:
1038
diff
changeset
|
75 Vue.set(state.currentProfile, surveyDate, result.points); |
1056
28eb62f7c676
additional survey as dynamic property
Thomas Junk <thomas.junk@intevation.de>
parents:
1044
diff
changeset
|
76 if (!state.minAlt || state.minAlt > result.minAlt) { |
28eb62f7c676
additional survey as dynamic property
Thomas Junk <thomas.junk@intevation.de>
parents:
1044
diff
changeset
|
77 state.minAlt = result.minAlt; |
28eb62f7c676
additional survey as dynamic property
Thomas Junk <thomas.junk@intevation.de>
parents:
1044
diff
changeset
|
78 } |
28eb62f7c676
additional survey as dynamic property
Thomas Junk <thomas.junk@intevation.de>
parents:
1044
diff
changeset
|
79 if (!state.maxAlt || state.maxAlt < result.maxAlt) { |
28eb62f7c676
additional survey as dynamic property
Thomas Junk <thomas.junk@intevation.de>
parents:
1044
diff
changeset
|
80 state.maxAlt = result.maxAlt; |
28eb62f7c676
additional survey as dynamic property
Thomas Junk <thomas.junk@intevation.de>
parents:
1044
diff
changeset
|
81 } |
1057
7242b5a427bc
completely nulling the units
Thomas Junk <thomas.junk@intevation.de>
parents:
1056
diff
changeset
|
82 if (!state.totalLength || state.totalLength < result.lengthPolyLine) { |
1056
28eb62f7c676
additional survey as dynamic property
Thomas Junk <thomas.junk@intevation.de>
parents:
1044
diff
changeset
|
83 state.totalLength = result.lengthPolyLine; |
28eb62f7c676
additional survey as dynamic property
Thomas Junk <thomas.junk@intevation.de>
parents:
1044
diff
changeset
|
84 } |
767
dedf252b3e01
feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents:
646
diff
changeset
|
85 }, |
dedf252b3e01
feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents:
646
diff
changeset
|
86 setStartPoint: (state, start) => { |
dedf252b3e01
feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents:
646
diff
changeset
|
87 state.startPoint = start; |
dedf252b3e01
feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents:
646
diff
changeset
|
88 }, |
dedf252b3e01
feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents:
646
diff
changeset
|
89 setEndPoint: (state, end) => { |
dedf252b3e01
feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents:
646
diff
changeset
|
90 state.endPoint = end; |
802
327aa4a18a1c
Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents:
786
diff
changeset
|
91 }, |
327aa4a18a1c
Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents:
786
diff
changeset
|
92 setFairwayCoordinates: (state, coordinates) => { |
327aa4a18a1c
Fairway profile WIP
Thomas Junk <thomas.junk@intevation.de>
parents:
786
diff
changeset
|
93 state.fairwayCoordinates = coordinates; |
1015
d2f30a784fb3
feat: add selectfield to fairwayprofile
Thomas Junk <thomas.junk@intevation.de>
parents:
1013
diff
changeset
|
94 }, |
d2f30a784fb3
feat: add selectfield to fairwayprofile
Thomas Junk <thomas.junk@intevation.de>
parents:
1013
diff
changeset
|
95 clearCurrentProfile: state => { |
1056
28eb62f7c676
additional survey as dynamic property
Thomas Junk <thomas.junk@intevation.de>
parents:
1044
diff
changeset
|
96 state.additionalSurvey = ""; |
1025
a55f20dc8d8d
refac: store profiles by date
Thomas Junk <thomas.junk@intevation.de>
parents:
1020
diff
changeset
|
97 state.currentProfile = {}; |
1057
7242b5a427bc
completely nulling the units
Thomas Junk <thomas.junk@intevation.de>
parents:
1056
diff
changeset
|
98 state.minAlt = null; |
7242b5a427bc
completely nulling the units
Thomas Junk <thomas.junk@intevation.de>
parents:
1056
diff
changeset
|
99 state.maxAlt = null; |
7242b5a427bc
completely nulling the units
Thomas Junk <thomas.junk@intevation.de>
parents:
1056
diff
changeset
|
100 state.totalLength = null; |
7242b5a427bc
completely nulling the units
Thomas Junk <thomas.junk@intevation.de>
parents:
1056
diff
changeset
|
101 state.fairwayCoordinates = []; |
7242b5a427bc
completely nulling the units
Thomas Junk <thomas.junk@intevation.de>
parents:
1056
diff
changeset
|
102 state.startPoint = null; |
7242b5a427bc
completely nulling the units
Thomas Junk <thomas.junk@intevation.de>
parents:
1056
diff
changeset
|
103 state.endPoint = null; |
1177
48ae4458710d
save cross profiles to local storage to restore them from a dropdown
Markus Kottlaender <markus@intevation.de>
parents:
1165
diff
changeset
|
104 }, |
48ae4458710d
save cross profiles to local storage to restore them from a dropdown
Markus Kottlaender <markus@intevation.de>
parents:
1165
diff
changeset
|
105 previousCuts: (state, previousCuts) => { |
48ae4458710d
save cross profiles to local storage to restore them from a dropdown
Markus Kottlaender <markus@intevation.de>
parents:
1165
diff
changeset
|
106 state.previousCuts = previousCuts; |
1372
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
107 }, |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
108 profileLoading: (state, loading) => { |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
109 state.profileLoading = loading; |
767
dedf252b3e01
feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents:
646
diff
changeset
|
110 } |
1028
dd67e46366ef
refac: loading of profile data via fairwayprofile store
Thomas Junk <thomas.junk@intevation.de>
parents:
1027
diff
changeset
|
111 }, |
dd67e46366ef
refac: loading of profile data via fairwayprofile store
Thomas Junk <thomas.junk@intevation.de>
parents:
1027
diff
changeset
|
112 actions: { |
1146
74e180ad3d6b
fairway profile UI improvements
Markus Kottlaender <markus@intevation.de>
parents:
1114
diff
changeset
|
113 clearSelection({ commit, dispatch, rootGetters, rootState }) { |
74e180ad3d6b
fairway profile UI improvements
Markus Kottlaender <markus@intevation.de>
parents:
1114
diff
changeset
|
114 dispatch("bottlenecks/setSelectedBottleneck", null, { root: true }); |
74e180ad3d6b
fairway profile UI improvements
Markus Kottlaender <markus@intevation.de>
parents:
1114
diff
changeset
|
115 commit("clearCurrentProfile"); |
74e180ad3d6b
fairway profile UI improvements
Markus Kottlaender <markus@intevation.de>
parents:
1114
diff
changeset
|
116 commit("application/showSplitscreen", false, { root: true }); |
1237
74562dc29e10
refactored drawtool
Markus Kottlaender <markus@intevation.de>
parents:
1177
diff
changeset
|
117 rootState.map.cutTool.setActive(false); |
1146
74e180ad3d6b
fairway profile UI improvements
Markus Kottlaender <markus@intevation.de>
parents:
1114
diff
changeset
|
118 rootGetters["map/getLayerByName"]("Cut Tool") |
74e180ad3d6b
fairway profile UI improvements
Markus Kottlaender <markus@intevation.de>
parents:
1114
diff
changeset
|
119 .data.getSource() |
74e180ad3d6b
fairway profile UI improvements
Markus Kottlaender <markus@intevation.de>
parents:
1114
diff
changeset
|
120 .clear(); |
74e180ad3d6b
fairway profile UI improvements
Markus Kottlaender <markus@intevation.de>
parents:
1114
diff
changeset
|
121 }, |
1111
f106aee673e7
selected bottleneck and surveys now handled by bottleneck store
Markus Kottlaender <markus@intevation.de>
parents:
1096
diff
changeset
|
122 loadProfile({ commit, state }, survey) { |
1372
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
123 if (state.startPoint && state.endPoint) { |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
124 return new Promise((resolve, reject) => { |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
125 commit("profileLoading", true); |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
126 const profileLine = new LineString([ |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
127 state.startPoint, |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
128 state.endPoint |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
129 ]); |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
130 const geoJSON = generateFeatureRequest( |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
131 profileLine, |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
132 survey.bottleneck_id, |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
133 survey.date_info |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
134 ); |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
135 HTTP.post("/cross", geoJSON, { |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
136 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
1028
dd67e46366ef
refac: loading of profile data via fairwayprofile store
Thomas Junk <thomas.junk@intevation.de>
parents:
1027
diff
changeset
|
137 }) |
1372
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
138 .then(response => { |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
139 commit("profileLoaded", { |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
140 response: response, |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
141 surveyDate: survey.date_info |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
142 }); |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
143 resolve(response); |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
144 }) |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
145 .catch(error => { |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
146 reject(error); |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
147 }) |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
148 .finally(() => commit("profileLoading", false)); |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
149 }); |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
150 } |
1165
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
151 }, |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
152 cut({ commit, dispatch, rootState, rootGetters }, cut) { |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
153 const length = getLength(cut.getGeometry()); |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
154 commit( |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
155 "map/setCurrentMeasurement", |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
156 { |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
157 quantity: "Length", |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
158 unitSymbol: "m", |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
159 value: Math.round(length * 10) / 10 |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
160 }, |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
161 { root: true } |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
162 ); |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
163 |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
164 // if a survey has been selected, request a profile |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
165 // TODO an improvement could be to check if the line intersects |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
166 // with the bottleneck area's polygon before trying the server request |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
167 if (rootState.bottlenecks.selectedSurvey) { |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
168 commit("clearCurrentProfile"); |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
169 const inputLineString = cut.getGeometry().clone(); |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
170 inputLineString.transform("EPSG:3857", "EPSG:4326"); |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
171 const [start, end] = inputLineString |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
172 .getCoordinates() |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
173 .map(coords => coords.map(coord => parseFloat(coord.toFixed(8)))); |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
174 commit("setStartPoint", start); |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
175 commit("setEndPoint", end); |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
176 const profileLine = new LineString([start, end]); |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
177 dispatch("loadProfile", rootState.bottlenecks.selectedSurvey) |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
178 .then(() => { |
1372
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
179 rootState.map.cutTool.setActive(false); |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
180 rootGetters["map/getVSourceByName"]( |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
181 "Fairway Dimensions" |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
182 ).forEachFeatureIntersectingExtent( |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
183 // need to use EPSG:3857 which is the proj of vectorSource |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
184 profileLine |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
185 .clone() |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
186 .transform("EPSG:4326", "EPSG:3857") |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
187 .getExtent(), |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
188 feature => { |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
189 // transform back to prepare for usage |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
190 var intersectingPolygon = feature |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
191 .getGeometry() |
1165
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
192 .clone() |
1372
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
193 .transform("EPSG:3857", "EPSG:4326"); |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
194 const fairwayCoordinates = calculateFairwayCoordinates( |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
195 profileLine, |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
196 intersectingPolygon, |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
197 DEMODATA |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
198 ); |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
199 commit("setFairwayCoordinates", fairwayCoordinates); |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
200 } |
553aadd97087
new cross profile workflow (WIP)
Markus Kottlaender <markus@intevation.de>
parents:
1362
diff
changeset
|
201 ); |
1165
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
202 }) |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
203 .then(() => { |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
204 commit("application/showSplitscreen", true, { root: true }); |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
205 }) |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
206 .catch(error => { |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
207 const { status, data } = error.response; |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
208 displayError({ |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
209 title: "Backend Error", |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
210 message: `${status}: ${data.message || data}` |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
211 }); |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
212 }); |
a44ac5193b38
fixed code duplication
Markus Kottlaender <markus@intevation.de>
parents:
1146
diff
changeset
|
213 } |
1177
48ae4458710d
save cross profiles to local storage to restore them from a dropdown
Markus Kottlaender <markus@intevation.de>
parents:
1165
diff
changeset
|
214 }, |
48ae4458710d
save cross profiles to local storage to restore them from a dropdown
Markus Kottlaender <markus@intevation.de>
parents:
1165
diff
changeset
|
215 previousCuts({ commit, rootState }) { |
48ae4458710d
save cross profiles to local storage to restore them from a dropdown
Markus Kottlaender <markus@intevation.de>
parents:
1165
diff
changeset
|
216 const previousCuts = |
48ae4458710d
save cross profiles to local storage to restore them from a dropdown
Markus Kottlaender <markus@intevation.de>
parents:
1165
diff
changeset
|
217 JSON.parse(localStorage.getItem("previousCuts")) || []; |
48ae4458710d
save cross profiles to local storage to restore them from a dropdown
Markus Kottlaender <markus@intevation.de>
parents:
1165
diff
changeset
|
218 commit( |
48ae4458710d
save cross profiles to local storage to restore them from a dropdown
Markus Kottlaender <markus@intevation.de>
parents:
1165
diff
changeset
|
219 "previousCuts", |
48ae4458710d
save cross profiles to local storage to restore them from a dropdown
Markus Kottlaender <markus@intevation.de>
parents:
1165
diff
changeset
|
220 previousCuts.filter(cut => { |
48ae4458710d
save cross profiles to local storage to restore them from a dropdown
Markus Kottlaender <markus@intevation.de>
parents:
1165
diff
changeset
|
221 return ( |
48ae4458710d
save cross profiles to local storage to restore them from a dropdown
Markus Kottlaender <markus@intevation.de>
parents:
1165
diff
changeset
|
222 cut.bottleneckName === rootState.bottlenecks.selectedBottleneck |
48ae4458710d
save cross profiles to local storage to restore them from a dropdown
Markus Kottlaender <markus@intevation.de>
parents:
1165
diff
changeset
|
223 ); |
48ae4458710d
save cross profiles to local storage to restore them from a dropdown
Markus Kottlaender <markus@intevation.de>
parents:
1165
diff
changeset
|
224 }) |
48ae4458710d
save cross profiles to local storage to restore them from a dropdown
Markus Kottlaender <markus@intevation.de>
parents:
1165
diff
changeset
|
225 ); |
1028
dd67e46366ef
refac: loading of profile data via fairwayprofile store
Thomas Junk <thomas.junk@intevation.de>
parents:
1027
diff
changeset
|
226 } |
767
dedf252b3e01
feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents:
646
diff
changeset
|
227 } |
646
4450f2ab41e0
refac: Fairwawprofile view adapted
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
228 }; |