Boost.Geometry.Index

- Main Page
- Modules
- Classes
- Files

Functions
R-tree free functions (boost::geometry::index::)

## Functions

template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator >
void | boost::geometry::index::insert (rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > &tree, Value const &v)
| Insert a value to the index.
template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator , typename Iterator >
void | boost::geometry::index::insert (rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > &tree, Iterator first, Iterator last)
| Insert a range of values to the index.
template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator , typename ConvertibleOrRange >
void | boost::geometry::index::insert (rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > &tree, ConvertibleOrRange const &conv_or_rng)
| Insert a value created using convertible object or a range of values to the index.
template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator >
rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::size_type | boost::geometry::index::remove (rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > &tree, Value const &v)
| Remove a value from the container.
template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator , typename Iterator >
rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::size_type | boost::geometry::index::remove (rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > &tree, Iterator first, Iterator last)
| Remove a range of values from the container.
template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator , typename ConvertibleOrRange >
rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::size_type | boost::geometry::index::remove (rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > &tree, ConvertibleOrRange const &conv_or_rng)
| Remove a value corresponding to an object convertible to it or a range of values from the container.
template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator , typename Predicates , typename OutIter >
rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::size_type | boost::geometry::index::query (rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > const &tree, Predicates const &predicates, OutIter out_it)
| Finds values meeting passed predicates e.g. nearest to some Point and/or intersecting some Box.
template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator , typename Predicates >
rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > ::const_query_iterator | boost::geometry::index::qbegin (rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > const &tree, Predicates const &predicates)
| Returns the query iterator pointing at the begin of the query range.
template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator >
rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > ::const_query_iterator | boost::geometry::index::qend (rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > const &tree)
| Returns the query iterator pointing at the end of the query range.
template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator >
rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::const_iterator | boost::geometry::index::begin (rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > const &tree)
| Returns the iterator pointing at the begin of the rtree values range.
template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator >
rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::const_iterator | boost::geometry::index::end (rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > const &tree)
| Returns the iterator pointing at the end of the rtree values range.
template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator >
void | boost::geometry::index::clear (rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > &tree)
| Remove all values from the index.
template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator >
size_t | boost::geometry::index::size (rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > const &tree)
| Get the number of values stored in the index.
template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator >
bool | boost::geometry::index::empty (rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > const &tree)
| Query if there are no values stored in the index.
template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator >
rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::bounds_type | boost::geometry::index::bounds (rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > const &tree)
| Get the box containing all stored values or an invalid box if the index has no values.
template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator >
void | boost::geometry::index::swap (rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > &l, rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > &r)
| Exchanges the contents of the container with those of other.

## Function Documentation

template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator >

rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator>::const_iterator boost::geometry::index::begin | ( | rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > const & | tree | ) | `[inline]`

Returns the iterator pointing at the begin of the rtree values range.

This method returns the iterator which may be used to iterate over all values stored in the rtree.

Example

      std::for_each(bgi::begin(tree), bgi::end(tree), do_something());
      // the same as
      std::for_each(boost::begin(tree), boost::end(tree), do_something());

Iterator category
  ForwardIterator

Throws
  If allocation throws.

Warning:
  The modification of the rtree may invalidate the iterators.

Returns:
  The iterator pointing at the begin of the range.

template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator >

rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator>::bounds_type boost::geometry::index::bounds | ( | rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > const & | tree | ) | `[inline]`

Get the box containing all stored values or an invalid box if the index has no values.

It calls `rtree::envelope()`.

Parameters:

  tree | The spatial index.

Returns:
  The box containing all stored values or an invalid box.

template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator >

void boost::geometry::index::clear | ( | rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > & | tree | ) | `[inline]`

Remove all values from the index.

It calls `rtree::clear()`.

Parameters:

  tree | The spatial index.

template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator >

bool boost::geometry::index::empty | ( | rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > const & | tree | ) | `[inline]`

Query if there are no values stored in the index.

It calls `rtree::empty()`.

Parameters:

  tree | The spatial index.

