The R-tree spatial index. More...
#include <rtree.hpp>
Public Types | |
typedef Value | value_type |
The type of Value stored in the container. More... | |
typedef Parameters | parameters_type |
R-tree parameters type. More... | |
typedef IndexableGetter | indexable_getter |
The function object extracting Indexable from Value. More... | |
typedef EqualTo | value_equal |
The function object comparing objects of type Value. More... | |
typedef Allocator | allocator_type |
The type of allocator used by the container. More... | |
typedef index::detail::indexable_type < detail::translator < IndexableGetter, EqualTo > >::type | indexable_type |
The Indexable type to which Value is translated. More... | |
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. More... | |
typedef allocators_type::reference | reference |
Type of reference to Value. More... | |
typedef allocators_type::const_reference | const_reference |
Type of reference to const Value. More... | |
typedef allocators_type::pointer | pointer |
Type of pointer to Value. More... | |
typedef allocators_type::const_pointer | const_pointer |
Type of pointer to const Value. More... | |
typedef allocators_type::difference_type | difference_type |
Type of difference type. More... | |
typedef allocators_type::size_type | size_type |
Unsigned integral type used by the container. More... | |
typedef index::detail::rtree::iterators::query_iterator < value_type, allocators_type > | const_query_iterator |
Type of const query iterator. More... | |
Public Member Functions | |
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 (BOOST_RV_REF(rtree) src) | |
The moving constructor. More... | |
rtree (BOOST_RV_REF(rtree) src, allocator_type const &allocator) | |
The moving constructor. More... | |
rtree & | operator= (BOOST_COPY_ASSIGN_REF(rtree) src) |
The assignment operator. More... | |
rtree & | operator= (BOOST_RV_REF(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. More... | |
template<typename Predicates > | |
const_query_iterator | qbegin (Predicates const &predicates) const |
Returns the query iterator pointing at the begin of the query range. More... | |
const_query_iterator | qend () const |
Returns the query iterator pointing at the end of the query 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... | |
Friends | |
class | detail::rtree::utilities::view< rtree > |
The R-tree spatial index.
This is self-balancing spatial index capable to store various types of Values and balancing algorithms.
std::pair<Indexable, T>
and boost::tuple<Indexable, ...>
. For example, if std::pair<Box, int>
is stored in the container, the default IndexableGetter translates from std::pair<Box, int> const&
to Box const&
.true
if they're 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.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. |
typedef Allocator boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::allocator_type |
The type of allocator used by the container.
typedef geometry::model::box< geometry::model::point< typename coordinate_type<indexable_type>::type, dimension<indexable_type>::value, typename coordinate_system<indexable_type>::type > > boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::bounds_type |
The Box type used by the R-tree.
typedef allocators_type::const_pointer boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::const_pointer |
Type of pointer to const Value.
typedef index::detail::rtree::iterators::query_iterator<value_type, allocators_type> boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::const_query_iterator |
Type of const query iterator.
typedef allocators_type::const_reference boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::const_reference |
Type of reference to const Value.
typedef allocators_type::difference_type boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::difference_type |
Type of difference type.
typedef IndexableGetter boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::indexable_getter |
The function object extracting Indexable from Value.
typedef index::detail::indexable_type< detail::translator<IndexableGetter, EqualTo> >::type boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::indexable_type |
The Indexable type to which Value is translated.
typedef Parameters boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::parameters_type |
R-tree parameters type.
typedef allocators_type::pointer boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::pointer |
Type of pointer to Value.
typedef allocators_type::reference boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::reference |
Type of reference to Value.
typedef allocators_type::size_type boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::size_type |
Unsigned integral type used by the container.
typedef EqualTo boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::value_equal |
The function object comparing objects of type Value.
typedef Value boost::geometry::index::rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::value_type |
The type of Value stored in the container.
|
inlineexplicit |
The constructor.
parameters | The parameters object. |
getter | The function object extracting Indexable from Value. |
equal | The function object comparing Values. |
|
inline |
The constructor.
parameters | The parameters object. |
getter | The function object extracting Indexable from Value. |
equal | The function object comparing Values. |
allocator | The allocator object. |
|
inline |
The constructor.
The tree is created using packing algorithm.
first | The beginning of the range of Values. |
last | The end of the range of Values. |
parameters | The parameters object. |
getter | The function object extracting Indexable from Value. |
equal | The function object comparing Values. |
allocator | The allocator object. |
References boost::polygon::ll().
|
inlineexplicit |
The constructor.
The tree is created using packing algorithm.
rng | The range of Values. |
parameters | The parameters object. |
getter | The function object extracting Indexable from Value. |
equal | The function object comparing Values. |
allocator | The allocator object. |
References boost::asio::begin, boost::end, and boost::polygon::ll().
|
inline |
The destructor.
|
inline |
The copy constructor.
It uses parameters, translator and allocator from the source tree.
src | The rtree which content will be copied. |
|
inline |
The copy constructor.
It uses Parameters and translator from the source tree.
src | The rtree which content will be copied. |
allocator | The allocator which will be used. |
|
inline |
The moving constructor.
It uses parameters, translator and allocator from the source tree.
src | The rtree which content will be moved. |
References boost::swap.
|
inline |
The moving constructor.
It uses parameters and translator from the source tree.
src | The rtree which content will be moved. |
allocator | The allocator. |
References boost::swap.
|
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.
References boost::geometry::assign_inverse().
Referenced by boost::geometry::index::bounds(), and boost::geometry::index::empty().
|
inline |
Removes all values stored in the container.
Referenced by boost::geometry::index::clear().
|
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.
vori | The value or indexable which will be counted. |
References BOOST_MPL_ASSERT_MSG, boost::spirit::x3::int_, and boost::program_options::value().
|
inline |
Query if the container is empty.
|
inline |
Returns allocator used by the rtree.
|
inline |
Returns function retrieving Indexable from Value.
|
inline |
Insert a value to the index.
value | The value which will be stored in the container. |
Referenced by boost::geometry::index::insert().
|
inline |
Insert a range of values to the index.
first | The beginning of the range of values. |
last | The end of the range of values. |
References boost::xpressive::first, and boost::last.
|
inline |
Insert a value created using convertible object or a range of values to the index.
conv_or_rng | An object of type convertible to value_type or a range of values. |
References boost::spirit::x3::bool_, and boost::program_options::value().
|
inline |
The assignment operator.
It uses parameters and translator from the source tree.
src | The rtree which content will be copied. |
References boost::spirit::x3::bool_, and boost::program_options::value().
|
inline |
The moving assignment.
It uses parameters and translator from the source tree.
src | The rtree which content will be moved. |
References boost::spirit::x3::bool_, boost::swap, and boost::program_options::value().
|
inline |
Returns parameters.
|
inline |
Returns the query iterator pointing at the begin of the query range.
This method returns the iterator which may be used to perform iterative queries. For the information about the predicates which may be passed to this method see query().
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; }
predicates | Predicates. |
Referenced by boost::geometry::index::qbegin().
|
inline |
Returns the query iterator pointing at the end of the query range.
This method returns the iterator which may be used to check if the query has ended.
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; }
Referenced by boost::geometry::index::qend().
|
inline |
Finds values meeting passed predicates e.g.
nearest to some Point and/or intersecting some Box.
This query function performs spatial and k-nearest neighbor searches. It allows to pass a set of predicates. Values will be returned only if all predicates are met.
Spatial predicates
Spatial predicates may be generated by one of the functions listed below:
boost::geometry::index::contains()
, boost::geometry::index::covered_by()
, boost::geometry::index::covers()
, boost::geometry::index::disjoint()
, boost::geometry::index::intersects()
, boost::geometry::index::overlaps()
, boost::geometry::index::within()
,It is possible to negate spatial predicates:
! boost::geometry::index::contains()
, ! boost::geometry::index::covered_by()
, ! boost::geometry::index::covers()
, ! boost::geometry::index::disjoint()
, ! boost::geometry::index::intersects()
, ! boost::geometry::index::overlaps()
, ! boost::geometry::index::within()
Satisfies predicate
This is a special kind of predicate which allows to pass a user-defined function or function object which checks if Value should be returned by the query. It's generated by:
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&&()
.
// 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));
nearest()
perdicate may be passed to the query. Passing more of them results in compile-time error.predicates | Predicates. |
out_it | The output iterator, e.g. generated by std::back_inserter(). |
References BOOST_MPL_ASSERT_MSG, and boost::program_options::value().
Referenced by boost::geometry::index::query().
|
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.
value | The value which will be removed from the container. |
References boost::program_options::value().
Referenced by boost::geometry::index::remove().
|
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.
first | The beginning of the range of values. |
last | The end of the range of values. |
References boost::xpressive::first, and boost::last.
|
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.
conv_or_rng | The object of type convertible to value_type or a range of values. |
References boost::spirit::x3::bool_, and boost::program_options::value().
|
inline |
Returns the number of stored values.
Referenced by boost::geometry::index::size().
|
inline |
Swaps contents of two rtrees.
Parameters, translator and allocators are swapped as well.
other | The rtree which content will be swapped with this rtree content. |
References boost::spirit::x3::bool_, boost::swap, and boost::program_options::value().
Referenced by boost::geometry::index::swap().
|
inline |
Returns function comparing Values.
|
friend |