comparison 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
comparison
equal deleted inserted replaced
3471:48d09fb1d6c7 3472:71022e6bd98e
1 /* This is Free Software under GNU Affero General Public License v >= 3.0
2 * without warranty, see README.md and license for details.
3 *
4 * SPDX-License-Identifier: AGPL-3.0-or-later
5 * License-Filename: LICENSES/AGPL-3.0.txt
6 *
7 * Copyright (C) 2018 by via donau
8 * – Österreichische Wasserstraßen-Gesellschaft mbH
9 * Software engineering by Intevation GmbH
10 *
11 * Author(s):
12 * Raimund Renkert <raimund.renkert@intevation.de>
13 */
14
15 export default {
16 surveyCurrency(bottleneck) {
17 if (
18 bottleneck.get("revisiting_time") === null ||
19 bottleneck.get("revisiting_time") === 0
20 ) {
21 return "white";
22 }
23 if (bottleneck.get("date_max") === null) {
24 return "red";
25 }
26 let revTime = bottleneck.get("revisiting_time") * 30.5;
27 let latest = Date.parse(bottleneck.get("date_max").replace("Z", ""));
28 var diff = Math.floor((Date.now() - latest) / 86400000);
29 if (diff <= revTime) {
30 return "lime";
31 } else if (revTime < diff && diff <= revTime * 1.5) {
32 return "yellow";
33 } else if (revTime * 1.5 < diff) {
34 return "red";
35 }
36 },
37 forecastAccuracy(gauge) {
38 let fa3d = gauge.get("forecast_accuracy_3d");
39 let fa1d = gauge.get("forecast_accuracy_1d");
40 if (typeof fa3d == "number" && typeof fa1d == "number") {
41 if (fa1d > 15) {
42 return "red";
43 } else if (fa3d > 15) {
44 return "yellow";
45 } else {
46 return "lime";
47 }
48 }
49 return "white";
50 }
51 };