[BUGFIX] Time manager: keep the filter already set on the layer - #7055
[BUGFIX] Time manager: keep the filter already set on the layer#7055nboisteault wants to merge 1 commit into
Conversation
`setLayersFilter()` passed only its date filter to `lizMap.triggerLayerFilter()`, which replaces `exp_filter` on the layer. A filter already set on a controlled layer, typically from the form filter, was therefore dropped as soon as the time manager applied a date range, so the two filters never composed. The filter each controlled layer has when the time manager is opened is now kept in `tmBaseFilters` and combined with the date filter of every step. Closing the time manager restores that filter instead of clearing the layer, so only the date part is removed. When no filter was set on the layer, the filter string is unchanged, which keeps the existing GETFILTERTOKEN assertions valid. Known limitation: the base filter is captured when the time manager is opened, so changing the form filter while it is running is not picked up until it is reopened. The `time_manager` test project gets a numeric form filter on `gid`, needed to cover this: it had no form filter at all, so no layer filter could coexist with the date filter. Fix 3liz#6773 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Hey @nboisteault, that is almost the same fix I did in #6847, and it's basically the same One thing before it lands: this captures the base filter from Bigger picture though, this is exactly the mess I flagged in #6876: |
Problem
Fixes #6773.
When a controlled layer already has a filter — typically set from the form filter — the time manager and that filter do not compose: the date range never restricts the features that the layer filter selected.
Root cause
setLayersFilter()passed only its own date filter:lizMap.triggerLayerFilter()replacesrequest_params.exp_filteron the layer, so the filter already applied was dropped at the first date step. Symmetrically, closing the time manager calleddeactivateMaplayerFilter(), wiping the layer filter along with the date one.Reproduced with a form filter keeping
gid <= 2: the GETFILTERTOKEN sent when opening the time manager contained only"test_date"conditions, the"gid"condition was gone.Fix
The filter each controlled layer has when the time manager is opened is captured in
tmBaseFiltersand combined with the date filter of every step. Closing the time manager restores that filter instead of clearing the layer, so only the date part is removed.When the layer had no filter, the filter string is byte-for-byte unchanged, which keeps the existing (quite precise) GETFILTERTOKEN assertions in
time-manager.spec.jsandtime-manager-years.spec.jsvalid.Known limitation: the base filter is captured when the time manager is opened, so changing the form filter while the time manager is running is not picked up until it is reopened. Handling that properly needs the layer filters to be tracked per origin rather than as a single
exp_filterstring, which is a larger change.Test
Added a test in
time-manager.spec.js: it filters the layer with the form filter, then asserts the time manager's GETFILTERTOKEN carries both the"gid"and the"test_date"conditions, and that closing the time manager restores the"gid"condition alone.The
time_managertest project hadformFilterLayers: {}, so no layer filter could coexist with the date filter; a numeric form filter ongidis added to the fixture.Verified locally: without the fix the test fails on the
"gid"assertion (the filter contains only"test_date"), and passes with it.Unrelated pre-existing local failures, identical on a clean
masteron my QGIS 3.44 stack:Manual play,Let's playandAuto play uses full ISO dates in filter(my stack resolves the time frame type to months, showingJanuary 2007where the tests expect2007).🤖 Generated with Claude Code