Support easy enumeration of all elements with BOOST_FOREACH
using namespace boost::geometry;
typedef model::d2::point_xy<double> point2_t;
index::rtree<point2_t, index::quadratic<16>> tree;
BOOST_FOREACH(point2_t const& pt, tree)
{
std::cout << wkt(pt) << std::endl;
}
Alternatively provide a predicate bgi:all
that returns all elements and can be used with the queried
adaptor.
Change History
(3)
Owner: |
changed from Barend Gehrels to awulkiew
|
Keywords: |
rtree iterator range for added
|
Resolution: |
→ fixed
|
Status: |
new → closed
|
Milestone: |
To Be Determined → Boost 1.59.0
|
Thanks for the suggestion!
Boost.Foreach and Boost.Range is now supported in develop branch and will be in Boost 1.59. I added
const_iterator
,begin()
andend()
members to the rtree. The category of iterator is ForwardIterator so the rtree is now adapted to (const) ForwardRange concept. It should be possible to adapt it to BidirectionalRange so if this was needed, just let me know.Unfortunately the thing with
queried()
adaptor is more complicated. Currently it isn't a lazy-range but a container (wrappedstd::vector
). If it was used to iterate over all values stored in the rtree all of them would be copied into this container. I probably shouldn't change it to lazy-range now since currently it's a RandomAccessRange so e.g. it can be sorted, etc. A lazy-range would be ForwardRange, this could be a breaking change. But if you think it should be done please write a suggestion e.g. on the mailing list so we could discuss. I plan to fix it by implementing the "new"view::query()
andcont::query()
adaptors (currently a proposal so I'm waiting for the committee to know what names I could use) and deprecating thequeried()
adaptor.For now (Boost <= 1.58) I propose a workaround. You could create a range representing all of the values stored in the rtree by yourself. You need to pass
bgi::satisfies()
predicate with a UnaryFunction always returningtrue
intoqbegin()
. Well, there may be a problem, until nowconst_query_iterator
was InputIterator. This might cause problems in some cases, e.g. related to Boost.Range concept checks. Besides the change you proposed I also upgradedconst_query_iterator
to ForwardIterator. But, I think that something like this could work: