Describe the bug
When filtering by drawing a polygon or rectangle, it has no effect on point layers with column mode geojson.
This is happening because
- inside the function
geojsonPosAccessor in the file point-layer.ts, d is normally an array, so accessing the position value with d[geojson.fieldIdx] works and returns a string "POINT (yy xx)".
But when I click filter, and the function is called from filter-utils.ts line 387, d is an object with this structure: { index: 0, dataContainer: {...} }, leading to pos being undefined.
- Even if we arrive at line 387 in
filter-utils.ts with the geojson value, say like this:
export const geojsonPosAccessor =
({geojson}: {geojson: LayerColumn}) =>
d => {
if (Array.isArray(d)) {
return d[geojson.fieldIdx];
} else if (typeof d === 'object' && d.dataContainer) {
return d.dataContainer.valueAt(d.index, geojson.fieldIdx);
}
};
it still expects an array of coordinates, throwing Uncaught TypeError: pos.every is not a function on the same line.
A solution could be just extract the coordinates from the geojson string using regex, something like
// Vibe coding solution warning
if (isPointGeometry) {
// Parse "POINT (lng lat)"
const match = geometry.match(
/POINT\s*\(\s*([-+]?[0-9]*\.?[0-9]+)\s+([-+]?[0-9]*\.?[0-9]+)\s*\)/
);
if (!match) return;
lng = parseFloat(match[1]);
lat = parseFloat(match[2]);
}
But it's ugly, so here I am.
Maybe we can add an ad hoc helper function inside the point layer class to get the coordinates?
Thoughts?
To Reproduce
Steps to reproduce the behavior:
- Create a simple csv like this:
point
POINT (7.63 45.04)
POINT (10.07 45.82)
- Import into kepler using add data modal
- Change the layer type from geojson to point, and make sure it uses column "point" in geojson mode
- Draw a rectangle around a point, right click it and select the layer
- See error in console: Uncaught TypeError: can't access property "every", pos is undefined on line 387 of
filter-utils.ts
Expected behavior
It should correctly filter points without throwing errors.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Reproduced in all demo websites and locally.
Describe the bug
When filtering by drawing a polygon or rectangle, it has no effect on point layers with column mode geojson.
This is happening because
geojsonPosAccessorin the filepoint-layer.ts,dis normally an array, so accessing the position value withd[geojson.fieldIdx]works and returns a string "POINT (yy xx)".But when I click filter, and the function is called from
filter-utils.tsline 387,dis an object with this structure:{ index: 0, dataContainer: {...} }, leading to pos beingundefined.filter-utils.tswith the geojson value, say like this:Uncaught TypeError: pos.every is not a functionon the same line.A solution could be just extract the coordinates from the geojson string using regex, something like
Maybe we can add an ad hoc helper function inside the point layer class to get the coordinates?
Thoughts?
To Reproduce
Steps to reproduce the behavior:
filter-utils.tsExpected behavior
It should correctly filter points without throwing errors.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Reproduced in all demo websites and locally.