mourner / rbush

RBush — a high-performance JavaScript R-tree-based 2D spatial index for points and rectangles

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Comment on performance of rbush vs. quadtrees for points

danvk opened this issue · comments

The documentation mentions that rbush can be used with points instead of rectangles by specifying custom accessors:

var tree = rbush(9, ['[0]', '[1]', '[0]', '[1]']); // accept [x, y] points
tree.insert([20, 50]);

But it doesn't explain whether this is a good idea—if I have a million points and want to do bounding box queries, will I be happier using rbush or something less general like a quadtree?

Thanks for the great library!

Good question! There are not many good JS quadtree implementations out there, but in my experience, RBush with a custom format works great for points and I've used it in many of my other modules (for example, concaveman). If you find any other indexing library perform better, let me know.

One recommendation I have is that if your list of points is static (you don't need to add/remove points after indexing), you should use kdbush, my other indexing library that performs point indexing 5-8x faster than RBush.

Thanks for the pointer! I sent you a PR to add a note about this to the README.