When given a set of points with same coordinates in a dimension, they end up in left and right part of the tree. Is this within spec? Not sure. However the nodeSearch function expects exactly this and will fail and returns nothing, thus nothing is removed.
My fix is a search for differences in the coordinates and split there. This can lead to unbalanced trees, optimizing is left to the user :)
removeNode
This function resorts the tree when a root node is removed, results where strange, I skipped it and instead I rebuild the subtree using the buildTree func.
Findings:
buildTree
When given a set of points with same coordinates in a dimension, they end up in left and right part of the tree. Is this within spec? Not sure. However the nodeSearch function expects exactly this and will fail and returns nothing, thus nothing is removed.
My fix is a search for differences in the coordinates and split there. This can lead to unbalanced trees, optimizing is left to the user :)
removeNode
This function resorts the tree when a root node is removed, results where strange, I skipped it and instead I rebuild the subtree using the buildTree func.
Sideeffects
Sorry my editor did reformat some of the code.
Did not rebuild min.js