Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r80838 - in sandbox-branches/geometry/index_dev: boost/geometry/extensions/index/rtree/visitors test/rtree
From: adam.wulkiewicz_at_[hidden]
Date: 2012-10-03 19:59:02


Author: awulkiew
Date: 2012-10-03 19:59:01 EDT (Wed, 03 Oct 2012)
New Revision: 80838
URL: http://svn.boost.org/trac/boost/changeset/80838

Log:
fixed some warnings and error, added nearest query test which don't find all values.

Text files modified:
   sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/rtree/visitors/insert.hpp | 13 +++++++----
   sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/rtree/visitors/nearest.hpp | 6 ++++
   sandbox-branches/geometry/index_dev/test/rtree/test_rtree.hpp | 42 ++++++++++++++++++++++++++++++++++++++++
   3 files changed, 55 insertions(+), 6 deletions(-)

Modified: sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/rtree/visitors/insert.hpp
==============================================================================
--- sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/rtree/visitors/insert.hpp (original)
+++ sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/rtree/visitors/insert.hpp 2012-10-03 19:59:01 EDT (Wed, 03 Oct 2012)
@@ -23,11 +23,12 @@
 
 // Default choose_next_node
 template <typename Value, typename Options, typename Box, typename Allocators, typename ChooseNextNodeTag>
-struct choose_next_node;
+class choose_next_node;
 
 template <typename Value, typename Options, typename Box, typename Allocators>
-struct choose_next_node<Value, Options, Box, Allocators, choose_by_content_diff_tag>
+class choose_next_node<Value, Options, Box, Allocators, choose_by_content_diff_tag>
 {
+public:
     typedef typename Options::parameters_type parameters_type;
 
     typedef typename rtree::node<Value, parameters_type, Box, Allocators, typename Options::node_tag>::type node;
@@ -345,13 +346,14 @@
 
 // Insert visitor forward declaration
 template <typename Element, typename Value, typename Options, typename Translator, typename Box, typename Allocators, typename InsertTag>
-struct insert;
+class insert;
 
 // Default insert visitor used for nodes elements
 template <typename Element, typename Value, typename Options, typename Translator, typename Box, typename Allocators>
-struct insert<Element, Value, Options, Translator, Box, Allocators, insert_default_tag>
+class insert<Element, Value, Options, Translator, Box, Allocators, insert_default_tag>
     : public detail::insert<Element, Value, Options, Translator, Box, Allocators>
 {
+public:
     typedef detail::insert<Element, Value, Options, Translator, Box, Allocators> base;
     typedef typename base::node node;
     typedef typename base::internal_node internal_node;
@@ -398,9 +400,10 @@
 
 // Default insert visitor specialized for Values elements
 template <typename Value, typename Options, typename Translator, typename Box, typename Allocators>
-struct insert<Value, Value, Options, Translator, Box, Allocators, insert_default_tag>
+class insert<Value, Value, Options, Translator, Box, Allocators, insert_default_tag>
     : public detail::insert<Value, Value, Options, Translator, Box, Allocators>
 {
+public:
     typedef detail::insert<Value, Value, Options, Translator, Box, Allocators> base;
     typedef typename base::node node;
     typedef typename base::internal_node internal_node;

Modified: sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/rtree/visitors/nearest.hpp
==============================================================================
--- sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/rtree/visitors/nearest.hpp (original)
+++ sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/rtree/visitors/nearest.hpp 2012-10-03 19:59:01 EDT (Wed, 03 Oct 2012)
@@ -112,7 +112,11 @@
 
     inline distance_type comparable_distance() const
     {
- return m_neighbors.size() < 0
+ // smallest distance is in the first neighbor only
+ // if there is at least m_count values found
+ // this is just for safety reasons since is_comparable_distance_valid() is checked earlier
+ // TODO - may be replaced by ASSERT
+ return m_neighbors.size() < m_count
             ? (std::numeric_limits<distance_type>::max)()
             : m_neighbors.front().first;
     }

Modified: sandbox-branches/geometry/index_dev/test/rtree/test_rtree.hpp
==============================================================================
--- sandbox-branches/geometry/index_dev/test/rtree/test_rtree.hpp (original)
+++ sandbox-branches/geometry/index_dev/test/rtree/test_rtree.hpp 2012-10-03 19:59:01 EDT (Wed, 03 Oct 2012)
@@ -21,6 +21,32 @@
 #include <boost/geometry/extensions/index/rtree/visitors/are_levels_ok.hpp>
 #include <boost/geometry/extensions/index/rtree/visitors/are_boxes_ok.hpp>
 
+// Set point's coordinates
+
+template <typename Point>
+struct generate_outside_point
+{};
+
+template <typename T, typename C>
+struct generate_outside_point< bg::model::point<T, 2, C> >
+{
+ typedef bg::model::point<T, 2, C> P;
+ static P apply()
+ {
+ return P(13, 26);
+ }
+};
+
+template <typename T, typename C>
+struct generate_outside_point< bg::model::point<T, 3, C> >
+{
+ typedef bg::model::point<T, 3, C> P;
+ static P apply()
+ {
+ return P(13, 26, 13);
+ }
+};
+
 // Values, input and rtree generation
 
 template <typename Value>
@@ -480,6 +506,21 @@
     }
 }
 
+// rtree nearest not found
+
+template <typename Rtree, typename Point, typename CoordinateType>
+void test_nearest_not_found(Rtree const& rtree, Point const& pt, CoordinateType max_distance_1, CoordinateType max_distance_k)
+{
+ typename Rtree::value_type output;
+ size_t n_res = rtree.nearest(bgi::max_bounded(pt, max_distance_1), output);
+ BOOST_CHECK(0 == n_res);
+
+ std::vector<typename Rtree::value_type> output_v;
+ n_res = rtree.nearest(bgi::max_bounded(pt, max_distance_k), 5, std::back_inserter(output_v));
+ BOOST_CHECK(output_v.size() == n_res);
+ BOOST_CHECK(n_res < 5);
+}
+
 // rtree copying and moving
 
 template <typename Value, typename Algo, typename Box>
@@ -580,6 +621,7 @@
     
     test_nearest(tree, input, pt);
     test_nearest_k(tree, input, pt, 10);
+ test_nearest_not_found(tree, generate_outside_point<P>::apply(), 1, 3);
 
     test_copy_assignment_move(tree, qbox);
 


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