Returns:
  true if there are no values in the index.

template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator >

rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator>::const_iterator boost::geometry::index::end | ( | rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > const & | tree | ) | `[inline]`

Returns the iterator pointing at the end of the rtree values range.

This method returns the iterator which may be compared with the iterator returned by begin() in order to check if the iteration has ended.

Example

      std::for_each(bgi::begin(tree), bgi::end(tree), do_something());
      // the same as
      std::for_each(boost::begin(tree), boost::end(tree), do_something());

Iterator category
  ForwardIterator

Throws
  Nothing.

Warning:
  The modification of the rtree may invalidate the iterators.

Returns:
  The iterator pointing at the end of the range.

template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator >

void boost::geometry::index::insert | ( | rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > & | tree,
|  | Value const & | v
| ) |  | `[inline]`

Insert a value to the index.

It calls `rtree::insert(value_type const&)`.

Parameters:

  tree | The spatial index.
  v | The value which will be stored in the index.

template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator , typename Iterator >

void boost::geometry::index::insert | ( | rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > & | tree,
|  | Iterator | first,
|  | Iterator | last
| ) |  | `[inline]`

Insert a range of values to the index.

It calls `rtree::insert(Iterator, Iterator)`.

Parameters:

  tree | The spatial index.
  first | The beginning of the range of values.
  last | The end of the range of values.

template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator , typename ConvertibleOrRange >

void boost::geometry::index::insert | ( | rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > & | tree,
|  | ConvertibleOrRange const & | conv_or_rng
| ) |  | `[inline]`

Insert a value created using convertible object or a range of values to the index.

It calls `rtree::insert(ConvertibleOrRange const&)`.

Parameters:

  tree | The spatial index.
  conv_or_rng | The object of type convertible to value_type or a range of values.

template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator , typename Predicates >

rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator>::const_query_iterator boost::geometry::index::qbegin | ( | rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > const & | tree,
|  | Predicates const & | predicates
| ) |  | `[inline]`

Returns the query iterator pointing at the begin of the query range.

This method returns the iterator which may be used to perform iterative queries. For the information about the predicates which may be passed to this method see query().

Example

      std::for_each(bgi::qbegin(tree, bgi::nearest(pt, 3)), bgi::qend(tree), do_something());

Iterator category
  ForwardIterator

Throws
  If predicates copy throws. If allocation throws.

Warning:
  The modification of the rtree may invalidate the iterators.

Parameters:

  tree | The rtree.
  predicates | Predicates.

Returns:
  The iterator pointing at the begin of the query range.

template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator >

rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator>::const_query_iterator boost::geometry::index::qend | ( | rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > const & | tree | ) | `[inline]`

Returns the query iterator pointing at the end of the query range.

This method returns the iterator which may be used to check if the query has ended.

Example

      std::for_each(bgi::qbegin(tree, bgi::nearest(pt, 3)), bgi::qend(tree), do_something());

Iterator category
  ForwardIterator

Throws
  Nothing

Warning:
  The modification of the rtree may invalidate the iterators.

Returns:
  The iterator pointing at the end of the query range.

template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator , typename Predicates , typename OutIter >

rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator>::size_type boost::geometry::index::query | ( | rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > const & | tree,
|  | Predicates const & | predicates,
|  | OutIter | out_it
| ) |  | `[inline]`

Finds values meeting passed predicates e.g. nearest to some Point and/or intersecting some Box.

This query function performs spatial and k-nearest neighbor searches. It allows to pass a set of predicates. Values will be returned only if all predicates are met.

Spatial predicates

Spatial predicates may be generated by one of the functions listed below:

- `boost::geometry::index::contains()`,
- `boost::geometry::index::covered_by()`,
- `boost::geometry::index::covers()`,
- `boost::geometry::index::disjoint()`,
- `boost::geometry::index::intersects()`,
- `boost::geometry::index::overlaps()`,
- `boost::geometry::index::within()`,

It is possible to negate spatial predicates:

