Skip to content

fix: polygon filtered index per layer, instead of per dataset#3452

Open
igorDykhta wants to merge 2 commits into
masterfrom
igr/improve-polygon-layer-decouple
Open

fix: polygon filtered index per layer, instead of per dataset#3452
igorDykhta wants to merge 2 commits into
masterfrom
igr/improve-polygon-layer-decouple

Conversation

@igorDykhta
Copy link
Copy Markdown
Collaborator

For #3277

Polygon filters were applied at the dataset level, modifying a shared filteredIndex that ALL layers on that dataset use. When two layers (e.g., "pickup" and "dropoff") share the same dataset:

  • Single-layer selection: Filtering by one layer's positions removed rows from the dataset, causing the other layer to lose data points even though it wasn't targeted.
  • Multiple layers selected: The filter used AND logic (.every()), requiring a row's position to be inside the polygon according to ALL selected layers simultaneously — which rarely happens when layers use different coordinate columns.

Polygon filtering was moved from the dataset level to a per-layer level:

  • Polygon filters were excluded from the dataset's CPU filter pipeline (getFilterRecord), so dataset.filteredIndex is no longer affected by them.
  • A new filteredIndexByLayer property was added to each dataset, computed by a new computePolygonFilteredIndexByLayer function that applies polygon filters independently per-layer using each layer's own position accessor.
  • Each layer now uses its own polygon-filtered index (from filteredIndexByLayer[layerId]) when building its render data, falling back to the base filteredIndex if it's not targeted by any polygon filter.
  • This ensures that polygon filters only affect the layers they explicitly target, leaving other layers on the same dataset untouched.

Signed-off-by: Ihor Dykhta <ihordykhta@Ihors-MacBook-Pro.local>
@igorDykhta igorDykhta self-assigned this May 21, 2026
Copilot AI review requested due to automatic review settings May 21, 2026 20:12
@igorDykhta igorDykhta added investigation needed 3.3 Kepler.gl 3.3 release labels May 21, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes polygon filtering behavior so that polygon filters are applied per-layer rather than at the shared dataset level, preventing unintended cross-layer filtering when multiple layers share a dataset (and avoiding the prior “AND across layers” behavior when multiple layers are selected).

Changes:

  • Excludes polygon filters from the dataset-level CPU filter pipeline so dataset.filteredIndex is no longer impacted by polygon filtering.
  • Adds filteredIndexByLayer to datasets and computes per-layer polygon-filtered indices in KeplerTable.filterTable.
  • Updates layer data/update triggers to use the per-layer filtered index when present, and adjusts unit tests/helpers accordingly.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/node/reducers/vis-state-test.js Updates polygon filter tests to assert per-layer filtering and unchanged dataset filteredIndex.
test/helpers/comparison-utils.js Adjusts dataset comparisons to optionally ignore the new internal filteredIndexByLayer field.
src/utils/src/filter-utils.ts Removes polygon filters from dataset CPU filtering via getFilterRecord while keeping them tracked in the record.
src/table/src/kepler-table.ts Introduces filteredIndexByLayer and computes per-layer polygon-filtered indices during dataset filtering.
src/layers/src/mapboxgl-layer.ts Uses per-layer filtered index for update triggers / data building in Mapbox GL layer.
src/layers/src/base-layer.ts Uses per-layer filtered index when updating meta and calculating data attributes for a layer.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

* Compute per-layer filtered indices for polygon filters.
* Polygon filters are layer-specific: they should only affect the layers listed in filter.layerId.
* For each layer on this dataset, compute a filtered index that applies only the polygon filters
* targeting that specific layer (using OR logic when multiple layers on the same dataset are selected).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.3 Kepler.gl 3.3 release investigation needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants