Subject: Re: [geometry] Rtree in a Hierarchical Method
From: Adam Wulkiewicz (adam.wulkiewicz_at_[hidden])
Date: 2014-02-20 14:40:42
> I found the Rtree implementation really really easy to use and robust.
I'm glad to hear that you like it.
> However I am planing on using Rtrees on a hierarchical method. And for it I
> need to know all leaves and its members on all different levels. I can't
> find a way to do it. I looked around but could not understand how this
> information is stored or how to retrieve it. Can anyone help me out?
By hierarchical method do you mean that you'd like to traverse the rtree
internal structure, i.e. internal nodes and leafs by yourself?
If the answer to the above is yes, then there of course is a method. But
it's not a part of the 'official' interface and is hidden in the
details. Since it's in the details, it may be changed in the future.
That's why it's prefered to use the official interface whenever
possible. Maybe if you shared what you wanted to do it could be possible
to find different solution?
Nevertheless, here is how you can access the rtree internals and mess
around a little bit. To traverse nodes, the rtree is using a visitor
pattern. The interface is similar to the Boost.Variant's
static_visitor<>. E.g. check out the utilities here:
e.g. here is a visitor which traverses all of the nodes and checks if
the bounding boxes of all nodes are correct:
So there must be a visitor class which knows how to handle internal
nodes and leafs. And then the visitor object msut be created and applied
to some node. E.g. the one above is applied to the root node (by the
rtree) and for each internal node it applies itself recursively to all
children nodes. To apply the visitor to the root node, in the example
above index::detail::utilities::view<> is used (see line 122-133).
Geometry list run by mateusz at loskot.net