![]() |
Home | Libraries | People | FAQ | More |
The R-tree spatial index.
This is self-balancing spatial index capable to store various types of Values and balancing algorithms.
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:
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
and std::pair<Indexable,
T>
. For example,
if boost::tuple<Indexable,
...>
is stored in the container, the default translator translates from std::pair<Box, int>
to std::pair<Box, int> const&
.
Box const&
#include <boost/geometry/index/rtree.hpp>
template<
typename Value
,
typename Parameters
,
typename Translator
=index::translator
<Value>
,
typename Allocator
=std::allocator<Value>
>
class rtree
{
// ...
};
Parameter |
Description |
---|---|
|
The type of objects stored in the container. |
|
Compile-time parameters. |
|
The type of the translator which translates from Value to Indexable. |
|
The allocator used to allocate/deallocate memory, construct/destroy nodes and Values. |
Type |
Description |
---|---|
The type of Value stored in the container. |
|
R-tree parameters type. |
|
Value to Indexable Translator type. |
|
The type of allocator used by the container. |
|
Unsigned integral type used by the container. |
|
The Indexable type to which Value is translated. |
|
The Box type used by the R-tree. |
Function |
Description |
---|---|
The constructor. |
|
|
The constructor. |
The constructor. |
|
The constructor. |
|
The destructor. |
|
The copy constructor. |
|
The copy constructor. |
|
The moving constructor. |
|
The moving constructor. |
Modifier |
Function |
Description |
---|---|---|
The assignment operator. |
||
The moving assignment. |
||
Swaps contents of two rtrees. |
||
Insert a value to the index. |
||
Insert a range of values to the index. |
||
Insert a range of values to the index. |
||
Remove a value from the container. |
||
Remove a range of values from the container. |
||
Remove a range of values from the container. |
||
|
Finds values meeting passed predicates e.g. nearest to some Point and/or intersecting some Box. |
|
|
Returns the number of stored values. |
|
|
Query if the container is empty. |
|
Removes all values stored in the container. |
||
|
Returns the box able to contain all values stored in the container. |
|
|
Count Values or Indexables stored in the container. |
|
|
Returns parameters. |
|
|
Returns the translator object. |
|
|
Returns allocator used by the rtree. |
The constructor.
rtree
(
parameters_type
const &
parameters
=parameters_type
()
,
translator_type
const &
translator
=translator_type
()
)
explicit
Type |
Name |
Description |
---|---|---|
|
|
The parameters object. |
|
|
The translator object. |
If allocator default constructor throws.
The constructor.
rtree
(
parameters_type
const &
parameters
,
translator_type
const &
translator
,
allocator_type
allocator
)
Type |
Name |
Description |
---|---|---|
|
|
The parameters object. |
|
|
The translator object. |
|
The allocator object. |
If allocator copy constructor throws.
The constructor.
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
()
)
Type |
Name |
Description |
---|---|---|
|
|
The beginning of the range of Values. |
|
|
The end of the range of Values. |
|
|
The parameters object. |
|
|
The translator object. |
|
The allocator object. |
The constructor.
template<
typename Range
>
rtree
(
Range const &
rng
,
parameters_type
const &
parameters
=parameters_type
()
,
translator_type
const &
translator
=translator_type
()
,
allocator_type
allocator
=allocator_type
()
)
explicit
Type |
Name |
Description |
---|---|---|
|
|
The range of Values. |
|
|
The parameters object. |
|
|
The translator object. |
|
The allocator object. |
The copy constructor.
It uses parameters, translator and allocator from the source tree.
rtree
(
rtree
const &
src
)
Type |
Name |
Description |
---|---|---|
|
|
The rtree which content will be copied. |
The copy constructor.
It uses Parameters and translator from the source tree.
rtree
(
rtree
const &
src
,
allocator_type
const &
allocator
)
Type |
Name |
Description |
---|---|---|
|
|
The rtree which content will be copied. |
|
|
The allocator which will be used. |
The moving constructor.
It uses parameters, translator and allocator from the source tree.
rtree
(
rtree
&&
src
)
Type |
Name |
Description |
---|---|---|
|
|
The rtree which content will be moved. |
Nothing.
The moving constructor.
It uses parameters and translator from the source tree.
rtree
(
rtree
&&
src
,
allocator_type
const &
allocator
)
Type |
Name |
Description |
---|---|---|
|
|
The rtree which content will be moved. |
|
|
The allocator. |
The assignment operator.
It uses parameters and translator from the source tree.
rtree
&
operator=
(
const
rtree
&
src
)
Type |
Name |
Description |
---|---|---|
|
|
The rtree which content will be copied. |
The moving assignment.
It uses parameters and translator from the source tree.
rtree
&
operator=
(
rtree
&&
src
)
Type |
Name |
Description |
---|---|---|
|
|
The rtree which content will be moved. |
Only if allocators aren't equal.
Swaps contents of two rtrees.
Parameters, translator and allocators are swapped as well.
void
swap
(
rtree
&
other
)
Type |
Name |
Description |
---|---|---|
|
|
The rtree which content will be swapped with this rtree content. |
If allocators swap throws.
Insert a value to the index.
void
insert
(
value_type
const &
value
)
Type |
Name |
Description |
---|---|---|
|
|
The value which will be stored in the container. |
![]() |
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.
template<
typename Iterator
>
void
insert
(
Iterator
first
,
Iterator
last
)
Type |
Name |
Description |
---|---|---|
|
|
The beginning of the range of values. |
|
|
The end of the range of values. |
![]() |
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.
template<
typename Range
>
void
insert
(
Range const &
rng
)
Type |
Name |
Description |
---|---|---|
|
|
The range of values. |
![]() |
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.
In contrast to the
or std::set
method this method removes
only one value from the container.
std::map erase()
size_type
remove
(
value_type
const &
value
)
Type |
Name |
Description |
---|---|---|
|
|
The value which will be removed from the container. |
1 if the value was removed, 0 otherwise.
![]() |
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.
In contrast to the
or std::set
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.
std::map erase()
template<
typename Iterator
>
size_type
remove
(
Iterator
first
,
Iterator
last
)
Type |
Name |
Description |
---|---|---|
|
|
The beginning of the range of values. |
|
|
The end of the range of values. |
The number of removed values.
![]() |
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.
In contrast to the
or std::set
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.
std::map erase()
template<
typename Range
>
size_type
remove
(
Range const &
rng
)
Type |
Name |
Description |
---|---|---|
|
|
The range of values. |
The number of removed values.
![]() |
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.
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&&()
template<
typename Predicates
,
typename OutIter
>
size_type
query
(
Predicates const &
predicates
,
OutIter
out_it
)
const
Type |
Name |
Description |
---|---|---|
|
|
Predicates. |
|
|
The output iterator, e.g. generated by std::back_inserter(). |
The number of values found.
// 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));
If Value copy constructor or copy assignment throws.
![]() |
Warning |
---|---|
Only one |
Returns the number of stored values.
size_type
size
()
const
The number of stored values.
Nothing.
Query if the container is empty.
bool
empty
()
const
true if the container is empty.
Nothing.
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
is returned.
geometry::assign_inverse()
bounds_type
bounds
()
const
The box able to contain all values stored in the container or an invalid box if there are no values in the container.
Nothing.
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.
template<
typename ValueOrIndexable
>
size_type
count
(
ValueOrIndexable const &
vori
)
const
Type |
Name |
Description |
---|---|---|
|
|
The value or indexable which will be counted. |
The number of values found.
Nothing.
Returns parameters.
parameters_type
const &
parameters
()
const
The parameters object.
Nothing.
Returns the translator object.
translator_type
const &
translator
()
const
The translator object.
Nothing.
Returns allocator used by the rtree.
allocator_type
get_allocator
()
const
The allocator.
If allocator copy constructor throws.
Function |
Description |
---|---|
Insert a value to the index. |
|
Insert a range of values to the index. |
|
Insert a range of values to the index. |
|
Remove a value from the container. |
|
Remove a range of values from the container. |
|
Remove a range of values from the container. |
|
Finds values meeting passed predicates e.g. nearest to some Point and/or intersecting some Box. |
|
Remove all values from the index. |
|
Get the number of values stored in the index. |
|
Query if there are no values stored in the index. |
|
Get the box containing all stored values or an invalid box if the index has no values. |
|
Exchanges the contents of the container with those of other. |
Insert a value to the index.
It calls rtree::insert(value_type
const&)
.
template<
typename Value
,
typename Options
,
typename Translator
,
typename Allocator
>
void boost::geometry::index::insert
(
rtree< Value, Options, Translator, Allocator > &
tree
,
Value const &
v
)
Type |
Name |
Description |
---|---|---|
|
|
The spatial index. |
|
|
The value which will be stored in the index. |
Insert a range of values to the index.
It calls rtree::insert(Iterator,
Iterator)
.
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
)
Type |
Name |
Description |
---|---|---|
|
|
The spatial index. |
|
|
The beginning of the range of values. |
|
|
The end of the range of values. |
Insert a range of values to the index.
It calls rtree::insert(Range
const&)
.
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
)
Type |
Name |
Description |
---|---|---|
|
|
The spatial index. |
|
|
The range of values. |
Remove a value from the container.
Remove a value from the container. In contrast to the
or std::set
method this function removes
only one value from the container.
std::map erase()
It calls rtree::remove(value_type
const&)
.
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
)
Type |
Name |
Description |
---|---|---|
|
|
The spatial index. |
|
|
The value which will be removed from the index. |
1 if value was removed, 0 otherwise.
Remove a range of values from the container.
Remove a range of values from the container. In contrast to the
or std::set
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.
std::map erase()
It calls rtree::remove(Iterator,
Iterator)
.
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
)
Type |
Name |
Description |
---|---|---|
|
|
The spatial index. |
|
|
The beginning of the range of values. |
|
|
The end of the range of values. |
The number of removed values.
Remove a range of values from the container.
Remove a range of values from the container. In contrast to the
or std::set
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.
std::map erase()
It calls rtree::remove(Range
const&)
.
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
)
Type |
Name |
Description |
---|---|---|
|
|
The spatial index. |
|
|
The range of values. |
The number of removed values.
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&&()
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
)
Type |
Name |
Description |
---|---|---|
|
|
The rtree. |
|
|
Predicates. |
|
|
The output iterator, e.g. generated by std::back_inserter(). |
The number of values found.
// 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));
If Value copy constructor or copy assignment throws.
![]() |
Warning |
---|---|
Only one |
Remove all values from the index.
It calls rtree::clear()
.
template<
typename Value
,
typename Options
,
typename Translator
,
typename Allocator
>
void boost::geometry::index::clear
(
rtree< Value, Options, Translator, Allocator > &
tree
)
Type |
Name |
Description |
---|---|---|
|
|
The spatial index. |
Get the number of values stored in the index.
It calls rtree::size()
.
template<
typename Value
,
typename Options
,
typename Translator
,
typename Allocator
>
size_t boost::geometry::index::size
(
rtree< Value, Options, Translator, Allocator > const &
tree
)
Type |
Name |
Description |
---|---|---|
|
|
The spatial index. |
The number of values stored in the index.
Query if there are no values stored in the index.
It calls rtree::empty()
.
template<
typename Value
,
typename Options
,
typename Translator
,
typename Allocator
>
bool boost::geometry::index::empty
(
rtree< Value, Options, Translator, Allocator > const &
tree
)
Type |
Name |
Description |
---|---|---|
|
|
The spatial index. |
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.
It calls
.
rtree::envelope()
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
)
Type |
Name |
Description |
---|---|---|
|
|
The spatial index. |
The box containing all stored values or an invalid box.
Exchanges the contents of the container with those of other.
It calls rtree::swap()
.
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
)
Type |
Name |
Description |
---|---|---|
|
|
The first rtree. |
|
|
The second rtree. |
Linear r-tree creation algorithm parameters.
#include <boost/geometry/index/parameters.hpp>
template<
size_t MaxElements
,
size_t MinElements
>
struct linear
{
// ...
};
Parameter |
Description |
---|---|
|
Maximum number of elements in nodes. |
|
Minimum number of elements in nodes. |
Quadratic r-tree creation algorithm parameters.
#include <boost/geometry/index/parameters.hpp>
template<
size_t MaxElements
,
size_t MinElements
>
struct quadratic
{
// ...
};
Parameter |
Description |
---|---|
|
Maximum number of elements in nodes. |
|
Minimum number of elements in nodes. |
R*-tree creation algorithm parameters.
#include <boost/geometry/index/parameters.hpp>
template<
size_t MaxElements
,
size_t MinElements
,
size_t OverlapCostThreshold
=0
,
size_t ReinsertedElements
=detail::default_rstar_reinserted_elements_s
<MaxElements>::value
>
struct rstar
{
// ...
};
Parameter |
Description |
---|---|
|
Maximum number of elements in nodes. |
|
Minimum number of elements in nodes. |
|
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. |
|
Number of elements reinserted by forced reinsertions algorithm. |
Linear r-tree creation algorithm parameters - run-time version.
#include <boost/geometry/index/parameters.hpp>
class dynamic_linear
{
// ...
};
Function |
Description |
---|---|
The constructor. |
The constructor.
dynamic_linear
(
size_t
max_elements
,
size_t
min_elements
)
Type |
Name |
Description |
---|---|---|
|
|
Maximum number of elements in nodes. |
|
|
Minimum number of elements in nodes. |
Quadratic r-tree creation algorithm parameters - run-time version.
#include <boost/geometry/index/parameters.hpp>
class dynamic_quadratic
{
// ...
};
Function |
Description |
---|---|
The constructor. |
The constructor.
dynamic_quadratic
(
size_t
max_elements
,
size_t
min_elements
)
Type |
Name |
Description |
---|---|---|
|
|
Maximum number of elements in nodes. |
|
|
Minimum number of elements in nodes. |
R*-tree creation algorithm parameters - run-time version.
#include <boost/geometry/index/parameters.hpp>
class dynamic_rstar
{
// ...
};
Function |
Description |
---|---|
The constructor. |
The constructor.
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()
)
Type |
Name |
Description |
---|---|---|
|
|
Maximum number of elements in nodes. |
|
|
Minimum number of elements in nodes. |
|
|
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. |
|
|
Number of elements reinserted by forced reinsertions algorithm. |
The default translator.
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, ...>.
#include <boost/geometry/index/translator.hpp>
template<
typename Value
>
struct translator
{
// ...
};
Parameter |
Description |
---|---|
|
The Value type which may be translated directly to the Indexable. |
Function |
Description |
---|---|
Generate |
|
Generate |
|
Generate |
|
Generate |
|
Generate |
|
Generate satisfies() predicate. |
|
Generate nearest() predicate. |
Generate covered_by()
predicate.
Generate a predicate defining Value and Geometry relationship. Value
will be returned by the query if
returns true.
bg::covered_by(Indexable, Geometry)
template<
typename Geometry
>
detail::covered_by<Geometry> boost::geometry::index::covered_by
(
Geometry const &
g
)
Parameter |
Description |
---|---|
|
The Geometry type. |
Type |
Name |
Description |
---|---|---|
|
|
The Geometry object. |
bgi::query(spatial_index, bgi::covered_by(box), std::back_inserter(result));
Generate disjoint()
predicate.
Generate a predicate defining Value and Geometry relationship. Value
will be returned by the query if
returns true.
bg::disjoint(Indexable, Geometry)
template<
typename Geometry
>
detail::disjoint<Geometry> boost::geometry::index::disjoint
(
Geometry const &
g
)
Parameter |
Description |
---|---|
|
The Geometry type. |
Type |
Name |
Description |
---|---|---|
|
|
The Geometry object. |
bgi::query(spatial_index, bgi::disjoint(box), std::back_inserter(result));
Generate intersects()
predicate.
Generate a predicate defining Value and Geometry relationship. Value
will be returned by the query if
returns true.
bg::intersects(Indexable, Geometry)
template<
typename Geometry
>
detail::intersects<Geometry> boost::geometry::index::intersects
(
Geometry const &
g
)
Parameter |
Description |
---|---|
|
The Geometry type. |
Type |
Name |
Description |
---|---|---|
|
|
The Geometry object. |
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.
Generate a predicate defining Value and Geometry relationship. Value
will be returned by the query if
returns true.
bg::overlaps(Indexable, Geometry)
template<
typename Geometry
>
detail::overlaps<Geometry> boost::geometry::index::overlaps
(
Geometry const &
g
)
Parameter |
Description |
---|---|
|
The Geometry type. |
Type |
Name |
Description |
---|---|---|
|
|
The Geometry object. |
bgi::query(spatial_index, bgi::overlaps(box), std::back_inserter(result));
Generate within()
predicate.
Generate a predicate defining Value and Geometry relationship. Value
will be returned by the query if
returns true.
bg::within(Indexable, Geometry)
template<
typename Geometry
>
detail::within<Geometry> boost::geometry::index::within
(
Geometry const &
g
)
Parameter |
Description |
---|---|
|
The Geometry type. |
Type |
Name |
Description |
---|---|---|
|
|
The Geometry object. |
bgi::query(spatial_index, bgi::within(box), std::back_inserter(result));
Generate satisfies() predicate.
A wrapper around user-defined UnaryPredicate checking if Value should be returned by spatial query.
template<
typename UnaryPredicate
>
detail::satisfies<UnaryPredicate> boost::geometry::index::satisfies
(
UnaryPredicate const &
pred
)
Parameter |
Description |
---|---|
|
A type of unary predicate function or function object. |
Type |
Name |
Description |
---|---|---|
|
|
The unary predicate function or function object. |
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.
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
to which Point
must be closest.
Values
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:
template<
typename PointOrRelation
>
detail::nearest<PointOrRelation> boost::geometry::index::nearest
(
PointOrRelation const &
point_relation
,
unsigned
k
)
Type |
Name |
Description |
---|---|---|
|
|
The point or relation describing how the distance will be calculated. |
|
|
The maximum number of values to return. |
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 |
---|---|
Only one |
Function |
Description |
---|---|
Generate to_nearest() relationship. |
|
Generate to_centroid() relationship. |
|
Generate to_furthest() relationship. |
Generate to_nearest() relationship.
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.
template<
typename T
>
detail::to_nearest<T> boost::geometry::index::to_nearest
(
T const &
v
)
Parameter |
Description |
---|---|
|
Type of wrapped object. This may be a Point for PointRelation or CoordinateType for MinRelation or MaxRelation |
Type |
Name |
Description |
---|---|---|
|
|
Point or distance value. |
Generate to_centroid() relationship.
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.
template<
typename T
>
detail::to_centroid<T> boost::geometry::index::to_centroid
(
T const &
v
)
Parameter |
Description |
---|---|
|
Type of wrapped object. This may be a Point for PointRelation or some CoordinateType for MinRelation or MaxRelation |
Type |
Name |
Description |
---|---|---|
|
|
Point or distance value. |
Generate to_furthest() relationship.
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.
template<
typename T
>
detail::to_furthest<T> boost::geometry::index::to_furthest
(
T const &
v
)
Parameter |
Description |
---|---|
|
Type of wrapped object. This may be a Point for PointRelation or some CoordinateType for MinRelation or MaxRelation |
Type |
Name |
Description |
---|---|---|
|
|
Point or distance value. |
Function |
Description |
---|---|
The query index adaptor generator. |
The query index adaptor generator.
template<
typename Predicates
>
detail::query<Predicates> boost::geometry::index::adaptors::queried
(
Predicates const &
pred
)
Type |
Name |
Description |
---|---|---|
|
|
Predicates. |
Function |
Description |
---|---|
Insert iterator generator. |
Insert iterator generator.
Returns insert iterator capable to insert values to the container (spatial index) which has member function insert(value_type const&) defined.
template<
typename Container
>
insert_iterator<Container> boost::geometry::index::inserter
(
Container &
c
)
Type |
Name |
Description |
---|---|---|
|
|
The reference to the container (spatial index) to which values will be inserted. |
The insert iterator inserting values to the container.