Boost C++ Libraries Home Libraries People FAQ More

PrevUpHome

Reference

boost::geometry::index::rtree
Functions related to the rtree
R-tree parameters
Spatial predicates (boost::geometry::index::)
Distance predicates (boost::geometry::index::)
Adaptors (boost::geometry::index::adaptors::)
Translators (boost::geometry::index::translators::)
Inserters (boost::geometry::index::)

The R-tree spatial index.

Description

This is self-balancing spatial index capable to store various types of Values and balancing algorithms.

Parameters

The user must pass a type defining the Parameters which will be used in rtree creation process. This type is used e.g. to specify balancing algorithm with specific parameters like min and max number of elements in node.

Predefined algorithms with compile-time parameters are:

Predefined algorithms with run-time parameters are:

Translator

The Translator translates from Value to Indexable each time r-tree requires it. Which means that this operation is done for each Value access. Therefore the Translator should return the Indexable by const reference instead of a value. Default translator can translate all types adapted to Point or Box concepts (called Indexables). It also handles std::pair<Indexable, T> and boost::tuple<Indexable, ...>. For example, if std::pair<Box, int> is stored in the container, the default translator translates from std::pair<Box, int> const& to Box const&.

Header

#include <boost/geometry/extensions/index/rtree.hpp>

Synopsis
template<typename Value,
         typename Parameters,
         typename Translator = translator::def<Value>,
         typename Allocator = std::allocator<Value>>
class rtree
{
  // ...
};
Template parameter(s)

Parameter

Description

Value

The type of objects stored in the container.

Parameters

Compile-time parameters.

Translator

The type of the translator which translates from Value to Indexable.

Allocator

The allocator used to allocate/deallocate memory, construct/destroy nodes and Values.

Typedef(s)

Type

Description

value_type

The type of Value stored in the container.

parameters_type

R-tree parameters type.

translator_type

Value to Indexable Translator type.

allocator_type

The type of allocator used by the container.

size_type

Unsigned integral type used by the container.

indexable_type

The Indexable type to which Value is translated.

box_type

The Box type used by the R-tree.

Constructor(s) and destructor

Function

Description

rtree()

The constructor.

rtree(parameters_type, translator_type const &, allocator_type)

The constructor.

rtree(Iterator, Iterator)

The constructor.

rtree(Range const &)

The constructor.

~rtree()

The destructor.

rtree(rtree const &)

The copy constructor.

rtree(rtree const &, allocator_type const &)

The copy constructor.

rtree(rtree &&)

The moving constructor.

rtree(rtree &&, allocator_type const &)

The moving constructor.

Member(s)

Function

Description

operator=(const rtree &)

The assignment operator.

operator=(rtree &&)

The moving assignment.

swap(rtree &)

Swaps contents of two rtrees.

insert(value_type const &)

Insert a value to the index.

insert(Iterator, Iterator)

Insert a range of values to the index.

insert(Range const &)

Insert a range of values to the index.

remove(value_type const &)

Remove a value from the container.

remove(Iterator, Iterator)

Remove a range of values from the container.

remove(Range const &)

Remove a range of values from the container.

spatial_query(Predicates const &, OutIter)

Finds values meeting spatial predicates, e.g. intersecting some Box.

nearest_query(DistancesPredicates const &, value_type &)

Finds one value meeting distances predicates, e.g. nearest to some Point.

nearest_query(DistancesPredicates const &, Predicates const &, value_type &)

Finds one value meeting distances predicates and spatial predicates, e.g. nearest to some Point and intersecting some Box.

nearest_query(DistancesPredicates const &, size_type, OutIter)

Finds k values meeting distances predicates, e.g. k nearest values to some Point.

nearest_query(DistancesPredicates const &, size_type, Predicates const &, OutIter)

Finds k values meeting distances predicates and spatial predicates, e.g. k nearest values to some Point and intersecting some Box.

size()

Returns the number of stored values.

empty()

Query if the container is empty.

clear()

Removes all values stored in the container.

box()

Returns the box containing all values stored in the container.

count(ValueOrIndexable const &)

Count Values or Indexables stored in the container.

parameters()

Returns parameters.

translator()

Returns the translator object.

get_allocator()

Returns allocator used by the rtree.

The constructor.

Synopsis
rtree(parameters_type parameters = parameters_type(), translator_type const & translator = translator_type())
Parameter(s)

Type

Name

Description

parameters_type

parameters

The parameters object.

translator_type const &

translator

The translator object.

Throws

If allocator default constructor throws.

The constructor.

Synopsis
rtree(parameters_type parameters,
      translator_type const & translator,
      allocator_type allocator)
Parameter(s)

Type

Name

Description

parameters_type

parameters

The parameters object.

translator_type const &

translator

The translator object.

allocator_type

allocator

The allocator object.

Throws

If allocator copy constructor throws.

The constructor.

Synopsis
template<typename Iterator>
rtree(Iterator first,
      Iterator last,
      parameters_type parameters = parameters_type(),
      translator_type const & translator = translator_type(),
      allocator_type allocator = allocator_type())
Parameter(s)

Type

Name

Description

Iterator

first

The beginning of the range of Values.

Iterator

last

The end of the range of Values.

parameters_type

parameters

The parameters object.

translator_type const &

translator

The translator object.

allocator_type

allocator

The allocator object.

Throws
  • If allocator copy constructor throws.
  • If Value copy constructor or copy assignment throws.
  • If allocation throws.
  • When memory allocation for Node fails.

The constructor.

Synopsis
template<typename Range>
rtree(Range const & rng,
      parameters_type parameters = parameters_type(),
      translator_type const & translator = translator_type(),
      allocator_type allocator = allocator_type())
