comparison client/src/store/gauges.js @ 3501:c5c7cc24fe72

client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
author Markus Kottlaender <markus@intevation.de>
date Tue, 28 May 2019 11:28:38 +0200
parents d7cc5cda82a9
children 796b923269a6
comparison
equal deleted inserted replaced
3500:5c4f117d8f98 3501:c5c7cc24fe72
28 waterlevelsCSV: "", 28 waterlevelsCSV: "",
29 longtermWaterlevels: [], 29 longtermWaterlevels: [],
30 longtermInterval: [], 30 longtermInterval: [],
31 yearWaterlevels: [], 31 yearWaterlevels: [],
32 nashSutcliffe: null, 32 nashSutcliffe: null,
33 nashSutcliffeOverview: [],
33 dateFrom: dateFrom, 34 dateFrom: dateFrom,
34 dateTo: dateTo, 35 dateTo: dateTo,
35 yearCompare: new Date().getFullYear() 36 yearCompare: new Date().getFullYear()
36 }; 37 };
37 }; 38 };
43 getters: { 44 getters: {
44 selectedGauge: state => { 45 selectedGauge: state => {
45 return state.gauges.find( 46 return state.gauges.find(
46 g => g.properties.isrs_code === state.selectedGaugeISRS 47 g => g.properties.isrs_code === state.selectedGaugeISRS
47 ); 48 );
49 },
50 nashSutcliffeOverview: state => feature => {
51 return state.nashSutcliffeOverview.find(
52 d => d.feature.get("id") === feature.get("id")
53 );
48 } 54 }
49 }, 55 },
50 mutations: { 56 mutations: {
51 gauges: (state, gauges) => { 57 gauges: (state, gauges) => {
52 state.gauges = gauges; 58 state.gauges = gauges;
69 yearWaterlevels: (state, data) => { 75 yearWaterlevels: (state, data) => {
70 state.yearWaterlevels = data; 76 state.yearWaterlevels = data;
71 }, 77 },
72 nashSutcliffe: (state, data) => { 78 nashSutcliffe: (state, data) => {
73 state.nashSutcliffe = data; 79 state.nashSutcliffe = data;
80 },
81 addNashSutcliffeOverviewEntry: (state, data) => {
82 let existingIndex = state.nashSutcliffeOverview.findIndex(
83 d => d.feature.get("id") === data.feature.get("id")
84 );
85 if (existingIndex !== -1)
86 state.nashSutcliffeOverview.splice(existingIndex, 1);
87 state.nashSutcliffeOverview.push(data);
74 }, 88 },
75 dateFrom: (state, dateFrom) => { 89 dateFrom: (state, dateFrom) => {
76 state.dateFrom = dateFrom; 90 state.dateFrom = dateFrom;
77 }, 91 },
78 dateTo: (state, dateTo) => { 92 dateTo: (state, dateTo) => {
261 .catch(error => { 275 .catch(error => {
262 commit("nashSutcliffe", null); 276 commit("nashSutcliffe", null);
263 reject(error); 277 reject(error);
264 }); 278 });
265 }); 279 });
280 },
281 loadNashSutcliffeForOverview(context, isrsCode) {
282 return new Promise((resolve, reject) => {
283 HTTP.get(`/data/nash-sutcliffe/${isrsCode}`, {
284 headers: { "X-Gemma-Auth": localStorage.getItem("token") }
285 })
286 .then(response => {
287 resolve(response.data);
288 })
289 .catch(error => {
290 reject(error);
291 });
292 });
266 } 293 }
267 } 294 }
268 }; 295 };