Boost logo

Geometry :

Subject: [ggl] boost geometry rtree
From: Adam Wulkiewicz (adam.wulkiewicz)
Date: 2011-07-09 02:42:40


gc wrote:
> Hi,
>
>
> I've been trying to use the rtree in extensions but am failing at getting a
> basic test running http://codepad.org/oBLTP4dy
>
> I'm sure I'm missing something obvious.
> This was compiled with 0.9.0 but I've also tried with trunk and had no
> luck..

Hi,

Yes, this is because geometry::area don't work for all types it should.
Try using model::point instead of model::d2::point_xy.

You can also try different rtree's implementation which you can find
here: https://svn.boost.org/svn/boost/sandbox-branches/geometry/index.
Interface is slightly different, e.g. elements numbers, and used
algorithms are passed as template arguments. Just check the examples in
geometry/index/tests.

It looks like this:

namespace g = boost::geometry;

typedef g::model::point
   <float, 2, g::cs::cartesian> P;

typedef g::model::box<P> B;

g::index::rtree
   <B, g::index::rstar<4, 2> > t;

g::index::insert(t, B(P(0, 0), P(1, 1)));
g::index::insert(t, B(P(2, 2), P(3, 3)));
g::index::insert(t, B(P(4, 4), P(5, 5)));
g::index::insert(t, B(P(6, 6), P(7, 7)));
g::index::insert(t, B(P(8, 8), P(9, 9)));

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
}

Btw, I've implemented this new interface and moved repository as
described above. Since elements numbers are known in compile time
boost::arrays may be used instead of std::vectors but one can't pass
parameters to the rtree in run-time. There is new type of nodes
implemented which the tree creation is faster for and it takes less
memory space. Thoughts?

Regards,
Adam


Geometry list run by mateusz at loskot.net