Parameter(s)

Type

Name

Description

Range const &

rng

The range of Values.

parameters_type

parameters

The parameters object.

translator_type const &

translator

The translator object.

allocator_type

allocator

The allocator object.

Throws
  • If allocator copy constructor throws.
  • If Value copy constructor or copy assignment throws.
  • If allocation throws.
  • When memory allocation for Node fails.

The destructor.

Synopsis
~rtree()
Throws

Nothing.

The copy constructor.

Description

It uses parameters, translator and allocator from the source tree.

Synopsis
rtree(rtree const & src)
Parameter(s)

Type

Name

Description

rtree const &

src

The rtree which content will be copied.

Throws
  • If allocator copy constructor throws.
  • If Value copy constructor throws.
  • If allocation throws.
  • When memory allocation for Node fails.

The copy constructor.

Description

It uses Parameters and translator from the source tree.

Synopsis
rtree(rtree const & src, allocator_type const & allocator)
Parameter(s)

Type

Name

Description

rtree const &

src

The rtree which content will be copied.

allocator_type const &

allocator

The allocator which will be used.

Throws
  • If allocator copy constructor throws.
  • If Value copy constructor throws.
  • If allocation throws.
  • When memory allocation for Node fails.

The moving constructor.

Description

It uses parameters, translator and allocator from the source tree.

Synopsis
rtree(rtree && src)
Parameter(s)

Type

Name

Description

rtree &&

src

The rtree which content will be moved.

Throws

Nothing.

The moving constructor.

Description

It uses parameters and translator from the source tree.

Synopsis
rtree(rtree && src, allocator_type const & allocator)
Parameter(s)

Type

Name

Description

rtree &&

src

The rtree which content will be moved.

allocator_type const &

allocator

The allocator.

