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

[SVN r80838]
This commit is contained in:
Adam Wulkiewicz
2012-10-03 23:59:01 +00:00
parent fa88da6b99
commit a8356c2625
3 changed files with 55 additions and 6 deletions

View File

@@ -23,11 +23,12 @@ namespace detail {
// 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 @@ protected:
// 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 @@ struct insert<Element, Value, Options, Translator, Box, Allocators, insert_defau
// 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;

View File

@@ -112,7 +112,11 @@ public:
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;
}

View File

@@ -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 @@ void test_nearest_k(Rtree const& rtree, std::vector<Value> const& input, Point c
}
}
// 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 @@ void test_rtree_by_value(Parameters const& parameters)
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);