Mercurial > gemma
annotate client/src/store/fairwayprofile.js @ 4624:209b10f7bb2c geoserver_sql_views
Add config for GeoServer database session startup SQL
Prepended to setting the role in order to avoid any configuration
overwriting it.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Wed, 09 Oct 2019 18:47:13 +0200 |
parents | 9887061df57b |
children | 3b842e951317 |
rev | line source |
---|---|
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
1 /* This is Free Software under GNU Affero General Public License v >= 3.0 |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
2 * without warranty, see README.md and license for details. |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
3 * |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
4 * SPDX-License-Identifier: AGPL-3.0-or-later |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
5 * License-Filename: LICENSES/AGPL-3.0.txt |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
6 * |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
7 * Copyright (C) 2018 by via donau |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
8 * – Österreichische Wasserstraßen-Gesellschaft mbH |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
9 * Software engineering by Intevation GmbH |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
10 * |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
11 * Author(s): |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
12 * Thomas Junk <thomas.junk@intevation.de> |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
13 * Markus Kottländer <markuks.kottlaender@intevation.de> |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
14 */ |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
15 import Vue from "vue"; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
16 import { HTTP } from "@/lib/http"; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
17 import { prepareProfile } from "@/lib/geo"; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
18 import LineString from "ol/geom/LineString"; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
19 import { generateFeatureRequest } from "@/lib/geo"; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
20 import { getLength } from "ol/sphere"; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
21 import { displayError } from "@/lib/errors"; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
22 import { featureToFairwayCoordinates } from "@/lib/geo"; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
23 |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
24 // initial state |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
25 const init = () => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
26 return { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
27 additionalSurvey: null, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
28 minAlt: 0, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
29 maxAlt: 0, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
30 currentProfile: {}, |
3527
8a9ee18de13f
client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents:
3512
diff
changeset
|
31 selectedWaterLevel: "ref", |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
32 fairwayData: [], |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
33 startPoint: null, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
34 endPoint: null, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
35 previousCuts: [], |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
36 profileLoading: false, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
37 selectedCut: null, |
4502
4c3851391b6d
client: fairwayprofile: implement custom depth for x-cuts
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3571
diff
changeset
|
38 differencesLoading: false, |
4525
9887061df57b
Use CQL filter to load the current survey difference.
Raimund Renkert <raimund@renkert.org>
parents:
4502
diff
changeset
|
39 currentDifference: null, |
4502
4c3851391b6d
client: fairwayprofile: implement custom depth for x-cuts
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3571
diff
changeset
|
40 depth: 2.5, |
4c3851391b6d
client: fairwayprofile: implement custom depth for x-cuts
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3571
diff
changeset
|
41 useCustomDepth: true |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
42 }; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
43 }; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
44 |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
45 export default { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
46 init, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
47 namespaced: true, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
48 state: init(), |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
49 getters: { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
50 totalLength: state => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
51 const keys = Object.keys(state.currentProfile); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
52 return keys.length |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
53 ? Math.max(...keys.map(x => state.currentProfile[x].length)) |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
54 : 0; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
55 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
56 additionalSurvey: state => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
57 return state.additionalSurvey; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
58 } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
59 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
60 mutations: { |
4502
4c3851391b6d
client: fairwayprofile: implement custom depth for x-cuts
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3571
diff
changeset
|
61 setDepth: (state, value) => { |
4c3851391b6d
client: fairwayprofile: implement custom depth for x-cuts
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3571
diff
changeset
|
62 state.depth = value; |
4c3851391b6d
client: fairwayprofile: implement custom depth for x-cuts
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3571
diff
changeset
|
63 }, |
4c3851391b6d
client: fairwayprofile: implement custom depth for x-cuts
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3571
diff
changeset
|
64 setUseCustomDepth: (state, flag) => { |
4c3851391b6d
client: fairwayprofile: implement custom depth for x-cuts
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3571
diff
changeset
|
65 state.useCustomDepth = flag; |
4c3851391b6d
client: fairwayprofile: implement custom depth for x-cuts
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3571
diff
changeset
|
66 }, |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
67 additionalSurvey: (state, additionalSurvey) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
68 state.additionalSurvey = additionalSurvey; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
69 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
70 setSelectedWaterLevel: (state, level) => { |
3512
30a47d9fc667
client: fairway profiles: removed some old code
Markus Kottlaender <markus@intevation.de>
parents:
3207
diff
changeset
|
71 state.selectedWaterLevel = level; |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
72 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
73 setDifferencesLoading: (state, value) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
74 state.differencesLoading = value; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
75 }, |
4525
9887061df57b
Use CQL filter to load the current survey difference.
Raimund Renkert <raimund@renkert.org>
parents:
4502
diff
changeset
|
76 setCurrentDifference: (state, value) => { |
9887061df57b
Use CQL filter to load the current survey difference.
Raimund Renkert <raimund@renkert.org>
parents:
4502
diff
changeset
|
77 state.currentDifference = value; |
9887061df57b
Use CQL filter to load the current survey difference.
Raimund Renkert <raimund@renkert.org>
parents:
4502
diff
changeset
|
78 }, |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
79 profileLoaded: (state, answer) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
80 const { response, surveyDate } = answer; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
81 const { data } = response; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
82 const coordinates = data.geometry.coordinates; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
83 if (!coordinates) return; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
84 const startPoint = state.startPoint; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
85 const endPoint = state.endPoint; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
86 const geoJSON = data; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
87 const result = prepareProfile({ geoJSON, startPoint, endPoint }); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
88 // Use Vue.set() to make new object properties rective |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
89 // https://vuejs.org/v2/guide/reactivity.html#Change-Detection-Caveats |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
90 Vue.set(state.currentProfile, surveyDate, { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
91 points: result.points, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
92 length: result.lengthPolyLine |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
93 }); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
94 if (!state.minAlt || state.minAlt > result.minAlt) { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
95 state.minAlt = result.minAlt; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
96 } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
97 if (!state.maxAlt || state.maxAlt < result.maxAlt) { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
98 state.maxAlt = result.maxAlt; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
99 } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
100 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
101 setStartPoint: (state, start) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
102 state.startPoint = start; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
103 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
104 setEndPoint: (state, end) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
105 state.endPoint = end; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
106 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
107 addFairwayData: (state, coordinates) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
108 state.fairwayData.push(coordinates); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
109 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
110 clearFairwayData: state => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
111 state.fairwayData = []; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
112 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
113 clearCurrentProfile: state => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
114 state.currentProfile = {}; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
115 state.minAlt = null; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
116 state.maxAlt = null; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
117 state.totalLength = null; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
118 state.fairwayData = []; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
119 state.startPoint = null; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
120 state.endPoint = null; |
3527
8a9ee18de13f
client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents:
3512
diff
changeset
|
121 state.selectedWaterLevel = "ref"; |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
122 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
123 previousCuts: (state, previousCuts) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
124 state.previousCuts = previousCuts; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
125 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
126 profileLoading: (state, loading) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
127 state.profileLoading = loading; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
128 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
129 selectedCut: (state, cut) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
130 state.selectedCut = cut; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
131 } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
132 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
133 actions: { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
134 clearCurrentProfile({ commit, rootState }) { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
135 commit("clearCurrentProfile"); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
136 commit("map/cutToolEnabled", false, { root: true }); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
137 rootState.map.openLayersMaps.forEach(m => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
138 m.getLayer("CUTTOOL") |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
139 .getSource() |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
140 .clear(); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
141 }); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
142 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
143 loadProfile({ commit, state }, survey) { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
144 if (state.startPoint && state.endPoint) { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
145 return new Promise((resolve, reject) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
146 const profileLine = new LineString([ |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
147 state.startPoint, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
148 state.endPoint |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
149 ]); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
150 const geoJSON = generateFeatureRequest( |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
151 profileLine, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
152 survey.bottleneck_id, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
153 survey.date_info |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
154 ); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
155 HTTP.post("/cross", geoJSON, { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
156 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
157 }) |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
158 .then(response => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
159 if (response.data.geometry.coordinates.length) { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
160 commit("profileLoaded", { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
161 response: response, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
162 surveyDate: survey.date_info |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
163 }); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
164 resolve(response); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
165 } else { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
166 commit("clearCurrentProfile"); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
167 reject({ |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
168 response: { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
169 status: null, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
170 data: "No intersection with sounding data." |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
171 } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
172 }); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
173 } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
174 }) |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
175 .catch(error => reject(error)); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
176 }); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
177 } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
178 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
179 cut({ commit, dispatch, state, rootState, rootGetters }, cut) { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
180 return new Promise(resolve => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
181 const length = getLength(cut.getGeometry()); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
182 commit( |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
183 "map/setCurrentMeasurement", |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
184 { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
185 quantity: "Length", |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
186 unitSymbol: "m", |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
187 value: Math.round(length * 10) / 10 |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
188 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
189 { root: true } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
190 ); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
191 commit("clearFairwayData"); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
192 // if a survey has been selected, request a profile |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
193 // TODO an improvement could be to check if the line intersects |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
194 // with the bottleneck area's polygon before trying the server request |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
195 if (rootState.bottlenecks.selectedSurvey) { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
196 const inputLineString = cut.getGeometry().clone(); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
197 inputLineString.transform("EPSG:3857", "EPSG:4326"); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
198 const [start, end] = inputLineString |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
199 .getCoordinates() |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
200 .map(coords => coords.map(coord => parseFloat(coord.toFixed(8)))); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
201 commit("setStartPoint", start); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
202 commit("setEndPoint", end); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
203 const profileLine = new LineString([start, end]); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
204 |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
205 const profileLoaders = [ |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
206 dispatch("loadProfile", rootState.bottlenecks.selectedSurvey) |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
207 ]; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
208 if (state.additionalSurvey) { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
209 profileLoaders.push( |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
210 dispatch("loadProfile", state.additionalSurvey) |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
211 ); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
212 } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
213 |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
214 commit("profileLoading", true); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
215 Promise.all(profileLoaders) |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
216 .then(() => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
217 commit("map/cutToolEnabled", false, { root: true }); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
218 const los3 = rootGetters["map/openLayersMap"]().getLayer( |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
219 "FAIRWAYDIMENSIONSLOS3" |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
220 ); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
221 los3.getSource().forEachFeatureIntersectingExtent( |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
222 profileLine |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
223 .clone() |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
224 .transform("EPSG:4326", "EPSG:3857") |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
225 .getExtent(), |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
226 feature => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
227 const fairwayCoordinates = featureToFairwayCoordinates( |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
228 feature, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
229 profileLine |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
230 ); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
231 let fairwayData = { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
232 coordinates: fairwayCoordinates, |
3571
9e296d686f16
client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents:
3527
diff
changeset
|
233 los: 3 |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
234 }; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
235 if (fairwayCoordinates.length > 0) { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
236 commit("addFairwayData", fairwayData); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
237 } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
238 } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
239 ); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
240 const los2 = rootGetters["map/openLayersMap"]().getLayer( |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
241 "FAIRWAYDIMENSIONSLOS2" |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
242 ); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
243 los2.getSource().forEachFeatureIntersectingExtent( |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
244 profileLine |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
245 .clone() |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
246 .transform("EPSG:4326", "EPSG:3857") |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
247 .getExtent(), |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
248 feature => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
249 let fairwayCoordinates = featureToFairwayCoordinates( |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
250 feature, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
251 profileLine |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
252 ); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
253 let fairwayData = { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
254 coordinates: fairwayCoordinates, |
3571
9e296d686f16
client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents:
3527
diff
changeset
|
255 los: 2 |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
256 }; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
257 if (fairwayCoordinates.length > 0) { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
258 commit("addFairwayData", fairwayData); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
259 } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
260 } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
261 ); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
262 const los1 = rootGetters["map/openLayersMap"]().getLayer( |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
263 "FAIRWAYDIMENSIONSLOS1" |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
264 ); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
265 los1.getSource().forEachFeatureIntersectingExtent( |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
266 profileLine |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
267 .clone() |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
268 .transform("EPSG:4326", "EPSG:3857") |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
269 .getExtent(), |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
270 feature => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
271 const fairwayCoordinates = featureToFairwayCoordinates( |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
272 feature, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
273 profileLine |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
274 ); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
275 let fairwayData = { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
276 coordinates: fairwayCoordinates, |
3571
9e296d686f16
client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents:
3527
diff
changeset
|
277 los: 1 |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
278 }; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
279 if (fairwayCoordinates.length > 0) { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
280 commit("addFairwayData", fairwayData); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
281 } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
282 } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
283 ); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
284 resolve(); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
285 }) |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
286 .catch(error => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
287 const { status, data } = error.response; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
288 displayError({ |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
289 title: "Backend Error", |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
290 message: `${status ? status + ":" : ""} ${data.message || data}` |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
291 }); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
292 }) |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
293 .finally(() => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
294 commit("application/paneRotate", 1, { root: true }); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
295 if (state.additionalSurvey) { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
296 commit( |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
297 "application/paneSetup", |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
298 "COMPARESURVEYS_FAIRWAYPROFILE", |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
299 { root: true } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
300 ); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
301 } else { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
302 commit("application/paneSetup", "FAIRWAYPROFILE", { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
303 root: true |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
304 }); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
305 } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
306 commit("profileLoading", false); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
307 }); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
308 } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
309 }); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
310 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
311 previousCuts({ commit, rootState }) { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
312 const previousCuts = |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
313 JSON.parse(localStorage.getItem("previousCuts")) || []; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
314 commit( |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
315 "previousCuts", |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
316 previousCuts |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
317 .filter(cut => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
318 return ( |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
319 cut.bottleneckName === rootState.bottlenecks.selectedBottleneck |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
320 ); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
321 }) |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
322 .sort((a, b) => (a.timestamp < b.timestamp ? 1 : -1)) |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
323 ); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
324 } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
325 } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
326 }; |