Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r74447 - in sandbox-branches/geometry/index: boost/geometry/extensions/index boost/geometry/extensions/index/rtree boost/geometry/extensions/index/rtree/visitors tests
From: adam.wulkiewicz_at_[hidden]
Date: 2011-09-18 06:42:49


Author: awulkiew
Date: 2011-09-18 06:42:46 EDT (Sun, 18 Sep 2011)
New Revision: 74447
URL: http://svn.boost.org/trac/boost/changeset/74447

Log:
error fixed in rtree's overlaps predicate check specialization for node
Added:
   sandbox-branches/geometry/index/tests/rtree_function.hpp (contents, props changed)
Removed:
   sandbox-branches/geometry/index/tests/rtree_native.hpp
Text files modified:
   sandbox-branches/geometry/index/boost/geometry/extensions/index/predicates.hpp | 2 ++
   sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/predicates.hpp | 22 ++++++++++++----------
   sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/visitors/nearest.hpp | 7 +++++--
   sandbox-branches/geometry/index/tests/main.cpp | 8 ++------
   sandbox-branches/geometry/index/tests/translators.hpp | 2 +-
   5 files changed, 22 insertions(+), 19 deletions(-)

Modified: sandbox-branches/geometry/index/boost/geometry/extensions/index/predicates.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/predicates.hpp (original)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/predicates.hpp 2011-09-18 06:42:46 EDT (Sun, 18 Sep 2011)
@@ -93,6 +93,8 @@
 
 // predicate check
 
