0

Does anyway know how to pass a WMS cql_filter through a Leaflet TimeDimension?

I am using Geoserver and Leaflet, using the Cross Layer filter extension in Geoserver and TimeDimension plugin for Leaflet. I have two point layers, one of parking spaces (static, with no datetime field) and one of boats (moving, with a datetime field). I can display which parking spaces are vacant (boats beyond 5 metres) or taken (boats dwithin 5 metres) nicely through the TimeDimension like this:

var vacant_parking = L.tileLayer.wms(baseUrl, {
layers: 'workspace:parking_spacesLayer',
cql_filter: 'BEYOND(the_geom,collectGeometries(queryCollection(\'workspace:boatsLayer\',\'the_geom\',\'datetime=2021-11-09\')),5,meters)',
format: 'image/png',
transparent: true
});

var vacant_parking_time = L.timeDimension.layer.wms(vacant_parking, {
updateTimeDimension: true
});

But instead of filtering on just a fixed time (for eg datetime=2021-11-09) I need to pass the cql_filter through the timeDimension to be able to dynamically display which parking spaces are vacant (or taken) for any time or time period supplied by the user through the timedimension control.

I've tried a few different combinations, but these not working because the timeDimension reads only the datetime field in the layer specified ('workspace:parking_spacesLayer') and not the boats layer in the cql filter ('workspace:boatsLayer'). Specifically, I want to pre-filter the boatsLayer with the currently selected timedimension time before the cql_filter is executed on the parking_spacesLayer to highlight the vacant (or taken) parking spots at any given time.

I've tried:

nesting the boats layer inside the timeDimension layer to include the cql filter in the timedimension

var vacant_parking_time = L.timeDimension.layer.wms(
   (L.tileLayer.wms(baseUrl, {
     layers: 'workspace:parking_spacesLayer',
     cql_filter: 'BEYOND(the_geom,collectGeometries(queryCollection(\'workspace:boatsLayer\',\'the_geom\',\'INCLUDE\')),5,meters)',
     format: 'image/png',
    transparent: true
    })), {
    updateTimeDimension: true
}).addTo(map);

adding both layers to the WMS at the same time (layers: 'workspace:parking_spacesLayer,boatsLayer') which does filter both layers through the timedimension, but does not execute the cql_filter.

and replacing a specified time like this, replacing my_date with '2021-11-03' (which works for a fixed time), or with this.time; this._timeDimension.getCurrentTime(); this._timeDimension.currentLoadedTime(); $(".timecontrol-date").text(); $(".timecontrol-date").html().split("T")[0]; (none of which work).

cql_filter: 'BEYOND(the_geom,collectGeometries(queryCollection(\'workspace:boatsLayer\',\'the_geom\',\'datetime=' + my_date + '\')),5,meters)',

But not working so far. I suspect that I might need to use .apply() or .call() function to continuously update the datetime field.

Any ideas..?

Paul H
  • 1

1 Answers1

0

For This there is a plugin named WPS-download you can extend your geoserver with this plugin. After you can genereate MP4 videos for dynamic time change.

  • Thanks for the tip, I'll take a look at the WPS geometry functions. – Paul H Nov 15 '21 at 07:12
  • Hey Paul, there is one thing to interest in Geoserver. WPS Download plugin has problem before Geoserver 2.20. Please use the most recent version. We have some trouble in 2.19 after upgrading to 2.20 problem solved immediately. – Caner Çalık Nov 15 '21 at 17:34