Boost.Geometry.Index
 All Classes Functions Typedefs Groups
Public Types | Public Member Functions | List of all members
boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > Class Template Reference

The R-tree spatial index. More...

#include <rtree.hpp>

Public Types

typedef Value value_type
 The type of Value stored in the container.
 
typedef Parameters parameters_type
 R-tree parameters type.
 
typedef IndexableGetter indexable_getter
 The function object extracting Indexable from Value.
 
typedef EqualTo value_equal
 The function object comparing objects of type Value.
 
typedef Allocator allocator_type
 The type of allocator used by the container.
 
typedef
index::detail::indexable_type
< detail::translator
< IndexableGetter, EqualTo >
>::type 
indexable_type
 The Indexable type to which Value is translated.
 
typedef geometry::model::box
< geometry::model::point
< typename coordinate_type
< indexable_type >::type,
dimension< indexable_type >
::value, typename
coordinate_system
< indexable_type >::type > > 
bounds_type
 The Box type used by the R-tree.
 
typedef allocators_type::reference reference
 Type of reference to Value.
 
typedef
allocators_type::const_reference 
const_reference
 Type of reference to const Value.
 
typedef allocators_type::pointer pointer
 Type of pointer to Value.
 
typedef
allocators_type::const_pointer 
const_pointer
 Type of pointer to const Value.
 
typedef
allocators_type::difference_type 
difference_type
 Type of difference type.
 
typedef allocators_type::size_type size_type
 Unsigned integral type used by the container.
 
typedef
index::detail::rtree::iterators::iterator
< value_type, options_type,
translator_type, box_type,
allocators_type > 
const_iterator
 Type of const iterator, category ForwardIterator.
 
typedef
index::detail::rtree::iterators::query_iterator
< value_type, allocators_type > 
const_query_iterator
 Type of const query iterator, category ForwardIterator.
 

Public Member Functions

 rtree (parameters_type const &parameters=parameters_type(), indexable_getter const &getter=indexable_getter(), value_equal const &equal=value_equal())
 The constructor. More...
 
 rtree (parameters_type const &parameters, indexable_getter const &getter, value_equal const &equal, allocator_type const &allocator)
 The constructor. More...
 
template<typename Iterator >
 rtree (Iterator first, Iterator last, parameters_type const &parameters=parameters_type(), indexable_getter const &getter=indexable_getter(), value_equal const &equal=value_equal(), allocator_type const &allocator=allocator_type())
 The constructor. More...
 
template<typename Range >
 rtree (Range const &rng, parameters_type const &parameters=parameters_type(), indexable_getter const &getter=indexable_getter(), value_equal const &equal=value_equal(), allocator_type const &allocator=allocator_type())
 The constructor. More...
 
 ~rtree ()
 The destructor. More...
 
 rtree (rtree const &src)
 The copy constructor. More...
 
 rtree (rtree const &src, allocator_type const &allocator)
 The copy constructor. More...
 
 rtree (rtree &&src)
 The moving constructor. More...
 
 rtree (rtree &&src, allocator_type const &allocator)
 The moving constructor. More...
 
rtreeoperator= (rtree const &src)
 The assignment operator. More...
 
rtreeoperator= (rtree &&src)
 The moving assignment. More...
 
void swap (rtree &other)
 Swaps contents of two rtrees. More...
 
void insert (value_type const &value)
 Insert a value to the index. More...
 
template<typename Iterator >
void insert (Iterator first, Iterator last)
 Insert a range of values to the index. More...
 
template<typename ConvertibleOrRange >
void insert (ConvertibleOrRange const &conv_or_rng)
 Insert a value created using convertible object or a range of values to the index. More...
 
size_type remove (value_type const &value)
 Remove a value from the container. More...
 
template<typename Iterator >
size_type remove (Iterator first, Iterator last)
 Remove a range of values from the container. More...
 
template<typename ConvertibleOrRange >
size_type remove (ConvertibleOrRange const &conv_or_rng)
 Remove value corresponding to an object convertible to it or a range of values from the container. More...
 
template<typename Predicates , typename OutIter >
size_type query (Predicates const &predicates, OutIter out_it) const
 Finds values meeting passed predicates e.g. nearest to some Point and/or intersecting some Box. More...
 
template<typename Predicates >
const_query_iterator qbegin (Predicates const &predicates) const
 Returns a query iterator pointing at the begin of the query range. More...
 
const_query_iterator qend () const
 Returns a query iterator pointing at the end of the query range. More...
 
const_iterator begin () const
 Returns the iterator pointing at the begin of the rtree values range. More...
 
const_iterator end () const
 Returns the iterator pointing at the end of the rtree values range. More...
 
size_type size () const
 Returns the number of stored values. More...
 
bool empty () const
 Query if the container is empty. More...
 
