|
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.
|
|
|
| rtree (parameters_type const ¶meters=parameters_type(), indexable_getter const &getter=indexable_getter(), value_equal const &equal=value_equal()) |
| The constructor. More...
|
|
| rtree (parameters_type const ¶meters, 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 ¶meters=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 ¶meters=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...
|
|
rtree & | operator= (rtree const &src) |
| The assignment operator. More...
|
|
rtree & | operator= (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...
|
|
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
-
Value | The type of objects stored in the container. |
Parameters | Compile-time parameters. |
IndexableGetter | The function object extracting Indexable from Value. |
EqualTo | The function object comparing objects of type Value. |
Allocator | The allocator used to allocate/deallocate memory, construct/destroy nodes and Values. |
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
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>>
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>>
template<typename ValueOrIndexable >
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
-
vori | The 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>>
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>>
template<typename Iterator >
Insert a range of values to the index.
- Parameters
-
first | The beginning of the range of values. |
last | The 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 >
Insert a value created using convertible object or a range of values to the index.
- Parameters
-
conv_or_rng | An 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>>
template<typename Predicates >
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
-
- 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>>
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 >
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
-
predicates | Predicates. |
out_it | The output iterator, e.g. generated by std::back_inserter(). |
- Returns
- The number of values found.
template<typename Value, typename Parameters, typename IndexableGetter = index::indexable<Value>, typename EqualTo = index::equal_to<Value>, typename Allocator = std::allocator<Value>>
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
-
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 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 >
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
-
first | The beginning of the range of values. |
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 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 >
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_rng | The 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>>
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
-
other | The rtree which content will be swapped with this rtree content. |
- Throws
- If allocators swap throws.