Mercurial > gemma
view client/src/lib/classifications.js @ 4325:124a5a7fe8d6
enchange wms styling
* Enable opacity in SLD templates by splitting the corresponding
`_fill` value. The place of the change is in the handlers which are
specfic to geoserver templates. Adding it there keeps the way how opacity
is styled consistent with WFS styles towards the default values
in the database and the client.
author | Bernhard Reiter <bernhard@intevation.de> |
---|---|
date | Wed, 04 Sep 2019 15:30:08 +0200 |
parents | 767a6500a666 |
children | e8af2ed8666e |
line wrap: on
line source
/* This is Free Software under GNU Affero General Public License v >= 3.0 * without warranty, see README.md and license for details. * * SPDX-License-Identifier: AGPL-3.0-or-later * License-Filename: LICENSES/AGPL-3.0.txt * * Copyright (C) 2018 by via donau * – Österreichische Wasserstraßen-Gesellschaft mbH * Software engineering by Intevation GmbH * * Author(s): * Raimund Renkert <raimund.renkert@intevation.de> * Markus Kottländer <markus.kottlaender@intevation.de> */ import store from "@/store/index"; const getGauge = f => { if (f.getId().indexOf("bottlenecks") > -1) { const GaugeProxy = (function(feature) { const gauge = feature.get("gauge_obj"); const get = function(propName) { if (gauge) return gauge.get(propName); return feature.get(propName); }; return { get: get }; })(f); return GaugeProxy; } return f; }; const calcForecastVsRealityForNSC = nsc => { if (nsc && nsc.coeffs.reduce((sum, coeff) => sum + coeff.samples, 0)) { // 24h < configured value if ( nsc.coeffs[0].samples && nsc.coeffs[0].value < store.state.application.config.gm_forecast_vs_reality_nsc_24h ) return "DANGER"; // 72h < configured value if ( nsc.coeffs[2].samples && nsc.coeffs[2].value < store.state.application.config.gm_forecast_vs_reality_nsc_72h ) return "WARNING"; // both > configured value return "OK"; } // no data available return "NEUTRAL"; }; export default { surveyRecency(bottleneck) { if ( bottleneck.get("revisiting_time") === null || bottleneck.get("revisiting_time") === 0 ) { return "NEUTRAL"; } if (bottleneck.get("date_max") === null) { return "DANGER"; } let revTime = bottleneck.get("revisiting_time") * 30.5; let latest = Date.parse(bottleneck.get("date_max").replace("Z", "")); var diff = Math.floor((Date.now() - latest) / 86400000); let revTimeMultiplier = store.state.application.config.bn_revtime_multiplier; if (diff <= revTime) { return "OK"; } else if (revTime < diff && diff <= revTime * revTimeMultiplier) { return "WARNING"; } else if (revTime * revTimeMultiplier < diff) { return "DANGER"; } }, gmAvailability(feature) { let gauge = getGauge(feature); let gmDate = gauge.get("gm_measuredate"); let gmN = gauge.get("gm_n_14d"); if ( gmDate !== undefined && gmDate !== null && // latest measurement within configured hours Date.parse(gmDate) > Date.now() - store.state.application.config.gm_latest_hours * 60 * 60 * 1000 ) { // at least configured amount of measurements in last 14 days const valuesAtLeast = store.state.application.config.gm_min_values_14d; if (gmN !== undefined && gmN !== null && gmN >= valuesAtLeast) { return "OK"; } return "WARNING"; } return "DANGER"; }, forecastAccuracy(feature) { let gauge = getGauge(feature); let fa3d = gauge.get("forecast_accuracy_3d"); let fa1d = gauge.get("forecast_accuracy_1d"); if (typeof fa3d == "number" && typeof fa1d == "number") { if (fa1d > store.state.application.config.gm_forecast_offset_24h) { return "DANGER"; } else if (fa3d > store.state.application.config.gm_forecast_offset_72h) { return "WARNING"; } else { return "OK"; } } return "NEUTRAL"; }, forecastVsReality(feature) { let gauge = getGauge(feature); let nsc = gauge.get("nsc_data"); return calcForecastVsRealityForNSC(nsc); }, calcForecastVsRealityForNSC: calcForecastVsRealityForNSC };