Mercurial > gemma
annotate client/src/lib/classifications.js @ 3497:1457e2b9d900
Set threshold for green gauge data availability to 85%.
The SRS reads like 100%, but that seems unrealistic and the threshold
shall be configurable anyway. In the meantime 85% makes things look
nicer...
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Mon, 27 May 2019 18:45:20 +0200 |
parents | 965b2fbb1890 |
children | 4d44eda484dd |
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 }, |
3480
965b2fbb1890
Colorize gauge symbol based on availability of measurements
Tom Gottfried <tom@intevation.de>
parents:
3472
diff
changeset
|
37 gmAvailability(gauge) { |
965b2fbb1890
Colorize gauge symbol based on availability of measurements
Tom Gottfried <tom@intevation.de>
parents:
3472
diff
changeset
|
38 let gmDate = gauge.get("gm_measuredate"); |
965b2fbb1890
Colorize gauge symbol based on availability of measurements
Tom Gottfried <tom@intevation.de>
parents:
3472
diff
changeset
|
39 let gmN = gauge.get("gm_n_14d"); |
965b2fbb1890
Colorize gauge symbol based on availability of measurements
Tom Gottfried <tom@intevation.de>
parents:
3472
diff
changeset
|
40 if ( |
965b2fbb1890
Colorize gauge symbol based on availability of measurements
Tom Gottfried <tom@intevation.de>
parents:
3472
diff
changeset
|
41 gmDate !== undefined && |
965b2fbb1890
Colorize gauge symbol based on availability of measurements
Tom Gottfried <tom@intevation.de>
parents:
3472
diff
changeset
|
42 gmDate !== null && |
965b2fbb1890
Colorize gauge symbol based on availability of measurements
Tom Gottfried <tom@intevation.de>
parents:
3472
diff
changeset
|
43 Date.parse(gmDate) > Date.now() - 86400000 // latest value within 24 h |
965b2fbb1890
Colorize gauge symbol based on availability of measurements
Tom Gottfried <tom@intevation.de>
parents:
3472
diff
changeset
|
44 ) { |
965b2fbb1890
Colorize gauge symbol based on availability of measurements
Tom Gottfried <tom@intevation.de>
parents:
3472
diff
changeset
|
45 if ( |
965b2fbb1890
Colorize gauge symbol based on availability of measurements
Tom Gottfried <tom@intevation.de>
parents:
3472
diff
changeset
|
46 gmN !== undefined && |
965b2fbb1890
Colorize gauge symbol based on availability of measurements
Tom Gottfried <tom@intevation.de>
parents:
3472
diff
changeset
|
47 gmN !== null && |
3497
1457e2b9d900
Set threshold for green gauge data availability to 85%.
Sascha Wilde <wilde@intevation.de>
parents:
3480
diff
changeset
|
48 gmN >= 1124 // 1344: one value every 15 min in 14 days, but the Hydra says: |
1457e2b9d900
Set threshold for green gauge data availability to 85%.
Sascha Wilde <wilde@intevation.de>
parents:
3480
diff
changeset
|
49 // let 85% be enough for now. |
3480
965b2fbb1890
Colorize gauge symbol based on availability of measurements
Tom Gottfried <tom@intevation.de>
parents:
3472
diff
changeset
|
50 ) { |
965b2fbb1890
Colorize gauge symbol based on availability of measurements
Tom Gottfried <tom@intevation.de>
parents:
3472
diff
changeset
|
51 return "lime"; |
965b2fbb1890
Colorize gauge symbol based on availability of measurements
Tom Gottfried <tom@intevation.de>
parents:
3472
diff
changeset
|
52 } |
965b2fbb1890
Colorize gauge symbol based on availability of measurements
Tom Gottfried <tom@intevation.de>
parents:
3472
diff
changeset
|
53 return "yellow"; |
965b2fbb1890
Colorize gauge symbol based on availability of measurements
Tom Gottfried <tom@intevation.de>
parents:
3472
diff
changeset
|
54 } |
965b2fbb1890
Colorize gauge symbol based on availability of measurements
Tom Gottfried <tom@intevation.de>
parents:
3472
diff
changeset
|
55 return "red"; |
965b2fbb1890
Colorize gauge symbol based on availability of measurements
Tom Gottfried <tom@intevation.de>
parents:
3472
diff
changeset
|
56 }, |
3472
71022e6bd98e
client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 forecastAccuracy(gauge) { |
71022e6bd98e
client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 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
|
59 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
|
60 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
|
61 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
|
62 return "red"; |
71022e6bd98e
client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 } 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
|
64 return "yellow"; |
71022e6bd98e
client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 } else { |
71022e6bd98e
client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 return "lime"; |
71022e6bd98e
client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 } |
71022e6bd98e
client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
68 } |
71022e6bd98e
client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 return "white"; |
71022e6bd98e
client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 } |
71022e6bd98e
client: Use classifications for bottleneck diagrams on map and extracted classification algos
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 }; |