Boost logo

Geometry :

Subject: [ggl] rtree query interface
From: Adam Wulkiewicz (adam.wulkiewicz)
Date: 2011-09-29 12:32:32


Adam Wulkiewicz wrote:

...

> // query
>
> // this uses intersects()
> f = tree.query(Box(...), std::back_inserter(result));
> f = tree.query(bgi::intersects(Box()), std::back_inserter(result));
> f = tree.query(bgi::within(Box()), std::back_inserter(result));
> f = tree.query(bgi::overlaps(Box()), std::back_inserter(result));
> f = tree.query(bgi::covered_by(Box()), std::back_inserter(result));
>
> f = tree.query(
> boost::make_tuple(
> bgi::covered_by(Box())
> , bgi::intersects(Box())
> , bgi::overlaps(Box())
> )
> , std::back_inserter(result));

...

Another small improvement. User may now pass a value predicate and add
values to the result only if they pass the test. It takes less time than
e.g. searching for all values in some region and then testing them.

bool user_pred(Value const& v) { /* some condition */ }

std::vector<Value> result;

t.query(
   std::make_pair(
     Box(...),
     bgi::value(user_pred)
   ),
   std::back_inserter(result)
);

This will return all values intersecting the Box and meeting user_pred.

Regards,
Adam


Geometry list run by mateusz at loskot.net