mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-11 11:52:11 +00:00
Names changed query to spatial_query, nearest to nearest_query, query_filtered to adaptors::spatial_queried, nearest_filtered to adaptors::nearest_queried.
[SVN r81349]
This commit is contained in:
@@ -42,15 +42,15 @@ int main(void)
|
||||
rtree.insert(std::make_pair(b, 0));
|
||||
//]
|
||||
|
||||
//[rtree_quickstart_query
|
||||
//[rtree_quickstart_spatial_query
|
||||
// find values intersecting a box
|
||||
std::vector<value> result;
|
||||
rtree.query(b, std::back_inserter(result));
|
||||
rtree.spatial_query(b, std::back_inserter(result));
|
||||
//]
|
||||
|
||||
//[rtree_quickstart_nearest
|
||||
//[rtree_quickstart_nearest_query
|
||||
// find 5 nearest values to a point
|
||||
rtree.nearest(point(0, 0), 5, std::back_inserter(result));
|
||||
rtree.nearest_query(point(0, 0), 5, std::back_inserter(result));
|
||||
//]
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -13,19 +13,21 @@
|
||||
|
||||
namespace boost { namespace geometry { namespace index {
|
||||
|
||||
namespace adaptors {
|
||||
|
||||
template <typename Index>
|
||||
class nearest_filter
|
||||
class nearest_query_range
|
||||
{
|
||||
BOOST_MPL_ASSERT_MSG(
|
||||
(false),
|
||||
NOT_IMPLEMENTED_FOR_THIS_INDEX,
|
||||
(nearest_filter));
|
||||
(nearest_query_range));
|
||||
|
||||
typedef int* iterator;
|
||||
typedef const int* const_iterator;
|
||||
|
||||
template <typename DistancesPredicates, typename Predicates>
|
||||
inline nearest_filter(
|
||||
inline nearest_query_range(
|
||||
Index const&,
|
||||
DistancesPredicates const&,
|
||||
size_t,
|
||||
@@ -44,9 +46,9 @@ namespace detail {
|
||||
// TODO: awulkiew - consider removing references from predicates
|
||||
|
||||
template<typename DistancesPredicates, typename Predicates>
|
||||
struct nearest_filtered
|
||||
struct nearest_query
|
||||
{
|
||||
inline nearest_filtered(
|
||||
inline nearest_query(
|
||||
DistancesPredicates const& dpred,
|
||||
size_t k,
|
||||
Predicates const& pred
|
||||
@@ -64,21 +66,34 @@ struct nearest_filtered
|
||||
} // namespace detail
|
||||
|
||||
template <typename DistancesPredicates, typename Predicates>
|
||||
detail::nearest_filtered<DistancesPredicates, Predicates> nearest_filtered(
|
||||
detail::nearest_query<DistancesPredicates, Predicates>
|
||||
nearest_queried(
|
||||
DistancesPredicates const& dpred,
|
||||
size_t k,
|
||||
Predicates const& pred = detail::empty())
|
||||
Predicates const& pred)
|
||||
{
|
||||
return detail::nearest_filtered<DistancesPredicates, Predicates>(dpred, k, pred);
|
||||
return detail::nearest_query<DistancesPredicates, Predicates>(dpred, k, pred);
|
||||
}
|
||||
|
||||
template <typename DistancesPredicates>
|
||||
detail::nearest_query<DistancesPredicates, index::detail::empty>
|
||||
nearest_queried(
|
||||
DistancesPredicates const& dpred,
|
||||
size_t k)
|
||||
{
|
||||
return detail::nearest_query<DistancesPredicates, index::detail::empty>(dpred, k, index::detail::empty());
|
||||
}
|
||||
|
||||
} // namespace adaptors
|
||||
|
||||
template<typename Index, typename DistancesPredicates, typename Predicates>
|
||||
index::nearest_filter<Index>
|
||||
index::adaptors::nearest_query_range<Index>
|
||||
operator|(
|
||||
Index const& si,
|
||||
detail::nearest_filtered<DistancesPredicates, Predicates> const& f)
|
||||
index::adaptors::detail::nearest_query<DistancesPredicates, Predicates> const& f)
|
||||
{
|
||||
return index::nearest_filter<Index>(si, f.distances_predicates, f.count, f.predicates);
|
||||
return index::adaptors::nearest_query_range<Index>(
|
||||
si, f.distances_predicates, f.count, f.predicates);
|
||||
}
|
||||
|
||||
}}} // namespace boost::geometry::index
|
||||
|
||||
@@ -13,22 +13,23 @@
|
||||
|
||||
namespace boost { namespace geometry { namespace index {
|
||||
|
||||
namespace adaptors {
|
||||
|
||||
template <typename Index>
|
||||
class query_filter
|
||||
class spatial_query_range
|
||||
{
|
||||
BOOST_MPL_ASSERT_MSG(
|
||||
(false),
|
||||
NOT_IMPLEMENTED_FOR_THIS_INDEX,
|
||||
(query_filter));
|
||||
(spatial_query_range));
|
||||
|
||||
typedef int* iterator;
|
||||
typedef const int* const_iterator;
|
||||
|
||||
template <typename Predicates>
|
||||
inline query_filter(
|
||||
inline spatial_query_range(
|
||||
Index const&,
|
||||
Predicates const&
|
||||
)
|
||||
Predicates const&)
|
||||
{}
|
||||
|
||||
inline iterator begin() { return 0; }
|
||||
@@ -42,9 +43,9 @@ namespace detail {
|
||||
// TODO: awulkiew - consider removing reference from predicates
|
||||
|
||||
template<typename Predicates>
|
||||
struct query_filtered
|
||||
struct spatial_query
|
||||
{
|
||||
inline explicit query_filtered(Predicates const& pred)
|
||||
inline explicit spatial_query(Predicates const& pred)
|
||||
: predicates(pred)
|
||||
{}
|
||||
|
||||
@@ -54,18 +55,21 @@ struct query_filtered
|
||||
} // namespace detail
|
||||
|
||||
template <typename Predicates>
|
||||
detail::query_filtered<Predicates> query_filtered(Predicates const& pred)
|
||||
detail::spatial_query<Predicates>
|
||||
spatial_queried(Predicates const& pred)
|
||||
{
|
||||
return detail::query_filtered<Predicates>(pred);
|
||||
return detail::spatial_query<Predicates>(pred);
|
||||
}
|
||||
|
||||
} // namespace adaptors
|
||||
|
||||
template<typename Index, typename Predicates>
|
||||
index::query_filter<Index>
|
||||
index::adaptors::spatial_query_range<Index>
|
||||
operator|(
|
||||
Index const& si,
|
||||
index::detail::query_filtered<Predicates> const& f)
|
||||
index::adaptors::detail::spatial_query<Predicates> const& f)
|
||||
{
|
||||
return index::query_filter<Index>(si, f.predicates);
|
||||
return index::adaptors::spatial_query_range<Index>(si, f.predicates);
|
||||
}
|
||||
|
||||
}}} // namespace boost::geometry::index
|
||||
|
||||
@@ -22,8 +22,10 @@ namespace boost { namespace geometry { namespace index {
|
||||
template <typename Value, typename Options, typename Translator, typename Allocator>
|
||||
class rtree;
|
||||
|
||||
namespace adaptors {
|
||||
|
||||
template <typename Value, typename Options, typename Translator, typename Allocator>
|
||||
class query_filter< index::rtree<Value, Options, Translator, Allocator> >
|
||||
class spatial_query_range< index::rtree<Value, Options, Translator, Allocator> >
|
||||
{
|
||||
public:
|
||||
typedef std::vector<Value> result_type;
|
||||
@@ -31,12 +33,12 @@ public:
|
||||
typedef typename result_type::const_iterator const_iterator;
|
||||
|
||||
template <typename Predicates>
|
||||
inline query_filter(
|
||||
inline spatial_query_range(
|
||||
index::rtree<Value, Options, Translator, Allocator> const& rtree,
|
||||
Predicates const& pred
|
||||
)
|
||||
{
|
||||
rtree.query(pred, std::back_inserter(m_result));
|
||||
rtree.spatial_query(pred, std::back_inserter(m_result));
|
||||
}
|
||||
|
||||
inline iterator begin() { return m_result.begin(); }
|
||||
@@ -49,7 +51,7 @@ private:
|
||||
};
|
||||
|
||||
template <typename Value, typename Options, typename Translator, typename Allocator>
|
||||
class nearest_filter< index::rtree<Value, Options, Translator, Allocator> >
|
||||
class nearest_query_range< index::rtree<Value, Options, Translator, Allocator> >
|
||||
{
|
||||
public:
|
||||
typedef std::vector<Value> result_type;
|
||||
@@ -57,14 +59,14 @@ public:
|
||||
typedef typename result_type::const_iterator const_iterator;
|
||||
|
||||
template <typename DistancesPredicates, typename Predicates>
|
||||
inline nearest_filter(
|
||||
inline nearest_query_range(
|
||||
index::rtree<Value, Options, Translator, Allocator> const& rtree,
|
||||
DistancesPredicates const& dpred,
|
||||
size_t k,
|
||||
Predicates const& pred
|
||||
)
|
||||
{
|
||||
rtree.nearest(dpred, k, pred, std::back_inserter(m_result));
|
||||
rtree.nearest_query(dpred, k, pred, std::back_inserter(m_result));
|
||||
}
|
||||
|
||||
inline iterator begin() { return m_result.begin(); }
|
||||
@@ -76,6 +78,8 @@ private:
|
||||
result_type m_result;
|
||||
};
|
||||
|
||||
} // namespace adaptors
|
||||
|
||||
}}} // namespace boost::geometry::index
|
||||
|
||||
#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_FILTERS_HPP
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
template <typename Node>
|
||||
static inline void apply(typename rtree::elements_type<Node>::type & result_elements,
|
||||
Node & n,
|
||||
internal_node *parent,
|
||||
internal_node *parent,
|
||||
size_t current_child_index,
|
||||
parameters_type const& parameters,
|
||||
Translator const& translator,
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <boost/geometry/extensions/index/translator/translator.hpp>
|
||||
#include <boost/geometry/extensions/index/rtree/options.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/index/rtree/predicates.hpp>
|
||||
#include <boost/geometry/extensions/index/predicates.hpp>
|
||||
#include <boost/geometry/extensions/index/rtree/filters.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/index/rtree/node/node.hpp>
|
||||
@@ -45,6 +45,8 @@
|
||||
#include <boost/geometry/extensions/index/rtree/rstar/rstar.hpp>
|
||||
//#include <boost/geometry/extensions/index/rtree/kmeans/kmeans.hpp>
|
||||
|
||||
// TODO change the name to bounding_tree
|
||||
|
||||
namespace boost { namespace geometry { namespace index {
|
||||
|
||||
/*!
|
||||
@@ -335,7 +337,7 @@ public:
|
||||
\return The number of values found.
|
||||
*/
|
||||
template <typename Predicates, typename OutIter>
|
||||
inline size_type query(Predicates const& pred, OutIter out_it) const
|
||||
inline size_type spatial_query(Predicates const& pred, OutIter out_it) const
|
||||
{
|
||||
detail::rtree::visitors::query<value_type, options_type, translator_type, box_type, allocators_type, Predicates, OutIter>
|
||||
find_v(m_translator, pred, out_it);
|
||||
@@ -365,7 +367,7 @@ public:
|
||||
\return The number of values found.
|
||||
*/
|
||||
template <typename DistancesPredicates>
|
||||
inline size_type nearest(DistancesPredicates const& dpred, value_type & v) const
|
||||
inline size_type nearest_query(DistancesPredicates const& dpred, value_type & v) const
|
||||
{
|
||||
return raw_nearest_one(dpred, detail::empty(), v);
|
||||
}
|
||||
@@ -397,7 +399,7 @@ public:
|
||||
\return The number of values found.
|
||||
*/
|
||||
template <typename DistancesPredicates, typename Predicates>
|
||||
inline size_type nearest(DistancesPredicates const& dpred, Predicates const& pred, value_type & v) const
|
||||
inline size_type nearest_query(DistancesPredicates const& dpred, Predicates const& pred, value_type & v) const
|
||||
{
|
||||
return raw_nearest_one(dpred, pred, v);
|
||||
}
|
||||
@@ -422,7 +424,7 @@ public:
|
||||
\return The number of values found.
|
||||
*/
|
||||
template <typename DistancesPredicates, typename OutIter>
|
||||
inline size_type nearest(DistancesPredicates const& dpred, size_t k, OutIter out_it) const
|
||||
inline size_type nearest_query(DistancesPredicates const& dpred, size_t k, OutIter out_it) const
|
||||
{
|
||||
return raw_nearest_k(dpred, k, detail::empty(), out_it);
|
||||
}
|
||||
@@ -455,7 +457,7 @@ public:
|
||||
\return The number of values found.
|
||||
*/
|
||||
template <typename DistancesPredicates, typename Predicates, typename OutIter>
|
||||
inline size_type nearest(DistancesPredicates const& dpred, size_t k, Predicates const& pred, OutIter out_it) const
|
||||
inline size_type nearest_query(DistancesPredicates const& dpred, size_t k, Predicates const& pred, OutIter out_it) const
|
||||
{
|
||||
return raw_nearest_k(dpred, k, pred, out_it);
|
||||
}
|
||||
@@ -853,9 +855,9 @@ Find values meeting spatial predicates.
|
||||
\return The number of found values.
|
||||
*/
|
||||
template <typename Value, typename Options, typename Translator, typename Allocator, typename Predicates, typename OutIter>
|
||||
inline size_t query(rtree<Value, Options, Translator, Allocator> const& tree, Predicates const& pred, OutIter out_it)
|
||||
inline size_t spatial_query(rtree<Value, Options, Translator, Allocator> const& tree, Predicates const& pred, OutIter out_it)
|
||||
{
|
||||
return tree.query(pred, out_it);
|
||||
return tree.spatial_query(pred, out_it);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -868,9 +870,9 @@ Find the value meeting distances predicates.
|
||||
\return The number of found values.
|
||||
*/
|
||||
template <typename Value, typename Options, typename Translator, typename Allocator, typename DistancesPredicates>
|
||||
inline size_t nearest(rtree<Value, Options, Translator, Allocator> const& tree, DistancesPredicates const& dpred, Value & v)
|
||||
inline size_t nearest_query(rtree<Value, Options, Translator, Allocator> const& tree, DistancesPredicates const& dpred, Value & v)
|
||||
{
|
||||
return tree.nearest(dpred, v);
|
||||
return tree.nearest_query(dpred, v);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -884,9 +886,9 @@ Find the value meeting distances and spatial predicates.
|
||||
\return The number of found values.
|
||||
*/
|
||||
template <typename Value, typename Options, typename Translator, typename Allocator, typename DistancesPredicates, typename Predicates>
|
||||
inline size_t nearest(rtree<Value, Options, Translator, Allocator> const& tree, DistancesPredicates const& dpred, Predicates const& pred, Value & v)
|
||||
inline size_t nearest_query(rtree<Value, Options, Translator, Allocator> const& tree, DistancesPredicates const& dpred, Predicates const& pred, Value & v)
|
||||
{
|
||||
return tree.nearest(dpred, pred, v);
|
||||
return tree.nearest_query(dpred, pred, v);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -900,9 +902,9 @@ Find k values meeting distances predicates.
|
||||
\return The number of found values.
|
||||
*/
|
||||
template <typename Value, typename Options, typename Translator, typename Allocator, typename DistancesPredicates, typename OutIter>
|
||||
inline size_t nearest(rtree<Value, Options, Translator, Allocator> const& tree, DistancesPredicates const& dpred, size_t k, OutIter out_it)
|
||||
inline size_t nearest_query(rtree<Value, Options, Translator, Allocator> const& tree, DistancesPredicates const& dpred, size_t k, OutIter out_it)
|
||||
{
|
||||
return tree.nearest(dpred, k, out_it);
|
||||
return tree.nearest_query(dpred, k, out_it);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -917,9 +919,9 @@ Find k values meeting distances and spatial predicates.
|
||||
\return The number of found values.
|
||||
*/
|
||||
template <typename Value, typename Options, typename Translator, typename Allocator, typename DistancesPredicates, typename Predicates, typename OutIter>
|
||||
inline size_t nearest(rtree<Value, Options, Translator, Allocator> const& tree, DistancesPredicates const& dpred, size_t k, Predicates const& pred, OutIter out_it)
|
||||
inline size_t nearest_query(rtree<Value, Options, Translator, Allocator> const& tree, DistancesPredicates const& dpred, size_t k, Predicates const& pred, OutIter out_it)
|
||||
{
|
||||
return tree.nearest(dpred, k, pred, out_it);
|
||||
return tree.nearest_query(dpred, k, pred, out_it);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_VISITORS_QUERY_HPP
|
||||
#define BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_VISITORS_QUERY_HPP
|
||||
|
||||
#include <boost/geometry/extensions/index/rtree/predicates.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/index/rtree/node/node.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace index {
|
||||
|
||||
@@ -253,24 +253,24 @@ void test_exactly_the_same_outputs(Rtree const& rtree, Range1 const& output, Ran
|
||||
// spatial query
|
||||
|
||||
template <typename Rtree, typename Value, typename Predicates>
|
||||
void test_query(Rtree & rtree, Predicates const& pred, std::vector<Value> const& expected_output)
|
||||
void test_spatial_query(Rtree & rtree, Predicates const& pred, std::vector<Value> const& expected_output)
|
||||
{
|
||||
BOOST_CHECK( bgi::are_levels_ok(rtree) );
|
||||
BOOST_CHECK( bgi::are_boxes_ok(rtree) );
|
||||
|
||||
std::vector<Value> output;
|
||||
size_t n = rtree.query(pred, std::back_inserter(output));
|
||||
size_t n = rtree.spatial_query(pred, std::back_inserter(output));
|
||||
|
||||
BOOST_CHECK( expected_output.size() == n );
|
||||
test_compare_outputs(rtree, output, expected_output);
|
||||
|
||||
std::vector<Value> output2;
|
||||
size_t n2 = query(rtree, pred, std::back_inserter(output2));
|
||||
size_t n2 = spatial_query(rtree, pred, std::back_inserter(output2));
|
||||
|
||||
BOOST_CHECK( n == n2 );
|
||||
test_exactly_the_same_outputs(rtree, output, output2);
|
||||
|
||||
test_exactly_the_same_outputs(rtree, output, rtree | bgi::query_filtered(pred));
|
||||
test_exactly_the_same_outputs(rtree, output, rtree | bgi::adaptors::spatial_queried(pred));
|
||||
}
|
||||
|
||||
// rtree specific queries tests
|
||||
@@ -284,11 +284,11 @@ void test_intersects_and_disjoint(bgi::rtree<Value, Algo> const& tree, std::vect
|
||||
if ( bg::intersects(tree.translator()(v), qbox) )
|
||||
expected_output.push_back(v);
|
||||
|
||||
test_query(tree, qbox, expected_output);
|
||||
test_query(tree, bgi::intersects(qbox), expected_output);
|
||||
test_query(tree, !bgi::not_intersects(qbox), expected_output);
|
||||
test_query(tree, !bgi::disjoint(qbox), expected_output);
|
||||
test_query(tree, bgi::not_disjoint(qbox), expected_output);
|
||||
test_spatial_query(tree, qbox, expected_output);
|
||||
test_spatial_query(tree, bgi::intersects(qbox), expected_output);
|
||||
test_spatial_query(tree, !bgi::not_intersects(qbox), expected_output);
|
||||
test_spatial_query(tree, !bgi::disjoint(qbox), expected_output);
|
||||
test_spatial_query(tree, bgi::not_disjoint(qbox), expected_output);
|
||||
}
|
||||
|
||||
template <typename Value, typename Algo, typename Box>
|
||||
@@ -300,7 +300,7 @@ void test_covered_by(bgi::rtree<Value, Algo> const& tree, std::vector<Value> con
|
||||
if ( bg::covered_by(tree.translator()(v), qbox) )
|
||||
expected_output.push_back(v);
|
||||
|
||||
test_query(tree, bgi::covered_by(qbox), expected_output);
|
||||
test_spatial_query(tree, bgi::covered_by(qbox), expected_output);
|
||||
}
|
||||
|
||||
template <typename Tag>
|
||||
@@ -315,7 +315,7 @@ struct test_overlap_impl
|
||||
if ( bg::overlaps(tree.translator()(v), qbox) )
|
||||
expected_output.push_back(v);
|
||||
|
||||
test_query(tree, bgi::overlaps(qbox), expected_output);
|
||||
test_spatial_query(tree, bgi::overlaps(qbox), expected_output);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -357,7 +357,7 @@ void test_overlaps(bgi::rtree<Value, Algo> const& tree, std::vector<Value> const
|
||||
// if ( bg::touches(tree.translator()(v), qbox) )
|
||||
// expected_output.push_back(v);
|
||||
//
|
||||
// test_query(tree, bgi::touches(qbox), expected_output);
|
||||
// test_spatial_query(tree, bgi::touches(qbox), expected_output);
|
||||
// }
|
||||
//};
|
||||
//
|
||||
@@ -383,13 +383,13 @@ void test_within(bgi::rtree<Value, Algo> const& tree, std::vector<Value> const&
|
||||
if ( bg::within(tree.translator()(v), qbox) )
|
||||
expected_output.push_back(v);
|
||||
|
||||
test_query(tree, bgi::within(qbox), expected_output);
|
||||
test_spatial_query(tree, bgi::within(qbox), expected_output);
|
||||
}
|
||||
|
||||
// rtree nearest queries
|
||||
|
||||
template <typename Rtree, typename Value, typename Point>
|
||||
void test_nearest(Rtree const& rtree, std::vector<Value> const& input, Point const& pt)
|
||||
void test_nearest_query(Rtree const& rtree, std::vector<Value> const& input, Point const& pt)
|
||||
{
|
||||
// TODO: Nearest object may not be the same as found by the rtree if distances are equal
|
||||
// Should all objects with the same closest distance be picked?
|
||||
@@ -409,7 +409,7 @@ void test_nearest(Rtree const& rtree, std::vector<Value> const& input, Point con
|
||||
size_t n = ( (std::numeric_limits<D>::max)() == smallest_d ) ? 0 : 1;
|
||||
|
||||
Value output;
|
||||
size_t n_res = rtree.nearest(pt, output);
|
||||
size_t n_res = rtree.nearest_query(pt, output);
|
||||
|
||||
BOOST_CHECK(n == n_res);
|
||||
if ( n == n_res && 0 < n )
|
||||
@@ -451,7 +451,7 @@ struct TestNearestKTransform
|
||||
};
|
||||
|
||||
template <typename Rtree, typename Value, typename Point>
|
||||
void test_nearest_k(Rtree const& rtree, std::vector<Value> const& input, Point const& pt, size_t k)
|
||||
void test_nearest_query_k(Rtree const& rtree, std::vector<Value> const& input, Point const& pt, size_t k)
|
||||
{
|
||||
// TODO: Nearest object may not be the same as found by the rtree if distances are equal
|
||||
// All objects with the same closest distance should be picked
|
||||
@@ -485,7 +485,7 @@ void test_nearest_k(Rtree const& rtree, std::vector<Value> const& input, Point c
|
||||
|
||||
// calculate output using rtree
|
||||
std::vector<Value> output;
|
||||
rtree.nearest(pt, k, std::back_inserter(output));
|
||||
rtree.nearest_query(pt, k, std::back_inserter(output));
|
||||
|
||||
// check output
|
||||
bool are_sizes_ok = (expected_output.size() == output.size());
|
||||
@@ -504,19 +504,21 @@ void test_nearest_k(Rtree const& rtree, std::vector<Value> const& input, Point c
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
test_exactly_the_same_outputs(rtree, output, rtree | bgi::adaptors::nearest_queried(pt, k));
|
||||
}
|
||||
|
||||
// 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)
|
||||
void test_nearest_query_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);
|
||||
size_t n_res = rtree.nearest_query(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));
|
||||
n_res = rtree.nearest_query(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);
|
||||
}
|
||||
@@ -531,7 +533,7 @@ void test_copy_assignment_move(bgi::rtree<Value, Algo> const& tree, Box const& q
|
||||
BOOST_CHECK(s);
|
||||
|
||||
std::vector<Value> expected_output;
|
||||
tree.query(qbox, std::back_inserter(expected_output));
|
||||
tree.spatial_query(qbox, std::back_inserter(expected_output));
|
||||
|
||||
// copy constructor
|
||||
bgi::rtree<Value, Algo> t1(tree);
|
||||
@@ -539,7 +541,7 @@ void test_copy_assignment_move(bgi::rtree<Value, Algo> const& tree, Box const& q
|
||||
BOOST_CHECK(tree.size() == t1.size());
|
||||
|
||||
std::vector<Value> output;
|
||||
t1.query(qbox, std::back_inserter(output));
|
||||
t1.spatial_query(qbox, std::back_inserter(output));
|
||||
test_exactly_the_same_outputs(t1, output, expected_output);
|
||||
|
||||
// copying assignment operator
|
||||
@@ -548,7 +550,7 @@ void test_copy_assignment_move(bgi::rtree<Value, Algo> const& tree, Box const& q
|
||||
BOOST_CHECK(tree.size() == t1.size());
|
||||
|
||||
output.clear();
|
||||
t1.query(qbox, std::back_inserter(output));
|
||||
t1.spatial_query(qbox, std::back_inserter(output));
|
||||
test_exactly_the_same_outputs(t1, output, expected_output);
|
||||
|
||||
// moving constructor
|
||||
@@ -558,7 +560,7 @@ void test_copy_assignment_move(bgi::rtree<Value, Algo> const& tree, Box const& q
|
||||
BOOST_CHECK(t1.size() == 0);
|
||||
|
||||
output.clear();
|
||||
t2.query(qbox, std::back_inserter(output));
|
||||
t2.spatial_query(qbox, std::back_inserter(output));
|
||||
test_exactly_the_same_outputs(t2, output, expected_output);
|
||||
|
||||
// moving assignment operator
|
||||
@@ -568,7 +570,7 @@ void test_copy_assignment_move(bgi::rtree<Value, Algo> const& tree, Box const& q
|
||||
BOOST_CHECK(t2.size() == 0);
|
||||
|
||||
output.clear();
|
||||
t1.query(qbox, std::back_inserter(output));
|
||||
t1.spatial_query(qbox, std::back_inserter(output));
|
||||
test_exactly_the_same_outputs(t1, output, expected_output);
|
||||
}
|
||||
|
||||
@@ -580,7 +582,7 @@ void test_remove(bgi::rtree<Value, Algo> & tree, Box const& qbox)
|
||||
size_t prev_size = tree.size();
|
||||
|
||||
std::vector<Value> output;
|
||||
tree.query(qbox, std::back_inserter(output));
|
||||
tree.spatial_query(qbox, std::back_inserter(output));
|
||||
|
||||
BOOST_CHECK(0 < output.size());
|
||||
|
||||
@@ -589,7 +591,7 @@ void test_remove(bgi::rtree<Value, Algo> & tree, Box const& qbox)
|
||||
BOOST_CHECK(tree.size() == prev_size - output.size());
|
||||
|
||||
output.clear();
|
||||
tree.query(qbox, std::back_inserter(output));
|
||||
tree.spatial_query(qbox, std::back_inserter(output));
|
||||
|
||||
BOOST_CHECK(0 == output.size());
|
||||
}
|
||||
@@ -619,9 +621,9 @@ void test_rtree_by_value(Parameters const& parameters)
|
||||
P pt;
|
||||
bg::centroid(qbox, pt);
|
||||
|
||||
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_nearest_query(tree, input, pt);
|
||||
test_nearest_query_k(tree, input, pt, 10);
|
||||
test_nearest_query_not_found(tree, generate_outside_point<P>::apply(), 1, 3);
|
||||
|
||||
test_copy_assignment_move(tree, qbox);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user