Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment on performance of rbush vs. quadtrees for points #63

Closed
danvk opened this issue Dec 22, 2016 · 2 comments
Closed

Comment on performance of rbush vs. quadtrees for points #63

danvk opened this issue Dec 22, 2016 · 2 comments
Labels

Comments

@danvk
Copy link
Contributor

danvk commented Dec 22, 2016

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!

@mourner
Copy link
Owner

mourner commented Dec 22, 2016

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.

@danvk
Copy link
Contributor Author

danvk commented Dec 22, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants