mourner / kdbush

A fast static index for 2D points
ISC License
638 stars 69 forks source link

Fast theoretical insertion/removal #10

Closed mourner closed 4 years ago

mourner commented 7 years ago

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 least log^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.

Does this sound feasible, or are some of my quick assumptions wrong?

cc @anandthakker @mikolalysenko

slachtar commented 5 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.

mourner commented 4 years ago

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.

kaligrafy commented 4 years ago

Is this possible to implement a removal at least, this should be way less complicated than an insertion?

mourner commented 4 years ago

@kaligrafy no, it would be as complicated, and wouldn't make much sense to spent time on given solutions like RBush.