Boost logo

Geometry :

Subject: [ggl] Re: k-d tree interface
From: Adam Wulkiewicz (adam.wulkiewicz)
Date: 2011-06-10 04:42:23


Vishnu wrote:
> Thanks, Adam. This is useful even if searching for points is possible only
> within boxes. I looked at the interface, the four header files in rtree.
> Approximately, when do you think the rtree functionality will be moved from
> extensions into the stable code? Also, are you planning to add any examples
> of usage?

In the /extensions there is the 'old' implementation of an rtree. I'm
currently developing the new one which you can find here:
https://svn.boost.org/svn/boost/sandbox-branches/geometry/index_080_new.
You can find some examples in the /tests folder. I don't know if and
when it will be released. Of course, there will be examples,
documentation etc. For now see /tests/rtree_filters.hpp. Basically the
interface looks like this:

// typedefs
namespace g = boost::geometry;
typedef g::model::point<float, 2, g::cs::cartesian> P;
typedef g::model::box<P> B;

// construct rtree
g::index::rtree<B> t(4, 2);

// insert some boxes
g::index::insert(t, B(P(0, 0), P(1, 1)));
g::index::insert(t, B(P(2, 2), P(3, 3)));
// ...

// search
namespace f = g::index::filters;
BOOST_FOREACH(B &b,
   t | f::spatially_filtered(B(P(2.5f, 2.5f), P(4.5f, 4.5f))))
{
     // do something with boxes
}

Instead of boxes B you can use e.g. points, std::pair<Point, something>,
std::pair<Box, something> and more. See /tests/rtree_native.hpp.

Feel free to play with it but be aware that the interface may be
changed. I'll appreciate any suggestions and info about errors.

Regards,
Adam


Geometry list run by mateusz at loskot.net