Boost C++ Libraries Home Libraries People FAQ More

PrevUpHome

Reference

boost::geometry::index::rtree
Functions related to the rtree
R-tree parameters (boost::geometry::index::)
boost::geometry::index::translator
Predicates (boost::geometry::index::)
Nearest relations (boost::geometry::index::)
Adaptors (boost::geometry::index::adaptors::)
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/index/rtree.hpp>

Synopsis
template<typename Value,
         typename Parameters,
         typename Translator = index::translator<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.

bounds_type

The Box type used by the R-tree.

Constructor(s) and destructor

Function

Description

rtree()

The constructor.

rtree(parameters_type const &, 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)

Modifier

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.

const

query(Predicates const &, OutIter)

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

const

size()

Returns the number of stored values.

const

empty()

Query if the container is empty.

clear()

Removes all values stored in the container.

const

bounds()

Returns the box able to contain all values stored in the container.

const

count(ValueOrIndexable const &)

Count Values or Indexables stored in the container.

const

parameters()

Returns parameters.

const

translator()

Returns the translator object.

const

get_allocator()

Returns allocator used by the rtree.

The constructor.

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

explicit

Parameter(s)

Type

Name

Description

parameters_type const &

parameters

The parameters object.

translator_type const &

translator

The translator object.

Throws

If allocator default constructor throws.

The constructor.

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

Type

Name

Description

parameters_type const &

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 const & 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 const &

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 const & parameters = parameters_type(),
      translator_type const & translator = translator_type(),
      allocator_type allocator = allocator_type())
Modifier(s)

explicit

Parameter(s)

Type

Name

Description

Range const &

rng

The range of Values.

parameters_type const &

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 passed predicates e.g. nearest to some Point and/or intersecting some Box.

Description

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:

It is possible to negate spatial predicates:

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:

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:

Connecting predicates

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

Synopsis
template<typename Predicates, typename OutIter>
size_type query(Predicates const & predicates, OutIter out_it)
Modifier(s)

const

Parameter(s)

Type

Name

Description

Predicates const &

predicates

Predicates.

OutIter

out_it

The output iterator, e.g. generated by std::back_inserter().

Returns

The number of values found.

Example

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

Throws

If Value copy constructor or copy assignment throws.

[Warning] Warning

Only one nearest() perdicate may be passed to the query.

Returns the number of stored values.

Synopsis
size_type size()
Modifier(s)

const

Returns

The number of stored values.

Throws

Nothing.

Query if the container is empty.

Synopsis
bool empty()
Modifier(s)

const

Returns

true if the container is empty.

Throws

Nothing.

Removes all values stored in the container.

Synopsis
void clear()
Throws

Nothing.

Returns the box able to contain all values stored in the container.

Description

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

Synopsis
bounds_type bounds()
Modifier(s)

const

Returns

The box able to contain 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)
Modifier(s)

const

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()
Modifier(s)

const

Returns

The parameters object.

Throws

Nothing.

Returns the translator object.

Synopsis
translator_type const & translator()
Modifier(s)

const

Returns

The translator object.

Throws

Nothing.

Returns allocator used by the rtree.

Synopsis
allocator_type get_allocator()
Modifier(s)

const

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.

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

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

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.

bounds(rtree<...> const &)

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

swap(rtree<...> &, rtree<...> &)

Exchanges the contents of the container with those of other.

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.

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

Description

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:

It is possible to negate spatial predicates:

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:

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:

Connecting predicates

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

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

Type

Name

Description

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

tree

The rtree.

Predicates const &

predicates

Predicates.

OutIter

out_it

The output iterator, e.g. generated by std::back_inserter().

Returns

The number of values found.

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));
// 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));

Throws

If Value copy constructor or copy assignment throws.

[Warning] Warning

Only one nearest() perdicate may be passed to the query.

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::envelope().

Synopsis
template<typename Value,
         typename Options,
         typename Translator,
         typename Allocator>
rtree<Value, Options, Translator, Allocator>::bounds_type boost::geometry::index::bounds(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.

Exchanges the contents of the container with those of other.

Description

It calls rtree::swap().

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

Type

Name

Description

rtree< Value, Options, Translator, Allocator > &

l

The first rtree.

rtree< Value, Options, Translator, Allocator > &

r

The second rtree.

Linear r-tree creation algorithm parameters.

Header

#include <boost/geometry/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/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/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 - run-time version.

Header

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

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

Function

Description

dynamic_linear(size_t, size_t)

The constructor.

The constructor.

Synopsis
dynamic_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 - run-time version.

Header

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

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

Function

Description

dynamic_quadratic(size_t, size_t)

The constructor.

The constructor.

Synopsis
dynamic_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 - run-time version.

Header

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

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

Function

Description

dynamic_rstar(size_t, size_t)

The constructor.

The constructor.

Synopsis
dynamic_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.

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/index/translator.hpp>

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

Parameter

Description

Value

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

Functions

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.

Example

bgi::query(spatial_index, bgi::covered_by(box), std::back_inserter(result));

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.

Example

bgi::query(spatial_index, bgi::disjoint(box), std::back_inserter(result));

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.

Example

bgi::query(spatial_index, bgi::intersects(box), std::back_inserter(result));
bgi::query(spatial_index, bgi::intersects(ring), std::back_inserter(result));
bgi::query(spatial_index, bgi::intersects(polygon), std::back_inserter(result));

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.

Example

bgi::query(spatial_index, bgi::overlaps(box), std::back_inserter(result));

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.

Example

bgi::query(spatial_index, bgi::within(box), std::back_inserter(result));

Generate satisfies() predicate.

Description

A wrapper around user-defined UnaryPredicate checking if Value should be returned by spatial query.

Synopsis
template<typename UnaryPredicate>
detail::satisfies<UnaryPredicate> boost::geometry::index::satisfies(UnaryPredicate const & pred)
Template parameter(s)

Parameter

Description

UnaryPredicate

A type of unary predicate function or function object.

Parameter(s)

Type

Name

Description

UnaryPredicate const &

pred

The unary predicate function or function object.

Example

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(); }
}

// ...

rt.query(index::intersects(box) && index::satisfies(is_red),
std::back_inserter(result));

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(); }),
std::back_inserter(result));
#endif

Generate nearest() predicate.

Description

When nearest predicate is passed to the query, k-nearest neighbour search will be performed.

The simplest way of defining the knn query is passing a Point to which 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:

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

Type

Name

Description

PointOrRelation const &

point_relation

The point or relation describing how the distance will be 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(bgi::to_centroid(pt), 5) && bgi::within(box), std::back_inserter(result));

[Warning] Warning

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

Functions

Function

Description

to_nearest(T const &)

Generate to_nearest() relationship.

to_centroid(T const &)

Generate to_centroid() relationship.

to_furthest(T const &)

Generate to_furthest() relationship.

Generate to_nearest() 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 CoordinateType for MinRelation or MaxRelation

Parameter(s)

Type

Name

Description

T const &

v

Point or distance value.

Generate to_centroid() 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 CoordinateType for MinRelation or MaxRelation

Parameter(s)

Type

Name

Description

T const &

v

Point or distance value.

Generate to_furthest() 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 CoordinateType for MinRelation or MaxRelation

Parameter(s)

Type

Name

Description

T const &

v

Point or distance value.

Functions

Function

Description

queried(Predicates const &)

The query index adaptor generator.

The query index adaptor generator.

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

Type

Name

Description

Predicates const &

pred

Predicates.

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