|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r84057 - in trunk/boost/geometry/index/detail: . rtree/visitors
From: adam.wulkiewicz_at_[hidden]
Date: 2013-04-27 18:59:38
Author: awulkiew
Date: 2013-04-27 18:59:37 EDT (Sat, 27 Apr 2013)
New Revision: 84057
URL: http://svn.boost.org/trac/boost/changeset/84057
Log:
geometry.index: made changes required to allow copying of query iterators - geometries objects are now wrapped in predicates instead of const references, pointers to const translator instead of const references are stored in queries incremental visitors.
Text files modified:
trunk/boost/geometry/index/detail/predicates.hpp | 42 ++++++++++++++++++--------
trunk/boost/geometry/index/detail/rtree/visitors/nearest_query.hpp | 8 ++--
trunk/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp | 63 +++++++++++++++++++++------------------
3 files changed, 67 insertions(+), 46 deletions(-)
Modified: trunk/boost/geometry/index/detail/predicates.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/predicates.hpp (original)
+++ trunk/boost/geometry/index/detail/predicates.hpp 2013-04-27 18:59:37 EDT (Sat, 27 Apr 2013)
@@ -22,39 +22,55 @@
//struct empty {};
+template <typename Fun, bool IsFunction>
+struct satisfies_impl
+{
+ satisfies_impl(Fun f) : fun(&f) {}
+ Fun * fun;
+};
+
+template <typename Fun>
+struct satisfies_impl<Fun, false>
+{
+ satisfies_impl(Fun const& f) : fun(f) {}
+ Fun fun;
+};
+
template <typename Fun>
struct satisfies
+ : satisfies_impl<Fun, ::boost::is_function<Fun>::value>
{
- satisfies(Fun const& f) : fun(f) {}
- Fun const& fun;
+ typedef satisfies_impl<Fun, ::boost::is_function<Fun>::value> base;
+
+ satisfies(Fun const& f) : base(f) {}
};
template <typename Geometry>
struct covered_by
{
covered_by(Geometry const& g) : geometry(g) {}
- Geometry const& geometry;
+ Geometry geometry;
};
template <typename Geometry>
struct disjoint
{
disjoint(Geometry const& g) : geometry(g) {}
- Geometry const& geometry;
+ Geometry geometry;
};
template <typename Geometry>
struct intersects
{
intersects(Geometry const& g) : geometry(g) {}
- Geometry const& geometry;
+ Geometry geometry;
};
template <typename Geometry>
struct overlaps
{
overlaps(Geometry const& g) : geometry(g) {}
- Geometry const& geometry;
+ Geometry geometry;
};
//template <typename Geometry>
@@ -68,35 +84,35 @@
struct within
{
within(Geometry const& g) : geometry(g) {}
- Geometry const& geometry;
+ Geometry geometry;
};
template <typename Geometry>
struct not_covered_by
{
not_covered_by(Geometry const& g) : geometry(g) {}
- Geometry const& geometry;
+ Geometry geometry;
};
template <typename Geometry>
struct not_disjoint
{
not_disjoint(Geometry const& g) : geometry(g) {}
- Geometry const& geometry;
+ Geometry geometry;
};
template <typename Geometry>
struct not_intersects
{
not_intersects(Geometry const& g) : geometry(g) {}
- Geometry const& geometry;
+ Geometry geometry;
};
template <typename Geometry>
struct not_overlaps
{
not_overlaps(Geometry const& g) : geometry(g) {}
- Geometry const& geometry;
+ Geometry geometry;
};
//template <typename Geometry>
@@ -110,7 +126,7 @@
struct not_within
{
not_within(Geometry const& g) : geometry(g) {}
- Geometry const& geometry;
+ Geometry geometry;
};
template <typename DistancePredicates>
@@ -120,7 +136,7 @@
: distance_predicates(dpred)
, count(k)
{}
- DistancePredicates const& distance_predicates;
+ DistancePredicates distance_predicates;
unsigned count;
};
Modified: trunk/boost/geometry/index/detail/rtree/visitors/nearest_query.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/visitors/nearest_query.hpp (original)
+++ trunk/boost/geometry/index/detail/rtree/visitors/nearest_query.hpp 2013-04-27 18:59:37 EDT (Sat, 27 Apr 2013)
@@ -381,7 +381,7 @@
> internal_stack_type;
inline nearest_query_incremental(Translator const& translator, Predicates const& pred)
- : m_translator(translator)
+ : m_translator(::boost::addressof(translator))
, m_pred(pred)
, current_neighbor((std::numeric_limits<size_type>::max)())
@@ -524,10 +524,10 @@
for ( typename elements_type::const_iterator it = elements.begin() ; it != elements.end() ; ++it)
{
// if value meets predicates
- if ( index::detail::predicates_check<index::detail::value_tag, 0, predicates_len>(m_pred, *it, m_translator(*it)) )
+ if ( index::detail::predicates_check<index::detail::value_tag, 0, predicates_len>(m_pred, *it, (*m_translator)(*it)) )
{
// calculate values distance for distance predicate
- value_distances_type distances = value_distances_calc::apply(dist_pred(), m_translator(*it));
+ value_distances_type distances = value_distances_calc::apply(dist_pred(), (*m_translator)(*it));
// if distance meets distance predicate
if ( value_distances_predicates_check::apply(dist_pred(), distances) )
@@ -604,7 +604,7 @@
return nearest_predicate_access::get(m_pred).count;
}
- Translator const& m_translator;
+ const Translator * m_translator;
Predicates m_pred;
Modified: trunk/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp (original)
+++ trunk/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp 2013-04-27 18:59:37 EDT (Sat, 27 Apr 2013)
@@ -76,9 +76,10 @@
};
template <typename Value, typename Options, typename Translator, typename Box, typename Allocators, typename Predicates>
-struct spatial_query_incremental
+class spatial_query_incremental
: public rtree::visitor<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag, true>::type
{
+public:
typedef typename rtree::node<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type node;
typedef typename rtree::internal_node<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type internal_node;
typedef typename rtree::leaf<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type leaf;
@@ -92,8 +93,9 @@
static const unsigned predicates_len = index::detail::predicates_length<Predicates>::value;
inline spatial_query_incremental(Translator const& t, Predicates const& p)
- : tr(t), pred(p)
- , values(0), value_index(0)
+ : m_translator(::boost::addressof(t))
+ , m_pred(p)
+ , m_values(0), m_value_index(0)
{}
inline void operator()(internal_node const& n)
@@ -101,66 +103,66 @@
typedef typename rtree::elements_type<internal_node>::type elements_type;
elements_type const& elements = rtree::elements(n);
- internal_stack.push_back(std::make_pair(elements.begin(), elements.end()));
+ m_internal_stack.push_back(std::make_pair(elements.begin(), elements.end()));
}
inline void operator()(leaf const& n)
{
- values = boost::addressof(rtree::elements(n));
- value_index = 0;
+ m_values = boost::addressof(rtree::elements(n));
+ m_value_index = 0;
}
Value const& dereference() const
{
- BOOST_ASSERT_MSG(values, "not dereferencable");
- return (*values)[value_index];
+ BOOST_ASSERT_MSG(m_values, "not dereferencable");
+ return (*m_values)[m_value_index];
}
void increment()
{
- if ( values )
- ++value_index;
+ if ( m_values )
+ ++m_value_index;
for (;;)
{
// if leaf is choosen, move to the next value in leaf
- if ( values )
+ if ( m_values )
{
- if ( value_index < values->size() )
+ if ( m_value_index < m_values->size() )
{
// return if next value is found
- Value const& v = (*values)[value_index];
- if ( index::detail::predicates_check<index::detail::value_tag, 0, predicates_len>(pred, v, tr(v)) )
+ Value const& v = (*m_values)[m_value_index];
+ if ( index::detail::predicates_check<index::detail::value_tag, 0, predicates_len>(m_pred, v, (*m_translator)(v)) )
return;
- ++value_index;
+ ++m_value_index;
}
// no more values, clear current leaf
else
{
- values = 0;
- value_index = 0;
+ m_values = 0;
+ m_value_index = 0;
}
}
// if leaf isn't choosen, move to the next leaf
else
{
// return if there is no more nodes to traverse
- if ( internal_stack.empty() )
+ if ( m_internal_stack.empty() )
return;
// no more children in current node, remove it from stack
- if ( internal_stack.back().first == internal_stack.back().second )
+ if ( m_internal_stack.back().first == m_internal_stack.back().second )
{
- internal_stack.pop_back();
+ m_internal_stack.pop_back();
continue;
}
- internal_iterator it = internal_stack.back().first;
- ++internal_stack.back().first;
+ internal_iterator it = m_internal_stack.back().first;
+ ++m_internal_stack.back().first;
// next node is found, push it to the stack
- if ( index::detail::predicates_check<index::detail::bounds_tag, 0, predicates_len>(pred, 0, it->first) )
+ if ( index::detail::predicates_check<index::detail::bounds_tag, 0, predicates_len>(m_pred, 0, it->first) )
rtree::apply_visitor(*this, *(it->second));
}
}
@@ -168,15 +170,18 @@
friend bool operator==(spatial_query_incremental const& l, spatial_query_incremental const& r)
{
- return (l.values == r.values) && (l.value_index == r.value_index);
+ return (l.m_values == r.m_values) && (l.m_value_index == r.m_value_index);
}
- Translator const& tr;
- Predicates pred;
+private:
+
+ const Translator * m_translator;
+
+ Predicates m_pred;
- boost::container::vector< std::pair<internal_iterator, internal_iterator> > internal_stack;
- const leaf_elements * values;
- size_type value_index;
+ boost::container::vector< std::pair<internal_iterator, internal_iterator> > m_internal_stack;
+ const leaf_elements * m_values;
+ size_type m_value_index;
};
} // namespace visitors
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk