changeset 5142:ea22d3efa76c

client: Time based request for bottlenecks layer * Add CQL-filters für bottlnecks_geoserver
author Fadi Abbud <fadi.abbud@intevation.de>
date Tue, 31 Mar 2020 14:17:58 +0200
parents 722b7c305319
children 733f7136a30e
files client/src/components/layers/layers.js
diffstat 1 files changed, 32 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/layers/layers.js	Tue Mar 31 12:50:30 2020 +0200
+++ b/client/src/components/layers/layers.js	Tue Mar 31 14:17:58 2020 +0200
@@ -5,7 +5,12 @@
   Tile as TileLayer,
   Vector as VectorLayer
 } from "ol/layer";
-import { and as andFilter, equalTo } from "ol/format/filter";
+import {
+  and as andFilter,
+  equalTo,
+  lessThanOrEqualTo,
+  greaterThanOrEqualTo
+} from "ol/format/filter";
 
 import { HTTP } from "@/lib/http";
 import { ImageWMS as ImageSource } from "ol/source";
@@ -39,7 +44,21 @@
     HTTP.post(
       "/internal/wfs",
       new XMLSerializer().serializeToString(
-        new WFS().writeGetFeature(featureRequestOptions)
+        new WFS().writeGetFeature(
+          (function() {
+            if (featureRequestOptions.filter) {
+              for (let condition of featureRequestOptions.filter.conditions) {
+                if (condition.propertyName == "valid_from") {
+                  condition.expression = store.state.application.refreshLayersTime.toISOString();
+                }
+                if (condition.propertyName == "valid_to") {
+                  condition.expression = store.state.application.refreshLayersTime.toISOString();
+                }
+              }
+            }
+            return featureRequestOptions;
+          })()
+        )
       ),
       {
         headers: {
@@ -199,7 +218,17 @@
     buildVectorLoader(
       {
         featureTypes: ["bottlenecks_geoserver"],
-        geometryName: "area"
+        geometryName: "area",
+        filter: andFilter(
+          lessThanOrEqualTo(
+            "valid_from",
+            store.state.application.refreshLayersTime.toISOString()
+          ),
+          greaterThanOrEqualTo(
+            "valid_to",
+            store.state.application.refreshLayersTime.toISOString()
+          )
+        )
       },
       bottlenecksSource,
       false,