Mercurial > gemma
annotate client/src/store/fairwayavailability.js @ 5624:29d729607ac1
Added tag v5.7 for changeset ff0af91a7f62
author | Sascha Wilde <wilde@sha-bang.de> |
---|---|
date | Thu, 22 Dec 2022 18:42:14 +0100 |
parents | 791a372553a0 |
children |
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 * |
4329
83eb99662a91
client: improve ability to test FW diagrams
Bernhard Reiter <bernhard@intevation.de>
parents:
4121
diff
changeset
|
7 * Copyright (C) 2018, 2019 by via donau |
3207
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 */ |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
14 |
3449
654f5e2d94cf
afd: new format adapted
Thomas Junk <thomas.junk@intevation.de>
parents:
3438
diff
changeset
|
15 /*eslint no-unused-vars: ["error", { "varsIgnorePattern": "_" }]*/ |
654f5e2d94cf
afd: new format adapted
Thomas Junk <thomas.junk@intevation.de>
parents:
3438
diff
changeset
|
16 |
3376
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
17 import { |
5235
987a56071402
changed route parameter from objnam to bottleneck_id.
Thomas Junk <thomas.junk@intevation.de>
parents:
4468
diff
changeset
|
18 endOfMonth, |
987a56071402
changed route parameter from objnam to bottleneck_id.
Thomas Junk <thomas.junk@intevation.de>
parents:
4468
diff
changeset
|
19 endOfQuarter, |
987a56071402
changed route parameter from objnam to bottleneck_id.
Thomas Junk <thomas.junk@intevation.de>
parents:
4468
diff
changeset
|
20 endOfYear, |
3376
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
21 format, |
3377
ccb5455f0713
available_fairway_depthLNWL: tooltips added
Thomas Junk <thomas.junk@intevation.de>
parents:
3376
diff
changeset
|
22 startOfMonth, |
3376
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
23 startOfQuarter, |
5235
987a56071402
changed route parameter from objnam to bottleneck_id.
Thomas Junk <thomas.junk@intevation.de>
parents:
4468
diff
changeset
|
24 startOfYear |
3376
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
25 } from "date-fns"; |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
26 |
5235
987a56071402
changed route parameter from objnam to bottleneck_id.
Thomas Junk <thomas.junk@intevation.de>
parents:
4468
diff
changeset
|
27 import { HTTP } from "@/lib/http"; |
987a56071402
changed route parameter from objnam to bottleneck_id.
Thomas Junk <thomas.junk@intevation.de>
parents:
4468
diff
changeset
|
28 |
3397
3675c60afd4f
afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents:
3388
diff
changeset
|
29 const LIMITINGFACTORS = { |
3675c60afd4f
afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents:
3388
diff
changeset
|
30 WIDTH: "width", |
3675c60afd4f
afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents:
3388
diff
changeset
|
31 DEPTH: "depth" |
3675c60afd4f
afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents:
3388
diff
changeset
|
32 }; |
3675c60afd4f
afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents:
3388
diff
changeset
|
33 |
3407
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
34 const TYPES = { |
3486
1fbb6dc7d362
fairwayavailability: refactor constants
Thomas Junk <thomas.junk@intevation.de>
parents:
3477
diff
changeset
|
35 BOTTLENECK: "bottleneck", |
1fbb6dc7d362
fairwayavailability: refactor constants
Thomas Junk <thomas.junk@intevation.de>
parents:
3477
diff
changeset
|
36 SECTION: "section", |
1fbb6dc7d362
fairwayavailability: refactor constants
Thomas Junk <thomas.junk@intevation.de>
parents:
3477
diff
changeset
|
37 STRETCH: "stretch" |
3407
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
38 }; |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
39 |
3325
496cf0474e29
fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents:
3299
diff
changeset
|
40 const FREQUENCIES = { |
496cf0474e29
fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents:
3299
diff
changeset
|
41 MONTHLY: "monthly", |
496cf0474e29
fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents:
3299
diff
changeset
|
42 QUARTERLY: "quarterly", |
496cf0474e29
fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents:
3299
diff
changeset
|
43 YEARLY: "yearly" |
496cf0474e29
fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents:
3299
diff
changeset
|
44 }; |
496cf0474e29
fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents:
3299
diff
changeset
|
45 |
3376
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
46 const getIntervallBorders = (start, end, frequency) => { |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
47 switch (frequency) { |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
48 case FREQUENCIES.MONTHLY: |
3499 | 49 return [isoFormat(startOfMonth(start)), isoFormat(endOfMonth(end))]; |
3376
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
50 case FREQUENCIES.YEARLY: |
3499 | 51 return [isoFormat(startOfYear(start)), isoFormat(endOfYear(end))]; |
3376
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
52 case FREQUENCIES.QUARTERLY: |
3499 | 53 return [isoFormat(startOfQuarter(start)), isoFormat(endOfQuarter(end))]; |
3376
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
54 default: |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
55 throw new Error("Boom!"); |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
56 } |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
57 }; |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
58 |
4468
130e929bab8f
available_fairway_depth_dialogue: more intuitive date selection
Thomas Junk <thomas.junk@intevation.de>
parents:
4437
diff
changeset
|
59 const isoFormat = date => { |
130e929bab8f
available_fairway_depth_dialogue: more intuitive date selection
Thomas Junk <thomas.junk@intevation.de>
parents:
4437
diff
changeset
|
60 return format(date, "YYYY-MM-DD"); |
130e929bab8f
available_fairway_depth_dialogue: more intuitive date selection
Thomas Junk <thomas.junk@intevation.de>
parents:
4437
diff
changeset
|
61 }; |
130e929bab8f
available_fairway_depth_dialogue: more intuitive date selection
Thomas Junk <thomas.junk@intevation.de>
parents:
4437
diff
changeset
|
62 |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
63 const init = () => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
64 return { |
3486
1fbb6dc7d362
fairwayavailability: refactor constants
Thomas Junk <thomas.junk@intevation.de>
parents:
3477
diff
changeset
|
65 type: TYPES.BOTTLENECK, |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
66 selectedFairwayAvailabilityFeature: null, |
4468
130e929bab8f
available_fairway_depth_dialogue: more intuitive date selection
Thomas Junk <thomas.junk@intevation.de>
parents:
4437
diff
changeset
|
67 to: null, |
130e929bab8f
available_fairway_depth_dialogue: more intuitive date selection
Thomas Junk <thomas.junk@intevation.de>
parents:
4437
diff
changeset
|
68 from: null, |
3325
496cf0474e29
fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents:
3299
diff
changeset
|
69 frequency: FREQUENCIES.MONTHLY, |
3397
3675c60afd4f
afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents:
3388
diff
changeset
|
70 limitingFactor: null, |
3499 | 71 depthlimit1: 230, |
72 depthlimit2: 250, | |
5475
791a372553a0
Client:FWA: Fix setting request parameters and legend
Fadi Abbud <fadi.abbud@intevation.de>
parents:
5254
diff
changeset
|
73 widthlimit1: 80, |
791a372553a0
Client:FWA: Fix setting request parameters and legend
Fadi Abbud <fadi.abbud@intevation.de>
parents:
5254
diff
changeset
|
74 widthlimit2: 150, |
3437 | 75 csv: null, |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
76 fwData: null, |
3299
ef52926ce2fc
available_fairwaydepth_vs_lnwl: Scales adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
3288
diff
changeset
|
77 fwLNWLData: null, |
3353
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
78 fwLNWLOverviewData: [], |
3366 | 79 legendLNWL: null, |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
80 legend: null, |
3288
c2d753ef5aa1
fairway_availability: sane defaults and ISC colors for diagram
Thomas Junk <thomas.junk@intevation.de>
parents:
3215
diff
changeset
|
81 LOS: 3 |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
82 }; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
83 }; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
84 |
3438
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
85 /** |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
86 * transformAFD |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
87 * @param {string} csv |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
88 * |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
89 * takes the afd csv and transforms it to an intermediary format |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
90 * for display of diagrams |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
91 * |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
92 * Incoming csv Format |
3449
654f5e2d94cf
afd: new format adapted
Thomas Junk <thomas.junk@intevation.de>
parents:
3438
diff
changeset
|
93 * #label,# <LDC ,# >= LDC [h],# < 230.00 [h],# >= 230.00 [h],# >= 250.00 [h] |
3438
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
94 * 05-2019,215.500,0.000,0.000,215.500 |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
95 * |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
96 * Format: |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
97 * $LABEL, $LDC, $BELOWLIMIT1, $BETWEENLIMIT12, $ABOVELIMIT2^ |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
98 * |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
99 * This format is assumed to be fix |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
100 * |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
101 */ |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
102 const transformAFD = csv => { |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
103 return csv.map(e => { |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
104 const result = e.split(","); |
4009
aee74a3a17f3
available_fairway_depth: in case the resultset has no inbetween result, the bar chart should render correct
Thomas Junk <thomas.junk@intevation.de>
parents:
3704
diff
changeset
|
105 let label, _, ldc, lower, middle, highestLevel; |
aee74a3a17f3
available_fairway_depth: in case the resultset has no inbetween result, the bar chart should render correct
Thomas Junk <thomas.junk@intevation.de>
parents:
3704
diff
changeset
|
106 let levelsWithSum; |
aee74a3a17f3
available_fairway_depth: in case the resultset has no inbetween result, the bar chart should render correct
Thomas Junk <thomas.junk@intevation.de>
parents:
3704
diff
changeset
|
107 if (result.length == 6) { |
aee74a3a17f3
available_fairway_depth: in case the resultset has no inbetween result, the bar chart should render correct
Thomas Junk <thomas.junk@intevation.de>
parents:
3704
diff
changeset
|
108 [label, _, ldc, lower, middle, highestLevel] = result; |
aee74a3a17f3
available_fairway_depth: in case the resultset has no inbetween result, the bar chart should render correct
Thomas Junk <thomas.junk@intevation.de>
parents:
3704
diff
changeset
|
109 levelsWithSum = [ |
aee74a3a17f3
available_fairway_depth: in case the resultset has no inbetween result, the bar chart should render correct
Thomas Junk <thomas.junk@intevation.de>
parents:
3704
diff
changeset
|
110 { |
aee74a3a17f3
available_fairway_depth: in case the resultset has no inbetween result, the bar chart should render correct
Thomas Junk <thomas.junk@intevation.de>
parents:
3704
diff
changeset
|
111 height: Number(lower), |
aee74a3a17f3
available_fairway_depth: in case the resultset has no inbetween result, the bar chart should render correct
Thomas Junk <thomas.junk@intevation.de>
parents:
3704
diff
changeset
|
112 translateY: Number(middle) |
aee74a3a17f3
available_fairway_depth: in case the resultset has no inbetween result, the bar chart should render correct
Thomas Junk <thomas.junk@intevation.de>
parents:
3704
diff
changeset
|
113 }, |
aee74a3a17f3
available_fairway_depth: in case the resultset has no inbetween result, the bar chart should render correct
Thomas Junk <thomas.junk@intevation.de>
parents:
3704
diff
changeset
|
114 { |
aee74a3a17f3
available_fairway_depth: in case the resultset has no inbetween result, the bar chart should render correct
Thomas Junk <thomas.junk@intevation.de>
parents:
3704
diff
changeset
|
115 height: Number(middle), |
aee74a3a17f3
available_fairway_depth: in case the resultset has no inbetween result, the bar chart should render correct
Thomas Junk <thomas.junk@intevation.de>
parents:
3704
diff
changeset
|
116 translateY: 0 |
aee74a3a17f3
available_fairway_depth: in case the resultset has no inbetween result, the bar chart should render correct
Thomas Junk <thomas.junk@intevation.de>
parents:
3704
diff
changeset
|
117 } |
aee74a3a17f3
available_fairway_depth: in case the resultset has no inbetween result, the bar chart should render correct
Thomas Junk <thomas.junk@intevation.de>
parents:
3704
diff
changeset
|
118 ]; |
aee74a3a17f3
available_fairway_depth: in case the resultset has no inbetween result, the bar chart should render correct
Thomas Junk <thomas.junk@intevation.de>
parents:
3704
diff
changeset
|
119 } else { |
3438
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
120 { |
4009
aee74a3a17f3
available_fairway_depth: in case the resultset has no inbetween result, the bar chart should render correct
Thomas Junk <thomas.junk@intevation.de>
parents:
3704
diff
changeset
|
121 [label, _, ldc, middle, highestLevel] = result; |
aee74a3a17f3
available_fairway_depth: in case the resultset has no inbetween result, the bar chart should render correct
Thomas Junk <thomas.junk@intevation.de>
parents:
3704
diff
changeset
|
122 levelsWithSum = [ |
aee74a3a17f3
available_fairway_depth: in case the resultset has no inbetween result, the bar chart should render correct
Thomas Junk <thomas.junk@intevation.de>
parents:
3704
diff
changeset
|
123 { |
aee74a3a17f3
available_fairway_depth: in case the resultset has no inbetween result, the bar chart should render correct
Thomas Junk <thomas.junk@intevation.de>
parents:
3704
diff
changeset
|
124 height: Number(middle), |
aee74a3a17f3
available_fairway_depth: in case the resultset has no inbetween result, the bar chart should render correct
Thomas Junk <thomas.junk@intevation.de>
parents:
3704
diff
changeset
|
125 translateY: 0 |
aee74a3a17f3
available_fairway_depth: in case the resultset has no inbetween result, the bar chart should render correct
Thomas Junk <thomas.junk@intevation.de>
parents:
3704
diff
changeset
|
126 } |
aee74a3a17f3
available_fairway_depth: in case the resultset has no inbetween result, the bar chart should render correct
Thomas Junk <thomas.junk@intevation.de>
parents:
3704
diff
changeset
|
127 ]; |
3438
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
128 } |
4009
aee74a3a17f3
available_fairway_depth: in case the resultset has no inbetween result, the bar chart should render correct
Thomas Junk <thomas.junk@intevation.de>
parents:
3704
diff
changeset
|
129 } |
3438
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
130 return { |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
131 label: label, |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
132 ldc: ldc, |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
133 highestLevel: highestLevel, |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
134 lowerLevels: levelsWithSum |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
135 }; |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
136 }); |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
137 }; |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
138 |
3325
496cf0474e29
fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents:
3299
diff
changeset
|
139 const fairwayavailability = { |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
140 init, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
141 namespaced: true, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
142 state: init(), |
3353
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
143 getters: { |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
144 fwLNWLOverviewData: state => feature => { |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
145 return state.fwLNWLOverviewData.find( |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
146 d => d.feature.get("id") === feature.get("id") |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
147 ); |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
148 } |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
149 }, |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
150 mutations: { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
151 type: (state, type) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
152 state.type = type; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
153 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
154 setLOS: (state, LOS) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
155 state.LOS = LOS; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
156 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
157 setFrequency: (state, frequency) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
158 state.frequency = frequency; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
159 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
160 setFrom: (state, from) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
161 state.from = from; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
162 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
163 setTo: (state, to) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
164 state.to = to; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
165 }, |
3352
399a2eb496ee
available_fairway_depth_dialogue: adding limit fields. without transmission
Thomas Junk <thomas.junk@intevation.de>
parents:
3351
diff
changeset
|
166 setDepthlimit1: (state, depthlimit1) => { |
399a2eb496ee
available_fairway_depth_dialogue: adding limit fields. without transmission
Thomas Junk <thomas.junk@intevation.de>
parents:
3351
diff
changeset
|
167 state.depthlimit1 = depthlimit1; |
399a2eb496ee
available_fairway_depth_dialogue: adding limit fields. without transmission
Thomas Junk <thomas.junk@intevation.de>
parents:
3351
diff
changeset
|
168 }, |
399a2eb496ee
available_fairway_depth_dialogue: adding limit fields. without transmission
Thomas Junk <thomas.junk@intevation.de>
parents:
3351
diff
changeset
|
169 setDepthlimit2: (state, depthlimit2) => { |
399a2eb496ee
available_fairway_depth_dialogue: adding limit fields. without transmission
Thomas Junk <thomas.junk@intevation.de>
parents:
3351
diff
changeset
|
170 state.depthlimit2 = depthlimit2; |
399a2eb496ee
available_fairway_depth_dialogue: adding limit fields. without transmission
Thomas Junk <thomas.junk@intevation.de>
parents:
3351
diff
changeset
|
171 }, |
3397
3675c60afd4f
afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents:
3388
diff
changeset
|
172 setWidthlimit1: (state, widthlimit1) => { |
3675c60afd4f
afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents:
3388
diff
changeset
|
173 state.widthlimit1 = widthlimit1; |
3354
e12e8bf044a6
available_fairway_dialogue: added 2nd breadthelement
Thomas Junk <thomas.junk@intevation.de>
parents:
3352
diff
changeset
|
174 }, |
3397
3675c60afd4f
afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents:
3388
diff
changeset
|
175 setWidthlimit2: (state, widthlimit2) => { |
3675c60afd4f
afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents:
3388
diff
changeset
|
176 state.widthlimit2 = widthlimit2; |
3352
399a2eb496ee
available_fairway_depth_dialogue: adding limit fields. without transmission
Thomas Junk <thomas.junk@intevation.de>
parents:
3351
diff
changeset
|
177 }, |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
178 setSelectedFairwayAvailability: (state, feature) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
179 state.selectedFairwayAvailabilityFeature = feature; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
180 }, |
3353
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
181 addFwLNWLOverviewData: (state, data) => { |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
182 let existingIndex = state.fwLNWLOverviewData.findIndex( |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
183 d => d.feature.get("id") === data.feature.get("id") |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
184 ); |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
185 if (existingIndex !== -1) |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
186 state.fwLNWLOverviewData.splice(existingIndex, 1); |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
187 state.fwLNWLOverviewData.push(data); |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
188 }, |
4329
83eb99662a91
client: improve ability to test FW diagrams
Bernhard Reiter <bernhard@intevation.de>
parents:
4121
diff
changeset
|
189 setLegendLNWL: (state, headerLNWL) => { |
83eb99662a91
client: improve ability to test FW diagrams
Bernhard Reiter <bernhard@intevation.de>
parents:
4121
diff
changeset
|
190 state.headerLNWL = headerLNWL; |
83eb99662a91
client: improve ability to test FW diagrams
Bernhard Reiter <bernhard@intevation.de>
parents:
4121
diff
changeset
|
191 }, |
83eb99662a91
client: improve ability to test FW diagrams
Bernhard Reiter <bernhard@intevation.de>
parents:
4121
diff
changeset
|
192 // See docs/developers.md for an example how to directly |
83eb99662a91
client: improve ability to test FW diagrams
Bernhard Reiter <bernhard@intevation.de>
parents:
4121
diff
changeset
|
193 // call this method for testing. |
83eb99662a91
client: improve ability to test FW diagrams
Bernhard Reiter <bernhard@intevation.de>
parents:
4121
diff
changeset
|
194 setAvailableFairwayDepthData: (state, data) => { |
4437
a075da82e875
client:FWD: change unit to meter for the generated csv file
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4351
diff
changeset
|
195 const lines = data.split("\n"); |
a075da82e875
client:FWD: change unit to meter for the generated csv file
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4351
diff
changeset
|
196 let [header, rest] = [lines.shift(), lines]; |
a075da82e875
client:FWD: change unit to meter for the generated csv file
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4351
diff
changeset
|
197 // convert values to meter in the csv header |
a075da82e875
client:FWD: change unit to meter for the generated csv file
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4351
diff
changeset
|
198 state.csv = [ |
a075da82e875
client:FWD: change unit to meter for the generated csv file
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4351
diff
changeset
|
199 header.replace(/\d+\.?\d*/g, x => `${x / 100}m`), |
a075da82e875
client:FWD: change unit to meter for the generated csv file
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4351
diff
changeset
|
200 ...rest |
a075da82e875
client:FWD: change unit to meter for the generated csv file
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4351
diff
changeset
|
201 ].join("\n"); |
a075da82e875
client:FWD: change unit to meter for the generated csv file
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4351
diff
changeset
|
202 const csv = [header, ...rest].filter(x => x !== ""); //omit empty lines |
4329
83eb99662a91
client: improve ability to test FW diagrams
Bernhard Reiter <bernhard@intevation.de>
parents:
4121
diff
changeset
|
203 |
83eb99662a91
client: improve ability to test FW diagrams
Bernhard Reiter <bernhard@intevation.de>
parents:
4121
diff
changeset
|
204 // setLegend |
83eb99662a91
client: improve ability to test FW diagrams
Bernhard Reiter <bernhard@intevation.de>
parents:
4121
diff
changeset
|
205 const headerEntries = csv.shift().split(","); |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
206 headerEntries.shift(); |
3453 | 207 headerEntries.shift(); |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
208 state.legend = headerEntries.map(x => { |
3326
98ce6d101e01
available_fairway_depth: omit unit
Thomas Junk <thomas.junk@intevation.de>
parents:
3325
diff
changeset
|
209 let entry = x.split("#")[1]; // split leading # |
98ce6d101e01
available_fairway_depth: omit unit
Thomas Junk <thomas.junk@intevation.de>
parents:
3325
diff
changeset
|
210 entry = entry.replace("[h]", "").trim(); // omit unit |
98ce6d101e01
available_fairway_depth: omit unit
Thomas Junk <thomas.junk@intevation.de>
parents:
3325
diff
changeset
|
211 return entry; |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
212 }); |
4329
83eb99662a91
client: improve ability to test FW diagrams
Bernhard Reiter <bernhard@intevation.de>
parents:
4121
diff
changeset
|
213 |
83eb99662a91
client: improve ability to test FW diagrams
Bernhard Reiter <bernhard@intevation.de>
parents:
4121
diff
changeset
|
214 state.fwData = transformAFD(csv); |
4351
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
215 }, |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
216 // See docs/developers.md for an example how to directly |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
217 // call this method for testing. |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
218 setAvailableFairwayDepthLNWLData: (state, data) => { |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
219 state.csv = data; |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
220 |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
221 data = data.split("\n").filter(d => d); |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
222 data.shift(); // remove header line |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
223 data = data.map(d => { |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
224 let columns = d.split(","); |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
225 let result; |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
226 if (columns.length === 6) { |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
227 result = { |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
228 date: columns[0], |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
229 ldc: Number(columns[2]), |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
230 below: Number(columns[3]), |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
231 between: Number(columns[4]), |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
232 above: Number(columns[5]) |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
233 }; |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
234 } else { |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
235 result = { |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
236 date: columns[0], |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
237 ldc: Number(columns[2]), |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
238 below: Number(columns[3]), |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
239 between: null, |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
240 above: Number(columns[4]) |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
241 }; |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
242 } |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
243 return result; |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
244 }); |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
245 state.fwLNWLData = data; |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
246 } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
247 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
248 actions: { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
249 loadAvailableFairwayDepth: ({ commit }, options) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
250 return new Promise((resolve, reject) => { |
3407
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
251 const { |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
252 feature, |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
253 frequency, |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
254 LOS, |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
255 depthLimit1, |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
256 depthLimit2, |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
257 widthLimit1, |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
258 widthLimit2, |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
259 limitingFactor, |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
260 type |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
261 } = options; |
3376
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
262 let { from, to } = options; |
5249
d855426a6e5d
Fixed frontend for sections and stretches in new FWA implementation.
Sascha Wilde <wilde@intevation.de>
parents:
5238
diff
changeset
|
263 let name = ""; |
d855426a6e5d
Fixed frontend for sections and stretches in new FWA implementation.
Sascha Wilde <wilde@intevation.de>
parents:
5238
diff
changeset
|
264 if (type === TYPES.BOTTLENECK) { |
d855426a6e5d
Fixed frontend for sections and stretches in new FWA implementation.
Sascha Wilde <wilde@intevation.de>
parents:
5238
diff
changeset
|
265 name = feature.hasOwnProperty("properties") |
d855426a6e5d
Fixed frontend for sections and stretches in new FWA implementation.
Sascha Wilde <wilde@intevation.de>
parents:
5238
diff
changeset
|
266 ? feature.properties.bottleneck_id |
d855426a6e5d
Fixed frontend for sections and stretches in new FWA implementation.
Sascha Wilde <wilde@intevation.de>
parents:
5238
diff
changeset
|
267 : feature.get("bottleneck_id"); |
d855426a6e5d
Fixed frontend for sections and stretches in new FWA implementation.
Sascha Wilde <wilde@intevation.de>
parents:
5238
diff
changeset
|
268 } else { |
d855426a6e5d
Fixed frontend for sections and stretches in new FWA implementation.
Sascha Wilde <wilde@intevation.de>
parents:
5238
diff
changeset
|
269 name = feature.hasOwnProperty("properties") |
d855426a6e5d
Fixed frontend for sections and stretches in new FWA implementation.
Sascha Wilde <wilde@intevation.de>
parents:
5238
diff
changeset
|
270 ? feature.properties.name |
d855426a6e5d
Fixed frontend for sections and stretches in new FWA implementation.
Sascha Wilde <wilde@intevation.de>
parents:
5238
diff
changeset
|
271 : feature.get("objnam"); |
d855426a6e5d
Fixed frontend for sections and stretches in new FWA implementation.
Sascha Wilde <wilde@intevation.de>
parents:
5238
diff
changeset
|
272 } |
3376
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
273 [from, to] = getIntervallBorders(from, to, frequency); |
3407
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
274 let additionalParams = ""; |
3490
624c64670d48
fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents:
3486
diff
changeset
|
275 let endpoint = type; |
624c64670d48
fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents:
3486
diff
changeset
|
276 if (type === TYPES.BOTTLENECK) { |
624c64670d48
fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents:
3486
diff
changeset
|
277 if (limitingFactor === LIMITINGFACTORS.DEPTH) |
624c64670d48
fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents:
3486
diff
changeset
|
278 additionalParams = `&breaks=${depthLimit1},${depthLimit2}`; |
624c64670d48
fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents:
3486
diff
changeset
|
279 if (limitingFactor === LIMITINGFACTORS.WIDTH) |
624c64670d48
fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents:
3486
diff
changeset
|
280 additionalParams = `&breaks=${widthLimit1},${widthLimit2}`; |
624c64670d48
fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents:
3486
diff
changeset
|
281 } else if (type == TYPES.SECTION || type == TYPES.STRETCH) { |
624c64670d48
fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents:
3486
diff
changeset
|
282 additionalParams = `&depthbreaks=${depthLimit1},${depthLimit2}&widthbreaks=${widthLimit1},${widthLimit2}`; |
3407
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
283 } |
4121
9f03eb3817d6
Use UTC for FWA diagrams.
Sascha Wilde <wilde@intevation.de>
parents:
4086
diff
changeset
|
284 const start = encodeURIComponent("00:00:00+00:00"); |
9f03eb3817d6
Use UTC for FWA diagrams.
Sascha Wilde <wilde@intevation.de>
parents:
4086
diff
changeset
|
285 const end = encodeURIComponent("23:59:59+00:00"); |
5238
2f513505bc88
changed route for availability
Thomas Junk <thomas.junk@intevation.de>
parents:
5235
diff
changeset
|
286 const URL = `data/fairway/${endpoint}/${encodeURIComponent( |
3334
8c96b7379aea
client: fairway availability: made store action work with both types of feature objects
Markus Kottlaender <markus@intevation.de>
parents:
3331
diff
changeset
|
287 name |
4121
9f03eb3817d6
Use UTC for FWA diagrams.
Sascha Wilde <wilde@intevation.de>
parents:
4086
diff
changeset
|
288 )}?from=${from}T${start}&to=${to}T${end}&mode=${frequency}&los=${LOS}${additionalParams}`; |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
289 HTTP.get(URL, { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
290 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
|
291 }) |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
292 .then(response => { |
4329
83eb99662a91
client: improve ability to test FW diagrams
Bernhard Reiter <bernhard@intevation.de>
parents:
4121
diff
changeset
|
293 commit("setAvailableFairwayDepthData", response.data); |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
294 resolve(response); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
295 }) |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
296 .catch(error => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
297 reject(error); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
298 }); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
299 }); |
3353
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
300 }, |
3451 | 301 loadAvailableFairwayDepthLNWL: (context, options) => { |
3353
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
302 return new Promise((resolve, reject) => { |
3463
6f4dad7473d7
afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents:
3461
diff
changeset
|
303 const { |
6f4dad7473d7
afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents:
3461
diff
changeset
|
304 feature, |
6f4dad7473d7
afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents:
3461
diff
changeset
|
305 frequency, |
6f4dad7473d7
afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents:
3461
diff
changeset
|
306 LOS, |
6f4dad7473d7
afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents:
3461
diff
changeset
|
307 depthLimit1, |
6f4dad7473d7
afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents:
3461
diff
changeset
|
308 depthLimit2, |
6f4dad7473d7
afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents:
3461
diff
changeset
|
309 widthLimit1, |
6f4dad7473d7
afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents:
3461
diff
changeset
|
310 widthLimit2, |
6f4dad7473d7
afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents:
3461
diff
changeset
|
311 limitingFactor, |
6f4dad7473d7
afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents:
3461
diff
changeset
|
312 type |
6f4dad7473d7
afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents:
3461
diff
changeset
|
313 } = options; |
3376
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
314 let { from, to } = options; |
5254
09ec6a748fca
Fixed front end for FWA vs LDC, too.
wilde@azure1.rgb.intevation.de
parents:
5249
diff
changeset
|
315 let name = ""; |
09ec6a748fca
Fixed front end for FWA vs LDC, too.
wilde@azure1.rgb.intevation.de
parents:
5249
diff
changeset
|
316 if (type === TYPES.BOTTLENECK) { |
09ec6a748fca
Fixed front end for FWA vs LDC, too.
wilde@azure1.rgb.intevation.de
parents:
5249
diff
changeset
|
317 name = feature.hasOwnProperty("properties") |
09ec6a748fca
Fixed front end for FWA vs LDC, too.
wilde@azure1.rgb.intevation.de
parents:
5249
diff
changeset
|
318 ? feature.properties.bottleneck_id |
09ec6a748fca
Fixed front end for FWA vs LDC, too.
wilde@azure1.rgb.intevation.de
parents:
5249
diff
changeset
|
319 : feature.get("bottleneck_id"); |
09ec6a748fca
Fixed front end for FWA vs LDC, too.
wilde@azure1.rgb.intevation.de
parents:
5249
diff
changeset
|
320 } else { |
09ec6a748fca
Fixed front end for FWA vs LDC, too.
wilde@azure1.rgb.intevation.de
parents:
5249
diff
changeset
|
321 name = feature.hasOwnProperty("properties") |
09ec6a748fca
Fixed front end for FWA vs LDC, too.
wilde@azure1.rgb.intevation.de
parents:
5249
diff
changeset
|
322 ? feature.properties.name |
09ec6a748fca
Fixed front end for FWA vs LDC, too.
wilde@azure1.rgb.intevation.de
parents:
5249
diff
changeset
|
323 : feature.get("objnam"); |
09ec6a748fca
Fixed front end for FWA vs LDC, too.
wilde@azure1.rgb.intevation.de
parents:
5249
diff
changeset
|
324 } |
3376
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
325 [from, to] = getIntervallBorders(from, to, frequency); |
4121
9f03eb3817d6
Use UTC for FWA diagrams.
Sascha Wilde <wilde@intevation.de>
parents:
4086
diff
changeset
|
326 const start = encodeURIComponent("00:00:00+00:00"); |
9f03eb3817d6
Use UTC for FWA diagrams.
Sascha Wilde <wilde@intevation.de>
parents:
4086
diff
changeset
|
327 const end = encodeURIComponent("23:59:59+00:00"); |
3463
6f4dad7473d7
afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents:
3461
diff
changeset
|
328 let additionalParams = ""; |
3490
624c64670d48
fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents:
3486
diff
changeset
|
329 let endpoint = type || TYPES.BOTTLENECK; |
624c64670d48
fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents:
3486
diff
changeset
|
330 if (type === TYPES.BOTTLENECK) { |
624c64670d48
fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents:
3486
diff
changeset
|
331 if (limitingFactor === LIMITINGFACTORS.DEPTH) |
624c64670d48
fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents:
3486
diff
changeset
|
332 additionalParams = `&breaks=${depthLimit1},${depthLimit2}`; |
624c64670d48
fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents:
3486
diff
changeset
|
333 if (limitingFactor === LIMITINGFACTORS.WIDTH) |
624c64670d48
fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents:
3486
diff
changeset
|
334 additionalParams = `&breaks=${widthLimit1},${widthLimit2}`; |
624c64670d48
fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents:
3486
diff
changeset
|
335 } else if (type == TYPES.SECTION || type == TYPES.STRETCH) { |
624c64670d48
fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents:
3486
diff
changeset
|
336 additionalParams = `&depthbreaks=${depthLimit1},${depthLimit2}&widthbreaks=${widthLimit1},${widthLimit2}`; |
3463
6f4dad7473d7
afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents:
3461
diff
changeset
|
337 } |
5238
2f513505bc88
changed route for availability
Thomas Junk <thomas.junk@intevation.de>
parents:
5235
diff
changeset
|
338 const URL = `data/availability/${endpoint}/${encodeURIComponent( |
3353
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
339 name |
4121
9f03eb3817d6
Use UTC for FWA diagrams.
Sascha Wilde <wilde@intevation.de>
parents:
4086
diff
changeset
|
340 )}?from=${from}T${start}&to=${to}T${end}&mode=${frequency}&los=${LOS}${additionalParams}`; |
3353
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
341 HTTP.get(URL, { |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
342 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
343 }) |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
344 .then(response => { |
3437 | 345 const { data } = response; |
346 resolve(data); | |
3353
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
347 }) |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
348 .catch(error => { |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
349 reject(error); |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
350 }); |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
351 }); |
3368
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
352 }, |
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
353 loadAvailableFairwayDepthLNWLDiagram: ({ commit, dispatch }, options) => { |
4351
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
354 dispatch("loadAvailableFairwayDepthLNWL", options).then(data => { |
47aa3be2a7de
client: allow testing of Available FDLNW diagram
Bernhard Reiter <bernhard@intevation.de>
parents:
4329
diff
changeset
|
355 commit("setAvailableFairwayDepthLNWLData", data); |
3368
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
356 }); |
3457
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
357 }, |
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
358 loadAvailableFairwayDepthLNWLForMap: ({ dispatch }, options) => { |
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
359 return dispatch("loadAvailableFairwayDepthLNWL", options).then( |
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
360 response => { |
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
361 let data = response.split("\n").filter(d => d); |
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
362 data.shift(); // remove header line |
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
363 data = data.map(d => { |
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
364 let columns = d.split(","); |
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
365 return { |
3461
b43cf476d791
client: spuc05: implemented new data structure (CSV) and added support for multiple charts
Markus Kottlaender <markus@intevation.de>
parents:
3457
diff
changeset
|
366 ldc: Number(columns[2]), |
b43cf476d791
client: spuc05: implemented new data structure (CSV) and added support for multiple charts
Markus Kottlaender <markus@intevation.de>
parents:
3457
diff
changeset
|
367 below: Number(columns[3]), |
b43cf476d791
client: spuc05: implemented new data structure (CSV) and added support for multiple charts
Markus Kottlaender <markus@intevation.de>
parents:
3457
diff
changeset
|
368 between: Number(columns[4]), |
b43cf476d791
client: spuc05: implemented new data structure (CSV) and added support for multiple charts
Markus Kottlaender <markus@intevation.de>
parents:
3457
diff
changeset
|
369 above: Number(columns[5]) |
3457
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
370 }; |
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
371 }); |
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
372 return data[0]; |
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
373 } |
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
374 ); |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
375 } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
376 } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
377 }; |
3325
496cf0474e29
fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents:
3299
diff
changeset
|
378 |
3704
271683dee9bf
client: fairway availability diaglog: set correct type when opened from map popup
Markus Kottlaender <markus@intevation.de>
parents:
3499
diff
changeset
|
379 export { LIMITINGFACTORS, FREQUENCIES, TYPES, fairwayavailability }; |