Throws
  • If allocator copy constructor throws.
  • If Value copy constructor throws (only if allocators aren't equal).
  • If allocation throws (only if allocators aren't equal).
  • When memory allocation for Node fails (only if allocators aren't equal).

The assignment operator.

Description

It uses parameters and translator from the source tree.

Synopsis
rtree & operator=(const rtree & src)
Parameter(s)

Type

Name

Description

const rtree &

src

The rtree which content will be copied.

Throws
  • If Value copy constructor throws.
  • If allocation throws.
  • When nodes allocation fails.

The moving assignment.

Description

It uses parameters and translator from the source tree.

Synopsis
rtree & operator=(rtree && src)
Parameter(s)

Type

Name

Description

rtree &&

src

The rtree which content will be moved.

Throws

Only if allocators aren't equal.

  • If Value copy constructor throws.
  • If allocation throws.
  • When nodes allocation fails.

Swaps contents of two rtrees.

Description

Parameters, translator and allocators are swapped as well.

Synopsis
void swap(rtree & other)
Parameter(s)

Type

Name

Description

rtree &

other

The rtree which content will be swapped with this rtree content.

Throws

If allocators swap throws.

Insert a value to the index.

Synopsis
void insert(value_type const & value)
Parameter(s)

Type

Name

Description

value_type const &

value

The value which will be stored in the container.

Throws
  • If Value copy constructor or copy assignment throws.
  • If allocation throws.
  • When nodes allocation fails.
[Warning] Warning

This operation is not thread safe. If it throws, the R-tree may be left in an inconsistent state, elements must not be inserted or removed, methods may return invalid data.

Insert a range of values to the index.

Synopsis
template<typename Iterator>
void insert(Iterator first, Iterator last)
Parameter(s)

Type

Name

Description

Iterator

first

The beginning of the range of values.

Iterator

last

The end of the range of values.

Throws
  • If Value copy constructor or copy assignment throws.
  • If allocation throws.
  • When nodes allocation fails.
[Warning] Warning

This operation is not thread safe. If it throws, the R-tree may be left in an inconsistent state, elements must not be inserted or removed, methods may return invalid data.

Insert a range of values to the index.

Synopsis
template<typename Range>
void insert(Range const & rng)
Parameter(s)

Type

Name

Description

Range const &

rng

The range of values.

Throws
  • If Value copy constructor or copy assignment throws.
  • If allocation throws.
  • When nodes allocation fails.
[Warning] Warning

This operation is not thread safe. If it throws, the R-tree may be left in an inconsistent state, elements must not be inserted or removed, methods may return invalid data.

Remove a value from the container.

Description

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

Synopsis
size_type remove(value_type const & value)
Parameter(s)

Type

Name

Description

value_type const &

value

The value which will be removed from the container.

Returns

1 if the value was removed, 0 otherwise.

Throws
  • If Value copy constructor or copy assignment throws.
  • If allocation throws.
  • When nodes allocation fails.
[Warning] Warning

This operation is not thread safe. If it throws, the R-tree may be left in an inconsistent state, elements must not be inserted or removed, methods may return invalid data.

Remove a range of values from the container.

Description

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 method removes only one value for each one passed in the range, not all equal values.

Synopsis
template<typename Iterator>
size_type remove(Iterator first, Iterator last)
Parameter(s)

Type

Name

Description

Iterator

first

The beginning of the range of values.

Iterator

last

The end of the range of values.

Returns

The number of removed values.

Throws
  • If Value copy constructor or copy assignment throws.
  • If allocation throws.
  • When nodes allocation fails.
[Warning] Warning

This operation is not thread safe. If it throws, the R-tree may be left in an inconsistent state, elements must not be inserted or removed, methods may return invalid data.

Remove a range of values from the container.

Description

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.

Synopsis
template<typename Range>
size_type remove(Range const & rng)
Parameter(s)

Type

Name

Description

Range const &

rng

The range of values.

Returns

The number of removed values.

Throws
  • If Value copy constructor or copy assignment throws.
  • If allocation throws.
  • When nodes allocation fails.
[Warning] Warning

This operation is not thread safe. If it throws, the R-tree may be left in an inconsistent state, elements must not be inserted or removed, methods may return invalid data.

Finds values meeting spatial predicates, e.g. intersecting some Box.

Description

Spatial predicates may be a Geometry. In this case Values intersecting the Geometry are returned.

It may be generated by one of the functions listed below:

Those predicates may be passed together in std::pair or boost::tuple.

Synopsis
template<typename Predicates, typename OutIter>
size_type spatial_query(Predicates const & pred, OutIter out_it)
Parameter(s)

Type

Name

Description

Predicates const &

pred

The spatial predicates or a Geometry.

OutIter

out_it

The output iterator of the result range. E.g. an iterator generated by std::back_inserter(container)

Returns

The number of values found.

Throws
  • If Value copy constructor or copy assignment throws.
  • If OutIter dereference or increment throws.

Finds one value meeting distances predicates, e.g. nearest to some Point.

Description

Distances predicates may be a Point. In this the case the Value closest to Point is returned.

It is possible to define how distance to Value is calculated. This is done by passing PointRelation. It can be generated by following functions:

It is possible to define define distances bounds, for example that some distance must be between min_distance and max_distance. This is done by passing DistancesPredicates which can be generated by following functions:

MinRelation and MaxRelation describes bounds and can be generated by following functions:

Synopsis
template<typename DistancesPredicates>
size_type nearest_query(DistancesPredicates const & dpred, value_type & v)
Parameter(s)

Type

Name

Description

DistancesPredicates const &

dpred

The distances predicates or a Point.

value_type &

v

The reference to the object which will contain the result.

Returns

The number of values found.

Throws

If Value copy constructor or copy assignment throws.

Finds one value meeting distances predicates and spatial predicates, e.g. nearest to some Point and intersecting some Box.

Description

Distances predicates may be a Point. In this the case the Value closest to Point is returned.

It is possible to define how distance to Value is calculated. This is done by passing PointRelation. It can be generated by following functions:

It is possible to define define distances bounds, for example that some distance must be between min_distance and max_distance. This is done by passing DistancesPredicates which can be generated by following functions:

MinRelation and MaxRelation describes bounds and can be generated by following functions:

Spatial predicates may be a Geometry. In this case Values intersecting the Geometry are returned.

It may be generated by one of the functions listed below:

Those predicates may be passed together in std::pair or boost::tuple.

Synopsis
template<typename DistancesPredicates, typename Predicates>
size_type nearest_query(DistancesPredicates const & dpred,
                        Predicates const & pred,
                        value_type & v)
Parameter(s)

Type

Name

Description

DistancesPredicates const &

dpred

The distances predicates or a Point.

Predicates const &

pred

The spatial predicates or a Geometry

value_type &

v

The reference to the object which will contain the result.

Returns

The number of values found.

Throws

If Value copy constructor or copy assignment throws.

Finds k values meeting distances predicates, e.g. k nearest values to some Point.

Description

Distances predicates may be a Point. In this the case the Value closest to Point is returned.

It is possible to define how distance to Value is calculated. This is done by passing PointRelation. It can be generated by following functions:

It is possible to define define distances bounds, for example that some distance must be between min_distance and max_distance. This is done by passing DistancesPredicates which can be generated by following functions:

MinRelation and MaxRelation describes bounds and can be generated by following functions:

Synopsis
template<typename DistancesPredicates, typename OutIter>
size_type nearest_query(DistancesPredicates const & dpred,
                        size_type k,
                        OutIter out_it)
Parameter(s)

Type

Name

Description

DistancesPredicates const &

dpred

The distances predicates or a Point.

size_type

k

The max number of values.

OutIter

out_it

The output iterator of the result range. E.g. a back_insert_iterator.

Returns

The number of values found.

Throws

If Value copy constructor or copy assignment throws. If OutIter dereference or increment throws.

Finds k values meeting distances predicates and spatial predicates, e.g. k nearest values to some Point and intersecting some Box.

Description

Distances predicates may be a Point. In this the case the Value closest to Point is returned.

It is possible to define how distance to Value is calculated. This is done by passing PointRelation. It can be generated by following functions:

It is possible to define define distances bounds, for example that some distance must be between min_distance and max_distance. This is done by passing DistancesPredicates which can be generated by following functions:

MinRelation and MaxRelation describes bounds and can be generated by following functions:

Spatial predicates may be a Geometry. In this case Values intersecting the Geometry are returned.

It may be generated by one of the functions listed below:

Those predicates may be passed together in std::pair or boost::tuple.

Synopsis
template<typename DistancesPredicates,
         typename Predicates,
         typename OutIter>
size_type nearest_query(DistancesPredicates const & dpred,
                        size_type k,
                        Predicates const & pred,
                        OutIter out_it)
Parameter(s)

Type

Name

Description

DistancesPredicates const &

dpred

The distances predicates or a Point

size_type

k

The max number of values.

Predicates const &

pred

The spatial predicates or a Geometry.

OutIter

out_it

The output iterator of the result range. E.g. a back_insert_iterator.

Returns

The number of values found.

Throws

If Value copy constructor or copy assignment throws. If OutIter dereference or increment throws.

Returns the number of stored values.

Synopsis
size_type size()
Returns

The number of stored values.

Throws

Nothing.

Query if the container is empty.

Synopsis
bool empty()
Returns

true if the container is empty.

Throws

Nothing.

Removes all values stored in the container.

Synopsis
void clear()
Throws

Nothing.

Returns the box containing all values stored in the container.

Description

Returns the box containing all values stored in the container. If the container is empty the result of geometry::assign_inverse() is returned.

Synopsis
box_type const & box()
Returns

The box containing all values stored in the container or an invalid box if there are no values in the container.

Throws

Nothing.

Count Values or Indexables stored in the container.

Description

For indexable_type it returns the number of values which indexables equals the parameter. For value_type it returns the number of values which equals the parameter.

Synopsis
template<typename ValueOrIndexable>
size_type count(ValueOrIndexable const & vori)
Parameter(s)

Type

Name

Description

ValueOrIndexable const &

vori

The value or indexable which will be counted.

Returns

The number of values found.

Throws

Nothing.

Returns parameters.

Synopsis
parameters_type const & parameters()
Returns

The parameters object.

Throws

Nothing.

Returns the translator object.

Synopsis
translator_type const & translator()
Returns

The translator object.

Throws

Nothing.

Returns allocator used by the rtree.

Synopsis
allocator_type get_allocator()
Returns

The allocator.

Throws

If allocator copy constructor throws.

Functions

Function

Description

insert(rtree<...> &, Value const &)

Insert a value to the index.

insert(rtree<...> &, Iterator, Iterator)

Insert a range of values to the index.

insert(rtree<...> &, Range const &)

Insert a range of values to the index.

remove(rtree<...> &, Value const &)

Remove a value from the container.

remove(rtree<...> &, Iterator, Iterator)

Remove a range of values from the container.

remove(rtree<...> &, Range const &)

Remove a range of values from the container.

spatial_query(rtree<...> const &, Predicates const &, OutIter)

Find values meeting spatial predicates.

nearest_query(rtree<...> const &, DistancesPredicates const &, Value &)

Find the value meeting distances predicates.

nearest_query(rtree<...> const &, DistancesPredicates const &, Predicates const &, Value &)

Find the value meeting distances and spatial predicates.

nearest_query(rtree<...> const &, DistancesPredicates const &, typename rtree<...>::size_type, OutIter)

Find k values meeting distances predicates.

nearest_query(rtree<...> const &, DistancesPredicates const &, typename rtree<...>::size_type, Predicates const &, OutIter)

Find k values meeting distances and spatial predicates.

clear(rtree<...> &)

Remove all values from the index.

size(rtree<...> const &)

Get the number of values stored in the index.

empty(rtree<...> const &)

Query if there are no values stored in the index.

box(rtree<...> const &)

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

Insert a value to the index.

Description

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

Synopsis
template<typename Value,
         typename Options,
         typename Translator,
         typename Allocator>
void boost::geometry::index::insert(rtree< Value, Options, Translator, Allocator > & tree, Value const & v)
Parameter(s)

Type

Name

Description

rtree< Value, Options, Translator, Allocator > &

tree

The spatial index.

Value const &

v

The value which will be stored in the index.

Insert a range of values to the index.

Description

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

Synopsis
template<typename Value,
         typename Options,
         typename Translator,
         typename Allocator,
         typename Iterator>
void boost::geometry::index::insert(rtree< Value, Options, Translator, Allocator > & tree,
                                    Iterator first,
                                    Iterator last)
Parameter(s)

Type

Name

Description

rtree< Value, Options, Translator, Allocator > &

tree

The spatial index.

Iterator

first

The beginning of the range of values.

Iterator

last

The end of the range of values.

Insert a range of values to the index.

Description

It calls rtree::insert(Range const&).

Synopsis
template<typename Value,
         typename Options,
         typename Translator,
         typename Allocator,
         typename Range>
void boost::geometry::index::insert(rtree< Value, Options, Translator, Allocator > & tree, Range const & rng)
Parameter(s)

Type

Name

Description

rtree< Value, Options, Translator, Allocator > &

tree

The spatial index.

Range const &

rng

The range of values.

Remove a value from the container.

Description

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&).

Synopsis
template<typename Value,
         typename Options,
         typename Translator,
         typename Allocator>
rtree<Value, Options, Translator, Allocator>::size_type boost::geometry::index::remove(rtree< Value, Options, Translator, Allocator > & tree, Value const & v)
Parameter(s)

Type

Name

Description

rtree< Value, Options, Translator, Allocator > &

tree

The spatial index.

Value const &

v

The value which will be removed from the index.

Returns

1 if value was removed, 0 otherwise.

Remove a range of values from the container.

Description

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).

Synopsis
template<typename Value,
         typename Options,
         typename Translator,
         typename Allocator,
         typename Iterator>
rtree<Value, Options, Translator, Allocator>::size_type boost::geometry::index::remove(rtree< Value, Options, Translator, Allocator > & tree,
                                                                                       Iterator first,
                                                                                       Iterator last)
Parameter(s)

Type

Name

Description

rtree< Value, Options, Translator, Allocator > &

tree

The spatial index.

Iterator

first

The beginning of the range of values.

Iterator

last

The end of the range of values.

Returns

The number of removed values.

Remove a range of values from the container.

Description

Remove 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(Range const&).

Synopsis
template<typename Value,
         typename Options,
         typename Translator,
         typename Allocator,
         typename Range>
rtree<Value, Options, Translator, Allocator>::size_type boost::geometry::index::remove(rtree< Value, Options, Translator, Allocator > & tree, Range const & rng)
Parameter(s)

Type

Name

Description

rtree< Value, Options, Translator, Allocator > &

tree

The spatial index.

Range const &

rng

The range of values.

Returns

The number of removed values.

Find values meeting spatial predicates.

Description

It calls rtree::spatial_query with parameters (Predicates const&, OutIter).

Synopsis
template<typename Value,
         typename Options,
         typename Translator,
         typename Allocator,
         typename Predicates,
         typename OutIter>
size_t boost::geometry::index::spatial_query(rtree< Value, Options, Translator, Allocator > const & tree,
                                             Predicates const & pred,
                                             OutIter out_it)
Parameter(s)

Type

Name

Description

rtree< Value, Options, Translator, Allocator > const &

tree

The spatial index.

Predicates const &

pred

The spatial predicates.

OutIter

out_it

The output iterator of the result range.

Returns

The number of found values.

Find the value meeting distances predicates.

Description

It calls rtree::nearest_query with parameters (DistancesPredicates const& dpred, value_type & v).

Synopsis
template<typename Value,
         typename Options,
         typename Translator,
         typename Allocator,
         typename DistancesPredicates>
size_t boost::geometry::index::nearest_query(rtree< Value, Options, Translator, Allocator > const & tree,
                                             DistancesPredicates const & dpred,
                                             Value & v)
Parameter(s)

Type

Name

Description

rtree< Value, Options, Translator, Allocator > const &

tree

The spatial index.

DistancesPredicates const &

dpred

The distances predicates.

Value &

v

The result.

Returns

The number of found values.

Find the value meeting distances and spatial predicates.

Description

It calls rtree::nearest_query with parameters (DistancesPredicates const& dpred, Predicates const& pred, value_type & v).

Synopsis
template<typename Value,
         typename Options,
         typename Translator,
         typename Allocator,
         typename DistancesPredicates,
         typename Predicates>
size_t boost::geometry::index::nearest_query(rtree< Value, Options, Translator, Allocator > const & tree,
                                             DistancesPredicates const & dpred,
                                             Predicates const & pred,
                                             Value & v)
Parameter(s)

Type

Name

Description

rtree< Value, Options, Translator, Allocator > const &

tree

The spatial index.

DistancesPredicates const &

dpred

The distances predicates.

Predicates const &

pred

The spatial predicates.

Value &

v

The result.

Returns

The number of found values.

Find k values meeting distances predicates.

Description

It calls rtree::nearest_query with parameters (DistancesPredicates const & dpred, size_type k, OutIter out_it).

Synopsis
template<typename Value,
         typename Options,
         typename Translator,
         typename Allocator,
         typename DistancesPredicates,
         typename OutIter>
size_t boost::geometry::index::nearest_query(rtree< Value, Options, Translator, Allocator > const & tree,
                                             DistancesPredicates const & dpred,
                                             typename rtree< Value, Options, Translator, Allocator >::size_type k,
                                             OutIter out_it)
Parameter(s)

Type

Name

Description

rtree< Value, Options, Translator, Allocator > const &

tree

The spatial index.

DistancesPredicates const &

dpred

The distances predicates.

typename rtree< Value, Options, Translator, Allocator >::size_type

k

The max number of values.

OutIter

out_it

The output iterator of the result range.

Returns

The number of found values.

Find k values meeting distances and spatial predicates.

Description

It calls rtree::nearest_query with parameters (DistancesPredicates const & dpred, size_type k, Predicates const & pred, OutIter out_it).

Synopsis
template<typename Value,
         typename Options,
         typename Translator,
         typename Allocator,
         typename DistancesPredicates,
         typename Predicates,
         typename OutIter>
size_t boost::geometry::index::nearest_query(rtree< Value, Options, Translator, Allocator > const & tree,
                                             DistancesPredicates const & dpred,
                                             typename rtree< Value, Options, Translator, Allocator >::size_type k,
                                             Predicates const & pred,
                                             OutIter out_it)
Parameter(s)

Type

Name

Description

rtree< Value, Options, Translator, Allocator > const &

tree

The spatial index.

DistancesPredicates const &

dpred

The distances predicates.

typename rtree< Value, Options, Translator, Allocator >::size_type

k

The max number of values.

Predicates const &

pred

The spatial predicates.

OutIter

out_it

The output iterator of the result range.

Returns

The number of found values.

Remove all values from the index.

Description

It calls rtree::clear().

Synopsis
template<typename Value,
         typename Options,
         typename Translator,
         typename Allocator>
void boost::geometry::index::clear(rtree< Value, Options, Translator, Allocator > & tree)
Parameter(s)

Type

Name

Description

rtree< Value, Options, Translator, Allocator > &

tree

The spatial index.

Get the number of values stored in the index.

Description

It calls rtree::size().

Synopsis
template<typename Value,
         typename Options,
         typename Translator,
         typename Allocator>
size_t boost::geometry::index::size(rtree< Value, Options, Translator, Allocator > const & tree)
Parameter(s)

Type

Name

Description

rtree< Value, Options, Translator, Allocator > const &

tree

The spatial index.

Returns

The number of values stored in the index.

Query if there are no values stored in the index.

Description

It calls rtree::empty().

Synopsis
template<typename Value,
         typename Options,
         typename Translator,
         typename Allocator>
bool boost::geometry::index::empty(rtree< Value, Options, Translator, Allocator > const & tree)
Parameter(s)

Type

Name

Description

rtree< Value, Options, Translator, Allocator > const &

tree

The spatial index.

Returns

true if there are no values in the index.

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

Description

It calls rtree::box().

Synopsis
template<typename Value,
         typename Options,
         typename Translator,
         typename Allocator>
rtree<Value, Options, Translator, Allocator>::box_type const& boost::geometry::index::box(rtree< Value, Options, Translator, Allocator > const & tree)
Parameter(s)

Type

Name

Description

rtree< Value, Options, Translator, Allocator > const &

tree

The spatial index.

Returns

The box containing all stored values or an invalid box.

Linear r-tree creation algorithm parameters.

Header

#include <boost/geometry/extensions/index/parameters.hpp>

Synopsis
template<size_t MaxElements, size_t MinElements>
struct linear
{
  // ...
};
Template parameter(s)

Parameter

Description

size_t MaxElements

Maximum number of elements in nodes.

size_t MinElements

Minimum number of elements in nodes.

Quadratic r-tree creation algorithm parameters.

Header

#include <boost/geometry/extensions/index/parameters.hpp>

Synopsis
template<size_t MaxElements, size_t MinElements>
struct quadratic
{
  // ...
};
Template parameter(s)

Parameter

Description

size_t MaxElements

Maximum number of elements in nodes.

size_t MinElements

Minimum number of elements in nodes.

R*-tree creation algorithm parameters.

Header

#include <boost/geometry/extensions/index/parameters.hpp>

Synopsis
template<size_t MaxElements,
         size_t MinElements,
         size_t OverlapCostThreshold = 0,
         size_t ReinsertedElements = detail::default_rstar_reinserted_elements_s<MaxElements>::value>
struct rstar
{
  // ...
};
Template parameter(s)

Parameter

Description

size_t MaxElements

Maximum number of elements in nodes.

size_t MinElements

Minimum number of elements in nodes.

size_t OverlapCostThreshold

The number of leaf node children elements above which nearly minimum overlap cost is calculated instead of minimum overlap cost. If 0 minimum overlap cost is always calculated.

size_t ReinsertedElements

Number of elements reinserted by forced reinsertions algorithm.

Linear r-tree creation algorithm parameters.

Header

#include <boost/geometry/extensions/index/parameters.hpp>

Synopsis
class linear
{
  // ...
};
Constructor(s) and destructor

Function

Description

linear(size_t, size_t)

The constructor.

The constructor.

Synopsis
linear(size_t max_elements, size_t min_elements)
Parameter(s)

Type

Name

Description

size_t

max_elements

Maximum number of elements in nodes.

size_t

min_elements

Minimum number of elements in nodes.

Quadratic r-tree creation algorithm parameters.

Header

#include <boost/geometry/extensions/index/parameters.hpp>

Synopsis
class quadratic
{
  // ...
};
Constructor(s) and destructor

Function

Description

quadratic(size_t, size_t)

The constructor.

The constructor.

Synopsis
quadratic(size_t max_elements, size_t min_elements)
Parameter(s)

Type

Name

Description

size_t

max_elements

Maximum number of elements in nodes.

size_t

min_elements

Minimum number of elements in nodes.

R*-tree creation algorithm parameters.

Header

#include <boost/geometry/extensions/index/parameters.hpp>

Synopsis
class rstar
{
  // ...
};
Constructor(s) and destructor

Function

Description

rstar(size_t, size_t)

The constructor.

The constructor.

Synopsis
rstar(size_t max_elements,
      size_t min_elements,
      size_t overlap_cost_threshold = 0,
      size_t reinserted_elements = detail::default_rstar_reinserted_elements_d())
Parameter(s)

Type

Name

Description

size_t

max_elements

Maximum number of elements in nodes.

size_t

min_elements

Minimum number of elements in nodes.

size_t

overlap_cost_threshold

The number of leaf node children elements above which nearly minimum overlap cost is calculated instead of minimum overlap cost. If 0 minimum overlap cost is always calculated.

size_t

reinserted_elements

Number of elements reinserted by forced reinsertions algorithm.

Functions

Function

Description

empty()

Generate empty predicate.

value(ValuePredicate const &)

Generate value predicate.

covered_by(Geometry const &)

Generate covered_by() predicate.

disjoint(Geometry const &)

Generate disjoint() predicate.

intersects(Geometry const &)

Generate intersects() predicate.

overlaps(Geometry const &)

Generate overlaps() predicate.

within(Geometry const &)

Generate within() predicate.

Generate empty predicate.

Synopsis
detail::empty boost::geometry::index::empty()

Generate value predicate.

Description

A wrapper around user-defined functor describing if Value should be returned by spatial query.

Synopsis
template<typename ValuePredicate>
detail::value<ValuePredicate> boost::geometry::index::value(ValuePredicate const & vpred)
Template parameter(s)

Parameter

Description

ValuePredicate

Functor type.

Parameter(s)

Type

Name

Description

ValuePredicate const &

vpred

The functor.

Generate covered_by() predicate.

Description

Generate a predicate defining Value and Geometry relationship. Value will be returned by the query if bg::covered_by(Indexable, Geometry) returns true.

Synopsis
template<typename Geometry>
detail::covered_by<Geometry> boost::geometry::index::covered_by(Geometry const & g)
Template parameter(s)

Parameter

Description

Geometry

The Geometry type.

Parameter(s)

Type

Name

Description

Geometry const &

g

The Geometry object.

Generate disjoint() predicate.

Description

Generate a predicate defining Value and Geometry relationship. Value will be returned by the query if bg::disjoint(Indexable, Geometry) returns true.

Synopsis
template<typename Geometry>
detail::disjoint<Geometry> boost::geometry::index::disjoint(Geometry const & g)
Template parameter(s)

Parameter

Description

Geometry

The Geometry type.

Parameter(s)

Type

Name

Description

Geometry const &

g

The Geometry object.

Generate intersects() predicate.

Description

Generate a predicate defining Value and Geometry relationship. Value will be returned by the query if bg::intersects(Indexable, Geometry) returns true.

Synopsis
template<typename Geometry>
detail::intersects<Geometry> boost::geometry::index::intersects(Geometry const & g)
Template parameter(s)

Parameter

Description

Geometry

The Geometry type.

Parameter(s)

Type

Name

Description

Geometry const &

g

The Geometry object.

Generate overlaps() predicate.

Description

Generate a predicate defining Value and Geometry relationship. Value will be returned by the query if bg::overlaps(Indexable, Geometry) returns true.

Synopsis
template<typename Geometry>
detail::overlaps<Geometry> boost::geometry::index::overlaps(Geometry const & g)
Template parameter(s)

Parameter

Description

Geometry

The Geometry type.

Parameter(s)

Type

Name

Description

Geometry const &

g

The Geometry object.

Generate within() predicate.

Description

Generate a predicate defining Value and Geometry relationship. Value will be returned by the query if bg::within(Indexable, Geometry) returns true.

Synopsis
template<typename Geometry>
detail::within<Geometry> boost::geometry::index::within(Geometry const & g)
Template parameter(s)

Parameter

Description

Geometry

The Geometry type.

Parameter(s)

Type

Name

Description

Geometry const &

g

The Geometry object.

Functions

Function

Description

to_nearest(T const &)

Generate to_nearest() Point-Indexable relationship.

to_centroid(T const &)

Generate to_centroid() Point-Indexable relationship.

to_furthest(T const &)

Generate to_furthest() Point-Indexable relationship.

unbounded(PointRelation const &)

Generate unbounded() distance predicate.

min_bounded(PointRelation const &, MinRelation const &)

Generate min_bounded() distance predicate.

max_bounded(PointRelation const &, MaxRelation const &)

Generate max_bounded() distance predicate.

bounded(PointRelation const &, MinRelation const &, MaxRelation const &)

Generate bounded() distance predicate.

Generate to_nearest() Point-Indexable relationship.

Description

Generate a nearest query Point and Value's Indexable relationship while calculating distances. This function may be used to define that knn query should calculate distances as smallest as possible between query Point and Indexable's points. In other words it should be the distance to the nearest Indexable's point. This function may be also used to define distances bounds which indicates that Indexable's nearest point should be closer or further than value v. This is default relation.

Synopsis
template<typename T>
detail::to_nearest<T> boost::geometry::index::to_nearest(T const & v)
Template parameter(s)

Parameter

Description

T

Type of wrapped object. This may be a Point for PointRelation or some Value for MinRelation or MaxRelation

Parameter(s)

Type

Name

Description

T const &

v

Point or bound value.

Generate to_centroid() Point-Indexable relationship.

Description

Generate a nearest query Point and Value's Indexable relationship while calculating distances. This function may be used to define that knn query should calculate distances between query Point and Indexable's centroid. This function may be also used to define distances bounds which indicates that Indexable's centroid should be closer or further than value v.

Synopsis
template<typename T>
detail::to_centroid<T> boost::geometry::index::to_centroid(T const & v)
Template parameter(s)

Parameter

Description

T

Type of wrapped object. This may be a Point for PointRelation or some Value for MinRelation or MaxRelation

Parameter(s)

Type

Name

Description

T const &

v

Point or bound value.

Generate to_furthest() Point-Indexable relationship.

Description

Generate a nearest query Point and Value's Indexable relationship while calculating distances. This function may be used to define that knn query should calculate distances as biggest as possible between query Point and Indexable's points. In other words it should be the distance to the furthest Indexable's point. This function may be also used to define distances bounds which indicates that Indexable's furthest point should be closer or further than value v.

Synopsis
template<typename T>
detail::to_furthest<T> boost::geometry::index::to_furthest(T const & v)
Template parameter(s)

Parameter

Description

T

Type of wrapped object. This may be a Point for PointRelation or some Value for MinRelation or MaxRelation

Parameter(s)

Type

Name

Description

T const &

v

Point or bound value.

Generate unbounded() distance predicate.

Description

Generate a distance predicate. This defines distances bounds which are used by knn query. This function indicates that there is no distance bounds and Values should be returned if distances between Point and Indexable are the smallest. Distance calculation is defined by PointRelation. This is default nearest predicate.

Synopsis
template<typename PointRelation>
detail::unbounded<PointRelation> boost::geometry::index::unbounded(PointRelation const & pr)
Template parameter(s)

Parameter

Description

PointRelation

PointRelation type.

Parameter(s)

Type

Name

Description

PointRelation const &

pr

The point relation. This may be generated by index::to_nearest(), index::to_centroid() or index::to_furthest() with Point passed as a parameter.

Generate min_bounded() distance predicate.

Description

Generate a distance predicate. This defines distances bounds which are used by knn query. This function indicates that Values should be returned only if distances between Point and Indexable are greater or equal to some min_distance passed in MinRelation. Check for closest Value is defined by PointRelation. So it is possible e.g. to return Values with centroids closest to some Point but only if nearest points are further than some distance.

Synopsis
template<typename PointRelation, typename MinRelation>
detail::min_bounded<PointRelation, MinRelation> boost::geometry::index::min_bounded(PointRelation const & pr, MinRelation const & minr)
Template parameter(s)

Parameter

Description

PointRelation

PointRelation type.

MinRelation

MinRelation type.

Parameter(s)

Type

Name

Description

PointRelation const &

pr

The point relation. This may be generated by to_nearest(), to_centroid() or to_furthest() with Point passed as a parameter.

MinRelation const &

minr

The minimum bound relation. This may be generated by to_nearest(), to_centroid() or to_furthest() with distance value passed as a parameter.

Generate max_bounded() distance predicate.

Description

Generate a distance predicate. This defines distances bounds which are used by knn query. This function indicates that Values should be returned only if distances between Point and Indexable are lesser or equal to some max_distance passed in MaxRelation. Check for closest Value is defined by PointRelation. So it is possible e.g. to return Values with centroids closest to some Point but only if nearest points are closer than some distance.

Synopsis
template<typename PointRelation, typename MaxRelation>
detail::max_bounded<PointRelation, MaxRelation> boost::geometry::index::max_bounded(PointRelation const & pr, MaxRelation const & maxr)
Template parameter(s)

Parameter

Description

PointRelation

PointRelation type.

MaxRelation

MaxRelation type.

Parameter(s)

Type

Name

Description

PointRelation const &

pr

The point relation. This may be generated by to_nearest(), to_centroid() or to_furthest() with Point passed as a parameter.

MaxRelation const &

maxr

The maximum bound relation. This may be generated by to_nearest(), to_centroid() or to_furthest() with distance value passed as a parameter.

Generate bounded() distance predicate.

Description

Generate a distance predicate. This defines distances bounds which are used by knn query. This function indicates that Values should be returned only if distances between Point and Indexable are greater or equal to some min_distance passed in MinRelation and lesser or equal to some max_distance passed in MaxRelation. Check for closest Value is defined by PointRelation. So it is possible e.g. to return Values with centroids closest to some Point but only if nearest points are further than some distance and closer than some other distance.

Synopsis
template<typename PointRelation,
         typename MinRelation,
         typename MaxRelation>
detail::bounded<PointRelation, MinRelation, MaxRelation> boost::geometry::index::bounded(PointRelation const & pr,
                                                                                         MinRelation const & minr,
                                                                                         MaxRelation const & maxr)
Template parameter(s)

Parameter

Description

PointRelation

PointRelation type.

MinRelation

MinRelation type.

MaxRelation

MaxRelation type.

Parameter(s)

Type

Name

Description

PointRelation const &

pr

The point relation. This may be generated by to_nearest(), to_centroid() or to_furthest() with Point passed as a parameter.

MinRelation const &

minr

The minimum bound relation. This may be generated by to_nearest(), to_centroid() or to_furthest() with distance value passed as a parameter.

MaxRelation const &

maxr

The maximum bound relation. This may be generated by to_nearest(), to_centroid() or to_furthest() with distance value passed as a parameter.

Functions

Function

Description

nearest_queried(DistancesPredicates const &, size_t, Predicates const &)

The nearest query index adaptor generator.

nearest_queried(DistancesPredicates const &, size_t)

The nearest query index adaptor generator.

spatial_queried(Predicates const &)

The spatial query index adaptor generator.

The nearest query index adaptor generator.

Synopsis
template<typename DistancesPredicates, typename Predicates>
detail::nearest_query<DistancesPredicates, Predicates> boost::geometry::index::adaptors::nearest_queried(DistancesPredicates const & dpred,
                                                                                                         size_t k,
                                                                                                         Predicates const & pred)
Parameter(s)

Type

Name

Description

DistancesPredicates const &

dpred

Distance predicates.

size_t

k

The number of values to find.

Predicates const &

pred

Spatial predicates.

The nearest query index adaptor generator.

Synopsis
template<typename DistancesPredicates>
detail::nearest_query<DistancesPredicates, index::detail::empty> boost::geometry::index::adaptors::nearest_queried(DistancesPredicates const & dpred, size_t k)
Parameter(s)

Type

Name

Description

DistancesPredicates const &

dpred

Distance predicates.

size_t

k

The number of values to find.

The spatial query index adaptor generator.

Synopsis
template<typename Predicates>
detail::spatial_query<Predicates> boost::geometry::index::adaptors::spatial_queried(Predicates const & pred)
Parameter(s)

Type

Name

Description

Predicates const &

pred

Spatial predicates.

The default translator.

Description

It translates Value object to Indexable object. The default version handles Values which are Indexables. This translator is also specialized for std::pair<Indexable, Second> and boost::tuple<Indexable, ...>.

Header

#include <boost/geometry/extensions/index/translator/def.hpp>

Synopsis
template<typename Value>
struct def
{
  // ...
};
Template parameter(s)

Parameter

Description

Value

The Value type which may be translated directly to the Indexable.

The index translator.

Description

This translator translates from index of an element in an external Container to the Indexable. The container should have operator[](size_type) defined. Index translator uses translator::def<...> to translate from Container::value_type to the Indexable which means that it can handle Indexables, std::pairs and boost::tuples stored in an external Container.

Header

#include <boost/geometry/extensions/index/translator/index.hpp>

Synopsis
template<typename Container>
class index
{
  // ...
};
Template parameter(s)

Parameter

Description

Container

The Container type.

Constructor(s) and destructor

Function

Description

index(Container const &)

The constructor.

The constructor.

Synopsis
index(Container const & c)
Parameter(s)

Type

Name

Description

Container const &

c

The container which stores indexed values.

Functions

Function

Description

inserter(Container &)

Insert iterator generator.

Insert iterator generator.

Description

Returns insert iterator capable to insert values to the container (spatial index) which has member function insert(value_type const&) defined.

Synopsis
template<typename Container>
insert_iterator<Container> boost::geometry::index::inserter(Container & c)
Parameter(s)

Type

Name

Description

Container &

c

The reference to the container (spatial index) to which values will be inserted.

Returns

The insert iterator inserting values to the container.


PrevUpHome