From 03da86e962a2d2907c2fde985423e04a15f84dcd Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Mon, 6 May 2013 16:15:38 +0000 Subject: [PATCH] geometry.index: nearest() predicate point relations shielded by BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL. [SVN r84170] --- .../geometry/index/distance_predicates.hpp | 4 +++ include/boost/geometry/index/predicates.hpp | 25 +++++++------------ include/boost/geometry/index/rtree.hpp | 8 ++---- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/include/boost/geometry/index/distance_predicates.hpp b/include/boost/geometry/index/distance_predicates.hpp index 142108eb5..59b32af47 100644 --- a/include/boost/geometry/index/distance_predicates.hpp +++ b/include/boost/geometry/index/distance_predicates.hpp @@ -21,6 +21,8 @@ namespace boost { namespace geometry { namespace index { // relations generators +#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL + /*! \brief Generate to_nearest() relationship. @@ -89,6 +91,8 @@ detail::to_furthest to_furthest(T const& v) return detail::to_furthest(v); } +#endif // BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL + // distance predicates generators /*! diff --git a/include/boost/geometry/index/predicates.hpp b/include/boost/geometry/index/predicates.hpp index 4b111201c..02fa6558f 100644 --- a/include/boost/geometry/index/predicates.hpp +++ b/include/boost/geometry/index/predicates.hpp @@ -175,10 +175,10 @@ A wrapper around user-defined UnaryPredicate checking if Value should be returne \par Example \verbatim -bool is_red(__value__ const& v) { return v.is_red(); } +bool is_red(Value const& v) { return v.is_red(); } struct is_red_o { -template bool operator()(__value__ const& v) { return v.is_red(); } +template bool operator()(Value const& v) { return v.is_red(); } } // ... @@ -190,7 +190,7 @@ rt.query(index::intersects(box) && index::satisfies(is_red_o()), std::back_inserter(result)); #ifndef BOOST_NO_CXX11_LAMBDAS -rt.query(index::intersects(box) && index::satisfies([](__value__ const& v) { return v.is_red(); }), +rt.query(index::intersects(box) && index::satisfies([](Value const& v) { return v.is_red(); }), std::back_inserter(result)); #endif \endverbatim @@ -214,17 +214,10 @@ When nearest predicate is passed to the query, k-nearest neighbour search will b The simplest way of defining the knn query is passing a \c Point to which \c Values must be closest. -It is possible to define how distance between values and query Point is calculated. This is done by passing PointRelation. -It can be generated by following functions: -\li \c boost::geometry::index::to_nearest() - default, -\li \c boost::geometry::index::to_centroid(), -\li \c boost::geometry::index::to_furthest(). - \par Example \verbatim bgi::query(spatial_index, bgi::nearest(pt, 5), std::back_inserter(result)); bgi::query(spatial_index, bgi::nearest(pt, 5) && bgi::intersects(box), std::back_inserter(result)); -bgi::query(spatial_index, bgi::nearest(bgi::to_centroid(pt), 5) && bgi::within(box), std::back_inserter(result)); \endverbatim \warning @@ -232,14 +225,14 @@ Only one \c nearest() predicate may be used in a query. \ingroup predicates -\param point_relation The point or relation describing how the distance will be calculated. -\param k The maximum number of values to return. +\param point The point from which distance is calculated. +\param k The maximum number of values to return. */ -template inline -detail::nearest -nearest(PointOrRelation const& point_relation, unsigned k) +template inline +detail::nearest +nearest(Point const& point, unsigned k) { - return detail::nearest(point_relation, k); + return detail::nearest(point, k); } namespace detail { diff --git a/include/boost/geometry/index/rtree.hpp b/include/boost/geometry/index/rtree.hpp index becb4566a..39fab6167 100644 --- a/include/boost/geometry/index/rtree.hpp +++ b/include/boost/geometry/index/rtree.hpp @@ -714,14 +714,12 @@ public: tree.query(bgi::overlaps(box) && bgi::satisfies(my_fun), std::back_inserter(result)); // return 5 elements nearest to pt and elements are intersecting box tree.query(bgi::nearest(pt, 5) && bgi::intersects(box), std::back_inserter(result)); - // return 5 elements which centroids are nearest to pt and elements aren't within box - tree.query(bgi::nearest(bgi::to_centroid(pt), 5) && !bgi::within(box), std::back_inserter(result)); \endverbatim \par Throws If Value copy constructor or copy assignment throws. - \info + \warning Only one \c nearest() perdicate may be passed to the query. Passing more of them results in compile-time assert. \param predicates Predicates. @@ -1456,14 +1454,12 @@ bgi::query(tree, bgi::intersects(poly) && !bgi::within(box), std::back_inserter( bgi::query(tree, bgi::overlaps(box) && bgi::satisfies(my_fun), std::back_inserter(result)); // return 5 elements nearest to pt and elements are intersecting box bgi::query(tree, bgi::nearest(pt, 5) && bgi::intersects(box), std::back_inserter(result)); -// return 5 elements which centroids are nearest to pt and elements aren't within box -bgi::query(tree, bgi::nearest(bgi::to_centroid(pt), 5) && !bgi::within(box), std::back_inserter(result)); \endverbatim \par Throws If Value copy constructor or copy assignment throws. -\note +\warning Only one \c nearest() perdicate may be passed to the query. Passing more of them results in compile-time assert. \ingroup rtree_functions