Boost logo

Geometry :

Subject: [ggl] rtree query interface
From: Adam Wulkiewicz (adam.wulkiewicz)
Date: 2011-09-28 20:30:24

Adam Wulkiewicz wrote:


> // 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

namespace bgi = boost::geometry::index;


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::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

I hope it isn't too complicated.


Geometry list run by mateusz at