georust / rstar

R*-tree spatial index for the Rust ecosystem
https://docs.rs/rstar
Apache License 2.0
384 stars 67 forks source link

Clarify nearest_neighbors() method #133

Open JosiahParry opened 11 months ago

JosiahParry commented 11 months ago

https://github.com/georust/rstar/blob/0ed77481c6e8a77454edff6b303afb6fa062c0c6/rstar/src/rtree.rs#L681

The nearest_neighbors() method seems like it can be usefull for KNN however it is not immediately clear in the docs how it works. Does it return a vector of all neighboring points sorted by distance?

Can this method be clarified further?

adamreichold commented 11 months ago

I think you are looking for nearest_neighbor_iter. nearest_neighbors is meant only for when there is no single nearest neighbour but multiple objects have exactly the same distance as quoted from the documentation.

JosiahParry commented 11 months ago

Thanks for the response @adamreichold! That might be what I need. I still think the documentation can be improved, howevre.