Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext
nearest(Geometry const &, unsigned)

Generate nearest() predicate.

Description

When nearest predicate is passed to the query, k-nearest neighbour search will be performed. nearest() predicate takes a Geometry from which distances to Values are calculated and the maximum number of Values that should be returned. Internally boost::geometry::comparable_distance() is used to perform the calculation.

Synopsis
template<typename Geometry>
detail::nearest<Geometry> boost::geometry::index::nearest(Geometry const & geometry, unsigned k)
Parameter(s)

Type

Name

Description

Geometry const &

geometry

The geometry from which distance is calculated.

unsigned

k

The maximum number of values to return.

Example

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(box, 5), std::back_inserter(result));

[Warning] Warning

Only one nearest() predicate may be used in a query.


PrevUpHomeNext