+// TODO: use empty definitions here + MPL_ASSERT
+
 template <typename Geometry, typename Tag>
 struct predicate_check
 {

Modified: sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/predicates.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/predicates.hpp (original)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/predicates.hpp 2011-09-18 06:42:46 EDT (Sun, 18 Sep 2011)
@@ -52,16 +52,18 @@
 // return geometry::intersects(i, p.geometry);
 // }
 //};
-//
-//template <typename Geometry>
-//struct predicate_check<overlaps<Geometry>, rtree::node_predicates_tag>
-//{
-// template <typename Indexable>
-// static inline bool apply(overlaps<Geometry> const& p, Indexable const& i)
-// {
-// return geometry::overlaps(i, p.geometry);
-// }
-//};
+
+template <typename Geometry>
+struct predicate_check<overlaps<Geometry>, rtree::node_predicates_tag>
+{
+ template <typename Indexable>
+ static inline bool apply(overlaps<Geometry> const& p, Indexable const& i)
+ {
+ // TODO: awulkiew - possibly change to the version without border case
+ // e.g. intersects_without_border(0,0x1,1, 1,1x2,2) should give false
+ return geometry::intersects(i, p.geometry);
+ }
+};
 
 template <typename Geometry>
 struct predicate_check<within<Geometry>, rtree::node_predicates_tag>

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-18 06:42:46 EDT (Sun, 18 Sep 2011)
@@ -155,13 +155,16 @@
         , m_result(r)
     {}
 
+ //TODO: awulkiew - check this approach: store one, global vector of active branches, add branches only if mindist is ok
+
     inline void operator()(internal_node const& n)
     {
         // array of active nodes
- index::pushable_array<
+ /*index::pushable_array<
             std::pair<node_distance_type, const node *>,
             Options::parameters_type::max_elements
- > active_branch_list;
+ > active_branch_list;*/
+ std::vector< std::pair<node_distance_type, const node *> > active_branch_list;
 
         typedef typename rtree::elements_type<internal_node>::type elements_type;
         elements_type const& elements = rtree::elements(n);

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-18 06:42:46 EDT (Sun, 18 Sep 2011)
@@ -11,17 +11,13 @@
 #include <boost/test/unit_test.hpp>
 
 #include <tests/translators.hpp>
-#include <tests/rtree_native.hpp>
+#include <tests/rtree_function.hpp>
 #include <tests/rtree_filters.hpp>
 
-BOOST_AUTO_TEST_CASE( test_main )
+BOOST_AUTO_TEST_CASE( aaaa )
 {
     std::cout << "test\n";
 
- tests_rtree_native_hpp< boost::geometry::index::linear<32, 8> >();
- tests_rtree_native_hpp< boost::geometry::index::quadratic<32, 8> >();
- tests_rtree_native_hpp< boost::geometry::index::rstar<32, 8> >();
-
     tests_rtree_filters_hpp();
 
 #ifdef _MSC_VER

Added: sandbox-branches/geometry/index/tests/rtree_function.hpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/tests/rtree_function.hpp 2011-09-18 06:42:46 EDT (Sun, 18 Sep 2011)
@@ -0,0 +1,209 @@
+#ifndef TESTS_RTREE_FUNCTION_HPP
+#define TESTS_RTREE_FUNCTION_HPP
+
+#include <boost/geometry/geometry.hpp>
+
+#include <boost/geometry/extensions/index/rtree/rtree.hpp>
+#include <boost/geometry/extensions/index/translator/index.hpp>
+
+#include <boost/geometry/extensions/index/rtree/visitors/print.hpp>
+
+#include <boost/range/algorithm.hpp>
+#include <boost/foreach.hpp>
+
+#include <map>
+
+template <typename Options>
+void tests_rtree_function_box3f_impl()
+{
+ namespace bg = boost::geometry;
+ namespace bgi = bg::index;
+
+ typedef bg::model::point<float, 3, bg::cs::cartesian> P;
+ typedef bg::model::box<P> B;
+ typedef B val_t;
+
+ bgi::rtree<val_t, Options> t;
+
+ bgi::insert(t, B(P(0, 0, 0), P(1, 1, 1)));
+ bgi::insert(t, B(P(2, 2, 2), P(3, 3, 3)));
+ bgi::insert(t, B(P(4, 4, 4), P(5, 5, 5)));
+ bgi::insert(t, B(P(6, 6, 6), P(7, 7, 7)));
+ bgi::insert(t, B(P(8, 8, 8), P(9, 9, 9)));
+
+ B g(P(4.5f, 4.5f, 4.5f), P(5.5f, 5.5f, 5.5f));
+ B gi(P(4, 4, 4), P(5, 5, 5));
+ std::vector<val_t> result;
+
+ size_t f = bgi::query(t, g, std::back_inserter(result));
+ BOOST_CHECK( 1 == f && 1 == result.size() && bg::equals(result[0], gi) );
+
+ result.clear();
+ f = bgi::query(t, bgi::intersects(g), std::back_inserter(result));
+ BOOST_CHECK( 1 == f && 1 == result.size() && bg::equals(result[0], gi) );
+
+ BOOST_CHECK( bg::overlaps(g, gi) );
+
+ result.clear();
+ f = bgi::query(t, bgi::overlaps(g), std::back_inserter(result));
+ BOOST_CHECK( 1 == f && 1 == result.size() && bg::equals(result[0], gi) );
+
+ result.clear();
+ f = bgi::query(t, bgi::within(g), std::back_inserter(result));
+ BOOST_CHECK( 0 == f && 0 == result.size() );
+
+ result.clear();
+ f = bgi::query(t, bgi::covered_by(g), std::back_inserter(result));
+ BOOST_CHECK( 0 == f && 0 == result.size() );
+
+ P p(3.9f, 3.5f, 3.5f);
+ val_t result_val;
+
+ f = bgi::nearest(t, p, result_val);
+ BOOST_CHECK( 1 == f && bg::equals(result_val, gi) );
+}
+
+BOOST_AUTO_TEST_CASE(tests_rtree_function_box3f)
+{
+ std::cout << "tests/rtree_function_box3f\n";
+
+ namespace bg = boost::geometry;
+ namespace bgi = bg::index;
+
+ tests_rtree_function_box3f_impl< bgi::linear<4, 2> >();
+ tests_rtree_function_box3f_impl< bgi::quadratic<4, 2> >();
+ tests_rtree_function_box3f_impl< bgi::rstar<4, 2> >();
+}
+
+
+ // std::cout << "Boxes2d\n";
+ // {
+ // typedef bg::model::point<float, 2, bg::cs::cartesian> P;
+ // typedef bg::model::box<P> B;
+
+ // bgi::rtree<B, Options> t;
+ // bgi::insert(t, B(P(0, 0), P(1, 1)));
+ // bgi::insert(t, B(P(2, 2), P(3, 3)));
+ // 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::cerr << t;
+ // }
+
+ // std::cout << "-------------------------------------------------\n";
+ // std::cout << "-------------------------------------------------\n";
+
+ // std::cout << "Points\n";
+ // {
+ // typedef bg::model::point<float, 2, bg::cs::cartesian> P;
+ // typedef bg::model::box<P> B;
+
+ // bgi::rtree<P, Options> t;
+ // bgi::insert(t, P(0, 0));
+ // bgi::insert(t, P(2, 2));
+ // bgi::insert(t, P(4, 4));
+ // bgi::insert(t, P(6, 6));
+ // bgi::insert(t, P(8, 8));
+ // std::cerr << t;
+ // }
+
+ // std::cout << "-------------------------------------------------\n";
+ // std::cout << "-------------------------------------------------\n";
+
+ // std::cout << "std::pair<Box, int>\n";
+ // {
+ // typedef bg::model::point<float, 2, bg::cs::cartesian> P;
+ // typedef bg::model::box<P> B;
+ // typedef std::pair<B, int> V;
+
+ // bgi::rtree<V, Options> t;
+ // bgi::insert(t, V(B(P(0, 0), P(1, 1)), 0));
+ // bgi::insert(t, V(B(P(2, 2), P(3, 3)), 1));
+ // bgi::insert(t, V(B(P(4, 4), P(5, 5)), 2));
+ // bgi::insert(t, V(B(P(6, 6), P(7, 7)), 3));
+ // bgi::insert(t, V(B(P(8, 8), P(9, 9)), 4));
+ // std::cerr << t;
+ // }
+
+ // std::cout << "-------------------------------------------------\n";
+ // std::cout << "-------------------------------------------------\n";
+
+ // std::cout << "boost::shared_ptr< std::pair<Box, int> >\n";
+ // {
+ // typedef bg::model::point<float, 2, bg::cs::cartesian> P;
+ // typedef bg::model::box<P> B;
+ //
+ // typedef boost::shared_ptr< std::pair<B, int> > V;
+
+ // V v1( new std::pair<B, int>(B(P(0, 0), P(1, 1)), 0) );
+ // V v2( new std::pair<B, int>(B(P(2, 2), P(3, 3)), 1) );
+ // V v3( new std::pair<B, int>(B(P(4, 4), P(5, 5)), 2) );
+ // V v4( new std::pair<B, int>(B(P(6, 6), P(7, 7)), 3) );
+ // V v5( new std::pair<B, int>(B(P(8, 8), P(9, 9)), 4) );
+
+ // bgi::rtree<V, Options> t;
+ // bgi::insert(t, v1);
+ // bgi::insert(t, v2);
+ // bgi::insert(t, v3);
+ // bgi::insert(t, v4);
+ // bgi::insert(t, v5);
+ // std::cerr << t;
+ // }
+
+ // std::cout << "-------------------------------------------------\n";
+ // std::cout << "-------------------------------------------------\n";
+
+ // std::cout << "std::map<int, Box>::iterator\n";
+ // {
+ // typedef bg::model::point<float, 2, bg::cs::cartesian> P;
+ // typedef bg::model::box<P> B;
+ //
+ // typedef std::map<int, B>::iterator V;
+
+ // std::map<int, B> m;
+ // m.insert(std::pair<int, B>(0, B(P(0, 0), P(1, 1))));
+ // m.insert(std::pair<int, B>(1, B(P(2, 2), P(3, 3))));
+ // m.insert(std::pair<int, B>(2, B(P(4, 4), P(5, 5))));
+ // m.insert(std::pair<int, B>(3, B(P(6, 6), P(7, 7))));
+ // m.insert(std::pair<int, B>(4, B(P(8, 8), P(9, 9))));
+
+ // bgi::rtree<V, Options> t;
+ // V vit = m.begin();
+ // bgi::insert(t, vit++);
+ // bgi::insert(t, vit++);
+ // bgi::insert(t, vit++);
+ // bgi::insert(t, vit++);
+ // bgi::insert(t, vit);
+ // std::cerr << t;
+ // }
+
+ // std::cout << "-------------------------------------------------\n";
+ // std::cout << "-------------------------------------------------\n";
+
+ // std::cout << "size_t\n";
+ // {
+ // typedef bg::model::point<float, 2, bg::cs::cartesian> P;
+ // typedef bg::model::box<P> B;
+
+ // typedef size_t V;
+ // typedef bgi::translator::index<std::vector<B> > Tr;
+
+ // std::vector<B> v;
+ // v.push_back(B(P(0, 0), P(1, 1)));
+ // v.push_back(B(P(2, 2), P(3, 3)));
+ // v.push_back(B(P(4, 4), P(5, 5)));
+ // v.push_back(B(P(6, 6), P(7, 7)));
+ // v.push_back(B(P(8, 8), P(9, 9)));
+
+ //Tr tr(v);
+ // bgi::rtree<V, Options, Tr> t(tr);
+
+ // bgi::insert(t, 0u);
+ // bgi::insert(t, 1u);
+ // bgi::insert(t, 2u);
+ // bgi::insert(t, 3u);
+ // bgi::insert(t, 4u);
+ // std::cerr << t;
+ // }
+
+#endif // TESTS_RTREE_FUNCTION_HPP

Deleted: sandbox-branches/geometry/index/tests/rtree_native.hpp
==============================================================================
--- sandbox-branches/geometry/index/tests/rtree_native.hpp 2011-09-18 06:42:46 EDT (Sun, 18 Sep 2011)
+++ (empty file)
@@ -1,169 +0,0 @@
-#ifndef TESTS_RTREE_NATIVE_HPP
-#define TESTS_RTREE_NATIVE_HPP
-
-#include <boost/geometry/geometry.hpp>
-
-#include <boost/geometry/extensions/index/rtree/rtree.hpp>
-#include <boost/geometry/extensions/index/translator/index.hpp>
-
-#include <boost/geometry/extensions/index/rtree/visitors/print.hpp>
-
-#include <boost/range/algorithm.hpp>
-#include <boost/foreach.hpp>
-
-#include <map>
-
-template <typename Options>
-void tests_rtree_native_hpp()
-{
- std::cout << "tests/rtree_native.hpp\n";
-
- std::cout << "Boxes3d\n";
- {
- typedef boost::geometry::model::point<float, 3, boost::geometry::cs::cartesian> P;
- typedef boost::geometry::model::box<P> B;
-
- boost::geometry::index::rtree<B, Options> t;
- boost::geometry::index::insert(t, B(P(0, 0, 0), P(1, 1, 1)));
- boost::geometry::index::insert(t, B(P(2, 2, 2), P(3, 3, 3)));
- boost::geometry::index::insert(t, B(P(4, 4, 4), P(5, 5, 5)));
- boost::geometry::index::insert(t, B(P(6, 6, 6), P(7, 7, 7)));
- boost::geometry::index::insert(t, B(P(8, 8, 8), P(9, 9, 9)));
- std::cerr << t;
- }
-
- std::cout << "-------------------------------------------------\n";
- std::cout << "-------------------------------------------------\n";
-
- std::cout << "Boxes2d\n";
- {
- typedef boost::geometry::model::point<float, 2, boost::geometry::cs::cartesian> P;
- typedef boost::geometry::model::box<P> B;
-
- boost::geometry::index::rtree<B, Options> t;
- boost::geometry::index::insert(t, B(P(0, 0), P(1, 1)));
- boost::geometry::index::insert(t, B(P(2, 2), P(3, 3)));
- boost::geometry::index::insert(t, B(P(4, 4), P(5, 5)));
- boost::geometry::index::insert(t, B(P(6, 6), P(7, 7)));
- boost::geometry::index::insert(t, B(P(8, 8), P(9, 9)));
- std::cerr << t;
- }
-
- std::cout << "-------------------------------------------------\n";
- std::cout << "-------------------------------------------------\n";
-
- std::cout << "Points\n";
- {
- typedef boost::geometry::model::point<float, 2, boost::geometry::cs::cartesian> P;
- typedef boost::geometry::model::box<P> B;
-
- boost::geometry::index::rtree<P, Options> t;
- boost::geometry::index::insert(t, P(0, 0));
- boost::geometry::index::insert(t, P(2, 2));
- boost::geometry::index::insert(t, P(4, 4));
- boost::geometry::index::insert(t, P(6, 6));
- boost::geometry::index::insert(t, P(8, 8));
- std::cerr << t;
- }
-
- std::cout << "-------------------------------------------------\n";
- std::cout << "-------------------------------------------------\n";
-
- std::cout << "std::pair<Box, int>\n";
- {
- typedef boost::geometry::model::point<float, 2, boost::geometry::cs::cartesian> P;
- typedef boost::geometry::model::box<P> B;
- typedef std::pair<B, int> V;
-
- boost::geometry::index::rtree<V, Options> t;
- boost::geometry::index::insert(t, V(B(P(0, 0), P(1, 1)), 0));
- boost::geometry::index::insert(t, V(B(P(2, 2), P(3, 3)), 1));
- boost::geometry::index::insert(t, V(B(P(4, 4), P(5, 5)), 2));
- boost::geometry::index::insert(t, V(B(P(6, 6), P(7, 7)), 3));
- boost::geometry::index::insert(t, V(B(P(8, 8), P(9, 9)), 4));
- std::cerr << t;
- }
-
- std::cout << "-------------------------------------------------\n";
- std::cout << "-------------------------------------------------\n";
-
- std::cout << "boost::shared_ptr< std::pair<Box, int> >\n";
- {
- typedef boost::geometry::model::point<float, 2, boost::geometry::cs::cartesian> P;
- typedef boost::geometry::model::box<P> B;
-
- typedef boost::shared_ptr< std::pair<B, int> > V;
-
- V v1( new std::pair<B, int>(B(P(0, 0), P(1, 1)), 0) );
- V v2( new std::pair<B, int>(B(P(2, 2), P(3, 3)), 1) );
- V v3( new std::pair<B, int>(B(P(4, 4), P(5, 5)), 2) );
- V v4( new std::pair<B, int>(B(P(6, 6), P(7, 7)), 3) );
- V v5( new std::pair<B, int>(B(P(8, 8), P(9, 9)), 4) );
-
- boost::geometry::index::rtree<V, Options> t;
- boost::geometry::index::insert(t, v1);
- boost::geometry::index::insert(t, v2);
- boost::geometry::index::insert(t, v3);
- boost::geometry::index::insert(t, v4);
- boost::geometry::index::insert(t, v5);
- std::cerr << t;
- }
-
- std::cout << "-------------------------------------------------\n";
- std::cout << "-------------------------------------------------\n";
-
- std::cout << "std::map<int, Box>::iterator\n";
- {
- typedef boost::geometry::model::point<float, 2, boost::geometry::cs::cartesian> P;
- typedef boost::geometry::model::box<P> B;
-
- typedef std::map<int, B>::iterator V;
-
- std::map<int, B> m;
- m.insert(std::pair<int, B>(0, B(P(0, 0), P(1, 1))));
- m.insert(std::pair<int, B>(1, B(P(2, 2), P(3, 3))));
- m.insert(std::pair<int, B>(2, B(P(4, 4), P(5, 5))));
- m.insert(std::pair<int, B>(3, B(P(6, 6), P(7, 7))));
- m.insert(std::pair<int, B>(4, B(P(8, 8), P(9, 9))));
-
- boost::geometry::index::rtree<V, Options> t;
- V vit = m.begin();
- boost::geometry::index::insert(t, vit++);
- boost::geometry::index::insert(t, vit++);
- boost::geometry::index::insert(t, vit++);
- boost::geometry::index::insert(t, vit++);
- boost::geometry::index::insert(t, vit);
- std::cerr << t;
- }
-
- std::cout << "-------------------------------------------------\n";
- std::cout << "-------------------------------------------------\n";
-
- std::cout << "size_t\n";
- {
- typedef boost::geometry::model::point<float, 2, boost::geometry::cs::cartesian> P;
- typedef boost::geometry::model::box<P> B;
-
- typedef size_t V;
- typedef boost::geometry::index::translator::index<std::vector<B> > Tr;
-
- std::vector<B> v;
- v.push_back(B(P(0, 0), P(1, 1)));
- v.push_back(B(P(2, 2), P(3, 3)));
- v.push_back(B(P(4, 4), P(5, 5)));
- v.push_back(B(P(6, 6), P(7, 7)));
- v.push_back(B(P(8, 8), P(9, 9)));
-
- Tr tr(v);
- boost::geometry::index::rtree<V, Options, Tr> t(tr);
-
- boost::geometry::index::insert(t, 0u);
- boost::geometry::index::insert(t, 1u);
- boost::geometry::index::insert(t, 2u);
- boost::geometry::index::insert(t, 3u);
- boost::geometry::index::insert(t, 4u);
- std::cerr << t;
- }
-}
-
-#endif // TESTS_RTREE_NATIVE_HPP

Modified: sandbox-branches/geometry/index/tests/translators.hpp
==============================================================================
--- sandbox-branches/geometry/index/tests/translators.hpp (original)
+++ sandbox-branches/geometry/index/tests/translators.hpp 2011-09-18 06:42:46 EDT (Sun, 18 Sep 2011)
@@ -34,7 +34,7 @@
 
 BOOST_AUTO_TEST_CASE(tests_translators)
 {
- std::cout << "tests/translators.hpp\n";
+ std::cout << "tests/translators\n";
 
     namespace bg = boost::geometry;
     namespace bgm = bg::model;


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