 Geometry :

Subject: [ggl] rtree query interface
Date: 2011-09-28 20:30:24

...

> // nearest
>
> // nearest neighbor
> f = tree.nearest(Point(...), result);
> // nearest neighbor with predicates
> f = tree.nearest(Point(...), bgi::within(Box()), result);
> // k nearest neighbors
> f = tree.nearest(Point(...), 10, std::back_inserter(result));
> // k nearest neighbors with predicates
> f = tree.nearest(Point(...), 10
> , bgi::within(Box()), std::back_inserter(result));

...

Small improvement... Now instead of just passing Point as the first
parameter one may pass DistancesPredicates. The user may describe which
points of the box will be used in distances calculation. Distances used
in searching and testing for being inside some range may be defined
separately.

namespace bgi = boost::geometry::index;

tree.nearest(
bgi::bounded(
bgi::centroid(Point(...)),
bgi::far(10),
bgi::near(20)),
10,
result);

This query will return 10 boxes which centroids are closest to the
Point(...). The distance to the furthest box's point will be bigger than
10 and the distance to the closest box's point will be smaller than 20.
So this will return 10 boxes with smallest distance between the Point
and boxes' centroids intersecting a ring with inner radius 10 and outer 20.

Other distances predicates may be or are generated by:

PointRelation - default
bgi::unbounded(PointRelation)
bgi::min_bounded(PointRelation, MinRelation)
bgi::max_bounded(PointRelation, MaxRelation)
bgi::bounded(PointRelation, MinRelation, MaxRelation)

Relations may be or are generated by:

Point/Number - depends on relation type, near relation is used by default
bgi::near(Point/Number)
bgi::far(Point/Number)
bgi::centroid(Point/Number)

I hope it isn't too complicated.

Regards,