void clear ()
 Removes all values stored in the container. More...
 
bounds_type bounds () const
 Returns the box able to contain all values stored in the container. More...
 
template<typename ValueOrIndexable >
size_type count (ValueOrIndexable const &vori) const
 Count Values or Indexables stored in the container. More...
 
parameters_type parameters () const
 Returns parameters. More...
 
indexable_getter indexable_get () const
 Returns function retrieving Indexable from Value. More...
 
value_equal value_eq () const
 Returns function comparing Values. More...
 
allocator_type get_allocator () const
 Returns allocator used by the rtree. More...
 

Detailed Description

template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
class boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >

The R-tree spatial index.

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:
IndexableGetter
The object of IndexableGetter type translates from Value to Indexable each time r-tree requires it. This means that this operation is done for each Value access. Therefore the IndexableGetter should return the Indexable by a reference type. The Indexable should not be calculated since it could harm the performance. The default IndexableGetter can translate all types adapted to Point, Box or Segment concepts (called Indexables). Furthermore, it can handle std::pair<Indexable, T>, boost::tuple<Indexable, ...> and std::tuple<Indexable, ...> when possible. For example, for Value of type std::pair<Box, int>, the default IndexableGetter translates from std::pair<Box, int> const& to Box const&.
EqualTo
The object of EqualTo type compares Values and returns true if they are equal. It's similar to std::equal_to<>. The default EqualTo returns the result of boost::geometry::equals() for types adapted to some Geometry concept defined in Boost.Geometry and the result of operator== for other types. Components of Pairs and Tuples are compared left-to-right.
Template Parameters
ValueThe type of objects stored in the container.
ParametersCompile-time parameters.
IndexableGetterThe function object extracting Indexable from Value.
EqualToThe function object comparing objects of type Value.
AllocatorThe allocator used to allocate/deallocate memory, construct/destroy nodes and Values.

Constructor & Destructor Documentation

template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::rtree ( parameters_type const &  parameters = parameters_type(),
indexable_getter const &  getter = indexable_getter(),
value_equal const &  equal = value_equal() 
)
inlineexplicit

The constructor.

Parameters
parametersThe parameters object.
getterThe function object extracting Indexable from Value.
equalThe function object comparing Values.
Throws
If allocator default constructor throws.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::rtree ( parameters_type const &  parameters,
indexable_getter const &  getter,
value_equal const &  equal,
allocator_type const &  allocator 
)
inline

The constructor.

Parameters
parametersThe parameters object.
getterThe function object extracting Indexable from Value.
equalThe function object comparing Values.
allocatorThe allocator object.
Throws
If allocator copy constructor throws.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
template<typename Iterator >
boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::rtree ( Iterator  first,
Iterator  last,
parameters_type const &  parameters = parameters_type(),
indexable_getter const &  getter = indexable_getter(),
value_equal const &  equal = value_equal(),
allocator_type const &  allocator = allocator_type() 
)
inline

The constructor.

The tree is created using packing algorithm.

Parameters
firstThe beginning of the range of Values.
lastThe end of the range of Values.
parametersThe parameters object.
getterThe function object extracting Indexable from Value.
equalThe function object comparing Values.
allocatorThe allocator object.
Throws
  • If allocator copy constructor throws.
  • If Value copy constructor or copy assignment throws.
  • If allocation throws or returns invalid value.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
template<typename Range >
boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::rtree ( Range const &  rng,
parameters_type const &  parameters = parameters_type(),
indexable_getter const &  getter = indexable_getter(),
value_equal const &  equal = value_equal(),
allocator_type const &  allocator = allocator_type() 
)
inlineexplicit

The constructor.

The tree is created using packing algorithm.

Parameters
rngThe range of Values.
parametersThe parameters object.
getterThe function object extracting Indexable from Value.
equalThe function object comparing Values.
allocatorThe allocator object.
Throws
  • If allocator copy constructor throws.
  • If Value copy constructor or copy assignment throws.
  • If allocation throws or returns invalid value.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::~rtree ( )
inline

The destructor.

Throws
Nothing.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::rtree ( rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > const &  src)
inline

The copy constructor.

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

Parameters
srcThe rtree which content will be copied.
Throws
  • If allocator copy constructor throws.
  • If Value copy constructor throws.
  • If allocation throws or returns invalid value.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::rtree ( rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > const &  src,
allocator_type const &  allocator 
)
inline

The copy constructor.

It uses Parameters and translator from the source tree.

Parameters
srcThe rtree which content will be copied.
allocatorThe allocator which will be used.
Throws
  • If allocator copy constructor throws.
  • If Value copy constructor throws.
  • If allocation throws or returns invalid value.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::rtree ( rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > &&  src)
inline

The moving constructor.

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