- `! boost::geometry::index::contains()`,
- `! boost::geometry::index::covered_by()`,
- `! boost::geometry::index::covers()`,
- `! boost::geometry::index::disjoint()`,
- `! boost::geometry::index::intersects()`,
- `! boost::geometry::index::overlaps()`,
- `! boost::geometry::index::within()`

Satisfies predicate

This is a special kind of predicate which allows to pass a user-defined function or function object which checks if Value should be returned by the query. It's generated by:

- `boost::geometry::index::satisfies()`.

Nearest predicate

If the nearest predicate is passed a k-nearest neighbor search will be performed. This query will result in returning k values to the output iterator. Only one nearest predicate may be passed to the query. It may be generated by:

- `boost::geometry::index::nearest()`.

Connecting predicates

Predicates may be passed together connected with `operator&&()`.

Example

      // return elements intersecting box
      bgi::query(tree, bgi::intersects(box), std::back_inserter(result));
      // return elements intersecting poly but not within box
      bgi::query(tree, bgi::intersects(poly) && !bgi::within(box), std::back_inserter(result));
      // return elements overlapping box and meeting my_fun value predicate
      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));

      // For each found value do_something (it is a type of function object)
      tree.query(bgi::intersects(box),
                 boost::make_function_output_iterator(do_something()));

Throws
  If Value copy constructor or copy assignment throws.

Warning:
  Only one `nearest()` perdicate may be passed to the query. Passing more of them results in compile-time error.

Parameters:

  tree | The rtree.
  predicates | Predicates.
  out_it | The output iterator, e.g. generated by std::back_inserter().

Returns:
  The number of values found.

template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator >

rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator>::size_type boost::geometry::index::remove | ( | rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > & | tree,
|  | Value const & | v
| ) |  | `[inline]`

Remove a value from the container.

Remove a value from the container. In contrast to the `std::set` or `std::map erase()` method this function removes only one value from the container.

It calls `rtree::remove(value_type const&)`.

Parameters:

  tree | The spatial index.
  v | The value which will be removed from the index.

Returns:
  1 if value was removed, 0 otherwise.

template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator , typename Iterator >

rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator>::size_type boost::geometry::index::remove | ( | rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > & | tree,
|  | Iterator | first,
|  | Iterator | last
| ) |  | `[inline]`

Remove a range of values from the container.

Remove a range of values from the container. In contrast to the `std::set` or `std::map erase()` method it doesn't take iterators pointing to values stored in this container. It removes values equal to these passed as a range. Furthermore this function removes only one value for each one passed in the range, not all equal values.

It calls `rtree::remove(Iterator, Iterator)`.

Parameters:

  tree | The spatial index.
  first | The beginning of the range of values.
  last | The end of the range of values.

Returns:
  The number of removed values.

template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator , typename ConvertibleOrRange >

rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator>::size_type boost::geometry::index::remove | ( | rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > & | tree,
|  | ConvertibleOrRange const & | conv_or_rng
| ) |  | `[inline]`

Remove a value corresponding to an object convertible to it or a range of values from the container.

Remove a value corresponding to an object convertible to it or a range of values from the container. In contrast to the `std::set` or `std::map erase()` method it removes values equal to these passed as a range. Furthermore this method removes only one value for each one passed in the range, not all equal values.

It calls `rtree::remove(ConvertibleOrRange const&)`.

Parameters:

  tree | The spatial index.
  conv_or_rng | The object of type convertible to value_type or the range of values.

Returns:
  The number of removed values.

template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator >

size_t boost::geometry::index::size | ( | rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > const & | tree | ) | `[inline]`

Get the number of values stored in the index.

It calls `rtree::size()`.

Parameters:

  tree | The spatial index.

Returns:
  The number of values stored in the index.

template<typename Value , typename Parameters , typename IndexableGetter , typename EqualTo , typename Allocator >

void boost::geometry::index::swap | ( | rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > & | l,
|  | rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > & | r
| ) |  | `[inline]`

Exchanges the contents of the container with those of other.

It calls `rtree::swap()`.

Parameters:

  l | The first rtree.
  r | The second rtree.

All Classes Functions Typedefs