annotate client/src/lib/classifications.js @ 3472:71022e6bd98e

client: Use classifications for bottleneck diagrams on map and extracted classification algos
author Raimund Renkert <raimund.renkert@intevation.de>
date Mon, 27 May 2019 12:09:13 +0200
parents
children 965b2fbb1890
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3472
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 /* This is Free Software under GNU Affero General Public License v >= 3.0
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
2 * without warranty, see README.md and license for details.
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
3 *
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
4 * SPDX-License-Identifier: AGPL-3.0-or-later
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
5 * License-Filename: LICENSES/AGPL-3.0.txt
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
6 *
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
7 * Copyright (C) 2018 by via donau
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8 * – Österreichische Wasserstraßen-Gesellschaft mbH
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
9 * Software engineering by Intevation GmbH
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
10 *
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11 * Author(s):
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12 * Raimund Renkert <raimund.renkert@intevation.de>
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
13 */
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
15 export default {
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
16 surveyCurrency(bottleneck) {
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
17 if (
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18 bottleneck.get("revisiting_time") === null ||
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19 bottleneck.get("revisiting_time") === 0
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20 ) {
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21 return "white";
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22 }
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 if (bottleneck.get("date_max") === null) {
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 return "red";
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 }
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26 let revTime = bottleneck.get("revisiting_time") * 30.5;
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27 let latest = Date.parse(bottleneck.get("date_max").replace("Z", ""));
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 var diff = Math.floor((Date.now() - latest) / 86400000);
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 if (diff <= revTime) {
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30 return "lime";
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31 } else if (revTime < diff && diff <= revTime * 1.5) {
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 return "yellow";
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33 } else if (revTime * 1.5 < diff) {
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34 return "red";
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35 }
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36 },
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37 forecastAccuracy(gauge) {
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
38 let fa3d = gauge.get("forecast_accuracy_3d");
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39 let fa1d = gauge.get("forecast_accuracy_1d");
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40 if (typeof fa3d == "number" && typeof fa1d == "number") {
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
41 if (fa1d > 15) {
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42 return "red";
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 } else if (fa3d > 15) {
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 return "yellow";
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45 } else {
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
46 return "lime";
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
47 }
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
48 }
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
49 return "white";
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
50 }
71022e6bd98e client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 };