Skip to content

fix: polygon filter not working for point layers in GeoJSON column mode#3310

Closed
pierreeurope wants to merge 1 commit into
keplergl:masterfrom
pierreeurope:fix/geojson-column-polygon-filter
Closed

fix: polygon filter not working for point layers in GeoJSON column mode#3310
pierreeurope wants to merge 1 commit into
keplergl:masterfrom
pierreeurope:fix/geojson-column-polygon-filter

Conversation

@pierreeurope
Copy link
Copy Markdown
Contributor

Summary

Polygon filter (draw-to-filter) doesn't work for point layers using GeoJSON column mode. Points inside the drawn polygon are not correctly filtered.

Root Cause

Two issues in geojsonPosAccessor in point-layer.ts:

  1. Wrong data access pattern: When called from getPolygonFilterFunctor in filter-utils.ts, data is an object { index, dataContainer }, but the accessor treated it as an array (d[geojson.fieldIdx]), returning undefined.

  2. No coordinate parsing: Even with correct data access, the accessor returned raw WKT strings (e.g. "POINT (7.63 45.04)") instead of [lng, lat] coordinates that isInPolygon expects.

Fix

  • Curry geojsonPosAccessor with dataContainer (matching the pattern used by pointPosAccessor and geoarrowPosAccessor)
  • Use dataContainer.valueAt() to properly access field values
  • Parse WKT POINT strings into [lng, lat, alt] coordinate arrays
  • Support GeoJSON objects with coordinates property
  • Return [NaN, NaN, 0] for invalid/null data so the existing Number.isFinite check in filter-utils gracefully excludes them

Fixes #3278

@pierreeurope pierreeurope force-pushed the fix/geojson-column-polygon-filter branch 2 times, most recently from e9f1d01 to 84aa5fc Compare February 10, 2026 11:04
@pierreeurope
Copy link
Copy Markdown
Contributor Author

Note: I just noticed #3301 addresses the same issue. Apologies for the duplicate — I should have checked open PRs more carefully before submitting. Happy to close this in favor of #3301 if the maintainers prefer, or keep both open for comparison. The approaches differ slightly (this PR parses WKT in the accessor, while #3301 caches parsed results and supports MultiPoint).

@pierreeurope pierreeurope force-pushed the fix/geojson-column-polygon-filter branch 2 times, most recently from 897cfa2 to ac96fc9 Compare February 10, 2026 19:17
When filtering points by drawing a polygon, layers using GeoJSON column
mode failed because:

1. geojsonPosAccessor received data as {index, dataContainer} object
   from filter-utils but tried to access it as an array via
   d[geojson.fieldIdx], returning undefined
2. Even with correct data access, the accessor returned raw WKT strings
   (e.g. 'POINT (7.63 45.04)') instead of [lng, lat] coordinates

Fix by:
- Currying geojsonPosAccessor with dataContainer (matching the pattern
  used by pointPosAccessor and geoarrowPosAccessor)
- Using dataContainer.valueAt() to properly access field values
- Parsing WKT POINT strings into [lng, lat, alt] coordinate arrays
- Supporting GeoJSON objects with coordinates property
- Returning [NaN, NaN, 0] for invalid data so the existing
  Number.isFinite check in filter-utils gracefully excludes them

Fixes keplergl#3278

Signed-off-by: pierreeurope <pierre.europe@pm.me>
@pierreeurope pierreeurope force-pushed the fix/geojson-column-polygon-filter branch from ac96fc9 to 8311197 Compare February 10, 2026 19:58
@pierreeurope
Copy link
Copy Markdown
Contributor Author

Closing in favor of #3321 which addresses the same issue with a more comprehensive approach.

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.

[Bug] Can't filter geojson column mode points by polygon

1 participant