From 8d002db8a9de6aeb95cce11878a42db2282f59dd Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 18 Apr 2013 00:06:35 +0000 Subject: [PATCH] geometry.index rtree: error fixed in linear redistribute_elements, errors fixed in experimental spatial query iterator and visitor. [SVN r83945] --- .../rtree/linear/redistribute_elements.hpp | 5 ++-- .../detail/rtree/visitors/spatial_query.hpp | 24 ++++++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/include/boost/geometry/index/detail/rtree/linear/redistribute_elements.hpp b/include/boost/geometry/index/detail/rtree/linear/redistribute_elements.hpp index dc423777b..6762228ed 100644 --- a/include/boost/geometry/index/detail/rtree/linear/redistribute_elements.hpp +++ b/include/boost/geometry/index/detail/rtree/linear/redistribute_elements.hpp @@ -293,8 +293,9 @@ struct redistribute_elementssize() <= value_index ) { values = 0; @@ -136,6 +139,7 @@ struct spatial_query_incremental break; } + // return if next value is found Value const& v = (*values)[value_index]; if ( index::detail::predicates_check(pred, v, tr(v)) ) return; @@ -143,19 +147,25 @@ struct spatial_query_incremental } // move to the next leaf if values aren't set - for ( ; !values ; ++internal_stack.back().first ) + while ( !values ) { + // return if there is no more nodes to traverse if ( internal_stack.empty() ) return; + // no more children in current node, remove it from stack if ( internal_stack.back().first == internal_stack.back().second ) { internal_stack.pop_back(); continue; } - if ( index::detail::predicates_check(pred, 0, internal_stack.back().first->first) ) - rtree::apply_visitor(*this, *(internal_stack.back().first->second)); + internal_iterator it = internal_stack.back().first; + ++internal_stack.back().first; + + // next node is found, push it to the stack + if ( index::detail::predicates_check(pred, 0, it->first) ) + rtree::apply_visitor(*this, *(it->second)); } } } @@ -181,16 +191,14 @@ class spatial_query_iterator typedef visitors::spatial_query_incremental visitor_type; typedef typename visitor_type::node_pointer node_pointer; - // WARNING! If const Value is passed to rebind it won't compile for interprocess' allocator typedef typename Allocators::allocator_type::template rebind::other allocator_type; public: - typedef std::input_iterator_tag iterator_category; typedef const Value value_type; typedef Value const& reference; typedef typename allocator_type::difference_type difference_type; - typedef typename allocator_type::pointer pointer; + typedef typename allocator_type::const_pointer pointer; inline spatial_query_iterator(Translator const& t, Predicates const& p) : m_visitor(t, p)