Open exialym opened 7 years ago
I solved this by replacing line 29 (https://github.com/ubilabs/kd-tree-javascript/blob/master/kdTree.js#L29)
function kdTree(points, metric, dimensions) {
with
function kdTree(points, metric, dimensions) {
points = points.slice();
points.forEach(function(p, i){
p.i = i;
});
then, each result obiect in the nearest
-array has its original position in the points
-array saved in the .i
attribute. Also, the slice
prevents mutation of the point positions, which happened in my use case.
How do you solve this problem? Is there anyway to get the nodes' indices of original buffer?