Mercurial > gemma
annotate client/src/store/fairwayavailability.js @ 3457:870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Fri, 24 May 2019 15:32:47 +0200 |
parents | 41349a9c8ce9 |
children | b43cf476d791 |
rev | line source |
---|---|
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
1 /* This is Free Software under GNU Affero General Public License v >= 3.0 |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
2 * without warranty, see README.md and license for details. |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
3 * |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
4 * SPDX-License-Identifier: AGPL-3.0-or-later |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
5 * License-Filename: LICENSES/AGPL-3.0.txt |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
6 * |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
7 * Copyright (C) 2018 by via donau |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
8 * – Österreichische Wasserstraßen-Gesellschaft mbH |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
9 * Software engineering by Intevation GmbH |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
10 * |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
11 * Author(s): |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
12 * Thomas Junk <thomas.junk@intevation.de> |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
13 */ |
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, |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
20 subYears, |
3377
ccb5455f0713
available_fairway_depthLNWL: tooltips added
Thomas Junk <thomas.junk@intevation.de>
parents:
3376
diff
changeset
|
21 startOfMonth, |
ccb5455f0713
available_fairway_depthLNWL: tooltips added
Thomas Junk <thomas.junk@intevation.de>
parents:
3376
diff
changeset
|
22 endOfMonth, |
3376
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
23 startOfYear, |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
24 endOfYear, |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
25 startOfQuarter, |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
26 endOfQuarter |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
27 } from "date-fns"; |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
28 |
3368
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
29 const LNWLDIAGRAMMOCKDATA = { |
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
30 lnwl: [ |
3388
1876b204b004
afdLNWL: fix display
Thomas Junk <thomas.junk@intevation.de>
parents:
3381
diff
changeset
|
31 { level: "LDC", value: 162, percent: 70 }, |
1876b204b004
afdLNWL: fix display
Thomas Junk <thomas.junk@intevation.de>
parents:
3381
diff
changeset
|
32 { level: "HDC", value: 564, percent: 30 } |
3368
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
33 ], |
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
34 afd: [ |
3388
1876b204b004
afdLNWL: fix display
Thomas Junk <thomas.junk@intevation.de>
parents:
3381
diff
changeset
|
35 { value: 200, percent: 20 }, |
1876b204b004
afdLNWL: fix display
Thomas Junk <thomas.junk@intevation.de>
parents:
3381
diff
changeset
|
36 { value: 230, percent: 30 }, |
1876b204b004
afdLNWL: fix display
Thomas Junk <thomas.junk@intevation.de>
parents:
3381
diff
changeset
|
37 { value: 250, percent: 50 } |
3368
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
38 ] |
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
39 }; |
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
40 |
3397
3675c60afd4f
afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents:
3388
diff
changeset
|
41 const LIMITINGFACTORS = { |
3675c60afd4f
afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents:
3388
diff
changeset
|
42 WIDTH: "width", |
3675c60afd4f
afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents:
3388
diff
changeset
|
43 DEPTH: "depth" |
3675c60afd4f
afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents:
3388
diff
changeset
|
44 }; |
3675c60afd4f
afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents:
3388
diff
changeset
|
45 |
3407
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
46 const TYPES = { |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
47 BOTTLENECKS: "bottlenecks", |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
48 SECTIONS: "sections", |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
49 STRETCHES: "stretches" |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
50 }; |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
51 |
3325
496cf0474e29
fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents:
3299
diff
changeset
|
52 const FREQUENCIES = { |
496cf0474e29
fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents:
3299
diff
changeset
|
53 MONTHLY: "monthly", |
496cf0474e29
fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents:
3299
diff
changeset
|
54 QUARTERLY: "quarterly", |
496cf0474e29
fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents:
3299
diff
changeset
|
55 YEARLY: "yearly" |
496cf0474e29
fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents:
3299
diff
changeset
|
56 }; |
496cf0474e29
fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents:
3299
diff
changeset
|
57 |
3376
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
58 const getIntervallBorders = (start, end, frequency) => { |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
59 switch (frequency) { |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
60 case FREQUENCIES.MONTHLY: |
3377
ccb5455f0713
available_fairway_depthLNWL: tooltips added
Thomas Junk <thomas.junk@intevation.de>
parents:
3376
diff
changeset
|
61 return [ |
ccb5455f0713
available_fairway_depthLNWL: tooltips added
Thomas Junk <thomas.junk@intevation.de>
parents:
3376
diff
changeset
|
62 format(startOfMonth(start), "YYYY-MM-DD"), |
ccb5455f0713
available_fairway_depthLNWL: tooltips added
Thomas Junk <thomas.junk@intevation.de>
parents:
3376
diff
changeset
|
63 format(endOfMonth(end), "YYYY-MM-DD") |
ccb5455f0713
available_fairway_depthLNWL: tooltips added
Thomas Junk <thomas.junk@intevation.de>
parents:
3376
diff
changeset
|
64 ]; |
3376
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
65 case FREQUENCIES.YEARLY: |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
66 return [ |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
67 format(startOfYear(start), "YYYY-MM-DD"), |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
68 format(endOfYear(end), "YYYY-MM-DD") |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
69 ]; |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
70 case FREQUENCIES.QUARTERLY: |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
71 return [ |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
72 format(startOfQuarter(start), "YYYY-MM-DD"), |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
73 format(endOfQuarter(end), "YYYY-MM-DD") |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
74 ]; |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
75 default: |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
76 throw new Error("Boom!"); |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
77 } |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
78 }; |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
79 |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
80 const init = () => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
81 return { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
82 type: "bottlenecks", |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
83 selectedFairwayAvailabilityFeature: null, |
3288
c2d753ef5aa1
fairway_availability: sane defaults and ISC colors for diagram
Thomas Junk <thomas.junk@intevation.de>
parents:
3215
diff
changeset
|
84 to: format(new Date(), "YYYY-MM-DD"), |
c2d753ef5aa1
fairway_availability: sane defaults and ISC colors for diagram
Thomas Junk <thomas.junk@intevation.de>
parents:
3215
diff
changeset
|
85 from: format(subYears(new Date(), 1), "YYYY-MM-DD"), |
3325
496cf0474e29
fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents:
3299
diff
changeset
|
86 frequency: FREQUENCIES.MONTHLY, |
3397
3675c60afd4f
afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents:
3388
diff
changeset
|
87 limitingFactor: null, |
3352
399a2eb496ee
available_fairway_depth_dialogue: adding limit fields. without transmission
Thomas Junk <thomas.junk@intevation.de>
parents:
3351
diff
changeset
|
88 depthlimit1: 250, |
399a2eb496ee
available_fairway_depth_dialogue: adding limit fields. without transmission
Thomas Junk <thomas.junk@intevation.de>
parents:
3351
diff
changeset
|
89 depthlimit2: 230, |
3397
3675c60afd4f
afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents:
3388
diff
changeset
|
90 widthlimit1: null, |
3675c60afd4f
afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents:
3388
diff
changeset
|
91 widthlimit2: null, |
3437 | 92 csv: null, |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
93 fwData: null, |
3299
ef52926ce2fc
available_fairwaydepth_vs_lnwl: Scales adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
3288
diff
changeset
|
94 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
|
95 fwLNWLOverviewData: [], |
3366 | 96 legendLNWL: null, |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
97 legend: null, |
3288
c2d753ef5aa1
fairway_availability: sane defaults and ISC colors for diagram
Thomas Junk <thomas.junk@intevation.de>
parents:
3215
diff
changeset
|
98 LOS: 3 |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
99 }; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
100 }; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
101 |
3438
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
102 /** |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
103 * transformAFD |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
104 * @param {string} csv |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
105 * |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
106 * 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
|
107 * for display of diagrams |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
108 * |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
109 * Incoming csv Format |
3449
654f5e2d94cf
afd: new format adapted
Thomas Junk <thomas.junk@intevation.de>
parents:
3438
diff
changeset
|
110 * #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
|
111 * 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
|
112 * |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
113 * Format: |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
114 * $LABEL, $LDC, $BELOWLIMIT1, $BETWEENLIMIT12, $ABOVELIMIT2^ |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
115 * |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
116 * This format is assumed to be fix |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
117 * |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
118 */ |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
119 const transformAFD = csv => { |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
120 return csv.map(e => { |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
121 const result = e.split(","); |
3449
654f5e2d94cf
afd: new format adapted
Thomas Junk <thomas.junk@intevation.de>
parents:
3438
diff
changeset
|
122 let [label, _, ldc, lower, middle, highestLevel] = result; |
3438
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
123 let levelsWithSum = [ |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
124 { |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
125 height: Number(lower), |
3453 | 126 translateY: Number(middle) |
3438
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
127 }, |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
128 { |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
129 height: Number(middle), |
3453 | 130 translateY: 0 |
3438
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
131 } |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
132 ]; |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
133 return { |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
134 label: label, |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
135 ldc: ldc, |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
136 highestLevel: highestLevel, |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
137 lowerLevels: levelsWithSum |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
138 }; |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
139 }); |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
140 }; |
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
141 |
3451 | 142 /** |
143 * transformAFDLNWL | |
144 * @param {*} csv | |
145 * | |
146 * takes the afd csv and transforms it to an intermediary format | |
147 * for display of diagrams | |
148 * | |
149 * Incoming csv Format | |
150 * #time,#LDC < 162.000 [%],#LDC >= 162.000 [%],#d < 230.000 [%],#d >= 230.000 [%],#d >= 250.000 [%] | |
151 * 05-2018,0.000,0.000,0.000,0.000,16.163 | |
152 * 06-2018,0.000,0.000,0.000,0.000,16.701 | |
153 * 07-2018,0.000,0.000,0.000,0.000,16.163 | |
154 * 08-2018,0.000,0.000,0.000,0.000,16.163 | |
155 * 09-2018,0.000,0.000,0.000,0.000,16.701 | |
156 * 10-2018,0.000,0.000,0.000,0.000,16.163 | |
157 * 11-2018,0.000,0.000,0.000,0.000,16.701 | |
158 * 12-2018,0.000,0.000,0.000,0.000,16.163 | |
159 * 01-2019,0.000,0.000,0.000,0.000,16.163 | |
160 * 02-2019,0.000,0.000,0.000,0.000,17.894 | |
161 * 03-2019,0.000,0.000,0.000,0.000,16.163 | |
162 * 04-2019,0.000,0.000,0.000,0.000,16.701 | |
163 * 05-2019,0.000,16.163,0.000,0.000,16.163 | |
164 */ | |
165 // CURRENTLY UNUSED | |
166 // const transformAFDLNWL = csv => { | |
167 // return csv.map(e => { | |
168 // const result = e.split(","); | |
169 // let [label, lowldc, ldc, lower, middle, highestLevel] = result; | |
170 // let levelsWithSum = [ | |
171 // { | |
172 // height: Number(lower), | |
173 // translateY: 0 | |
174 // }, | |
175 // { | |
176 // height: Number(middle), | |
177 // translateY: Number(lower) | |
178 // } | |
179 // ]; | |
180 // return { | |
181 // label: label, | |
182 // ldc: ldc, | |
183 // lowldc: lowldc, | |
184 // highestLevel: highestLevel, | |
185 // lowerLevels: levelsWithSum | |
186 // }; | |
187 // }); | |
188 // }; | |
189 | |
3325
496cf0474e29
fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents:
3299
diff
changeset
|
190 const fairwayavailability = { |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
191 init, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
192 namespaced: true, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
193 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
|
194 getters: { |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
195 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
|
196 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
|
197 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
|
198 ); |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
199 } |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
200 }, |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
201 mutations: { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
202 type: (state, type) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
203 state.type = type; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
204 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
205 setLOS: (state, LOS) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
206 state.LOS = LOS; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
207 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
208 setFrequency: (state, frequency) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
209 state.frequency = frequency; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
210 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
211 setFrom: (state, from) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
212 state.from = from; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
213 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
214 setTo: (state, to) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
215 state.to = to; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
216 }, |
3352
399a2eb496ee
available_fairway_depth_dialogue: adding limit fields. without transmission
Thomas Junk <thomas.junk@intevation.de>
parents:
3351
diff
changeset
|
217 setDepthlimit1: (state, depthlimit1) => { |
399a2eb496ee
available_fairway_depth_dialogue: adding limit fields. without transmission
Thomas Junk <thomas.junk@intevation.de>
parents:
3351
diff
changeset
|
218 state.depthlimit1 = depthlimit1; |
399a2eb496ee
available_fairway_depth_dialogue: adding limit fields. without transmission
Thomas Junk <thomas.junk@intevation.de>
parents:
3351
diff
changeset
|
219 }, |
399a2eb496ee
available_fairway_depth_dialogue: adding limit fields. without transmission
Thomas Junk <thomas.junk@intevation.de>
parents:
3351
diff
changeset
|
220 setDepthlimit2: (state, depthlimit2) => { |
399a2eb496ee
available_fairway_depth_dialogue: adding limit fields. without transmission
Thomas Junk <thomas.junk@intevation.de>
parents:
3351
diff
changeset
|
221 state.depthlimit2 = depthlimit2; |
399a2eb496ee
available_fairway_depth_dialogue: adding limit fields. without transmission
Thomas Junk <thomas.junk@intevation.de>
parents:
3351
diff
changeset
|
222 }, |
3397
3675c60afd4f
afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents:
3388
diff
changeset
|
223 setWidthlimit1: (state, widthlimit1) => { |
3675c60afd4f
afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents:
3388
diff
changeset
|
224 state.widthlimit1 = widthlimit1; |
3354
e12e8bf044a6
available_fairway_dialogue: added 2nd breadthelement
Thomas Junk <thomas.junk@intevation.de>
parents:
3352
diff
changeset
|
225 }, |
3397
3675c60afd4f
afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents:
3388
diff
changeset
|
226 setWidthlimit2: (state, widthlimit2) => { |
3675c60afd4f
afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents:
3388
diff
changeset
|
227 state.widthlimit2 = widthlimit2; |
3352
399a2eb496ee
available_fairway_depth_dialogue: adding limit fields. without transmission
Thomas Junk <thomas.junk@intevation.de>
parents:
3351
diff
changeset
|
228 }, |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
229 setSelectedFairwayAvailability: (state, feature) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
230 state.selectedFairwayAvailabilityFeature = feature; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
231 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
232 setFwData: (state, fwData) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
233 state.fwData = fwData; |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
234 }, |
3368
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
235 setFwLNWLData: (state, fwLNWLData) => { |
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
236 state.fwLNWLData = fwLNWLData; |
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
237 }, |
3437 | 238 setCSV: (state, csv) => { |
239 state.csv = csv; | |
240 }, | |
3353
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
241 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
|
242 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
|
243 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
|
244 ); |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
245 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
|
246 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
|
247 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
|
248 }, |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
249 setLegend: (state, header) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
250 const headerEntries = header.split(","); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
251 headerEntries.shift(); |
3453 | 252 headerEntries.shift(); |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
253 state.legend = headerEntries.map(x => { |
3326
98ce6d101e01
available_fairway_depth: omit unit
Thomas Junk <thomas.junk@intevation.de>
parents:
3325
diff
changeset
|
254 let entry = x.split("#")[1]; // split leading # |
98ce6d101e01
available_fairway_depth: omit unit
Thomas Junk <thomas.junk@intevation.de>
parents:
3325
diff
changeset
|
255 entry = entry.replace("[h]", "").trim(); // omit unit |
98ce6d101e01
available_fairway_depth: omit unit
Thomas Junk <thomas.junk@intevation.de>
parents:
3325
diff
changeset
|
256 return entry; |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
257 }); |
3366 | 258 }, |
259 setLegendLNWL: (state, headerLNWL) => { | |
260 this.headerLNWL = headerLNWL; | |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
261 } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
262 }, |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
263 actions: { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
264 loadAvailableFairwayDepth: ({ commit }, options) => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
265 return new Promise((resolve, reject) => { |
3407
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
266 const { |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
267 feature, |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
268 frequency, |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
269 LOS, |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
270 depthLimit1, |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
271 depthLimit2, |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
272 widthLimit1, |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
273 widthLimit2, |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
274 limitingFactor, |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
275 type |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
276 } = options; |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
277 if (type !== TYPES.BOTTLENECKS) return; |
3376
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
278 let { from, to } = options; |
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 let name = |
8c96b7379aea
client: fairway availability: made store action work with both types of feature objects
Markus Kottlaender <markus@intevation.de>
parents:
3331
diff
changeset
|
280 feature.constructor.name === "Feature" |
8c96b7379aea
client: fairway availability: made store action work with both types of feature objects
Markus Kottlaender <markus@intevation.de>
parents:
3331
diff
changeset
|
281 ? feature.get("objnam") |
8c96b7379aea
client: fairway availability: made store action work with both types of feature objects
Markus Kottlaender <markus@intevation.de>
parents:
3331
diff
changeset
|
282 : feature.properties.name; |
3376
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
283 [from, to] = getIntervallBorders(from, to, frequency); |
3407
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
284 let additionalParams = ""; |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
285 let endpoint = ""; |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
286 switch (type) { |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
287 case TYPES.BOTTLENECKS: |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
288 endpoint = "bottleneck"; |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
289 if (limitingFactor === LIMITINGFACTORS.DEPTH) |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
290 additionalParams = `&breaks=${depthLimit1},${depthLimit2}`; |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
291 if (limitingFactor === LIMITINGFACTORS.WIDTH) |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
292 additionalParams = `&breaks=${widthLimit1},${widthLimit2}`; |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
293 break; |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
294 default: |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
295 throw new Error("Wrong selection"); |
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
296 } |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
297 const start = encodeURIComponent("00:00:00+00:00"); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
298 const end = encodeURIComponent("23:59:59+00:00"); |
3407
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
299 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
|
300 name |
3407
7ea54c3b3fd6
afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents:
3397
diff
changeset
|
301 )}?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
|
302 HTTP.get(URL, { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
303 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
|
304 }) |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
305 .then(response => { |
3351
dcae9b3e864b
available_fairway_depths: remove mocks
Thomas Junk <thomas.junk@intevation.de>
parents:
3347
diff
changeset
|
306 const { data } = response; |
3437 | 307 commit("setCSV", data); |
3215
3b36bb33f5b0
available_fairway_depth: omit empty lines after split by newline
Thomas Junk <thomas.junk@intevation.de>
parents:
3207
diff
changeset
|
308 const csv = data.split("\n").filter(x => x !== ""); //omit empty lines |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
309 commit("setLegend", csv.shift()); |
3438
df6c2973f791
New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
310 let transformed = transformAFD(csv); |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
311 commit("setFwData", transformed); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
312 resolve(response); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
313 }) |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
314 .catch(error => { |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
315 reject(error); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
316 }); |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
317 }); |
3353
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
318 }, |
3451 | 319 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
|
320 return new Promise((resolve, reject) => { |
3376
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
321 const { feature, frequency, LOS } = options; |
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
322 let { from, to } = options; |
3353
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
323 let name = |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
324 feature.constructor.name === "Feature" |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
325 ? feature.get("objnam") |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
326 : feature.properties.name; |
3376
70b7078b4516
available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents:
3368
diff
changeset
|
327 [from, to] = getIntervallBorders(from, to, frequency); |
3353
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
328 const start = encodeURIComponent("00:00:00+00:00"); |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
329 const end = encodeURIComponent("23:59:59+00:00"); |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
330 const URL = `/data/bottleneck/availability/${encodeURIComponent( |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
331 name |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
332 )}?from=${from}T${start}&to=${to}T${end}&mode=${frequency}&los=${LOS}`; |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
333 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
|
334 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
|
335 }) |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
336 .then(response => { |
3437 | 337 const { data } = response; |
338 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
|
339 }) |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
340 .catch(error => { |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
341 reject(error); |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
342 }); |
b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3352
diff
changeset
|
343 }); |
3368
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
344 }, |
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
345 loadAvailableFairwayDepthLNWLDiagram: ({ commit, dispatch }, options) => { |
3451 | 346 dispatch("loadAvailableFairwayDepthLNWL", options).then(response => { |
347 commit("setCSV", response); | |
3368
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
348 //const data = response; |
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
349 let data = LNWLDIAGRAMMOCKDATA; |
3388
1876b204b004
afdLNWL: fix display
Thomas Junk <thomas.junk@intevation.de>
parents:
3381
diff
changeset
|
350 data["lnwl"] = data["lnwl"].filter(v => v.level !== "HDC"); |
1876b204b004
afdLNWL: fix display
Thomas Junk <thomas.junk@intevation.de>
parents:
3381
diff
changeset
|
351 data["afd"] = data.afd.reverse(); |
3368
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
352 Object.keys(data).forEach(diagramComponent => { |
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
353 let sum = 0; |
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
354 data[diagramComponent].map(elem => { |
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
355 elem["translateY"] = Number(elem["percent"]) + sum; |
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
356 sum += Number(elem["percent"]); |
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
357 return elem; |
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
358 }); |
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
359 }); |
3451 | 360 // transformAFDLNWL |
3368
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
361 commit("setFwLNWLData", data); |
70605404f37d
fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3366
diff
changeset
|
362 }); |
3457
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
363 }, |
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
364 loadAvailableFairwayDepthLNWLForMap: ({ dispatch }, options) => { |
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
365 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
|
366 response => { |
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
367 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
|
368 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
|
369 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
|
370 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
|
371 return { |
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
372 ldc: columns[2], |
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
373 below: columns[3], |
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
374 between: columns[4], |
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
375 above: columns[5] |
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
376 }; |
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
377 }); |
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
378 return data[0]; |
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
379 } |
870812d8f247
client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents:
3453
diff
changeset
|
380 ); |
3207
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
381 } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
382 } |
ba7bc3740fb3
client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
383 }; |
3325
496cf0474e29
fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents:
3299
diff
changeset
|
384 |
3397
3675c60afd4f
afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents:
3388
diff
changeset
|
385 export { LIMITINGFACTORS, FREQUENCIES, fairwayavailability }; |