mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-09 23:22:10 +00:00
geometry.index: nearest() predicate point relations shielded by BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL.
[SVN r84170]
This commit is contained in:
@@ -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<T> to_furthest(T const& v)
|
||||
return detail::to_furthest<T>(v);
|
||||
}
|
||||
|
||||
#endif // BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
|
||||
|
||||
// distance predicates generators
|
||||
|
||||
/*!
|
||||
|
||||
@@ -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 <typename Value> bool operator()(__value__ const& v) { return v.is_red(); }
|
||||
template <typename Value> 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 <typename PointOrRelation> inline
|
||||
detail::nearest<PointOrRelation>
|
||||
nearest(PointOrRelation const& point_relation, unsigned k)
|
||||
template <typename Point> inline
|
||||
detail::nearest<Point>
|
||||
nearest(Point const& point, unsigned k)
|
||||
{
|
||||
return detail::nearest<PointOrRelation>(point_relation, k);
|
||||
return detail::nearest<Point>(point, k);
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user