|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r74616 - in sandbox-branches/geometry/index: boost/geometry/extensions/index/rtree boost/geometry/extensions/index/rtree/visitors tests
From: adam.wulkiewicz_at_[hidden]
Date: 2011-09-30 06:03:48
Author: awulkiew
Date: 2011-09-30 06:03:46 EDT (Fri, 30 Sep 2011)
New Revision: 74616
URL: http://svn.boost.org/trac/boost/changeset/74616
Log:
rtree's clear(), box() + tests added.
Added:
sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/children_box.hpp (contents, props changed)
Text files modified:
sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/rtree.hpp | 83 +++++-
sandbox-branches/geometry/index/tests/rtree_function.hpp | 500 +++++++++++++++++++++------------------
2 files changed, 329 insertions(+), 254 deletions(-)
Modified: sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/rtree.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/rtree.hpp (original)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/rtree.hpp 2011-09-30 06:03:46 EDT (Fri, 30 Sep 2011)
@@ -32,6 +32,7 @@
#include <boost/geometry/extensions/index/rtree/visitors/destroy.hpp>
#include <boost/geometry/extensions/index/rtree/visitors/insert.hpp>
#include <boost/geometry/extensions/index/rtree/visitors/remove.hpp>
+#include <boost/geometry/extensions/index/rtree/visitors/children_box.hpp>
#include <boost/geometry/extensions/index/rtree/linear/linear.hpp>
#include <boost/geometry/extensions/index/rtree/quadratic/quadratic.hpp>
@@ -42,6 +43,17 @@
// TODO copying
// TODO move extensional/debug visitors to the other folder
+// TODO: awulkiew
+// iterators, begin/end/etc.
+
+// TODO: copy, assignment
+
+// TODO: should funcions like empty() clear() box() be free functions?
+// change name of empty() - empty predicate generator?
+
+// TODO which types should be public and which one should be private?
+// nodes, options etc. probably shouldn't
+
template <
typename Value,
typename Parameters,
@@ -69,16 +81,12 @@
, m_leafs_level(0)
, m_translator(translator)
{
- m_root = detail::rtree::create_node(leaf());
+ create();
}
~rtree()
{
- detail::rtree::visitors::destroy<value_type, options_type, translator_type, box_type> del_v;
- detail::rtree::apply_visitor(del_v, *m_root);
-
- // TODO: awulkiew - move this into the destroy visitor?
- detail::rtree::delete_node(m_root);
+ destroy();
}
template <typename Predicates, typename OutIter>
@@ -92,9 +100,6 @@
return find_v.found_count;
}
- // TODO: awulkiew - change Point to Geometry?
- // return number of elements instead of bool?
-
template <typename DistancePredicate>
inline size_t nearest(DistancePredicate const& dpred, value_type & v) const
{
@@ -155,16 +160,21 @@
return 0 == m_values_count;
}
- // TODO: awulkiew
- // clear()
- // aabb/box/get_box/etc.
- // iterators, begin/end/etc.
-
- //inline void clear()
- //{
- // // TODO: awulkiew - implement
- // BOOST_GEOMETRY_INDEX_ASSERT(false, "not implemented");
- //}
+ inline void clear()
+ {
+ destroy();
+ create();
+ }
+
+ inline box_type box() const
+ {
+ detail::rtree::visitors::children_box<value_type, options_type, translator_type, box_type>
+ children_box_v(m_translator);
+
+ detail::rtree::apply_visitor(children_box_v, *m_root);
+
+ return children_box_v.result;
+ }
template <typename Visitor>
inline void apply_visitor(Visitor & visitor) const
@@ -188,6 +198,28 @@
}
private:
+ inline void create()
+ {
+ m_root = detail::rtree::create_node(leaf());
+ m_values_count = 0;
+ m_leafs_level = 0;
+ }
+
+ inline void destroy()
+ {
+ detail::rtree::visitors::destroy<value_type, options_type, translator_type, box_type> del_v;
+ detail::rtree::apply_visitor(del_v, *m_root);
+
+ // TODO: awulkiew - consider moving this into the destroy visitor
+ // but have in mind that visitors works on references
+ // and address from reference would be passed here
+ detail::rtree::delete_node(m_root);
+
+ m_root = 0;
+ m_values_count = 0;
+ m_leafs_level = 0;
+ }
+
template <typename DistancesPredicates, typename Predicates>
inline size_t nearest_one(DistancesPredicates const& dpred, Predicates const& pred, value_type & v) const
{
@@ -295,6 +327,12 @@
}
template <typename Value, typename Options, typename Translator>
+inline void clear(rtree<Value, Options, Translator> & tree)
+{
+ return tree.clear();
+}
+
+template <typename Value, typename Options, typename Translator>
inline size_t size(rtree<Value, Options, Translator> const& tree)
{
return tree.size();
@@ -306,6 +344,13 @@
return tree.empty();
}
+template <typename Value, typename Options, typename Translator>
+inline typename rtree<Value, Options, Translator>::box_type
+box(rtree<Value, Options, Translator> const& tree)
+{
+ return tree.box();
+}
+
}}} // namespace boost::geometry::index
#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RTREE_HPP
Added: sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/children_box.hpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/children_box.hpp 2011-09-30 06:03:46 EDT (Fri, 30 Sep 2011)
@@ -0,0 +1,68 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Boost.Index - R-tree node children box calculating visitor
+//
+// Copyright 2011 Adam Wulkiewicz.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_VISITORS_CHILDREN_BOX_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_VISITORS_CHILDREN_BOX_HPP
+
+#include <boost/geometry/extensions/index/rtree/node/node.hpp>
+
+namespace boost { namespace geometry { namespace index {
+
+namespace detail { namespace rtree { namespace visitors {
+
+template <typename Value, typename Options, typename Translator, typename Box>
+class children_box
+ : public rtree::visitor<Value, typename Options::parameters_type, Box, typename Options::node_tag, true>::type
+ , index::nonassignable
+{
+ typedef typename rtree::internal_node<Value, typename Options::parameters_type, Box, typename Options::node_tag>::type internal_node;
+ typedef typename rtree::leaf<Value, typename Options::parameters_type, Box, typename Options::node_tag>::type leaf;
+
+public:
+ inline children_box(Translator const& tr)
+ : m_tr(tr)
+ {
+ geometry::assign_inverse(result);
+ }
+
+ inline void operator()(internal_node const& n)
+ {
+ typedef typename rtree::elements_type<internal_node>::type elements_type;
+ elements_type const& elements = rtree::elements(n);
+
+ for( typename elements_type::const_iterator it = elements.begin();
+ it != elements.end() ; ++it)
+ {
+ geometry::expand(result, it->first);
+ }
+ }
+
+ inline void operator()(leaf const& n)
+ {
+ typedef typename rtree::elements_type<leaf>::type elements_type;
+ elements_type const& elements = rtree::elements(n);
+
+ for(typename elements_type::const_iterator it = elements.begin();
+ it != elements.end() ; ++it)
+ {
+ geometry::expand(result, m_tr(*it));
+ }
+ }
+
+ Box result;
+
+private:
+ Translator const& m_tr;
+};
+
+}}} // namespace detail::rtree::visitors
+
+}}} // namespace boost::geometry::index
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_VISITORS_CHILDREN_BOX_HPP
Modified: sandbox-branches/geometry/index/tests/rtree_function.hpp
==============================================================================
--- sandbox-branches/geometry/index/tests/rtree_function.hpp (original)
+++ sandbox-branches/geometry/index/tests/rtree_function.hpp 2011-09-30 06:03:46 EDT (Fri, 30 Sep 2011)
@@ -15,263 +15,282 @@
namespace helpers
{
- template <typename Indexable, size_t DI, typename Tag>
- struct value_randomizer_impl_set {};
- template <typename Box, size_t DI>
- struct value_randomizer_impl_set<Box, DI, boost::geometry::box_tag>
- {
- inline static void apply(
- Box & b,
- typename boost::geometry::index::traits::coordinate_type<Box>::type m,
- typename boost::geometry::index::traits::coordinate_type<Box>::type w)
- {
- namespace bg = boost::geometry;
- typedef typename bg::index::traits::coordinate_type<Box>::type coord_t;
+template <typename Indexable, size_t DI, typename Tag>
+struct value_randomizer_impl_set {};
- coord_t c1 = ::rand() / coord_t(RAND_MAX / m);
- coord_t c2 = ::rand() / coord_t(RAND_MAX / w);
-
- bg::set<bg::min_corner, DI>(b, c1 - c2);
- bg::set<bg::max_corner, DI>(b, c1 + c2);
- }
- };
-
- template <typename Point, size_t DI>
- struct value_randomizer_impl_set<Point, DI, boost::geometry::point_tag>
+template <typename Box, size_t DI>
+struct value_randomizer_impl_set<Box, DI, boost::geometry::box_tag>
+{
+ inline static void apply(
+ Box & b,
+ typename boost::geometry::index::traits::coordinate_type<Box>::type m,
+ typename boost::geometry::index::traits::coordinate_type<Box>::type w)
{
- inline static void apply(
- Point & p,
- typename boost::geometry::index::traits::coordinate_type<Point>::type m,
- typename boost::geometry::index::traits::coordinate_type<Point>::type)
- {
- namespace bg = boost::geometry;
- typedef typename bg::index::traits::coordinate_type<Point>::type coord_t;
+ namespace bg = boost::geometry;
+ typedef typename bg::index::traits::coordinate_type<Box>::type coord_t;
- coord_t c = ::rand() / coord_t(RAND_MAX / m);
+ coord_t c1 = ::rand() / coord_t(RAND_MAX / m);
+ coord_t c2 = ::rand() / coord_t(RAND_MAX / w);
- bg::set<DI>(p, c);
- }
- };
+ bg::set<bg::min_corner, DI>(b, c1 - c2);
+ bg::set<bg::max_corner, DI>(b, c1 + c2);
+ }
+};
- template <typename Indexable, size_t D>
- struct value_randomizer_impl
+template <typename Point, size_t DI>
+struct value_randomizer_impl_set<Point, DI, boost::geometry::point_tag>
+{
+ inline static void apply(
+ Point & p,
+ typename boost::geometry::index::traits::coordinate_type<Point>::type m,
+ typename boost::geometry::index::traits::coordinate_type<Point>::type)
{
- inline static void apply(
- Indexable & i,
- typename boost::geometry::index::traits::coordinate_type<Indexable>::type m,
- typename boost::geometry::index::traits::coordinate_type<Indexable>::type w)
- {
- value_randomizer_impl<Indexable, D - 1>::apply(i, m, w);
- value_randomizer_impl_set<
- Indexable,
- D - 1,
- typename boost::geometry::index::traits::tag<Indexable>::type
- >::apply(i, m, w);
- }
- };
+ namespace bg = boost::geometry;
+ typedef typename bg::index::traits::coordinate_type<Point>::type coord_t;
- template <typename Indexable>
- struct value_randomizer_impl<Indexable, 1>
- {
- inline static void apply(
- Indexable & i,
- typename boost::geometry::index::traits::coordinate_type<Indexable>::type m,
- typename boost::geometry::index::traits::coordinate_type<Indexable>::type w)
- {
- value_randomizer_impl_set<
- Indexable,
- 0,
- typename boost::geometry::index::traits::tag<Indexable>::type
- >::apply(i, m, w);
- }
- };
+ coord_t c = ::rand() / coord_t(RAND_MAX / m);
- template <typename Indexable>
- struct value_randomizer
- {
- typedef Indexable value_type;
+ bg::set<DI>(p, c);
+ }
+};
- typedef typename boost::geometry::index::traits::coordinate_type<Indexable>::type coord_t;
-
- inline value_randomizer(coord_t mm, coord_t ww)
- : m(mm), w(ww)
- {}
+template <typename Indexable, size_t D>
+struct value_randomizer_impl
+{
+ inline static void apply(
+ Indexable & i,
+ typename boost::geometry::index::traits::coordinate_type<Indexable>::type m,
+ typename boost::geometry::index::traits::coordinate_type<Indexable>::type w)
+ {
+ value_randomizer_impl<Indexable, D - 1>::apply(i, m, w);
+ value_randomizer_impl_set<
+ Indexable,
+ D - 1,
+ typename boost::geometry::index::traits::tag<Indexable>::type
+ >::apply(i, m, w);
+ }
+};
- inline Indexable operator()() const
- {
- namespace bg = boost::geometry;
- namespace bgi = bg::index;
+template <typename Indexable>
+struct value_randomizer_impl<Indexable, 1>
+{
+ inline static void apply(
+ Indexable & i,
+ typename boost::geometry::index::traits::coordinate_type<Indexable>::type m,
+ typename boost::geometry::index::traits::coordinate_type<Indexable>::type w)
+ {
+ value_randomizer_impl_set<
+ Indexable,
+ 0,
+ typename boost::geometry::index::traits::tag<Indexable>::type
+ >::apply(i, m, w);
+ }
+};
- Indexable i;
- value_randomizer_impl<Indexable, bgi::traits::dimension<Indexable>::value>::apply(i, m, w);
- return i;
- }
+template <typename Indexable>
+struct value_randomizer
+{
+ typedef Indexable value_type;
- coord_t m, w;
- };
+ typedef typename boost::geometry::index::traits::coordinate_type<Indexable>::type coord_t;
+
+ inline value_randomizer(coord_t mm, coord_t ww)
+ : m(mm), w(ww)
+ {}
- template <typename Rtree, typename Cont, typename Randomizer>
- void random_insert(Rtree & t, Cont & c, size_t n, Randomizer r)
+ inline Indexable operator()() const
{
namespace bg = boost::geometry;
namespace bgi = bg::index;
- for ( size_t i = 0 ; i < n ; ++i )
- {
- typename Randomizer::value_type v = r();
- bgi::insert(t, v);
- c.push_back(v);
- }
+ Indexable i;
+ value_randomizer_impl<Indexable, bgi::traits::dimension<Indexable>::value>::apply(i, m, w);
+ return i;
}
- template <typename Cont, typename Translator>
- bool results_compare(Cont const& c1, Cont const& c2, Translator const& tr)
- {
- if ( c1.size() != c2.size() )
- return false;
-
- for ( typename Cont::const_iterator it = c1.begin() ; it != c1.end() ; ++it )
- {
- bool found = false;
- for ( typename Cont::const_iterator it2 = c2.begin() ; it2 != c2.end() ; ++it2 )
- if ( tr.equals(*it, *it2) )
- {
- found = true;
- break;
- }
+ coord_t m, w;
+};
- if ( !found )
- return false;
- }
+template <typename Rtree, typename Cont, typename Randomizer>
+void random_insert(Rtree & t, Cont & c, size_t n, Randomizer r)
+{
+ namespace bg = boost::geometry;
+ namespace bgi = bg::index;
- return true;
+ for ( size_t i = 0 ; i < n ; ++i )
+ {
+ typename Randomizer::value_type v = r();
+ bgi::insert(t, v);
+ c.push_back(v);
}
+}
+
+template <typename Cont, typename Translator>
+bool results_compare(Cont const& c1, Cont const& c2, Translator const& tr)
+{
+ if ( c1.size() != c2.size() )
+ return false;
- template <typename Point, typename Cont, typename Translator>
- bool nearest_results_compare(Point const& p, Cont const& c1, Cont const& c2, Translator const& tr)
+ for ( typename Cont::const_iterator it = c1.begin() ; it != c1.end() ; ++it )
{
- namespace bg = boost::geometry;
- namespace bgi = boost::geometry::index;
+ bool found = false;
+ for ( typename Cont::const_iterator it2 = c2.begin() ; it2 != c2.end() ; ++it2 )
+ if ( tr.equals(*it, *it2) )
+ {
+ found = true;
+ break;
+ }
- typedef typename Translator::indexable_type indexable_type;
- typedef bg::default_distance_result<Point, indexable_type>::type distance_type;
+ if ( !found )
+ return false;
+ }
- if ( c1.size() != c2.size() )
- return false;
+ return true;
+}
- if ( c1.size() == 0 && c2.size() == 0 )
- return true;
+template <typename Point, typename Cont, typename Translator>
+bool nearest_results_compare(Point const& p, Cont const& c1, Cont const& c2, Translator const& tr)
+{
+ namespace bg = boost::geometry;
+ namespace bgi = boost::geometry::index;
- distance_type biggest_distance1 = 0;
+ typedef typename Translator::indexable_type indexable_type;
+ typedef bg::default_distance_result<Point, indexable_type>::type distance_type;
- for ( typename Cont::const_iterator it = c1.begin() ; it != c1.end() ; ++it )
- {
- distance_type curr_distance = bgi::comparable_distance_near(p, tr(*it));
+ if ( c1.size() != c2.size() )
+ return false;
- if ( biggest_distance1 < curr_distance )
- biggest_distance1 = curr_distance;
- }
+ if ( c1.size() == 0 && c2.size() == 0 )
+ return true;
- distance_type biggest_distance2 = 0;
- for ( typename Cont::const_iterator it = c2.begin() ; it != c2.end() ; ++it )
- {
- distance_type curr_distance = bgi::comparable_distance_near(p, tr(*it));
+ distance_type biggest_distance1 = 0;
- if ( biggest_distance2 < curr_distance )
- biggest_distance2 = curr_distance;
- }
+ for ( typename Cont::const_iterator it = c1.begin() ; it != c1.end() ; ++it )
+ {
+ distance_type curr_distance = bgi::comparable_distance_near(p, tr(*it));
- return biggest_distance1 == biggest_distance2;
+ if ( biggest_distance1 < curr_distance )
+ biggest_distance1 = curr_distance;
}
- template <typename Predicate, typename Rtree, typename Cont, typename Randomizer>
- void random_query_check(Rtree const& t, Cont const& c, size_t n, Randomizer r)
+ distance_type biggest_distance2 = 0;
+ for ( typename Cont::const_iterator it = c2.begin() ; it != c2.end() ; ++it )
{
- namespace bg = boost::geometry;
- namespace bgi = bg::index;
+ distance_type curr_distance = bgi::comparable_distance_near(p, tr(*it));
- for ( size_t i = 0 ; i < n ; ++i )
- {
- Predicate pred = Predicate(r());
+ if ( biggest_distance2 < curr_distance )
+ biggest_distance2 = curr_distance;
+ }
- std::vector<typename Rtree::value_type> res1, res2;
+ return biggest_distance1 == biggest_distance2;
+}
- bgi::query(t, pred, std::back_inserter(res1));
+template <typename Point, typename Translator>
+struct val_mindist_cmp
+{
+ val_mindist_cmp(Point const& p, Translator const& t)
+ : pt(p), tr(t)
+ {}
- for ( typename Cont::const_iterator it = c.begin() ; it != c.end() ; ++it )
- {
- if ( bgi::predicates_check<bgi::detail::rtree::value_tag>(pred, *it, t.get_translator()(*it)) )
- res2.push_back(*it);
- }
+ template <typename Value>
+ bool operator()(Value const& v1, Value const& v2)
+ {
+ return boost::geometry::index::comparable_distance_near(pt, tr(v1))
+ < boost::geometry::index::comparable_distance_near(pt, tr(v2));
+ }
- std::stringstream ss;
- ss << "\nPredicate: " << typeid(Predicate).name() << "\nres1: " << res1.size() << ", res2: " << res2.size() << '\n';
+ Point const& pt;
+ Translator const& tr;
+};
- BOOST_CHECK_MESSAGE( helpers::results_compare(res1, res2, t.get_translator()), ss.str());
- }
+template <typename Box, typename Iter, typename Translator>
+Box values_box(Iter first, Iter last, Translator const& tr)
+{
+ namespace bg = boost::geometry;
+ namespace bgi = bg::index;
+
+ Box b;
+ bg::assign_inverse(b);
+
+ for ( ; first != last ; ++first )
+ {
+ bg::expand(b, tr(*first));
}
- template <typename Point, typename Translator>
- struct val_mindist_cmp
+ return b;
+}
+
+} // namespace helpers
+
+template <typename Predicate, typename Rtree, typename Cont, typename Randomizer>
+void random_query_check(Rtree const& t, Cont const& c, size_t n, Randomizer r)
+{
+ namespace bg = boost::geometry;
+ namespace bgi = bg::index;
+
+ for ( size_t i = 0 ; i < n ; ++i )
{
- val_mindist_cmp(Point const& p, Translator const& t)
- : pt(p), tr(t)
- {}
+ Predicate pred = Predicate(r());
+
+ std::vector<typename Rtree::value_type> res1, res2;
+
+ bgi::query(t, pred, std::back_inserter(res1));
- template <typename Value>
- bool operator()(Value const& v1, Value const& v2)
+ for ( typename Cont::const_iterator it = c.begin() ; it != c.end() ; ++it )
{
- return boost::geometry::index::comparable_distance_near(pt, tr(v1))
- < boost::geometry::index::comparable_distance_near(pt, tr(v2));
+ if ( bgi::predicates_check<bgi::detail::rtree::value_tag>(pred, *it, t.get_translator()(*it)) )
+ res2.push_back(*it);
}
- Point const& pt;
- Translator const& tr;
- };
-
- template <typename Predicate, typename Rtree, typename Cont, typename PointRandomizer, typename PredicateRandomizer>
- void random_nearest_check(
- Rtree const& t,
- Cont const& c,
- size_t n,
- PointRandomizer const& pr,
- size_t k,
- PredicateRandomizer const& r)
- {
- namespace bg = boost::geometry;
- namespace bgi = bg::index;
+ std::stringstream ss;
+ ss << "\nPredicate: " << typeid(Predicate).name() << "\nres1: " << res1.size() << ", res2: " << res2.size() << '\n';
- for ( size_t i = 0 ; i < n ; ++i )
- {
- typename PointRandomizer::value_type pt = pr();
- Predicate pred = Predicate(r());
+ BOOST_CHECK_MESSAGE( helpers::results_compare(res1, res2, t.get_translator()), ss.str());
+ }
+}
- std::vector<typename Rtree::value_type> res1, res2;
+template <typename Predicate, typename Rtree, typename Cont, typename PointRandomizer, typename PredicateRandomizer>
+void random_nearest_check(
+ Rtree const& t,
+ Cont const& c,
+ size_t n,
+ PointRandomizer const& pr,
+ size_t k,
+ PredicateRandomizer const& r)
+{
+ namespace bg = boost::geometry;
+ namespace bgi = bg::index;
- bgi::nearest(t, pt, k, pred, std::back_inserter(res1));
+ for ( size_t i = 0 ; i < n ; ++i )
+ {
+ typename PointRandomizer::value_type pt = pr();
+ Predicate pred = Predicate(r());
- for ( typename Cont::const_iterator it = c.begin() ; it != c.end() ; ++it )
- {
- if ( bgi::predicates_check<bgi::detail::rtree::value_tag>(pred, *it, t.get_translator()(*it)) )
- res2.push_back(*it);
- }
- std::sort(
- res2.begin(),
- res2.end(),
- val_mindist_cmp<
- typename PointRandomizer::value_type,
- typename Rtree::translator_type
- >(pt, t.get_translator())
- );
- if ( k < res2.size() )
- res2.resize(k);
+ std::vector<typename Rtree::value_type> res1, res2;
- std::stringstream ss;
- ss << "\nPredicate: " << typeid(Predicate).name() << "\nres1: " << res1.size() << ", res2: " << res2.size() << '\n';
+ bgi::nearest(t, pt, k, pred, std::back_inserter(res1));
- BOOST_CHECK_MESSAGE(helpers::nearest_results_compare(pt, res1, res2, t.get_translator()), ss.str());
+ for ( typename Cont::const_iterator it = c.begin() ; it != c.end() ; ++it )
+ {
+ if ( bgi::predicates_check<bgi::detail::rtree::value_tag>(pred, *it, t.get_translator()(*it)) )
+ res2.push_back(*it);
}
+ std::sort(
+ res2.begin(),
+ res2.end(),
+ helpers::val_mindist_cmp<
+ typename PointRandomizer::value_type,
+ typename Rtree::translator_type
+ >(pt, t.get_translator())
+ );
+ if ( k < res2.size() )
+ res2.resize(k);
+
+ std::stringstream ss;
+ ss << "\nPredicate: " << typeid(Predicate).name() << "\nres1: " << res1.size() << ", res2: " << res2.size() << '\n';
+
+ BOOST_CHECK_MESSAGE(helpers::nearest_results_compare(pt, res1, res2, t.get_translator()), ss.str());
}
}
@@ -286,22 +305,22 @@
{
namespace bgi = boost::geometry::index;
- helpers::random_query_check<B>(t, v, 5, helpers::value_randomizer<B>(10, 5));
- helpers::random_query_check<bgi::detail::covered_by<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
- helpers::random_query_check<bgi::detail::disjoint<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
- helpers::random_query_check<bgi::detail::intersects<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
- helpers::random_query_check<bgi::detail::within<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
- helpers::random_query_check<bgi::detail::not_covered_by<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
- helpers::random_query_check<bgi::detail::not_disjoint<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
- helpers::random_query_check<bgi::detail::not_intersects<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
- helpers::random_query_check<bgi::detail::not_within<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
-
- helpers::random_nearest_check<bgi::detail::empty>(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, bgi::empty);
- helpers::random_nearest_check<B>(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
- helpers::random_nearest_check<bgi::detail::intersects<B> >(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
- helpers::random_nearest_check<bgi::detail::within<B> >(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
- helpers::random_nearest_check<bgi::detail::covered_by<B> >(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
- helpers::random_nearest_check<bgi::detail::disjoint<B> >(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
+ random_query_check<B>(t, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::covered_by<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::disjoint<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::intersects<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::within<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::not_covered_by<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::not_disjoint<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::not_intersects<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::not_within<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
+
+ random_nearest_check<bgi::detail::empty>(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, bgi::empty);
+ random_nearest_check<B>(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
+ random_nearest_check<bgi::detail::intersects<B> >(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
+ random_nearest_check<bgi::detail::within<B> >(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
+ random_nearest_check<bgi::detail::covered_by<B> >(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
+ random_nearest_check<bgi::detail::disjoint<B> >(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
}
};
@@ -313,25 +332,25 @@
{
namespace bgi = boost::geometry::index;
- helpers::random_query_check<B>(t, v, 5, helpers::value_randomizer<B>(10, 5));
- helpers::random_query_check<bgi::detail::covered_by<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
- helpers::random_query_check<bgi::detail::disjoint<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
- helpers::random_query_check<bgi::detail::intersects<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
- helpers::random_query_check<bgi::detail::overlaps<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
- helpers::random_query_check<bgi::detail::within<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
- helpers::random_query_check<bgi::detail::not_covered_by<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
- helpers::random_query_check<bgi::detail::not_disjoint<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
- helpers::random_query_check<bgi::detail::not_intersects<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
- helpers::random_query_check<bgi::detail::not_overlaps<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
- helpers::random_query_check<bgi::detail::not_within<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
-
- helpers::random_nearest_check<bgi::detail::empty>(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, bgi::empty);
- helpers::random_nearest_check<B>(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
- helpers::random_nearest_check<bgi::detail::intersects<B> >(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
- helpers::random_nearest_check<bgi::detail::overlaps<B> >(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
- helpers::random_nearest_check<bgi::detail::within<B> >(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
- helpers::random_nearest_check<bgi::detail::covered_by<B> >(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
- helpers::random_nearest_check<bgi::detail::disjoint<B> >(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
+ random_query_check<B>(t, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::covered_by<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::disjoint<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::intersects<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::overlaps<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::within<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::not_covered_by<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::not_disjoint<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::not_intersects<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::not_overlaps<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::not_within<B> >(t, v, 5, helpers::value_randomizer<B>(10, 5));
+
+ random_nearest_check<bgi::detail::empty>(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, bgi::empty);
+ random_nearest_check<B>(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
+ random_nearest_check<bgi::detail::intersects<B> >(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
+ random_nearest_check<bgi::detail::overlaps<B> >(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
+ random_nearest_check<bgi::detail::within<B> >(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
+ random_nearest_check<bgi::detail::covered_by<B> >(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
+ random_nearest_check<bgi::detail::disjoint<B> >(t, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
}
};
@@ -350,7 +369,18 @@
helpers::random_insert(t, v, 10, helpers::value_randomizer<Value>(10, 1));
+ B bt = bgi::box(t);
+ B bv = helpers::values_box<B>(v.begin(), v.end(), tr);
+ BOOST_CHECK(bg::equals(bt, bv));
+
tests_rtree_function_queries<P, B, bgi::traits::tag<I>::type>::apply(t, v);
+
+ bgi::clear(t);
+ BOOST_CHECK(bgi::empty(t));
+ bt = bgi::box(t);
+ B be;
+ bg::assign_inverse(be);
+ BOOST_CHECK(bg::equals(be, bt));
}
BOOST_AUTO_TEST_CASE(tests_rtree_function_box3f)
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