| Home | Libraries | People | FAQ | More

##### nearest(Point 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 ``Point`` from which distance to ``Values`` is calculated and the maximum number of ``Values`` that should be returned.

###### Synopsis

    template<typename Point>
    detail::nearest<Point> boost::geometry::index::nearest(Point const & point, unsigned k)

###### Parameter(s)

Type | Name | Description
--- | --- | ---
`Point const &` | `point` | The point 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));

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