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