Closed mourner closed 4 years ago
Hello, I've a use case, where points are inserted/removed/updated dynamically but not in a hight rate. Could we see an insert/remove functions in the API? Thanks for this great work.
Still not sure if it's possible and pursuing this is too complicated for the benefit, so I'm closing this — better to recommend RBush for cases with insertion/removal.
Is this possible to implement a removal at least, this should be way less complicated than an insertion?
@kaligrafy no, it would be as complicated, and wouldn't make much sense to spent time on given solutions like RBush.
I've been thinking about implementing a fast algorithm for insertion and removal, which would allow this spatial index to be used in dynamic use cases. It might get a bit complicated, and it won't be as fast as optimal
log(n)
, but I think it can be made at leastlog^2(n)
.Let's look at a single point insertion. We need to reorder elements in our flat KD array to make it valid after addition of an item, but do this selectively, avoiding sorting the whole array again.
log(n)
axis splits that partition the array into KD "nodes".log(n)
.O(log(n)) + 2 * O(log(n/2)) + 4 * O(log(n/4)) + ...
~=O(log^2(n)
.Does this sound feasible, or are some of my quick assumptions wrong?
cc @anandthakker @mikolalysenko