annotate client/src/store/fairwayavailability.js @ 3704:271683dee9bf

client: fairway availability diaglog: set correct type when opened from map popup
author Markus Kottlaender <markus@intevation.de>
date Wed, 19 Jun 2019 16:15:42 +0200
parents 3d273d76a963
children aee74a3a17f3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
3397
3675c60afd4f afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents: 3388
diff changeset
29 const LIMITINGFACTORS = {
3675c60afd4f afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents: 3388
diff changeset
30 WIDTH: "width",
3675c60afd4f afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents: 3388
diff changeset
31 DEPTH: "depth"
3675c60afd4f afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents: 3388
diff changeset
32 };
3675c60afd4f afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents: 3388
diff changeset
33
3407
7ea54c3b3fd6 afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents: 3397
diff changeset
34 const TYPES = {
3486
1fbb6dc7d362 fairwayavailability: refactor constants
Thomas Junk <thomas.junk@intevation.de>
parents: 3477
diff changeset
35 BOTTLENECK: "bottleneck",
1fbb6dc7d362 fairwayavailability: refactor constants
Thomas Junk <thomas.junk@intevation.de>
parents: 3477
diff changeset
36 SECTION: "section",
1fbb6dc7d362 fairwayavailability: refactor constants
Thomas Junk <thomas.junk@intevation.de>
parents: 3477
diff changeset
37 STRETCH: "stretch"
3407
7ea54c3b3fd6 afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents: 3397
diff changeset
38 };
7ea54c3b3fd6 afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents: 3397
diff changeset
39
3325
496cf0474e29 fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents: 3299
diff changeset
40 const FREQUENCIES = {
496cf0474e29 fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents: 3299
diff changeset
41 MONTHLY: "monthly",
496cf0474e29 fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents: 3299
diff changeset
42 QUARTERLY: "quarterly",
496cf0474e29 fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents: 3299
diff changeset
43 YEARLY: "yearly"
496cf0474e29 fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents: 3299
diff changeset
44 };
496cf0474e29 fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents: 3299
diff changeset
45
3499
3d273d76a963 afd cosmetics
Thomas Junk <thomas.junk@intevation.de>
parents: 3490
diff changeset
46 const isoFormat = date => {
3d273d76a963 afd cosmetics
Thomas Junk <thomas.junk@intevation.de>
parents: 3490
diff changeset
47 return format(date, "YYYY-MM-DD");
3d273d76a963 afd cosmetics
Thomas Junk <thomas.junk@intevation.de>
parents: 3490
diff changeset
48 };
3d273d76a963 afd cosmetics
Thomas Junk <thomas.junk@intevation.de>
parents: 3490
diff changeset
49
3376
70b7078b4516 available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents: 3368
diff changeset
50 const getIntervallBorders = (start, end, frequency) => {
70b7078b4516 available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents: 3368
diff changeset
51 switch (frequency) {
70b7078b4516 available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents: 3368
diff changeset
52 case FREQUENCIES.MONTHLY:
3499
3d273d76a963 afd cosmetics
Thomas Junk <thomas.junk@intevation.de>
parents: 3490
diff changeset
53 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
54 case FREQUENCIES.YEARLY:
3499
3d273d76a963 afd cosmetics
Thomas Junk <thomas.junk@intevation.de>
parents: 3490
diff changeset
55 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
56 case FREQUENCIES.QUARTERLY:
3499
3d273d76a963 afd cosmetics
Thomas Junk <thomas.junk@intevation.de>
parents: 3490
diff changeset
57 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
58 default:
70b7078b4516 available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents: 3368
diff changeset
59 throw new Error("Boom!");
70b7078b4516 available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents: 3368
diff changeset
60 }
70b7078b4516 available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents: 3368
diff changeset
61 };
70b7078b4516 available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents: 3368
diff changeset
62
3207
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
63 const init = () => {
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
64 return {
3486
1fbb6dc7d362 fairwayavailability: refactor constants
Thomas Junk <thomas.junk@intevation.de>
parents: 3477
diff changeset
65 type: TYPES.BOTTLENECK,
3207
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
66 selectedFairwayAvailabilityFeature: null,
3499
3d273d76a963 afd cosmetics
Thomas Junk <thomas.junk@intevation.de>
parents: 3490
diff changeset
67 to: isoFormat(new Date()),
3d273d76a963 afd cosmetics
Thomas Junk <thomas.junk@intevation.de>
parents: 3490
diff changeset
68 from: isoFormat(subYears(new Date(), 1)),
3325
496cf0474e29 fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents: 3299
diff changeset
69 frequency: FREQUENCIES.MONTHLY,
3397
3675c60afd4f afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents: 3388
diff changeset
70 limitingFactor: null,
3499
3d273d76a963 afd cosmetics
Thomas Junk <thomas.junk@intevation.de>
parents: 3490
diff changeset
71 depthlimit1: 230,
3d273d76a963 afd cosmetics
Thomas Junk <thomas.junk@intevation.de>
parents: 3490
diff changeset
72 depthlimit2: 250,
3397
3675c60afd4f afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents: 3388
diff changeset
73 widthlimit1: null,
3675c60afd4f afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents: 3388
diff changeset
74 widthlimit2: null,
3437
6a044d6c2cdc afd: csv download
Thomas Junk <thomas.junk@intevation.de>
parents: 3411
diff changeset
75 csv: null,
3207
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
76 fwData: null,
3299
ef52926ce2fc available_fairwaydepth_vs_lnwl: Scales adjusted
Thomas Junk <thomas.junk@intevation.de>
parents: 3288
diff changeset
77 fwLNWLData: null,
3353
b01bf2399c20 client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents: 3352
diff changeset
78 fwLNWLOverviewData: [],
3366
8974efd71917 fa_LNWL: cleanup
Thomas Junk <thomas.junk@intevation.de>
parents: 3355
diff changeset
79 legendLNWL: null,
3207
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
80 legend: null,
3288
c2d753ef5aa1 fairway_availability: sane defaults and ISC colors for diagram
Thomas Junk <thomas.junk@intevation.de>
parents: 3215
diff changeset
81 LOS: 3
3207
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
82 };
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
83 };
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
84
3438
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
85 /**
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
86 * transformAFD
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
87 * @param {string} csv
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
88 *
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
89 * takes the afd csv and transforms it to an intermediary format
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
90 * for display of diagrams
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
91 *
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
92 * Incoming csv Format
3449
654f5e2d94cf afd: new format adapted
Thomas Junk <thomas.junk@intevation.de>
parents: 3438
diff changeset
93 * #label,# <LDC ,# >= LDC [h],# < 230.00 [h],# >= 230.00 [h],# >= 250.00 [h]
3438
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
94 * 05-2019,215.500,0.000,0.000,215.500
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
95 *
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
96 * Format:
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
97 * $LABEL, $LDC, $BELOWLIMIT1, $BETWEENLIMIT12, $ABOVELIMIT2^
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
98 *
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
99 * This format is assumed to be fix
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
100 *
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
101 */
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
102 const transformAFD = csv => {
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
103 return csv.map(e => {
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
104 const result = e.split(",");
3449
654f5e2d94cf afd: new format adapted
Thomas Junk <thomas.junk@intevation.de>
parents: 3438
diff changeset
105 let [label, _, ldc, lower, middle, highestLevel] = result;
3438
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
106 let levelsWithSum = [
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
107 {
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
108 height: Number(lower),
3453
41349a9c8ce9 diagram fix
Thomas Junk <thomas.junk@intevation.de>
parents: 3451
diff changeset
109 translateY: Number(middle)
3438
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
110 },
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
111 {
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
112 height: Number(middle),
3453
41349a9c8ce9 diagram fix
Thomas Junk <thomas.junk@intevation.de>
parents: 3451
diff changeset
113 translateY: 0
3438
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
114 }
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 return {
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
117 label: label,
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
118 ldc: ldc,
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
119 highestLevel: highestLevel,
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
120 lowerLevels: levelsWithSum
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
121 };
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
122 });
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
123 };
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
124
3325
496cf0474e29 fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents: 3299
diff changeset
125 const fairwayavailability = {
3207
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
126 init,
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
127 namespaced: true,
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
128 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
129 getters: {
b01bf2399c20 client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents: 3352
diff changeset
130 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
131 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
132 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
133 );
b01bf2399c20 client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents: 3352
diff changeset
134 }
b01bf2399c20 client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents: 3352
diff changeset
135 },
3207
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
136 mutations: {
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
137 type: (state, type) => {
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
138 state.type = type;
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
139 },
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
140 setLOS: (state, LOS) => {
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
141 state.LOS = LOS;
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
142 },
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
143 setFrequency: (state, frequency) => {
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
144 state.frequency = frequency;
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
145 },
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
146 setFrom: (state, from) => {
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
147 state.from = from;
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
148 },
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
149 setTo: (state, to) => {
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
150 state.to = to;
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
151 },
3352
399a2eb496ee available_fairway_depth_dialogue: adding limit fields. without transmission
Thomas Junk <thomas.junk@intevation.de>
parents: 3351
diff changeset
152 setDepthlimit1: (state, depthlimit1) => {
399a2eb496ee available_fairway_depth_dialogue: adding limit fields. without transmission
Thomas Junk <thomas.junk@intevation.de>
parents: 3351
diff changeset
153 state.depthlimit1 = depthlimit1;
399a2eb496ee available_fairway_depth_dialogue: adding limit fields. without transmission
Thomas Junk <thomas.junk@intevation.de>
parents: 3351
diff changeset
154 },
399a2eb496ee available_fairway_depth_dialogue: adding limit fields. without transmission
Thomas Junk <thomas.junk@intevation.de>
parents: 3351
diff changeset
155 setDepthlimit2: (state, depthlimit2) => {
399a2eb496ee available_fairway_depth_dialogue: adding limit fields. without transmission
Thomas Junk <thomas.junk@intevation.de>
parents: 3351
diff changeset
156 state.depthlimit2 = depthlimit2;
399a2eb496ee available_fairway_depth_dialogue: adding limit fields. without transmission
Thomas Junk <thomas.junk@intevation.de>
parents: 3351
diff changeset
157 },
3397
3675c60afd4f afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents: 3388
diff changeset
158 setWidthlimit1: (state, widthlimit1) => {
3675c60afd4f afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents: 3388
diff changeset
159 state.widthlimit1 = widthlimit1;
3354
e12e8bf044a6 available_fairway_dialogue: added 2nd breadthelement
Thomas Junk <thomas.junk@intevation.de>
parents: 3352
diff changeset
160 },
3397
3675c60afd4f afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents: 3388
diff changeset
161 setWidthlimit2: (state, widthlimit2) => {
3675c60afd4f afd: breadth->width
Thomas Junk <thomas.junk@intevation.de>
parents: 3388
diff changeset
162 state.widthlimit2 = widthlimit2;
3352
399a2eb496ee available_fairway_depth_dialogue: adding limit fields. without transmission
Thomas Junk <thomas.junk@intevation.de>
parents: 3351
diff changeset
163 },
3207
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
164 setSelectedFairwayAvailability: (state, feature) => {
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
165 state.selectedFairwayAvailabilityFeature = feature;
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
166 },
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
167 setFwData: (state, fwData) => {
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
168 state.fwData = fwData;
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
169 },
3368
70605404f37d fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents: 3366
diff changeset
170 setFwLNWLData: (state, fwLNWLData) => {
70605404f37d fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents: 3366
diff changeset
171 state.fwLNWLData = fwLNWLData;
70605404f37d fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents: 3366
diff changeset
172 },
3437
6a044d6c2cdc afd: csv download
Thomas Junk <thomas.junk@intevation.de>
parents: 3411
diff changeset
173 setCSV: (state, csv) => {
6a044d6c2cdc afd: csv download
Thomas Junk <thomas.junk@intevation.de>
parents: 3411
diff changeset
174 state.csv = csv;
6a044d6c2cdc afd: csv download
Thomas Junk <thomas.junk@intevation.de>
parents: 3411
diff changeset
175 },
3353
b01bf2399c20 client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents: 3352
diff changeset
176 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
177 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
178 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
179 );
b01bf2399c20 client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents: 3352
diff changeset
180 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
181 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
182 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
183 },
3207
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
184 setLegend: (state, header) => {
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
185 const headerEntries = header.split(",");
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
186 headerEntries.shift();
3453
41349a9c8ce9 diagram fix
Thomas Junk <thomas.junk@intevation.de>
parents: 3451
diff changeset
187 headerEntries.shift();
3207
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
188 state.legend = headerEntries.map(x => {
3326
98ce6d101e01 available_fairway_depth: omit unit
Thomas Junk <thomas.junk@intevation.de>
parents: 3325
diff changeset
189 let entry = x.split("#")[1]; // split leading #
98ce6d101e01 available_fairway_depth: omit unit
Thomas Junk <thomas.junk@intevation.de>
parents: 3325
diff changeset
190 entry = entry.replace("[h]", "").trim(); // omit unit
98ce6d101e01 available_fairway_depth: omit unit
Thomas Junk <thomas.junk@intevation.de>
parents: 3325
diff changeset
191 return entry;
3207
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
192 });
3366
8974efd71917 fa_LNWL: cleanup
Thomas Junk <thomas.junk@intevation.de>
parents: 3355
diff changeset
193 },
8974efd71917 fa_LNWL: cleanup
Thomas Junk <thomas.junk@intevation.de>
parents: 3355
diff changeset
194 setLegendLNWL: (state, headerLNWL) => {
8974efd71917 fa_LNWL: cleanup
Thomas Junk <thomas.junk@intevation.de>
parents: 3355
diff changeset
195 this.headerLNWL = headerLNWL;
3207
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
196 }
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
197 },
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
198 actions: {
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
199 loadAvailableFairwayDepth: ({ commit }, options) => {
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
200 return new Promise((resolve, reject) => {
3407
7ea54c3b3fd6 afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents: 3397
diff changeset
201 const {
7ea54c3b3fd6 afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents: 3397
diff changeset
202 feature,
7ea54c3b3fd6 afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents: 3397
diff changeset
203 frequency,
7ea54c3b3fd6 afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents: 3397
diff changeset
204 LOS,
7ea54c3b3fd6 afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents: 3397
diff changeset
205 depthLimit1,
7ea54c3b3fd6 afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents: 3397
diff changeset
206 depthLimit2,
7ea54c3b3fd6 afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents: 3397
diff changeset
207 widthLimit1,
7ea54c3b3fd6 afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents: 3397
diff changeset
208 widthLimit2,
7ea54c3b3fd6 afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents: 3397
diff changeset
209 limitingFactor,
7ea54c3b3fd6 afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents: 3397
diff changeset
210 type
7ea54c3b3fd6 afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents: 3397
diff changeset
211 } = options;
3376
70b7078b4516 available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents: 3368
diff changeset
212 let { from, to } = options;
3477
4eefeeae03fc client: fixed feature type check for production build
Markus Kottlaender <markus@intevation.de>
parents: 3465
diff changeset
213 let name = feature.hasOwnProperty("properties")
4eefeeae03fc client: fixed feature type check for production build
Markus Kottlaender <markus@intevation.de>
parents: 3465
diff changeset
214 ? feature.properties.name
4eefeeae03fc client: fixed feature type check for production build
Markus Kottlaender <markus@intevation.de>
parents: 3465
diff changeset
215 : feature.get("objnam");
3376
70b7078b4516 available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents: 3368
diff changeset
216 [from, to] = getIntervallBorders(from, to, frequency);
3407
7ea54c3b3fd6 afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents: 3397
diff changeset
217 let additionalParams = "";
3490
624c64670d48 fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents: 3486
diff changeset
218 let endpoint = type;
624c64670d48 fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents: 3486
diff changeset
219 if (type === TYPES.BOTTLENECK) {
624c64670d48 fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents: 3486
diff changeset
220 if (limitingFactor === LIMITINGFACTORS.DEPTH)
624c64670d48 fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents: 3486
diff changeset
221 additionalParams = `&breaks=${depthLimit1},${depthLimit2}`;
624c64670d48 fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents: 3486
diff changeset
222 if (limitingFactor === LIMITINGFACTORS.WIDTH)
624c64670d48 fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents: 3486
diff changeset
223 additionalParams = `&breaks=${widthLimit1},${widthLimit2}`;
624c64670d48 fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents: 3486
diff changeset
224 } 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
225 additionalParams = `&depthbreaks=${depthLimit1},${depthLimit2}&widthbreaks=${widthLimit1},${widthLimit2}`;
3407
7ea54c3b3fd6 afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents: 3397
diff changeset
226 }
3207
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
227 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
228 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
229 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
230 name
3407
7ea54c3b3fd6 afd: breaks for bottlenecks
Thomas Junk <thomas.junk@intevation.de>
parents: 3397
diff changeset
231 )}?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
232 HTTP.get(URL, {
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
233 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
234 })
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
235 .then(response => {
3351
dcae9b3e864b available_fairway_depths: remove mocks
Thomas Junk <thomas.junk@intevation.de>
parents: 3347
diff changeset
236 const { data } = response;
3437
6a044d6c2cdc afd: csv download
Thomas Junk <thomas.junk@intevation.de>
parents: 3411
diff changeset
237 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
238 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
239 commit("setLegend", csv.shift());
3438
df6c2973f791 New parsing of incoming afdcsv
Thomas Junk <thomas.junk@intevation.de>
parents: 3437
diff changeset
240 let transformed = transformAFD(csv);
3207
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
241 commit("setFwData", transformed);
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
242 resolve(response);
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
243 })
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
244 .catch(error => {
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
245 reject(error);
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 });
3353
b01bf2399c20 client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents: 3352
diff changeset
248 },
3451
Thomas Junk <thomas.junk@intevation.de>
parents: 3449
diff changeset
249 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
250 return new Promise((resolve, reject) => {
3463
6f4dad7473d7 afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents: 3461
diff changeset
251 const {
6f4dad7473d7 afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents: 3461
diff changeset
252 feature,
6f4dad7473d7 afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents: 3461
diff changeset
253 frequency,
6f4dad7473d7 afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents: 3461
diff changeset
254 LOS,
6f4dad7473d7 afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents: 3461
diff changeset
255 depthLimit1,
6f4dad7473d7 afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents: 3461
diff changeset
256 depthLimit2,
6f4dad7473d7 afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents: 3461
diff changeset
257 widthLimit1,
6f4dad7473d7 afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents: 3461
diff changeset
258 widthLimit2,
6f4dad7473d7 afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents: 3461
diff changeset
259 limitingFactor,
6f4dad7473d7 afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents: 3461
diff changeset
260 type
6f4dad7473d7 afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents: 3461
diff changeset
261 } = options;
3376
70b7078b4516 available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents: 3368
diff changeset
262 let { from, to } = options;
3477
4eefeeae03fc client: fixed feature type check for production build
Markus Kottlaender <markus@intevation.de>
parents: 3465
diff changeset
263 let name = feature.hasOwnProperty("properties")
4eefeeae03fc client: fixed feature type check for production build
Markus Kottlaender <markus@intevation.de>
parents: 3465
diff changeset
264 ? feature.properties.name
4eefeeae03fc client: fixed feature type check for production build
Markus Kottlaender <markus@intevation.de>
parents: 3465
diff changeset
265 : feature.get("objnam");
3376
70b7078b4516 available_fairway_depth: determine intervall borders for dates
Thomas Junk <thomas.junk@intevation.de>
parents: 3368
diff changeset
266 [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
267 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
268 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
269 let additionalParams = "";
3490
624c64670d48 fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents: 3486
diff changeset
270 let endpoint = type || TYPES.BOTTLENECK;
624c64670d48 fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents: 3486
diff changeset
271 if (type === TYPES.BOTTLENECK) {
624c64670d48 fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents: 3486
diff changeset
272 if (limitingFactor === LIMITINGFACTORS.DEPTH)
624c64670d48 fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents: 3486
diff changeset
273 additionalParams = `&breaks=${depthLimit1},${depthLimit2}`;
624c64670d48 fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents: 3486
diff changeset
274 if (limitingFactor === LIMITINGFACTORS.WIDTH)
624c64670d48 fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents: 3486
diff changeset
275 additionalParams = `&breaks=${widthLimit1},${widthLimit2}`;
624c64670d48 fairwayavailability: omit switch statement and streamline endpointselection
Thomas Junk <thomas.junk@intevation.de>
parents: 3486
diff changeset
276 } 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
277 additionalParams = `&depthbreaks=${depthLimit1},${depthLimit2}&widthbreaks=${widthLimit1},${widthLimit2}`;
3463
6f4dad7473d7 afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents: 3461
diff changeset
278 }
6f4dad7473d7 afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents: 3461
diff changeset
279 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
280 name
3463
6f4dad7473d7 afdLNWL: basical usage of classbreaks
Thomas Junk <thomas.junk@intevation.de>
parents: 3461
diff changeset
281 )}?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
282 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
283 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
284 })
b01bf2399c20 client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents: 3352
diff changeset
285 .then(response => {
3437
6a044d6c2cdc afd: csv download
Thomas Junk <thomas.junk@intevation.de>
parents: 3411
diff changeset
286 const { data } = response;
6a044d6c2cdc afd: csv download
Thomas Junk <thomas.junk@intevation.de>
parents: 3411
diff changeset
287 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
288 })
b01bf2399c20 client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents: 3352
diff changeset
289 .catch(error => {
b01bf2399c20 client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents: 3352
diff changeset
290 reject(error);
b01bf2399c20 client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents: 3352
diff changeset
291 });
b01bf2399c20 client: available fairway depth vs lnwl: fetching data for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents: 3352
diff changeset
292 });
3368
70605404f37d fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents: 3366
diff changeset
293 },
70605404f37d fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents: 3366
diff changeset
294 loadAvailableFairwayDepthLNWLDiagram: ({ commit, dispatch }, options) => {
3451
Thomas Junk <thomas.junk@intevation.de>
parents: 3449
diff changeset
295 dispatch("loadAvailableFairwayDepthLNWL", options).then(response => {
Thomas Junk <thomas.junk@intevation.de>
parents: 3449
diff changeset
296 commit("setCSV", response);
3461
b43cf476d791 client: spuc05: implemented new data structure (CSV) and added support for multiple charts
Markus Kottlaender <markus@intevation.de>
parents: 3457
diff changeset
297 let data = response.split("\n").filter(d => d);
b43cf476d791 client: spuc05: implemented new data structure (CSV) and added support for multiple charts
Markus Kottlaender <markus@intevation.de>
parents: 3457
diff changeset
298 data.shift(); // remove header line
b43cf476d791 client: spuc05: implemented new data structure (CSV) and added support for multiple charts
Markus Kottlaender <markus@intevation.de>
parents: 3457
diff changeset
299 data = data.map(d => {
b43cf476d791 client: spuc05: implemented new data structure (CSV) and added support for multiple charts
Markus Kottlaender <markus@intevation.de>
parents: 3457
diff changeset
300 let columns = d.split(",");
b43cf476d791 client: spuc05: implemented new data structure (CSV) and added support for multiple charts
Markus Kottlaender <markus@intevation.de>
parents: 3457
diff changeset
301 return {
b43cf476d791 client: spuc05: implemented new data structure (CSV) and added support for multiple charts
Markus Kottlaender <markus@intevation.de>
parents: 3457
diff changeset
302 date: columns[0],
b43cf476d791 client: spuc05: implemented new data structure (CSV) and added support for multiple charts
Markus Kottlaender <markus@intevation.de>
parents: 3457
diff changeset
303 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
304 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
305 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
306 above: Number(columns[5])
b43cf476d791 client: spuc05: implemented new data structure (CSV) and added support for multiple charts
Markus Kottlaender <markus@intevation.de>
parents: 3457
diff changeset
307 };
3368
70605404f37d fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents: 3366
diff changeset
308 });
70605404f37d fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents: 3366
diff changeset
309 commit("setFwLNWLData", data);
3461
b43cf476d791 client: spuc05: implemented new data structure (CSV) and added support for multiple charts
Markus Kottlaender <markus@intevation.de>
parents: 3457
diff changeset
310 return data;
3368
70605404f37d fa_lnwl: prototypical diagram added
Thomas Junk <thomas.junk@intevation.de>
parents: 3366
diff changeset
311 });
3457
870812d8f247 client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents: 3453
diff changeset
312 },
870812d8f247 client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents: 3453
diff changeset
313 loadAvailableFairwayDepthLNWLForMap: ({ dispatch }, options) => {
870812d8f247 client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents: 3453
diff changeset
314 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
315 response => {
870812d8f247 client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents: 3453
diff changeset
316 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
317 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
318 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
319 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
320 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
321 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
322 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
323 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
324 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
325 };
870812d8f247 client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents: 3453
diff changeset
326 });
870812d8f247 client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents: 3453
diff changeset
327 return data[0];
870812d8f247 client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents: 3453
diff changeset
328 }
870812d8f247 client: spuc05: implemented new data format (csv) for diagrams on map
Markus Kottlaender <markus@intevation.de>
parents: 3453
diff changeset
329 );
3207
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
330 }
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
331 }
ba7bc3740fb3 client: renamed store modules to better reflect their context
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
332 };
3325
496cf0474e29 fairway_availability_dialogue: extracted frequencies
Thomas Junk <thomas.junk@intevation.de>
parents: 3299
diff changeset
333
3704
271683dee9bf client: fairway availability diaglog: set correct type when opened from map popup
Markus Kottlaender <markus@intevation.de>
parents: 3499
diff changeset
334 export { LIMITINGFACTORS, FREQUENCIES, TYPES, fairwayavailability };