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

neighbors support? #1

Closed
RReverser opened this issue Feb 15, 2021 · 5 comments
Closed

neighbors support? #1

RReverser opened this issue Feb 15, 2021 · 5 comments

Comments

@RReverser
Copy link

Is it possible to port the neighbors method from flatbush? As far as I understand, it's currently not ported / not exposed via the API. /cc @mourner

@jbuckmccready
Copy link
Owner

It is definitely possible, just not yet implemented, I think it could be easily ported using the std::collections::binary_heap as the priority queue. I'll look at it sometime today.

@RReverser
Copy link
Author

Ah awesome, thanks!

@RReverser
Copy link
Author

RReverser commented Feb 15, 2021

Actually... I've realised that what I probably need instead is KD-tree as I'm working with point data, so I can keep the issue open but this is not urgent or anything.

@jbuckmccready
Copy link
Owner

jbuckmccready commented Feb 16, 2021

Ah yeah, you can use this spatial index for point data as well (by having min_x == max_x and min_y == max_y for all items added) but it is a little bit less efficient in memory and comparisons (but may still be plenty fast for your use case). The algorithm used can definitely be applied to points efficiently, there is actually an issue in the flatbush library about it: mourner/flatbush#33.

In Rust it would likely be a different type for performance and Rust's static type system, I don't have a use for that now but maybe I'll add that to this library sometime in the future as well.

I committed changes to support nearest neighbor queries (commit: f2ea39f), the unit tests pass but I haven't done any benchmarking, optimizations, or manual graphical confirmation tests yet.

I also probably want to add some examples, but I did update the docs and you can look at the tests for example use.

@RReverser
Copy link
Author

The algorithm used can definitely be applied to points efficiently, there is actually an issue in the flatbush library about it: mourner/flatbush#33.

Ah yes, I've posted that comment above after chatting with mourner - he said the changes to represent points are a bit tricky, so for now I've looked at KD-tree implementations and stopped on https://docs.rs/kd-tree which seems promising and works well.

I committed changes to support nearest neighbor queries (commit: f2ea39f), the unit tests pass but I haven't done any benchmarking, optimizations, or manual graphical confirmation tests yet.

Awesome, thanks. I'll close this issue for now then.

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

No branches or pull requests

2 participants