Mercurial > gemma
annotate client/src/store/gauges.js @ 5521:3cfbc5769e8b
Make invalid output of ISRSrange_area() less likely
Since ST_Transform() might produce an invalid polygon, add an extra
ST_MakeValid().
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 21 Oct 2021 20:20:30 +0200 |
parents | de86a96d55c3 |
children |
rev | line source |
---|---|
2590
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
1 /* This is Free Software under GNU Affero General Public License v >= 3.0 |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
2 * without warranty, see README.md and license for details. |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
3 * |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
4 * SPDX-License-Identifier: AGPL-3.0-or-later |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
5 * License-Filename: LICENSES/AGPL-3.0.txt |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
6 * |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
7 * Copyright (C) 2018 by via donau |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
8 * – Österreichische Wasserstraßen-Gesellschaft mbH |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
9 * Software engineering by Intevation GmbH |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
10 * |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
11 * Author(s): |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
12 * Markus Kottländer <markus@intevation.de> |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
13 */ |
4291
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
14 import Vue from "vue"; |
2596
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
15 import { HTTP } from "@/lib/http"; |
2985
1b8bb4f89227
client: removed .js and .vue extention from imports
Markus Kottlaender <markus@intevation.de>
parents:
2830
diff
changeset
|
16 import { WFS } from "ol/format"; |
4291
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
17 import { |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
18 isPast, |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
19 startOfDay, |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
20 endOfDay, |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
21 format, |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
22 isBefore, |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
23 addMinutes |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
24 } from "date-fns"; |
2590
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
25 |
2710
f393fabfdd35
client: waterlevel diagram: chart extent based on selected dates instead of data
Markus Kottlaender <markus@intevation.de>
parents:
2701
diff
changeset
|
26 let dateFrom = new Date(); |
f393fabfdd35
client: waterlevel diagram: chart extent based on selected dates instead of data
Markus Kottlaender <markus@intevation.de>
parents:
2701
diff
changeset
|
27 dateFrom.setDate(dateFrom.getDate() - 30); |
2775
2feb9f8f6c66
client: waterlevel diagram: implemented display of forecast data
Markus Kottlaender <markus@intevation.de>
parents:
2764
diff
changeset
|
28 let dateTo = new Date(); |
2feb9f8f6c66
client: waterlevel diagram: implemented display of forecast data
Markus Kottlaender <markus@intevation.de>
parents:
2764
diff
changeset
|
29 dateTo.setDate(dateTo.getDate() + 3); |
2710
f393fabfdd35
client: waterlevel diagram: chart extent based on selected dates instead of data
Markus Kottlaender <markus@intevation.de>
parents:
2701
diff
changeset
|
30 |
2590
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
31 const init = () => { |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
32 return { |
2596
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
33 gauges: [], |
2643
27933e66e848
client: gauges: use isrs_code as unique id for gauges
Markus Kottlaender <markus@intevation.de>
parents:
2604
diff
changeset
|
34 selectedGaugeISRS: null, |
2710
f393fabfdd35
client: waterlevel diagram: chart extent based on selected dates instead of data
Markus Kottlaender <markus@intevation.de>
parents:
2701
diff
changeset
|
35 waterlevels: [], |
3403
d7cc5cda82a9
client: waterlevel diagrams: implemented csv export
Markus Kottlaender <markus@intevation.de>
parents:
3152
diff
changeset
|
36 waterlevelsCSV: "", |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
37 longtermWaterlevels: [], |
2830
0632d543a427
client: spuc7/8: show time periods in diagram titles
Markus Kottlaender <markus@intevation.de>
parents:
2829
diff
changeset
|
38 longtermInterval: [], |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
39 yearWaterlevels: [], |
2751
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
40 nashSutcliffe: null, |
4291
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
41 nashSutcliffeCache: {}, |
2710
f393fabfdd35
client: waterlevel diagram: chart extent based on selected dates instead of data
Markus Kottlaender <markus@intevation.de>
parents:
2701
diff
changeset
|
42 dateFrom: dateFrom, |
2829
4a1211727d5f
client: spuc8: implemented year controls
Markus Kottlaender <markus@intevation.de>
parents:
2828
diff
changeset
|
43 dateTo: dateTo, |
4a1211727d5f
client: spuc8: implemented year controls
Markus Kottlaender <markus@intevation.de>
parents:
2828
diff
changeset
|
44 yearCompare: new Date().getFullYear() |
2590
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
45 }; |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
46 }; |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
47 |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
48 export default { |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
49 init, |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
50 namespaced: true, |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
51 state: init(), |
2604
85f9bf4a6eba
client: gauge waterlevel diagram: draw reference waterlevels
Markus Kottlaender <markus@intevation.de>
parents:
2596
diff
changeset
|
52 getters: { |
85f9bf4a6eba
client: gauge waterlevel diagram: draw reference waterlevels
Markus Kottlaender <markus@intevation.de>
parents:
2596
diff
changeset
|
53 selectedGauge: state => { |
85f9bf4a6eba
client: gauge waterlevel diagram: draw reference waterlevels
Markus Kottlaender <markus@intevation.de>
parents:
2596
diff
changeset
|
54 return state.gauges.find( |
2643
27933e66e848
client: gauges: use isrs_code as unique id for gauges
Markus Kottlaender <markus@intevation.de>
parents:
2604
diff
changeset
|
55 g => g.properties.isrs_code === state.selectedGaugeISRS |
2604
85f9bf4a6eba
client: gauge waterlevel diagram: draw reference waterlevels
Markus Kottlaender <markus@intevation.de>
parents:
2596
diff
changeset
|
56 ); |
85f9bf4a6eba
client: gauge waterlevel diagram: draw reference waterlevels
Markus Kottlaender <markus@intevation.de>
parents:
2596
diff
changeset
|
57 } |
85f9bf4a6eba
client: gauge waterlevel diagram: draw reference waterlevels
Markus Kottlaender <markus@intevation.de>
parents:
2596
diff
changeset
|
58 }, |
2590
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
59 mutations: { |
4291
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
60 addNSCtoCache: (state, entry) => { |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
61 const { isrsCode, nsc, timestamp } = entry; |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
62 Vue.set(state.nashSutcliffeCache, isrsCode, { |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
63 nsc, |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
64 timestamp |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
65 }); |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
66 }, |
2596
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
67 gauges: (state, gauges) => { |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
68 state.gauges = gauges; |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
69 }, |
2643
27933e66e848
client: gauges: use isrs_code as unique id for gauges
Markus Kottlaender <markus@intevation.de>
parents:
2604
diff
changeset
|
70 selectedGaugeISRS: (state, isrs) => { |
27933e66e848
client: gauges: use isrs_code as unique id for gauges
Markus Kottlaender <markus@intevation.de>
parents:
2604
diff
changeset
|
71 state.selectedGaugeISRS = isrs; |
2596
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
72 }, |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
73 waterlevels: (state, data) => { |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
74 state.waterlevels = data; |
2710
f393fabfdd35
client: waterlevel diagram: chart extent based on selected dates instead of data
Markus Kottlaender <markus@intevation.de>
parents:
2701
diff
changeset
|
75 }, |
3403
d7cc5cda82a9
client: waterlevel diagrams: implemented csv export
Markus Kottlaender <markus@intevation.de>
parents:
3152
diff
changeset
|
76 waterlevelsCSV: (state, data) => { |
d7cc5cda82a9
client: waterlevel diagrams: implemented csv export
Markus Kottlaender <markus@intevation.de>
parents:
3152
diff
changeset
|
77 state.waterlevelsCSV = data; |
d7cc5cda82a9
client: waterlevel diagrams: implemented csv export
Markus Kottlaender <markus@intevation.de>
parents:
3152
diff
changeset
|
78 }, |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
79 longtermWaterlevels: (state, data) => { |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
80 state.longtermWaterlevels = data; |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
81 }, |
2830
0632d543a427
client: spuc7/8: show time periods in diagram titles
Markus Kottlaender <markus@intevation.de>
parents:
2829
diff
changeset
|
82 longtermInterval: (state, interval) => { |
0632d543a427
client: spuc7/8: show time periods in diagram titles
Markus Kottlaender <markus@intevation.de>
parents:
2829
diff
changeset
|
83 state.longtermInterval = interval; |
0632d543a427
client: spuc7/8: show time periods in diagram titles
Markus Kottlaender <markus@intevation.de>
parents:
2829
diff
changeset
|
84 }, |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
85 yearWaterlevels: (state, data) => { |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
86 state.yearWaterlevels = data; |
2761
71e7237110ba
client: spuc8: prepared diagram
Markus Kottlaender <markus@intevation.de>
parents:
2751
diff
changeset
|
87 }, |
2751
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
88 nashSutcliffe: (state, data) => { |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
89 state.nashSutcliffe = data; |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
90 }, |
4122
d85d8de8c28c
refresh layers deletes nashsutcliffecache
Thomas Junk <thomas.junk@intevation.de>
parents:
4086
diff
changeset
|
91 deleteNashSutcliffeCache: state => { |
4292
18a34d9b289c
data availability layer: loader uses new cache
Thomas Junk <thomas.junk@intevation.de>
parents:
4291
diff
changeset
|
92 state.nashSutcliffeCache = {}; |
3501
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
93 }, |
2710
f393fabfdd35
client: waterlevel diagram: chart extent based on selected dates instead of data
Markus Kottlaender <markus@intevation.de>
parents:
2701
diff
changeset
|
94 dateFrom: (state, dateFrom) => { |
f393fabfdd35
client: waterlevel diagram: chart extent based on selected dates instead of data
Markus Kottlaender <markus@intevation.de>
parents:
2701
diff
changeset
|
95 state.dateFrom = dateFrom; |
f393fabfdd35
client: waterlevel diagram: chart extent based on selected dates instead of data
Markus Kottlaender <markus@intevation.de>
parents:
2701
diff
changeset
|
96 }, |
f393fabfdd35
client: waterlevel diagram: chart extent based on selected dates instead of data
Markus Kottlaender <markus@intevation.de>
parents:
2701
diff
changeset
|
97 dateTo: (state, dateTo) => { |
f393fabfdd35
client: waterlevel diagram: chart extent based on selected dates instead of data
Markus Kottlaender <markus@intevation.de>
parents:
2701
diff
changeset
|
98 state.dateTo = dateTo; |
2829
4a1211727d5f
client: spuc8: implemented year controls
Markus Kottlaender <markus@intevation.de>
parents:
2828
diff
changeset
|
99 }, |
4a1211727d5f
client: spuc8: implemented year controls
Markus Kottlaender <markus@intevation.de>
parents:
2828
diff
changeset
|
100 yearCompare: (state, year) => { |
4a1211727d5f
client: spuc8: implemented year controls
Markus Kottlaender <markus@intevation.de>
parents:
2828
diff
changeset
|
101 state.yearCompare = year; |
2590
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
102 } |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
103 }, |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
104 actions: { |
4291
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
105 getNashSutcliffeForISRS: ({ state, commit }, isrsCode) => { |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
106 return new Promise((resolve, reject) => { |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
107 const now = new Date(); |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
108 let nashSutcliffe = state.nashSutcliffeCache[isrsCode]; |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
109 if (nashSutcliffe) { |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
110 const { timestamp, nsc } = nashSutcliffe; |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
111 const isRecent = isBefore(now, addMinutes(timestamp, 15)); |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
112 if (isRecent) { |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
113 resolve(nsc); |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
114 return; |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
115 } |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
116 } |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
117 HTTP.get(`/data/nash-sutcliffe/${isrsCode}`, { |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
118 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
119 }) |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
120 .then(response => { |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
121 nashSutcliffe = response.data; |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
122 commit("addNSCtoCache", { |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
123 isrsCode, |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
124 nsc: nashSutcliffe, |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
125 timestamp: now |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
126 }); |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
127 resolve(nashSutcliffe); |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
128 }) |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
129 .catch(error => { |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
130 reject(error); |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
131 }); |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
132 }); |
81ab34bd2d0d
Legend: Improve display of data availability
Thomas Junk <thomas.junk@intevation.de>
parents:
4122
diff
changeset
|
133 }, |
4478
51dc4811a0e6
Gauges: Instead of dynamically scroll use crosshairs button
Thomas Junk <thomas.junk@intevation.de>
parents:
4292
diff
changeset
|
134 setSelectedGaugeISRS: ({ commit, state }, isrs) => { |
51dc4811a0e6
Gauges: Instead of dynamically scroll use crosshairs button
Thomas Junk <thomas.junk@intevation.de>
parents:
4292
diff
changeset
|
135 if (state.selectedGaugeISRS !== isrs) { |
51dc4811a0e6
Gauges: Instead of dynamically scroll use crosshairs button
Thomas Junk <thomas.junk@intevation.de>
parents:
4292
diff
changeset
|
136 commit("selectedGaugeISRS", isrs); |
51dc4811a0e6
Gauges: Instead of dynamically scroll use crosshairs button
Thomas Junk <thomas.junk@intevation.de>
parents:
4292
diff
changeset
|
137 } |
51dc4811a0e6
Gauges: Instead of dynamically scroll use crosshairs button
Thomas Junk <thomas.junk@intevation.de>
parents:
4292
diff
changeset
|
138 }, |
3152
8e31e5b9b37a
client: gauge diagrams: refresh data when switching between gauges
Markus Kottlaender <markus@intevation.de>
parents:
3042
diff
changeset
|
139 selectedGaugeISRS: ({ commit, dispatch, state }, isrs) => { |
8e31e5b9b37a
client: gauge diagrams: refresh data when switching between gauges
Markus Kottlaender <markus@intevation.de>
parents:
3042
diff
changeset
|
140 if (state.selectedGaugeISRS !== isrs) { |
8e31e5b9b37a
client: gauge diagrams: refresh data when switching between gauges
Markus Kottlaender <markus@intevation.de>
parents:
3042
diff
changeset
|
141 commit("selectedGaugeISRS", isrs); |
8e31e5b9b37a
client: gauge diagrams: refresh data when switching between gauges
Markus Kottlaender <markus@intevation.de>
parents:
3042
diff
changeset
|
142 commit("application/showGauges", true, { root: true }); |
8e31e5b9b37a
client: gauge diagrams: refresh data when switching between gauges
Markus Kottlaender <markus@intevation.de>
parents:
3042
diff
changeset
|
143 dispatch("loadWaterlevels"); |
8e31e5b9b37a
client: gauge diagrams: refresh data when switching between gauges
Markus Kottlaender <markus@intevation.de>
parents:
3042
diff
changeset
|
144 dispatch("loadLongtermWaterlevels"); |
8e31e5b9b37a
client: gauge diagrams: refresh data when switching between gauges
Markus Kottlaender <markus@intevation.de>
parents:
3042
diff
changeset
|
145 dispatch("loadYearWaterlevels"); |
8e31e5b9b37a
client: gauge diagrams: refresh data when switching between gauges
Markus Kottlaender <markus@intevation.de>
parents:
3042
diff
changeset
|
146 dispatch("loadNashSutcliffe"); |
8e31e5b9b37a
client: gauge diagrams: refresh data when switching between gauges
Markus Kottlaender <markus@intevation.de>
parents:
3042
diff
changeset
|
147 } |
2596
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
148 }, |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
149 loadGauges: ({ commit }) => { |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
150 return new Promise((resolve, reject) => { |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
151 var gaugesFeatureCollectionRequest = new WFS().writeGetFeature({ |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
152 srsName: "EPSG:4326", |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
153 featureNS: "gemma", |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
154 featurePrefix: "gemma", |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
155 featureTypes: ["gauges_geoserver"], |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
156 outputFormat: "application/json" |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
157 }); |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
158 HTTP.post( |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
159 "/internal/wfs", |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
160 new XMLSerializer().serializeToString(gaugesFeatureCollectionRequest), |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
161 { |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
162 headers: { |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
163 "X-Gemma-Auth": localStorage.getItem("token"), |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
164 "Content-type": "text/xml; charset=UTF-8" |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
165 } |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
166 } |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
167 ) |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
168 .then(response => { |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
169 commit("gauges", response.data.features); |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
170 resolve(response); |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
171 }) |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
172 .catch(error => { |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
173 reject(error); |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
174 }); |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
175 }); |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
176 }, |
2744
7dcca9649a61
client: waterlevel diagram: use selectedGaugeISRS to load waterlevels
Markus Kottlaender <markus@intevation.de>
parents:
2716
diff
changeset
|
177 loadWaterlevels({ state, commit }) { |
2701
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
178 return new Promise((resolve, reject) => { |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
179 HTTP.get( |
4086
23f88a6c1e88
importoverview, fairwayavailability, gauges: handle timezones
Thomas Junk <thomas.junk@intevation.de>
parents:
4018
diff
changeset
|
180 `/data/waterlevels/${ |
23f88a6c1e88
importoverview, fairwayavailability, gauges: handle timezones
Thomas Junk <thomas.junk@intevation.de>
parents:
4018
diff
changeset
|
181 state.selectedGaugeISRS |
23f88a6c1e88
importoverview, fairwayavailability, gauges: handle timezones
Thomas Junk <thomas.junk@intevation.de>
parents:
4018
diff
changeset
|
182 }?from=${encodeURIComponent( |
23f88a6c1e88
importoverview, fairwayavailability, gauges: handle timezones
Thomas Junk <thomas.junk@intevation.de>
parents:
4018
diff
changeset
|
183 format(startOfDay(state.dateFrom), "YYYY-MM-DDTHH:mm:ssZ") |
23f88a6c1e88
importoverview, fairwayavailability, gauges: handle timezones
Thomas Junk <thomas.junk@intevation.de>
parents:
4018
diff
changeset
|
184 )}&to=${encodeURIComponent( |
23f88a6c1e88
importoverview, fairwayavailability, gauges: handle timezones
Thomas Junk <thomas.junk@intevation.de>
parents:
4018
diff
changeset
|
185 format(endOfDay(state.dateTo), "YYYY-MM-DDTHH:mm:ssZ") |
23f88a6c1e88
importoverview, fairwayavailability, gauges: handle timezones
Thomas Junk <thomas.junk@intevation.de>
parents:
4018
diff
changeset
|
186 )}`, |
2701
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
187 { |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
188 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
189 } |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
190 ) |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
191 .then(response => { |
3403
d7cc5cda82a9
client: waterlevel diagrams: implemented csv export
Markus Kottlaender <markus@intevation.de>
parents:
3152
diff
changeset
|
192 commit("waterlevelsCSV", response.data); |
2701
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
193 let data = response.data |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
194 .split("\n") |
2828
c2b90cb426ed
client: waterlevels: better filtering of comment lines in API results
Markus Kottlaender <markus@intevation.de>
parents:
2815
diff
changeset
|
195 // remove empty rows and rows starting with # |
c2b90cb426ed
client: waterlevels: better filtering of comment lines in API results
Markus Kottlaender <markus@intevation.de>
parents:
2815
diff
changeset
|
196 .filter(wl => wl && wl[0] !== "#") |
2701
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
197 .map(wl => { |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
198 wl = wl.split(","); |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
199 return { |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
200 date: new Date(wl[0]), |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
201 waterlevel: Number(wl[1]), |
2793
16d08532c420
client: waterlevel diagram: added prediction's min max values to parsing of waterlevel csv
Markus Kottlaender <markus@intevation.de>
parents:
2791
diff
changeset
|
202 min: Number(wl[2]), |
16d08532c420
client: waterlevel diagram: added prediction's min max values to parsing of waterlevel csv
Markus Kottlaender <markus@intevation.de>
parents:
2791
diff
changeset
|
203 max: Number(wl[3]), |
16d08532c420
client: waterlevel diagram: added prediction's min max values to parsing of waterlevel csv
Markus Kottlaender <markus@intevation.de>
parents:
2791
diff
changeset
|
204 predicted: wl[4] === "f" ? false : true |
2701
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
205 }; |
2764
f0846d200ce4
client: waterlevel diagram: remove past predictions from waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2761
diff
changeset
|
206 }) |
f0846d200ce4
client: waterlevel diagram: remove past predictions from waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2761
diff
changeset
|
207 .filter(wl => !(wl.predicted && isPast(wl.date))); |
2701
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
208 data = data.sort((a, b) => a.date - b.date); |
2692
966c94e699fa
client: waterlevel diagram: simulate loading time and removed old demo code
Markus Kottlaender <markus@intevation.de>
parents:
2657
diff
changeset
|
209 commit("waterlevels", data); |
966c94e699fa
client: waterlevel diagram: simulate loading time and removed old demo code
Markus Kottlaender <markus@intevation.de>
parents:
2657
diff
changeset
|
210 resolve(data); |
2701
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
211 }) |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
212 .catch(error => { |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
213 commit("waterlevels", []); |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
214 reject(error); |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
215 }); |
2590
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
216 }); |
2751
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
217 }, |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
218 loadLongtermWaterlevels({ state, commit }) { |
2791
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
219 return new Promise((resolve, reject) => { |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
220 HTTP.get(`/data/longterm-waterlevels/${state.selectedGaugeISRS}`, { |
2791
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
221 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
222 }) |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
223 .then(response => { |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
224 const now = new Date(); |
2830
0632d543a427
client: spuc7/8: show time periods in diagram titles
Markus Kottlaender <markus@intevation.de>
parents:
2829
diff
changeset
|
225 let data = response.data.split("\n"); |
0632d543a427
client: spuc7/8: show time periods in diagram titles
Markus Kottlaender <markus@intevation.de>
parents:
2829
diff
changeset
|
226 // get result interval from first line |
3042
762b140e91a0
client: gauges: if interval is only one year display only that one year
Markus Kottlaender <markus@intevation.de>
parents:
2985
diff
changeset
|
227 let interval = data[0] |
762b140e91a0
client: gauges: if interval is only one year display only that one year
Markus Kottlaender <markus@intevation.de>
parents:
2985
diff
changeset
|
228 .split(",")[0] |
762b140e91a0
client: gauges: if interval is only one year display only that one year
Markus Kottlaender <markus@intevation.de>
parents:
2985
diff
changeset
|
229 .split(" ")[1] |
762b140e91a0
client: gauges: if interval is only one year display only that one year
Markus Kottlaender <markus@intevation.de>
parents:
2985
diff
changeset
|
230 .split("-") |
762b140e91a0
client: gauges: if interval is only one year display only that one year
Markus Kottlaender <markus@intevation.de>
parents:
2985
diff
changeset
|
231 .map(y => Number(y)); |
762b140e91a0
client: gauges: if interval is only one year display only that one year
Markus Kottlaender <markus@intevation.de>
parents:
2985
diff
changeset
|
232 if (interval[0] === interval[1]) interval = [interval[0]]; |
762b140e91a0
client: gauges: if interval is only one year display only that one year
Markus Kottlaender <markus@intevation.de>
parents:
2985
diff
changeset
|
233 commit("longtermInterval", interval); |
2830
0632d543a427
client: spuc7/8: show time periods in diagram titles
Markus Kottlaender <markus@intevation.de>
parents:
2829
diff
changeset
|
234 data = data |
2828
c2b90cb426ed
client: waterlevels: better filtering of comment lines in API results
Markus Kottlaender <markus@intevation.de>
parents:
2815
diff
changeset
|
235 // remove empty rows and rows starting with # |
c2b90cb426ed
client: waterlevels: better filtering of comment lines in API results
Markus Kottlaender <markus@intevation.de>
parents:
2815
diff
changeset
|
236 .filter(wl => wl && wl[0] !== "#") |
2791
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
237 .map(wl => { |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
238 wl = wl.split(","); |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
239 let dayAndMonth = wl[0].split("-").map(n => Number(n)); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
240 let date = new Date( |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
241 now.getFullYear(), |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
242 dayAndMonth[1] - 1, |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
243 dayAndMonth[0] |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
244 ); |
2791
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
245 return { |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
246 date: date, |
2791
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
247 min: Number(wl[1]), |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
248 max: Number(wl[2]), |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
249 mean: Number(wl[3]), |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
250 median: Number(wl[4]), |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
251 q25: Number(wl[5]), |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
252 q75: Number(wl[6]) |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
253 }; |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
254 }); |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
255 data = data.sort((a, b) => a.date - b.date); |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
256 commit("longtermWaterlevels", data); |
2791
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
257 resolve(data); |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
258 }) |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
259 .catch(error => { |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
260 commit("longtermWaterlevels", []); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
261 reject(error); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
262 }); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
263 }); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
264 }, |
2829
4a1211727d5f
client: spuc8: implemented year controls
Markus Kottlaender <markus@intevation.de>
parents:
2828
diff
changeset
|
265 loadYearWaterlevels({ state, commit }) { |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
266 return new Promise((resolve, reject) => { |
2829
4a1211727d5f
client: spuc8: implemented year controls
Markus Kottlaender <markus@intevation.de>
parents:
2828
diff
changeset
|
267 HTTP.get( |
5219 | 268 `/data/year-waterlevels/${state.selectedGaugeISRS}/${state.yearCompare}`, |
2829
4a1211727d5f
client: spuc8: implemented year controls
Markus Kottlaender <markus@intevation.de>
parents:
2828
diff
changeset
|
269 { |
4a1211727d5f
client: spuc8: implemented year controls
Markus Kottlaender <markus@intevation.de>
parents:
2828
diff
changeset
|
270 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
4a1211727d5f
client: spuc8: implemented year controls
Markus Kottlaender <markus@intevation.de>
parents:
2828
diff
changeset
|
271 } |
4a1211727d5f
client: spuc8: implemented year controls
Markus Kottlaender <markus@intevation.de>
parents:
2828
diff
changeset
|
272 ) |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
273 .then(response => { |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
274 const now = new Date(); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
275 let data = response.data |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
276 .split("\n") |
2828
c2b90cb426ed
client: waterlevels: better filtering of comment lines in API results
Markus Kottlaender <markus@intevation.de>
parents:
2815
diff
changeset
|
277 // remove empty rows and rows starting with # |
c2b90cb426ed
client: waterlevels: better filtering of comment lines in API results
Markus Kottlaender <markus@intevation.de>
parents:
2815
diff
changeset
|
278 .filter(wl => wl && wl[0] !== "#") |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
279 .map(wl => { |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
280 wl = wl.split(","); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
281 let dayAndMonth = wl[0].split("-").map(n => Number(n)); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
282 let date = new Date( |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
283 now.getFullYear(), |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
284 dayAndMonth[1] - 1, |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
285 dayAndMonth[0] |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
286 ); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
287 return { |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
288 date: date, |
2815
12f053763be2
client: spuc8: finished drawing charts, optimized code
Markus Kottlaender <markus@intevation.de>
parents:
2813
diff
changeset
|
289 mean: Number(wl[1]) |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
290 }; |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
291 }); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
292 data = data.sort((a, b) => a.date - b.date); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
293 commit("yearWaterlevels", data); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
294 resolve(data); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
295 }) |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
296 .catch(error => { |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
297 commit("yearWaterlevels", []); |
2791
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
298 reject(error); |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
299 }); |
2761
71e7237110ba
client: spuc8: prepared diagram
Markus Kottlaender <markus@intevation.de>
parents:
2751
diff
changeset
|
300 }); |
71e7237110ba
client: spuc8: prepared diagram
Markus Kottlaender <markus@intevation.de>
parents:
2751
diff
changeset
|
301 }, |
2751
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
302 loadNashSutcliffe({ state, commit }) { |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
303 return new Promise((resolve, reject) => { |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
304 HTTP.get(`/data/nash-sutcliffe/${state.selectedGaugeISRS}`, { |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
305 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
306 }) |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
307 .then(response => { |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
308 commit("nashSutcliffe", response.data); |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
309 resolve(response.data); |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
310 }) |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
311 .catch(error => { |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
312 commit("nashSutcliffe", null); |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
313 reject(error); |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
314 }); |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
315 }); |
3501
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
316 }, |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
317 loadNashSutcliffeForOverview(context, isrsCode) { |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
318 return new Promise((resolve, reject) => { |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
319 HTTP.get(`/data/nash-sutcliffe/${isrsCode}`, { |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
320 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
321 }) |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
322 .then(response => { |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
323 resolve(response.data); |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
324 }) |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
325 .catch(error => { |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
326 reject(error); |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
327 }); |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
328 }); |
2590
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
329 } |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
330 } |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
331 }; |