Skip to content

feat: mask raster for features hidden by table filters - #664

Open
BRaimbault wants to merge 6 commits into
fix/highlight-perfromancefrom
feat/ee-mask-filtered-features
Open

BRaimbault wants to merge 6 commits into
fix/highlight-perfromancefrom
feat/ee-mask-filtered-features

Conversation

@BRaimbault

@BRaimbault BRaimbault commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

What

Adds a translucent "no data" mask layer to EarthEngine that covers raster cells whose underlying feature has been hidden by the data-table filter (filter()) or by setVisibleIds().

Why

Filtering or hiding features via the data table already hides the vector polygon/point overlay, but the EE raster underneath kept rendering regardless, so a filtered-out area still visually appeared to have data. The mask closes that gap by painting the excluded region with noDataColor.

Key changes

  • EarthEngine creates a second GeoJSON source/layer per instance (${id}-mask), inserted before the polygon/outline/point layers so it renders under them but over the raster.
  • _updateMask() computes the mask's data as the complement of the currently visible features — the union of ids excluded by filter() and by setVisibleIds() — and is called whenever either changes.
  • Since the mask's data is deliberately the inverse of "visible," it must not be narrowed by Layer's own setVisibleIds filtering. Added a new excludeFromVisibleIdsFilter option to Layer#addLayer() (tracked via _visibleIdsFilterExemptIds) so setVisibleIds() skips setFilter() on the mask layer.
  • Tests cover: mask reflects filter() alone, setVisibleIds() alone, the union of both, clearing both, a no-op when the mask source isn't available yet, and that the mask layer itself is exempted from the visible-ids filter.

@sonarqubecloud

Copy link
Copy Markdown

@BRaimbault
BRaimbault marked this pull request as ready for review July 29, 2026 13:26
@BRaimbault
BRaimbault force-pushed the feat/ee-mask-filtered-features branch from e074398 to 7160cc3 Compare September 1, 2026 10:40
Prefer toHaveLength() over a generic length assertion, for better
failure reporting.
setVisibleIds() (base Layer class) applies an "only show these ids"
filter to every registered GL layer, including EarthEngine's new mask
layer added in the previous commit. Since the mask's own data is
deliberately the complement (the *hidden* ids), that filter matched
none of its features and silently zeroed it out - so selectionFilter/
Combined's combinedVisibleIds (which go through setVisibleIds) never
visibly masked the raster, even though dataFilters (which goes through
filter() instead) did.

Layer.addLayer() now accepts an excludeFromVisibleIdsFilter option,
used to exempt the mask layer from that blanket filter.
Rebasing in the raster-mask feature added a 5th layer (the mask) to
every addTo() call, making this pre-existing test's "4, not 8"
duplicate-call assertion stale.
@BRaimbault
BRaimbault force-pushed the feat/ee-mask-filtered-features branch from 7160cc3 to aab04e5 Compare September 4, 2026 08:50
@sonarqubecloud

sonarqubecloud Bot commented Sep 4, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant