Open
Description
After having removed some nodes, they can still be found in the kdTree in some situations.
Here is an example of the remove method errors:
https://gist.github.com/santoxi/ba8d283f9a21523fa45d23d8e9c3046e
as a temporary work-around, I added a fourth argument to "nearest" to pass a predicate to filter the matched nodes, which might be also useful to add:
this.nearest = function (point, maxNodes, maxDistance, predicate) {
predicate = predicate || (x => true);
....
linearDistance = metric(linearPoint, node.obj);
if (node.right === null && node.left === null) {
if (predicate(node.obj) && (bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[1])) {
saveNode(node, ownDistance);
}
return;
}
....
nearestSearch(bestChild);
if (predicate(node.obj) && (bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[1])) {
saveNode(node, ownDistance);
}
Metadata
Metadata
Assignees
Labels
No labels