I am using the Rtree implementation of boost::geometry to store (lots of) 2D points. Now I need to do distance-based nearest neigbors queries.
However, the manual on
The manual documents some model::ring class that I thought at first might fit for a circle, but it is actually more a kind of a piece-wise line (a polygon). Is that assumption correct ?
I think that's correct.
I noticed that you can define a unary-predicate, but is is... unary (thus, not suitable for a condition on two points).
Would the 'second' (or reference) point not be fixed? Because then you can use a simple bind expression to supply the reference point.
Additionally you can use the KNN algorithm with a very large n and add some kind of breaking condition on the predicate:
Breaking or pausing the query
for ( Rtree::const_query_iterator it = tree.qbegin(bgi::nearest(pt, 10000)) ; it != tree.qend() ; ++it ) { // do something with value if ( has_enough_nearest_values() ) break; }
This could work pretty well, assuming that the algorithm already traverses the points in order of ascending distance (you will want to check that assumption of course).