Parameters
srcThe rtree which content will be moved.
Throws
Nothing.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::rtree ( rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > &&  src,
allocator_type const &  allocator 
)
inline

The moving constructor.

It uses parameters and translator from the source tree.

Parameters
srcThe rtree which content will be moved.
allocatorThe allocator.
Throws
  • If allocator copy constructor throws.
  • If Value copy constructor throws (only if allocators aren't equal).
  • If allocation throws or returns invalid value (only if allocators aren't equal).

Member Function Documentation

template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
const_iterator boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::begin ( ) const
inline

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

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

Example
// Copy all values into the vector
std::copy(tree.begin(), tree.end(), std::back_inserter(vec));

for ( Rtree::const_iterator it = tree.begin() ; it != tree.end() ; ++it )
{
    // do something with value
}

// C++11 (auto)
for ( auto it = tree.begin() ; it != tree.end() ; ++it )
{
    // do something with value
}

// C++14 (generic lambda expression)
std::for_each(tree.begin(), tree.end(), [](auto const& val){
    // do something with value
})
Iterator category
ForwardIterator
Throws
If allocation throws.
Warning
The modification of the rtree may invalidate the iterators.
Returns
The iterator pointing at the begin of the range.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
bounds_type boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::bounds ( ) const
inline

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

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.

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.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
void boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::clear ( )
inline

Removes all values stored in the container.

Throws
Nothing.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
template<typename ValueOrIndexable >
size_type boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::count ( ValueOrIndexable const &  vori) const
inline

Count Values or Indexables stored in the container.

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.

Parameters
voriThe value or indexable which will be counted.
Returns
The number of values found.
Throws
Nothing.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
bool boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::empty ( ) const
inline

Query if the container is empty.

Returns
true if the container is empty.
Throws
Nothing.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
const_iterator boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::end ( ) const
inline

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

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

Example
for ( Rtree::const_iterator it = tree.begin() ; it != tree.end() ; ++it )
{
    // do something with value
}

// C++11 (lambda expression)
std::for_each(tree.begin(), tree.end(), [](value_type const& val){
    // do something with value
})
Iterator category
ForwardIterator
Throws
Nothing.
Warning
The modification of the rtree may invalidate the iterators.
Returns
The iterator pointing at the end of the range.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
allocator_type boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::get_allocator ( ) const
inline

Returns allocator used by the rtree.

Returns
The allocator.
Throws
If allocator copy constructor throws.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
indexable_getter boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::indexable_get ( ) const
inline

Returns function retrieving Indexable from Value.

Returns
The indexable_getter object.
Throws
Nothing.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
void boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::insert ( value_type const &  value)
inline

Insert a value to the index.

Parameters
valueThe value which will be stored in the container.
Throws
  • If Value copy constructor or copy assignment throws.
  • If allocation throws or returns invalid value.
Warning
This operation only guarantees that there will be no memory leaks. After an exception is thrown the R-tree may be left in an inconsistent state, elements must not be inserted or removed. Other operations are allowed however some of them may return invalid data.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
template<typename Iterator >
void boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::insert ( Iterator  first,
Iterator  last 
)
inline

Insert a range of values to the index.

Parameters
firstThe beginning of the range of values.
lastThe end of the range of values.
Throws
  • If Value copy constructor or copy assignment throws.
  • If allocation throws or returns invalid value.
Warning
This operation only guarantees that there will be no memory leaks. After an exception is thrown the R-tree may be left in an inconsistent state, elements must not be inserted or removed. Other operations are allowed however some of them may return invalid data.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
template<typename ConvertibleOrRange >
void boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::insert ( ConvertibleOrRange const &  conv_or_rng)
inline

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

Parameters
conv_or_rngAn object of type convertible to value_type or a range of values.
Throws
  • If Value copy constructor or copy assignment throws.
  • If allocation throws or returns invalid value.
Warning
This operation only guarantees that there will be no memory leaks. After an exception is thrown the R-tree may be left in an inconsistent state, elements must not be inserted or removed. Other operations are allowed however some of them may return invalid data.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
rtree& boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::operator= ( rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > const &  src)
inline

The assignment operator.

It uses parameters and translator from the source tree.

Parameters
srcThe rtree which content will be copied.
Throws
  • If Value copy constructor throws.
  • If allocation throws.
  • If allocation throws or returns invalid value.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
rtree& boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::operator= ( rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > &&  src)
inline

The moving assignment.

It uses parameters and translator from the source tree.

Parameters
srcThe rtree which content will be moved.
Throws
Only if allocators aren't equal.
  • If Value copy constructor throws.
  • If allocation throws or returns invalid value.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
parameters_type boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::parameters ( ) const
inline

Returns parameters.

Returns
The parameters object.
Throws
Nothing.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
template<typename Predicates >
const_query_iterator boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::qbegin ( Predicates const &  predicates) const
inline

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

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

Example
for ( Rtree::const_query_iterator it = tree.qbegin(bgi::nearest(pt, 10000)) ;
      it != tree.qend() ; ++it )
{
    // do something with value
    if ( has_enough_nearest_values() )
        break;
}

// C++11 (auto)
for ( auto it = tree.qbegin(bgi::nearest(pt, 3)) ; it != tree.qend() ; ++it )
{
    // do something with value
}

// C++14 (generic lambda expression)
std::for_each(tree.qbegin(bgi::nearest(pt, 3)), tree.qend(), [](auto const& val){
    // do something with value
});
Iterator category
ForwardIterator
Throws
If predicates copy throws. If allocation throws.
Warning
The modification of the rtree may invalidate the iterators.
Parameters
predicatesPredicates.
Returns
The iterator pointing at the begin of the query range.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
const_query_iterator boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::qend ( ) const
inline

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

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

Example
for ( Rtree::const_query_iterator it = tree.qbegin(bgi::nearest(pt, 10000)) ;
      it != tree.qend() ; ++it )
{
    // do something with value
    if ( has_enough_nearest_values() )
        break;
}

// C++11 (auto)
for ( auto it = tree.qbegin(bgi::nearest(pt, 3)) ; it != tree.qend() ; ++it )
{
    // do something with value
}

// C++14 (generic lambda expression)
std::for_each(tree.qbegin(bgi::nearest(pt, 3)), tree.qend(), [](auto const& val){
    // do something with value
});
Iterator category
ForwardIterator
Throws
Nothing
Warning
The modification of the rtree may invalidate the iterators.
Returns
The iterator pointing at the end of the query range.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
template<typename Predicates , typename OutIter >
size_type boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::query ( Predicates const &  predicates,
OutIter  out_it 
) const
inline

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

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

Spatial predicates

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

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

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

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

// For each value stored in the rtree do_something
// always_true is a type of function object always returning true
tree.query(bgi::satisfies(always_true()),
           boost::make_function_output_iterator(do_something()));

// C++11 (lambda expression)
tree.query(bgi::intersects(box),
           boost::make_function_output_iterator([](value_type const& val){
               // do something
           }));

// C++14 (generic lambda expression)
tree.query(bgi::intersects(box),
           boost::make_function_output_iterator([](auto const& val){
               // do something
           }));
Throws
If Value copy constructor or copy assignment throws. If predicates copy throws.
Warning
Only one nearest() perdicate may be passed to the query. Passing more of them results in compile-time error.
Parameters
predicatesPredicates.
out_itThe output iterator, e.g. generated by std::back_inserter().
Returns
The number of values found.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
size_type boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::remove ( value_type const &  value)
inline

Remove a value from the container.

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

Parameters
valueThe 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 or returns invalid value.
Warning
This operation only guarantees that there will be no memory leaks. After an exception is thrown the R-tree may be left in an inconsistent state, elements must not be inserted or removed. Other operations are allowed however some of them may return invalid data.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
template<typename Iterator >
size_type boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::remove ( Iterator  first,
Iterator  last 
)
inline

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

Parameters
firstThe beginning of the range of values.
lastThe end of the range of values.
Returns
The number of removed values.
Throws
  • If Value copy constructor or copy assignment throws.
  • If allocation throws or returns invalid value.
Warning
This operation only guarantees that there will be no memory leaks. After an exception is thrown the R-tree may be left in an inconsistent state, elements must not be inserted or removed. Other operations are allowed however some of them may return invalid data.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
template<typename ConvertibleOrRange >
size_type boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::remove ( ConvertibleOrRange const &  conv_or_rng)
inline

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

In contrast to the std::set or std::map erase() method it removes values equal to these passed as a range. Furthermore, this method removes only one value for each one passed in the range, not all equal values.

Parameters
conv_or_rngThe object of type convertible to value_type or a range of values.
Returns
The number of removed values.
Throws
  • If Value copy constructor or copy assignment throws.
  • If allocation throws or returns invalid value.
Warning
This operation only guarantees that there will be no memory leaks. After an exception is thrown the R-tree may be left in an inconsistent state, elements must not be inserted or removed. Other operations are allowed however some of them may return invalid data.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
size_type boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::size ( ) const
inline

Returns the number of stored values.

Returns
The number of stored values.
Throws
Nothing.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
void boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::swap ( rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > &  other)
inline

Swaps contents of two rtrees.

Parameters, translator and allocators are swapped as well.

Parameters
otherThe rtree which content will be swapped with this rtree content.
Throws
If allocators swap throws.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
value_equal boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::value_eq ( ) const
inline

Returns function comparing Values.

Returns
The value_equal function.
Throws
Nothing.

The documentation for this class was generated from the following file: