comparison client/src/components/layers/layers.js @ 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 8a7c39804d2f
children 265265725277
comparison
equal deleted inserted replaced
5141:722b7c305319 5142:ea22d3efa76c
3 import { 3 import {
4 Image as ImageLayer, 4 Image as ImageLayer,
5 Tile as TileLayer, 5 Tile as TileLayer,
6 Vector as VectorLayer 6 Vector as VectorLayer
7 } from "ol/layer"; 7 } from "ol/layer";
8 import { and as andFilter, equalTo } from "ol/format/filter"; 8 import {
9 and as andFilter,
10 equalTo,
11 lessThanOrEqualTo,
12 greaterThanOrEqualTo
13 } from "ol/format/filter";
9 14
10 import { HTTP } from "@/lib/http"; 15 import { HTTP } from "@/lib/http";
11 import { ImageWMS as ImageSource } from "ol/source"; 16 import { ImageWMS as ImageSource } from "ol/source";
12 import OSM from "ol/source/OSM"; 17 import OSM from "ol/source/OSM";
13 import Point from "ol/geom/Point"; 18 import Point from "ol/geom/Point";
37 } 42 }
38 featureRequestOptions.srsName = projection.getCode(); 43 featureRequestOptions.srsName = projection.getCode();
39 HTTP.post( 44 HTTP.post(
40 "/internal/wfs", 45 "/internal/wfs",
41 new XMLSerializer().serializeToString( 46 new XMLSerializer().serializeToString(
42 new WFS().writeGetFeature(featureRequestOptions) 47 new WFS().writeGetFeature(
48 (function() {
49 if (featureRequestOptions.filter) {
50 for (let condition of featureRequestOptions.filter.conditions) {
51 if (condition.propertyName == "valid_from") {
52 condition.expression = store.state.application.refreshLayersTime.toISOString();
53 }
54 if (condition.propertyName == "valid_to") {
55 condition.expression = store.state.application.refreshLayersTime.toISOString();
56 }
57 }
58 }
59 return featureRequestOptions;
60 })()
61 )
43 ), 62 ),
44 { 63 {
45 headers: { 64 headers: {
46 "X-Gemma-Auth": localStorage.getItem("token"), 65 "X-Gemma-Auth": localStorage.getItem("token"),
47 "Content-type": "text/xml; charset=UTF-8" 66 "Content-type": "text/xml; charset=UTF-8"
197 const bottlenecksSource = new VectorSource({ strategy: bboxStrategy }); 216 const bottlenecksSource = new VectorSource({ strategy: bboxStrategy });
198 bottlenecksSource.setLoader( 217 bottlenecksSource.setLoader(
199 buildVectorLoader( 218 buildVectorLoader(
200 { 219 {
201 featureTypes: ["bottlenecks_geoserver"], 220 featureTypes: ["bottlenecks_geoserver"],
202 geometryName: "area" 221 geometryName: "area",
222 filter: andFilter(
223 lessThanOrEqualTo(
224 "valid_from",
225 store.state.application.refreshLayersTime.toISOString()
226 ),
227 greaterThanOrEqualTo(
228 "valid_to",
229 store.state.application.refreshLayersTime.toISOString()
230 )
231 )
203 }, 232 },
204 bottlenecksSource, 233 bottlenecksSource,
205 false, 234 false,
206 async (f, store) => { 235 async (f, store) => {
207 if (f.get("fa_critical")) { 236 if (f.get("fa_critical")) {