Mercurial > gemma
comparison client/src/components/map/layers.js @ 3353:b01bf2399c20
client: available fairway depth vs lnwl: fetching data for diagrams on map
Data gets stored in the client for 15 mins. Diagrams are still drawn with static data for demo purpose.
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Tue, 21 May 2019 14:42:08 +0200 |
parents | 59db0b5921c5 |
children | e56b280582ae |
comparison
equal
deleted
inserted
replaced
3352:399a2eb496ee | 3353:b01bf2399c20 |
---|---|
468 featureTypes: ["bottlenecks_geoserver"], | 468 featureTypes: ["bottlenecks_geoserver"], |
469 geometryName: "area" | 469 geometryName: "area" |
470 }, | 470 }, |
471 source, | 471 source, |
472 false, | 472 false, |
473 async f => { | 473 async (f, store) => { |
474 if (f.get("fa_critical")) { | 474 if (f.get("fa_critical")) { |
475 f.set("fa_data", []); | 475 // look for fairway availability data in store. If present and |
476 // not older than 15 min use it or fetch new data and store it. | |
477 let data = store.getters[ | |
478 "fairwayavailability/fwLNWLOverviewData" | |
479 ](f); | |
480 if ( | |
481 data && | |
482 new Date().getTime() - data.createdAt.getTime() < 900000 | |
483 ) { | |
484 f.set("fa_data", data.data); | |
485 } else { | |
486 let from = new Date(); | |
487 from.setDate(from.getDate() - 30); | |
488 let to = new Date(); | |
489 data = await store.dispatch( | |
490 "fairwayavailability/loadAvailableFairwayDepthLNWL", | |
491 { | |
492 feature: f, | |
493 from: from.toISOString().split("T")[0], | |
494 to: to.toISOString().split("T")[0], | |
495 frequency: "monthly", | |
496 LOS: 3 | |
497 } | |
498 ); | |
499 if (data) { | |
500 store.commit("fairwayavailability/addFwLNWLOverviewData", { | |
501 feature: f, | |
502 data, | |
503 createdAt: new Date() | |
504 }); | |
505 f.set("fa_data", data); | |
506 } | |
507 } | |
476 } | 508 } |
477 return f; | 509 return f; |
478 } | 510 } |
479 ) | 511 ) |
480 ); | 512 ); |