|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r74618 - in sandbox-branches/geometry/index: boost/geometry/extensions/index/rtree boost/geometry/extensions/index/rtree/node boost/geometry/extensions/index/rtree/visitors tests
From: adam.wulkiewicz_at_[hidden]
Date: 2011-09-30 09:12:46
Author: awulkiew
Date: 2011-09-30 09:12:44 EDT (Fri, 30 Sep 2011)
New Revision: 74618
URL: http://svn.boost.org/trac/boost/changeset/74618
Log:
copy constructor implemented + tests updated, rtree::get_translator() changed to rtree::translator() + other files updated to respect this
Added:
sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/copy.hpp (contents, props changed)
Text files modified:
sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/node/node_default.hpp | 14 +--
sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/rtree.hpp | 51 ++++++++++++----
sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/are_boxes_ok.hpp | 2
sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/are_levels_ok.hpp | 2
sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/children_box.hpp | 16 ----
sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/gl_draw.hpp | 2
sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/nearest.hpp | 4
sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/print.hpp | 2
sandbox-branches/geometry/index/tests/additional_sizes_and_times.cpp | 28 ++++++++
sandbox-branches/geometry/index/tests/main.cpp | 3
sandbox-branches/geometry/index/tests/rtree_filters.hpp | 44 +++++++------
sandbox-branches/geometry/index/tests/rtree_function.hpp | 126 ++++++++++++++++++++++-----------------
12 files changed, 177 insertions(+), 117 deletions(-)
Modified: sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/node/node_default.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/node/node_default.hpp (original)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/node/node_default.hpp 2011-09-30 09:12:44 EDT (Fri, 30 Sep 2011)
@@ -153,7 +153,7 @@
template <typename Value, typename Translator>
inline typename Translator::indexable_type const&
- element_indexable(Value const& el, Translator const& tr)
+element_indexable(Value const& el, Translator const& tr)
{
return tr(el);
}
@@ -207,14 +207,14 @@
template <typename Node>
inline typename elements_type<Node>::type &
- elements(Node & n)
+elements(Node & n)
{
return n.elements;
}
template <typename Node>
inline typename elements_type<Node>::type const&
- elements(Node const& n)
+elements(Node const& n)
{
return n.elements;
}
@@ -224,13 +224,9 @@
template <typename Box, typename FwdIter, typename Translator>
inline Box elements_box(FwdIter first, FwdIter last, Translator const& tr)
{
- Box result;
+ BOOST_GEOMETRY_INDEX_ASSERT(first != last, "Can't calculate element's box");
- if (first == last)
- {
- geometry::assign_zero(result);
- return result;
- }
+ Box result;
geometry::convert(element_indexable(*first, tr), result);
++first;
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 09:12:44 EDT (Fri, 30 Sep 2011)
@@ -27,11 +27,12 @@
#include <boost/geometry/extensions/index/rtree/node/node.hpp>
-#include <boost/geometry/extensions/index/rtree/visitors/query.hpp>
-#include <boost/geometry/extensions/index/rtree/visitors/nearest.hpp>
-#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/copy.hpp>
+#include <boost/geometry/extensions/index/rtree/visitors/destroy.hpp>
+#include <boost/geometry/extensions/index/rtree/visitors/query.hpp>
+#include <boost/geometry/extensions/index/rtree/visitors/nearest.hpp>
#include <boost/geometry/extensions/index/rtree/visitors/children_box.hpp>
#include <boost/geometry/extensions/index/rtree/linear/linear.hpp>
@@ -47,6 +48,7 @@
// iterators, begin/end/etc.
// TODO: copy, assignment
+// allow copying of a tree with different template parameters? e.g. Parameters, Translator?
// TODO: should funcions like empty() clear() box() be free functions?
// change name of empty() - empty predicate generator?
@@ -84,9 +86,14 @@
create();
}
- ~rtree()
+ inline rtree(rtree const& src)
+ {
+ copy(src, *this);
+ }
+
+ inline ~rtree()
{
- destroy();
+ destroy(*this);
}
template <typename Predicates, typename OutIter>
@@ -162,12 +169,19 @@
inline void clear()
{
- destroy();
+ destroy(*this);
create();
}
inline box_type box() const
{
+ if ( empty() )
+ {
+ box_type result;
+ geometry::assign_inverse(result);
+ return result;
+ }
+
detail::rtree::visitors::children_box<value_type, options_type, translator_type, box_type>
children_box_v(m_translator);
@@ -182,7 +196,7 @@
detail::rtree::apply_visitor(visitor, *m_root);
}
- inline translator_type const& get_translator() const
+ inline translator_type const& translator() const
{
return m_translator;
}
@@ -205,19 +219,30 @@
m_leafs_level = 0;
}
- inline void destroy()
+ inline void destroy(rtree & t)
{
detail::rtree::visitors::destroy<value_type, options_type, translator_type, box_type> del_v;
- detail::rtree::apply_visitor(del_v, *m_root);
+ detail::rtree::apply_visitor(del_v, *t.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);
+ detail::rtree::delete_node(t.m_root);
- m_root = 0;
- m_values_count = 0;
- m_leafs_level = 0;
+ t.m_root = 0;
+ t.m_values_count = 0;
+ t.m_leafs_level = 0;
+ }
+
+ inline void copy(rtree const& src, rtree & dst) const
+ {
+ detail::rtree::visitors::copy<value_type, options_type, translator_type, box_type> copy_v;
+ detail::rtree::apply_visitor(copy_v, *src.m_root);
+
+ dst.m_root = copy_v.result;
+ dst.m_values_count = src.m_values_count;
+ dst.m_leafs_level = src.m_leafs_level;
+ dst.m_translator = src.m_translator;
}
template <typename DistancesPredicates, typename Predicates>
Modified: sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/are_boxes_ok.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/are_boxes_ok.hpp (original)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/are_boxes_ok.hpp 2011-09-30 09:12:44 EDT (Fri, 30 Sep 2011)
@@ -117,7 +117,7 @@
typename rt::value_type,
typename rt::options_type,
typename rt::translator_type,
- typename rt::box_type> v(tree.get_translator());
+ typename rt::box_type> v(tree.translator());
tree.apply_visitor(v);
Modified: sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/are_levels_ok.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/are_levels_ok.hpp (original)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/are_levels_ok.hpp 2011-09-30 09:12:44 EDT (Fri, 30 Sep 2011)
@@ -95,7 +95,7 @@
typename rt::value_type,
typename rt::options_type,
typename rt::translator_type,
- typename rt::box_type> v(tree.get_translator());
+ typename rt::box_type> v(tree.translator());
tree.apply_visitor(v);
Modified: sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/children_box.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/children_box.hpp (original)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/children_box.hpp 2011-09-30 09:12:44 EDT (Fri, 30 Sep 2011)
@@ -27,20 +27,14 @@
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);
- }
+ result = rtree::elements_box<Box>(elements.begin(), elements.end(), m_tr);
}
inline void operator()(leaf const& n)
@@ -48,11 +42,7 @@
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));
- }
+ result = rtree::elements_box<Box>(elements.begin(), elements.end(), m_tr);
}
Box result;
Added: sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/copy.hpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/copy.hpp 2011-09-30 09:12:44 EDT (Fri, 30 Sep 2011)
@@ -0,0 +1,76 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Boost.Index - R-tree copying 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_COPY_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_VISITORS_COPY_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>
+struct copy
+ : public rtree::visitor<Value, typename Options::parameters_type, Box, typename Options::node_tag, false>::type
+{
+ typedef typename rtree::node<Value, typename Options::parameters_type, Box, typename Options::node_tag>::type node;
+ 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;
+
+ explicit inline copy()
+ : result(0)
+ {}
+
+ inline void operator()(internal_node & n)
+ {
+ node * new_node = rtree::create_node(internal_node());
+
+ typedef typename rtree::elements_type<internal_node>::type elements_type;
+ elements_type & elements = rtree::elements(n);
+
+ elements_type & elements_dst = rtree::elements(rtree::get<internal_node>(*new_node));
+
+ for (typename elements_type::iterator it = elements.begin();
+ it != elements.end(); ++it)
+ {
+ rtree::apply_visitor(*this, *it->second);
+
+ elements_dst.push_back( std::make_pair(it->first, result) );
+ }
+
+ result = new_node;
+ }
+
+ inline void operator()(leaf & l)
+ {
+ node * new_node = rtree::create_node(leaf());
+
+ typedef typename rtree::elements_type<leaf>::type elements_type;
+ elements_type & elements = rtree::elements(l);
+
+ elements_type & elements_dst = rtree::elements(rtree::get<leaf>(*new_node));
+
+ for (typename elements_type::iterator it = elements.begin();
+ it != elements.end(); ++it)
+ {
+ elements_dst.push_back(*it);
+ }
+
+ result = new_node;
+ }
+
+ node * result;
+};
+
+}}} // namespace detail::rtree::visitors
+
+}}} // namespace boost::geometry::index
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_VISITORS_COPY_HPP
Modified: sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/gl_draw.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/gl_draw.hpp (original)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/gl_draw.hpp 2011-09-30 09:12:44 EDT (Fri, 30 Sep 2011)
@@ -201,7 +201,7 @@
typedef typename rtree<Value, Options, Translator>::box_type box_type;
detail::rtree::visitors::gl_draw<value_type, options_type, translator_type, box_type>
- gl_draw_v(tree.get_translator(), level_first, level_last, z_coord_level_multiplier);
+ gl_draw_v(tree.translator(), level_first, level_last, z_coord_level_multiplier);
tree.apply_visitor(gl_draw_v);
}
Modified: sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/nearest.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/nearest.hpp (original)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/nearest.hpp 2011-09-30 09:12:44 EDT (Fri, 30 Sep 2011)
@@ -191,7 +191,7 @@
// calculate node's distance(s) for distance predicate
node_distances_type node_dist_data = node_distances_calc::apply(m_dist_pred, it->first);
- // TODO: awulkiew - consider at first calculating just near distance,
+ // TODO: awulkiew - consider at first calculating near distance only,
// comparing it with m_result.comparable_distance if it's valid,
// after that calculate the rest of distances and check predicates
@@ -246,7 +246,7 @@
// calculate values distance for distance predicate
value_distances_type distances = value_distances_calc::apply(m_dist_pred, m_tr(*it));
- // TODO: awulkiew - consider at first calculating just point relation distance,
+ // TODO: awulkiew - consider at first calculating point relation distance only,
// comparing it with m_result.comparable_distance if it's valid,
// after that calculate the rest of distances and check predicates
Modified: sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/print.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/print.hpp (original)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/print.hpp 2011-09-30 09:12:44 EDT (Fri, 30 Sep 2011)
@@ -185,7 +185,7 @@
typedef typename rtree<Value, Options, Translator>::options_type options_type;
typedef typename rtree<Value, Options, Translator>::translator_type translator_type;
typedef typename rtree<Value, Options, Translator>::box_type box_type;
- detail::rtree::visitors::print<value_type, options_type, translator_type, box_type> print_v(os, tree.get_translator());
+ detail::rtree::visitors::print<value_type, options_type, translator_type, box_type> print_v(os, tree.translator());
tree.apply_visitor(print_v);
return os;
}
Modified: sandbox-branches/geometry/index/tests/additional_sizes_and_times.cpp
==============================================================================
--- sandbox-branches/geometry/index/tests/additional_sizes_and_times.cpp (original)
+++ sandbox-branches/geometry/index/tests/additional_sizes_and_times.cpp 2011-09-30 09:12:44 EDT (Fri, 30 Sep 2011)
@@ -183,6 +183,34 @@
std::cout << "found: " << temp << "\n";
}
+ // copying test
+ {
+ std::cout << "rtree copying time test... ("
+ << values_count << ")\n";
+ tim.restart();
+ RT t_copy(t);
+ std::cout << "time: " << tim.elapsed() << "s\n";
+ std::cout << "new size: " << t_copy.size() << '\n';
+
+ // t_copy searching test
+ {
+ std::cout << "tree copy query(intersects(B)) searching time test... ("
+ << queries_count << ")\n";
+ tim.restart();
+ size_t temp = 0;
+ for (size_t i = 0 ; i < queries_count ; ++i )
+ {
+ float x = coords[i].first;
+ float y = coords[i].second;
+ std::deque< std::pair<B, size_t> > result;
+ t_copy.query(bgi::intersects(B(P(x - 10, y - 10), P(x + 10, y + 10))), std::back_inserter(result));
+ temp += result.size();
+ }
+ std::cout << "time: " << tim.elapsed() << "s\n";
+ std::cout << "found: " << temp << "\n";
+ }
+ }
+
// searching test
{
std::cout << "query(!disjoint(B)) searching time test... ("
Modified: sandbox-branches/geometry/index/tests/main.cpp
==============================================================================
--- sandbox-branches/geometry/index/tests/main.cpp (original)
+++ sandbox-branches/geometry/index/tests/main.cpp 2011-09-30 09:12:44 EDT (Fri, 30 Sep 2011)
@@ -27,8 +27,7 @@
BOOST_AUTO_TEST_CASE( last_test_case )
{
- tests_rtree_filters_hpp();
-
+
#ifdef _MSC_VER
std::cin.get();
#endif
Modified: sandbox-branches/geometry/index/tests/rtree_filters.hpp
==============================================================================
--- sandbox-branches/geometry/index/tests/rtree_filters.hpp (original)
+++ sandbox-branches/geometry/index/tests/rtree_filters.hpp 2011-09-30 09:12:44 EDT (Fri, 30 Sep 2011)
@@ -12,24 +12,24 @@
#include <boost/range/algorithm.hpp>
#include <boost/foreach.hpp>
-template <typename R>
-void tests_rtree_filters_hpp_print_range(R const& r)
-{
- BOOST_FOREACH(typename boost::iterator_value<typename R::const_iterator>::type const& b, r)
- {
- float min_x = b.min_corner().template get<0>();
- float min_y = b.min_corner().template get<1>();
- float max_x = b.max_corner().template get<0>();
- float max_y = b.max_corner().template get<1>();
- std::cout << "(" << min_x << ", " << min_y << ")";
- std::cout << 'x';
- std::cout << "(" << max_x << ", " << max_y << ")";
- std::cout << '\n';
- }
- std::cout << std::endl;
-}
+//template <typename R>
+//void tests_rtree_filters_hpp_print_range(R const& r)
+//{
+// BOOST_FOREACH(typename boost::iterator_value<typename R::const_iterator>::type const& b, r)
+// {
+// float min_x = b.min_corner().template get<0>();
+// float min_y = b.min_corner().template get<1>();
+// float max_x = b.max_corner().template get<0>();
+// float max_y = b.max_corner().template get<1>();
+// std::cout << "(" << min_x << ", " << min_y << ")";
+// std::cout << 'x';
+// std::cout << "(" << max_x << ", " << max_y << ")";
+// std::cout << '\n';
+// }
+// std::cout << std::endl;
+//}
-void tests_rtree_filters_hpp()
+BOOST_AUTO_TEST_CASE(tests_rtree_query_filter)
{
#ifdef TEST_PRINT_INFO
std::cout << "tests/rtree_filters.hpp\n";
@@ -47,10 +47,14 @@
bgi::insert(t, B(P(4, 4), P(5, 5)));
bgi::insert(t, B(P(6, 6), P(7, 7)));
bgi::insert(t, B(P(8, 8), P(9, 9)));
- std::cout << t;
- std::cout << "Query: (2.5, 2.5)x(4.5, 4.5)\n";
- tests_rtree_filters_hpp_print_range(t | bgi::query_filtered(B(P(2.5f, 2.5f), P(4.5f, 4.5f))));
+ size_t n = 0;
+ BOOST_FOREACH(B const& b, t | bgi::query_filtered(B(P(1.5f, 1.5f), P(4.5f, 4.5f))))
+ {
+ ++n;
+ }
+
+ BOOST_CHECK(n == 2);
}
}
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 09:12:44 EDT (Fri, 30 Sep 2011)
@@ -224,7 +224,7 @@
} // 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)
+void random_query_check(Rtree const& t, Rtree const& t_copy, Cont const& c, size_t n, Randomizer r)
{
namespace bg = boost::geometry;
namespace bgi = bg::index;
@@ -233,26 +233,32 @@
{
Predicate pred = Predicate(r());
- std::vector<typename Rtree::value_type> res1, res2;
+ std::vector<typename Rtree::value_type> res1, res2, res3;
bgi::query(t, pred, std::back_inserter(res1));
+ bgi::query(t_copy, pred, std::back_inserter(res2));
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);
+ if ( bgi::predicates_check<bgi::detail::rtree::value_tag>(pred, *it, t.translator()(*it)) )
+ res3.push_back(*it);
}
std::stringstream ss;
- ss << "\nPredicate: " << typeid(Predicate).name() << "\nres1: " << res1.size() << ", res2: " << res2.size() << '\n';
+ ss << "\nPredicate: " << typeid(Predicate).name() << "\n"
+ << "res1: " << res1.size()
+ << ", res2: " << res2.size()
+ << ", res3: " << res3.size() << '\n';
- BOOST_CHECK_MESSAGE( helpers::results_compare(res1, res2, t.get_translator()), ss.str());
+ BOOST_CHECK_MESSAGE( helpers::results_compare(res1, res2, t.translator()), ss.str());
+ BOOST_CHECK_MESSAGE( helpers::results_compare(res1, res3, t.translator()), ss.str());
}
}
template <typename Predicate, typename Rtree, typename Cont, typename PointRandomizer, typename PredicateRandomizer>
void random_nearest_check(
Rtree const& t,
+ Rtree const& t_copy,
Cont const& c,
size_t n,
PointRandomizer const& pr,
@@ -267,30 +273,36 @@
typename PointRandomizer::value_type pt = pr();
Predicate pred = Predicate(r());
- std::vector<typename Rtree::value_type> res1, res2;
+ std::vector<typename Rtree::value_type> res1, res2, res3;
bgi::nearest(t, pt, k, pred, std::back_inserter(res1));
+ bgi::nearest(t_copy, pt, k, pred, std::back_inserter(res2));
+
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);
+ if ( bgi::predicates_check<bgi::detail::rtree::value_tag>(pred, *it, t.translator()(*it)) )
+ res3.push_back(*it);
}
std::sort(
- res2.begin(),
- res2.end(),
+ res3.begin(),
+ res3.end(),
helpers::val_mindist_cmp<
typename PointRandomizer::value_type,
typename Rtree::translator_type
- >(pt, t.get_translator())
+ >(pt, t.translator())
);
- if ( k < res2.size() )
- res2.resize(k);
+ if ( k < res3.size() )
+ res3.resize(k);
std::stringstream ss;
- ss << "\nPredicate: " << typeid(Predicate).name() << "\nres1: " << res1.size() << ", res2: " << res2.size() << '\n';
+ ss << "\nPredicate: " << typeid(Predicate).name() << "\n"
+ << "res1: " << res1.size()
+ << ", res2: " << res2.size()
+ << ", res3: " << res3.size() << '\n';
- BOOST_CHECK_MESSAGE(helpers::nearest_results_compare(pt, res1, res2, t.get_translator()), ss.str());
+ BOOST_CHECK_MESSAGE(helpers::nearest_results_compare(pt, res1, res2, t.translator()), ss.str());
+ BOOST_CHECK_MESSAGE(helpers::nearest_results_compare(pt, res1, res3, t.translator()), ss.str());
}
}
@@ -301,26 +313,26 @@
struct tests_rtree_function_queries<P, B, boost::geometry::point_tag>
{
template <typename Rtree, typename Cont>
- inline static void apply(Rtree const& t, Cont const& v)
+ inline static void apply(Rtree const& t, Rtree const& t_copy, Cont const& v)
{
namespace bgi = boost::geometry::index;
- 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));
+ random_query_check<B>(t, t_copy, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::covered_by<B> >(t, t_copy, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::disjoint<B> >(t, t_copy, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::intersects<B> >(t, t_copy, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::within<B> >(t, t_copy, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::not_covered_by<B> >(t, t_copy, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::not_disjoint<B> >(t, t_copy, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::not_intersects<B> >(t, t_copy, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::not_within<B> >(t, t_copy, v, 5, helpers::value_randomizer<B>(10, 5));
+
+ random_nearest_check<bgi::detail::empty>(t, t_copy, v, 5, helpers::value_randomizer<P>(10, 0), 3, bgi::empty);
+ random_nearest_check<B>(t, t_copy, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
+ random_nearest_check<bgi::detail::intersects<B> >(t, t_copy, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
+ random_nearest_check<bgi::detail::within<B> >(t, t_copy, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
+ random_nearest_check<bgi::detail::covered_by<B> >(t, t_copy, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
+ random_nearest_check<bgi::detail::disjoint<B> >(t, t_copy, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
}
};
@@ -328,29 +340,29 @@
struct tests_rtree_function_queries<P, B, boost::geometry::box_tag>
{
template <typename Rtree, typename Cont>
- inline static void apply(Rtree const& t, Cont const& v)
+ inline static void apply(Rtree const& t, Rtree const& t_copy, Cont const& v)
{
namespace bgi = boost::geometry::index;
- 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));
+ random_query_check<B>(t, t_copy, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::covered_by<B> >(t, t_copy, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::disjoint<B> >(t, t_copy, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::intersects<B> >(t, t_copy, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::overlaps<B> >(t, t_copy, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::within<B> >(t, t_copy, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::not_covered_by<B> >(t, t_copy, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::not_disjoint<B> >(t, t_copy, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::not_intersects<B> >(t, t_copy, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::not_overlaps<B> >(t, t_copy, v, 5, helpers::value_randomizer<B>(10, 5));
+ random_query_check<bgi::detail::not_within<B> >(t, t_copy, v, 5, helpers::value_randomizer<B>(10, 5));
+
+ random_nearest_check<bgi::detail::empty>(t, t_copy, v, 5, helpers::value_randomizer<P>(10, 0), 3, bgi::empty);
+ random_nearest_check<B>(t, t_copy, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
+ random_nearest_check<bgi::detail::intersects<B> >(t, t_copy, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
+ random_nearest_check<bgi::detail::overlaps<B> >(t, t_copy, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
+ random_nearest_check<bgi::detail::within<B> >(t, t_copy, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
+ random_nearest_check<bgi::detail::covered_by<B> >(t, t_copy, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
+ random_nearest_check<bgi::detail::disjoint<B> >(t, t_copy, v, 5, helpers::value_randomizer<P>(10, 0), 3, helpers::value_randomizer<B>(10, 5));
}
};
@@ -369,11 +381,17 @@
helpers::random_insert(t, v, 10, helpers::value_randomizer<Value>(10, 1));
+ bgi::rtree<Value, Options, Translator> t_copy(t);
+
+ BOOST_CHECK(bgi::size(t) == 10);
+ BOOST_CHECK(bgi::size(t) == bgi::size(t_copy));
+ BOOST_CHECK(bg::equals(bgi::box(t), bgi::box(t_copy)));
+
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);
+ tests_rtree_function_queries<P, B, bgi::traits::tag<I>::type>::apply(t, t_copy, v);
bgi::clear(t);
BOOST_CHECK(bgi::empty(t));
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