diff --git a/doc/generated/predicates.qbk b/doc/generated/predicates.qbk
index 558e8654e..7b2858581 100644
--- a/doc/generated/predicates.qbk
+++ b/doc/generated/predicates.qbk
@@ -195,9 +195,24 @@ A wrapper around user-defined UnaryPredicate checking if Value should be returne
[heading Example]
``
-bool is_red(Value const& v) { ... }
-...
-bgi::query(spatial_index, bgi::intersects(box) && bgi::satisfies(is_red), std::back_inserter(result));
+bool is_red(__value__ const& v) { return v.is_red(); }
+
+struct is_red_o {
+template
rtree<Value, Parameters, Translator = index::translator<Value>, Allocator> = std::allocator<Value> >-
Value - type of object which will be stored in the container,
Translator - index::translator<Value>
are defined as follows:
-Indexable = Point
| Box
@@ -116,7 +116,7 @@
A Translator is a type which knows how to handle Values.
It has two purposes:
-Value to a more suitable Indexable
type which is needed by most of operations,
@@ -134,7 +134,7 @@
If comparison of two Values is required, the default translator:
Point
and Box
diff --git a/doc/html/geometry_index/r_tree/introduction.html b/doc/html/geometry_index/r_tree/introduction.html
index 8dc523bbc..74f9022ec 100644
--- a/doc/html/geometry_index/r_tree/introduction.html
+++ b/doc/html/geometry_index/r_tree/introduction.html
@@ -3,7 +3,7 @@
R-tree is a tree data structure used for spatial searching. It was proposed - by Antonin Guttman in 1984 [1] as an expansion of B-tree for multi-dimensional data. It may + by Antonin Guttman in 1984 [1] as an expansion of B-tree for multi-dimensional data. It may be used to store points or volumetric data in order to perform a spatial query later. This query may return objects that are inside some area or are - close to some point in space [2]. + close to some point in space [2].
The R-tree structure is presented on the image below. Each R-tree's node @@ -51,7 +51,7 @@
The R-tree is a self-balanced data structure. The key part of balancing algorithm - is node splitting algorithm [3] [4]. Each algorithm produces different splits so the internal structure + is node splitting algorithm [3] [4]. Each algorithm produces different splits so the internal structure of a tree may be different for each one of them. In general more complex algorithms analyses elements better and produces less overlapping nodes. In the searching process less nodes must be traversed in order to find desired @@ -181,13 +181,13 @@
Key features of this implementation of the R-tree are:
-R-tree depends on Boost.Move, Boost.Container, Boost.Tuple, @@ -219,7 +219,7 @@
The spatial index was originally started by Federico J. Fernandez during @@ -227,7 +227,7 @@
@@ -235,20 +235,20 @@ J. Simonson for their support and ideas.
[1]
+
[1] Guttman, A. (1984). R-Trees: A Dynamic Index Structure for Spatial Searching
[2] +
[2] Cheung, K.; Fu, A. (1998). Enhanced Nearest Neighbour Search on the R-tree
[3] +
[3] Greene, D. (1989). An implementation and performance analysis of spatial data access methods
[4] +
[4] Beckmann, N.; Kriegel, H. P.; Schneider, R.; Seeger, B. (1990). The R*-tree: an efficient and robust access method for points and rectangles
Values which meets some predicates. Currently
supported are three types of predicates:
-For example queries may be used to retrieve Values:
-
- There are three ways to perform a query. In the following example Box
- is used as the predicate, this is a default spatial predicate described
- in the following section. Following queries returns Values
- intersecting some region defined as a Box.
- These three ways are:
+ There are three ways to perform a query presented below. All of them returns
+ Values intersecting some region defined as a Box.
Method call
std::vector<Value> returned_values; Box box_region(...); -rt.query(box_region, std::back_inserter(returned_values)); +rt.query(bgi::intersects(box_region), std::back_inserter(returned_values));
Function call
std::vector<Value> returned_values; Box box_region(...); -index::query(rt, box_region, std::back_inserter(returned_values)); +index::query(rt, bgi::intersects(box_region), std::back_inserter(returned_values));
Use of pipe operator generating a range
Box box_region(...); -BOOST_FOREACH(Value & v, rt | index::adaptors::queried(box_region)) +BOOST_FOREACH(Value & v, rt | index::adaptors::queried(bgi::intersects(box_region))) ; // do something with v
Spatial query returns Values which are related somehow to
- a geometry or some number of geometries. Names of spatial predicates corresponds
+ some Geometry - box, polygon, etc. Names of spatial predicates corresponds
to names of Boost.Geometry
algorithms. Examples of some basic queries may be found in tables below.
The query region and result Values
@@ -224,12 +221,10 @@
- To use a spatial predicate one may pass a geometry (which is a default
- case) or use one of the functions defined in boost::geometry::index
- namespace to define it explicitly.
+ To use a spatial predicate one may use one of the functions defined in
+ boost::geometry::index namespace.
rt.query(box, std::back_inserter(result)); // default case - intersects -rt.query(index::intersects(box), std::back_inserter(result)); // the same as default +rt.query(index::intersects(box), std::back_inserter(result)); rt.query(index::covered_by(box), std::back_inserter(result)); rt.query(index::disjont(box), std::back_inserter(result)); rt.query(index::overlaps(box), std::back_inserter(result)); @@ -250,10 +245,10 @@
Nearest neighbours queries returns Values which are closest
- to some point in space. Additionally it is possible to pass define how
- the distance to the Value
- should be calculated. The examples of some knn queries may be found in
- the table below. All queries returns 5 closest Values.
+ to some point in space. Additionally it is possible to define how the distance
+ to the Value should be
+ calculated. The examples of some knn queries may be found in the table
+ below. All queries return 5 closest Values.
The query point and Values are orange.
@@ -314,23 +309,42 @@
- There is a unique predicate index::satisfies(...) taking user-defined function or function
- object which checks if Value should be returned by the query.
- It may be used to check some specific conditions for user-defined Values.
+ The user may pass a UnaryPredicate
+ - function, function object or lambda expression taking const reference
+ to Value and returning bool. This object may be passed to the query in
+ order to check if Value should be returned by the query. To
+ do it one may use index::satisfies() function like on the example below:
bool fun(Value const& v) +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(fun), +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
@@ -397,14 +411,14 @@ query results because temporary container won't be used.
RTree rt3; -rt1.query(Box(/*...*/), bgi::inserter(rt3)); +rt1.query(bgi::intersects(Box(/*...*/))), bgi::inserter(rt3));
If you like Boost.Range you'll appreciate the third option. You may pass the result Range directly to the constructor. However in this case the temporary container is created.
-RTree rt4(rt1 | bgi::adaptors::queried(Box(/*...*/))); +RTree rt4(rt1 | bgi::adaptors::queried(bgi::intersects(Box(/*...*/)))));
This is self-balancing spatial index capable to store various types of @@ -58,7 +58,7 @@
The user must pass a type defining the Parameters which will be used in @@ -68,7 +68,7 @@
Predefined algorithms with compile-time parameters are:
-boost::geometry::index::linear,
Predefined algorithms with run-time parameters are:
-boost::geometry::index::dynamic_linear,
The Translator translates from Value to Indexable each time r-tree requires @@ -112,14 +112,14 @@
#include <boost/geometry/index/rtree.hpp>
template<typename Value,typename Parameters,@@ -132,7 +132,7 @@
If allocator default constructor throws. @@ -877,7 +877,7 @@
rtree(parameters_typeconst ¶meters,translator_typeconst &translator,@@ -885,7 +885,7 @@
If allocator copy constructor throws. @@ -984,7 +984,7 @@
template<typename Iterator>rtree(Iteratorfirst,@@ -995,7 +995,7 @@
template<typename Range>rtree(Range const &rng,@@ -1149,7 +1149,7 @@
@@ -1158,7 +1158,7 @@
~rtree()
Nothing. @@ -1307,20 +1307,20 @@
It uses parameters, translator and allocator from the source tree.
rtree(rtreeconst &src)
It uses Parameters and translator from the source tree.
rtree(rtreeconst &src,allocator_typeconst &allocator)
It uses parameters, translator and allocator from the source tree.
rtree(rtree&&src)
Nothing. @@ -1574,20 +1574,20 @@
It uses parameters and translator from the source tree.
rtree(rtree&&src,allocator_typeconst &allocator)
It uses parameters and translator from the source tree.
rtree&operator=(constrtree&src)
It uses parameters and translator from the source tree.
rtree&operator=(rtree&&src)
Only if allocators aren't equal.
-Parameters, translator and allocators are swapped as well.
voidswap(rtree&other)
If allocators swap throws. @@ -1925,13 +1925,13 @@
voidinsert(value_typeconst &value)
template<typename Iterator>voidinsert(Iteratorfirst,Iteratorlast)
template<typename Range>voidinsert(Range const &rng)
In contrast to the
@@ -2215,13 +2215,13 @@
std::set
size_typeremove(value_typeconst &value)
1 if the value was removed, 0 otherwise.
In contrast to the
@@ -2320,14 +2320,14 @@
std::set
template<typename Iterator>size_typeremove(Iteratorfirst,Iteratorlast)
The number of removed values.
In contrast to the
@@ -2443,14 +2443,14 @@
std::set
template<typename Range>size_typeremove(Range const &rng)
The number of removed values.
This query function performs spatial and k-nearest neighbor searches. @@ -2550,12 +2550,9 @@ Spatial predicates
- The simplest form of spatial predicate is a .
- In this case Values intersecting the Geometry
- are returned. More spatial predicates may be generated by one of the
- functions listed below:
+ Spatial predicates may be generated by one of the functions listed below:
Geometry
boost::geometry::index::covered_by(),
boost::geometry::index::disjoint(),
boost::geometry::index::intersects()
- - default,
+ boost::geometry::index::intersects(),
boost::geometry::index::overlaps(),
@@ -2576,7 +2572,7 @@
It is possible to negate spatial predicates:
-! boost::geometry::index::covered_by(),
- Value predicate + Satisfies predicate
This is a special kind of predicate which allows to pass a user-defined - functor which checks if Value should be returned by the query. It's generated - by: + function or function object which checks if Value should be returned + by the query. It's generated by:
-boost::geometry::index::value().
+
Nearest predicate @@ -2613,7 +2609,7 @@ iterator. Only one nearest predicate may be passed to the query. It may be generated by:
-@@ -2624,14 +2620,14 @@
template<typename Predicates,typename OutIter>size_typequery(Predicates const &predicates,OutIterout_it)
@@ -2640,7 +2636,7 @@
The number of values found.
// return elements intersecting box -tree.query(box, std::back_inserter(result)); +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 @@ -2730,7 +2726,7 @@- Throws + Throws
If Value copy constructor or copy assignment throws. @@ -2755,13 +2751,13 @@
- Synopsis + Synopsis
size_typesize()- Modifier(s) + Modifier(s)
@@ -2770,14 +2766,14 @@
- Returns + Returns
The number of stored values.
- Throws + Throws
Nothing. @@ -2792,13 +2788,13 @@
- Synopsis + Synopsis
boolempty()- Modifier(s) + Modifier(s)
@@ -2807,14 +2803,14 @@
- Returns + Returns
true if the container is empty.
- Throws + Throws
Nothing. @@ -2829,13 +2825,13 @@
- Synopsis + Synopsis
voidclear()- Throws + Throws
Nothing. @@ -2850,7 +2846,7 @@
- Description + Description
Returns the box able to contain all values stored in the container. If @@ -2858,13 +2854,13 @@
- Synopsis + Synopsis
bounds_typebounds()- Modifier(s) + Modifier(s)
@@ -2873,7 +2869,7 @@
- Returns + Returns
The box able to contain all values stored in the container or an invalid @@ -2881,7 +2877,7 @@
- Throws + Throws
Nothing. @@ -2897,7 +2893,7 @@
- Description + Description
For indexable_type it returns the number of values which indexables equals @@ -2906,14 +2902,14 @@
- Synopsis + Synopsis
template<typename ValueOrIndexable>size_typecount(ValueOrIndexable const &vori)- Modifier(s) + Modifier(s)
@@ -2922,7 +2918,7 @@
- Parameter(s) + Parameter(s)
@@ -2968,14 +2964,14 @@ - Returns + Returns
The number of values found.
- Throws + Throws
Nothing. @@ -2990,13 +2986,13 @@
- Synopsis + Synopsis
parameters_typeconst ¶meters()- Modifier(s) + Modifier(s)
@@ -3005,14 +3001,14 @@
- Returns + Returns
The parameters object.
- Throws + Throws
Nothing. @@ -3027,13 +3023,13 @@
- Synopsis + Synopsis
translator_typeconst &translator()- Modifier(s) + Modifier(s)
@@ -3042,14 +3038,14 @@
- Returns + Returns
The translator object.
- Throws + Throws
Nothing. @@ -3064,13 +3060,13 @@
- Synopsis + Synopsis
allocator_typeget_allocator()- Modifier(s) + Modifier(s)
@@ -3079,14 +3075,14 @@
- Returns + Returns
The allocator.
- Throws + Throws
If allocator copy constructor throws. @@ -3100,7 +3096,7 @@
1 if value was removed, 0 otherwise. @@ -3715,7 +3711,7 @@
Remove a range of values from the container. In contrast to the or std::set method it doesn't take iterators
@@ -3729,7 +3725,7 @@
std::map erase()
template<typename Value,typename Options,@@ -3742,7 +3738,7 @@
The number of removed values. @@ -3844,7 +3840,7 @@
Remove a range of values from the container. In contrast to the or std::set method it removes values
@@ -3857,7 +3853,7 @@
std::map erase()
template<typename Value,typename Options,@@ -3868,7 +3864,7 @@
The number of removed values. @@ -3955,7 +3951,7 @@
This query function performs spatial and k-nearest neighbor searches. @@ -3966,12 +3962,9 @@ Spatial predicates
- The simplest form of spatial predicate is a .
- In this case Values intersecting the Geometry
- are returned. More spatial predicates may be generated by one of the
- functions listed below:
+ Spatial predicates may be generated by one of the functions listed below:
Geometry
boost::geometry::index::covered_by(),
boost::geometry::index::disjoint(),
boost::geometry::index::intersects()
- - default,
+ boost::geometry::index::intersects(),
boost::geometry::index::overlaps(),
@@ -3992,7 +3984,7 @@
It is possible to negate spatial predicates:
-! boost::geometry::index::covered_by(),
- Value predicate + Satisfies predicate
This is a special kind of predicate which allows to pass a user-defined - functor which checks if Value should be returned by the query. It's generated - by: + function or function object which checks if Value should be returned + by the query. It's generated by:
-boost::geometry::index::value().
+
Nearest predicate @@ -4029,7 +4021,7 @@ iterator. Only one nearest predicate may be passed to the query. It may be generated by:
-@@ -4040,7 +4032,7 @@
template<typename Value,typename Options,@@ -4054,7 +4046,7 @@
The number of values found.
// return elements intersecting box -bgi::query(tree, box, std::back_inserter(result)); +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 @@ -4166,7 +4158,7 @@- Throws + Throws
If Value copy constructor or copy assignment throws. @@ -4192,14 +4184,14 @@
- Description + Description
It calls
rtree::clear().- Synopsis + Synopsis
template<typename Value,typename Options,@@ -4209,7 +4201,7 @@- Parameter(s) + Parameter(s)
@@ -4268,14 +4260,14 @@ - Description + Description
It calls
rtree::size().- Synopsis + Synopsis
template<typename Value,typename Options,@@ -4285,7 +4277,7 @@- Parameter(s) + Parameter(s)
@@ -4335,7 +4327,7 @@ - Returns + Returns
The number of values stored in the index. @@ -4351,14 +4343,14 @@
- Description + Description
It calls
rtree::empty().- Synopsis + Synopsis
template<typename Value,typename Options,@@ -4368,7 +4360,7 @@- Parameter(s) + Parameter(s)
@@ -4418,7 +4410,7 @@ - Returns + Returns
true if there are no values in the index. @@ -4435,14 +4427,14 @@
- Description + Description
It calls
.rtree::envelope()- Synopsis + Synopsis
template<typename Value,typename Options,@@ -4452,7 +4444,7 @@- Parameter(s) + Parameter(s)
@@ -4502,7 +4494,7 @@ - Returns + Returns
The box containing all stored values or an invalid box. @@ -4518,14 +4510,14 @@
- Description + Description
It calls
rtree::swap().- Synopsis + Synopsis
template<typename Value,typename Options,@@ -4535,7 +4527,7 @@- Parameter(s) + Parameter(s)
@@ -4623,14 +4615,14 @@ - Header + Header
#include <boost/geometry/index/parameters.hpp>- Synopsis + Synopsis
template<size_t MaxElements,size_t MinElements>struct linear@@ -4640,7 +4632,7 @@- Template + Template parameter(s)
@@ -4697,14 +4689,14 @@
- Header + Header
#include <boost/geometry/index/parameters.hpp>- Synopsis + Synopsis
template<size_t MaxElements,size_t MinElements>struct quadratic@@ -4714,7 +4706,7 @@- Template + Template parameter(s)
@@ -4771,14 +4763,14 @@
- Header + Header
#include <boost/geometry/index/parameters.hpp>- Synopsis + Synopsis
template<size_t MaxElements,size_t MinElements,@@ -4791,7 +4783,7 @@- Template + Template parameter(s)
@@ -4874,14 +4866,14 @@
- Header + Header
#include <boost/geometry/index/parameters.hpp>- Synopsis + Synopsis
class dynamic_linear{@@ -4890,7 +4882,7 @@- Constructor(s) + Constructor(s) and destructor
@@ -4933,11 +4925,11 @@ The constructor.
- Synopsis + Synopsis dynamic_linear(size_tmax_elements,size_tmin_elements)- Parameter(s) + Parameter(s)
@@ -5009,14 +5001,14 @@ - Header + Header
#include <boost/geometry/index/parameters.hpp>- Synopsis + Synopsis
class dynamic_quadratic{@@ -5025,7 +5017,7 @@- Constructor(s) + Constructor(s) and destructor
@@ -5068,11 +5060,11 @@ The constructor.
- Synopsis + Synopsis dynamic_quadratic(size_tmax_elements,size_tmin_elements)- Parameter(s) + Parameter(s)
@@ -5144,14 +5136,14 @@ - Header + Header
#include <boost/geometry/index/parameters.hpp>- Synopsis + Synopsis
class dynamic_rstar{@@ -5160,7 +5152,7 @@- Constructor(s) + Constructor(s) and destructor
@@ -5203,14 +5195,14 @@ The constructor.
- Synopsis + Synopsis dynamic_rstar(size_tmax_elements,size_tmin_elements,size_toverlap_cost_threshold=0,size_treinserted_elements=detail::default_rstar_reinserted_elements_d())- Parameter(s) + Parameter(s)
@@ -5319,7 +5311,7 @@ - Description + Description
It translates Value object to Indexable object. The default version handles @@ -5328,14 +5320,14 @@
- Header + Header
#include <boost/geometry/index/translator.hpp>- Synopsis + Synopsis
template<typename Value>struct translator@@ -5345,7 +5337,7 @@- Template + Template parameter(s)
@@ -5386,7 +5378,7 @@
- Functions + Functions
@@ -5517,7 +5509,7 @@ - Description + Description
Generate a predicate defining Value and Geometry relationship. Value @@ -5525,14 +5517,14 @@
- Synopsis + Synopsis
template<typename Geometry>detail::covered_by<Geometry> boost::geometry::index::covered_by(Geometry const &g)- Template + Template parameter(s)
@@ -5567,7 +5559,7 @@
- Parameter(s) + Parameter(s)
@@ -5613,7 +5605,7 @@ - Example + Example
@@ -5633,7 +5625,7 @@
- Description + Description
Generate a predicate defining Value and Geometry relationship. Value @@ -5641,14 +5633,14 @@
- Synopsis + Synopsis
template<typename Geometry>detail::disjoint<Geometry> boost::geometry::index::disjoint(Geometry const &g)- Template + Template parameter(s)
@@ -5683,7 +5675,7 @@
- Parameter(s) + Parameter(s)
@@ -5729,7 +5721,7 @@ - Example + Example
@@ -5749,7 +5741,7 @@
- Description + Description
Generate a predicate defining Value and Geometry relationship. Value @@ -5757,14 +5749,14 @@
- Synopsis + Synopsis
template<typename Geometry>detail::intersects<Geometry> boost::geometry::index::intersects(Geometry const &g)- Template + Template parameter(s)
@@ -5799,7 +5791,7 @@
- Parameter(s) + Parameter(s)
@@ -5845,7 +5837,7 @@ - Example + Example
@@ -5867,7 +5859,7 @@
- Description + Description
Generate a predicate defining Value and Geometry relationship. Value @@ -5875,14 +5867,14 @@
- Synopsis + Synopsis
template<typename Geometry>detail::overlaps<Geometry> boost::geometry::index::overlaps(Geometry const &g)- Template + Template parameter(s)
@@ -5917,7 +5909,7 @@
- Parameter(s) + Parameter(s)
@@ -5963,7 +5955,7 @@ - Example + Example
@@ -5983,7 +5975,7 @@
- Description + Description
Generate a predicate defining Value and Geometry relationship. Value @@ -5991,14 +5983,14 @@
- Synopsis + Synopsis
template<typename Geometry>detail::within<Geometry> boost::geometry::index::within(Geometry const &g)- Template + Template parameter(s)
@@ -6033,7 +6025,7 @@
- Parameter(s) + Parameter(s)
@@ -6079,7 +6071,7 @@ - Example + Example
@@ -6099,7 +6091,7 @@
- Description + Description
A wrapper around user-defined UnaryPredicate checking if Value should @@ -6107,14 +6099,14 @@
- Synopsis + Synopsis
template<typename UnaryPredicate>detail::satisfies<UnaryPredicate> boost::geometry::index::satisfies(UnaryPredicate const &pred)- Template + Template parameter(s)
@@ -6149,7 +6141,7 @@
- Parameter(s) + Parameter(s)
@@ -6194,13 +6186,28 @@ - Example + Example
-
bool is_red(Value const& v) { ... } -... -bgi::query(spatial_index, bgi::intersects(box) && bgi::satisfies(is_red), std::back_inserter(result)); +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@@ -6216,7 +6223,7 @@
- Description + Description
When nearest predicate is passed to the query, k-nearest neighbour search @@ -6230,7 +6237,7 @@ is calculated. This is done by passing PointRelation. It can be generated by following functions:
-+
boost::geometry::index::to_nearest()- default, @@ -6244,14 +6251,14 @@- Synopsis + Synopsis
template<typename PointOrRelation>detail::nearest<PointOrRelation> boost::geometry::index::nearest(PointOrRelation const &point_relation,unsignedk)- Parameter(s) + Parameter(s)
@@ -6315,7 +6322,7 @@ - Example + Example
@@ -6344,7 +6351,7 @@
- Functions + Functions
@@ -6419,7 +6426,7 @@ - Description + Description
Generate a nearest query Point and Value's Indexable relationship while @@ -6432,14 +6439,14 @@
- Synopsis + Synopsis
template<typename T>detail::to_nearest<T> boost::geometry::index::to_nearest(T const &v)- Template + Template parameter(s)
@@ -6475,7 +6482,7 @@
- Parameter(s) + Parameter(s)
@@ -6531,7 +6538,7 @@ - Description + Description
Generate a nearest query Point and Value's Indexable relationship while @@ -6542,14 +6549,14 @@
- Synopsis + Synopsis
template<typename T>detail::to_centroid<T> boost::geometry::index::to_centroid(T const &v)- Template + Template parameter(s)
@@ -6585,7 +6592,7 @@
- Parameter(s) + Parameter(s)
@@ -6641,7 +6648,7 @@ - Description + Description
Generate a nearest query Point and Value's Indexable relationship while @@ -6654,14 +6661,14 @@
- Synopsis + Synopsis
template<typename T>detail::to_furthest<T> boost::geometry::index::to_furthest(T const &v)- Template + Template parameter(s)
@@ -6697,7 +6704,7 @@
- Parameter(s) + Parameter(s)
@@ -6750,7 +6757,7 @@ - Functions + Functions
@@ -6793,14 +6800,14 @@ - Synopsis + Synopsis
template<typename Predicates>detail::query<Predicates> boost::geometry::index::adaptors::queried(Predicates const &pred)- Parameter(s) + Parameter(s)
@@ -6852,7 +6859,7 @@ - Functions + Functions
@@ -6894,7 +6901,7 @@ - Description + Description
Returns insert iterator capable to insert values to the container (spatial @@ -6902,14 +6909,14 @@
- Synopsis + Synopsis
template<typename Container>insert_iterator<Container> boost::geometry::index::inserter(Container &c)- Parameter(s) + Parameter(s)
@@ -6955,7 +6962,7 @@ - Returns + Returns
The insert iterator inserting values to the container. diff --git a/doc/html/geometry_index/r_tree/rtree_examples.html b/doc/html/geometry_index/r_tree/rtree_examples.html index 03a8c2071..b803abc4e 100644 --- a/doc/html/geometry_index/r_tree/rtree_examples.html +++ b/doc/html/geometry_index/r_tree/rtree_examples.html @@ -3,7 +3,7 @@
Examples - + @@ -86,7 +86,7 @@ // find values intersecting some area defined by a box box query_box(point(0, 0), point(5, 5)); std::vector<value> result_s; - rtree.query(query_box, std::back_inserter(result_s)); + rtree.query(bgi::intersects(query_box), std::back_inserter(result_s)); // find 5 nearest values to a point std::vector<value> result_n; @@ -179,7 +179,7 @@ // find values intersecting some area defined by a box box query_box(point(0, 0), point(5, 5)); std::vector<value> result_s; - rtree.query(query_box, std::back_inserter(result_s)); + rtree.query(bgi::intersects(query_box), std::back_inserter(result_s)); // find 5 nearest values to a point std::vector<value> result_n; @@ -264,7 +264,7 @@ // find values intersecting some area defined by a box box query_box(point(0, 0), point(5, 5)); std::vector<value> result_s; - rtree.query(query_box, std::back_inserter(result_s)); + rtree.query(bgi::intersects(query_box), std::back_inserter(result_s)); // find 5 nearest values to a point std::vector<value> result_n; @@ -404,7 +404,7 @@ // find values intersecting some area defined by a box box query_box(point(0, 0), point(5, 5)); std::vector<value> result_s; - rtree.query(query_box, std::back_inserter(result_s)); + rtree.query(bgi::intersects(query_box), std::back_inserter(result_s)); // find 5 nearest values to a point std::vector<value> result_n; @@ -493,7 +493,7 @@ // find values intersecting some area defined by a box box query_box(point(0, 0), point(5, 5)); std::vector<value> result_s; - rtree.query(query_box, std::back_inserter(result_s)); + rtree.query(bgi::intersects(query_box), std::back_inserter(result_s)); // find 5 nearest values to a point std::vector<value> result_n; @@ -588,7 +588,7 @@ // find values intersecting some area defined by a box box query_box(point(0, 0), point(5, 5)); std::vector<value> result_s; - rtree.query(query_box, std::back_inserter(result_s)); + rtree.query(bgi::intersects(query_box), std::back_inserter(result_s)); // find 5 nearest values to a point std::vector<value> result_n; @@ -699,7 +699,7 @@ std::cout << "Child: Querying for objects intersecting box = [(45, 45)(55, 55)]\n"; std::vector<B> result; - unsigned k = tree->query(B(P(45, 45), P(55, 55)), std::back_inserter(result)); + unsigned k = tree->query(bgi::intersects(B(P(45, 45), P(55, 55))), std::back_inserter(result)); std::cout << "Child: Found objects:\n"; std::cout << k << "\n"; diff --git a/doc/html/geometry_index/r_tree/rtree_quickstart.html b/doc/html/geometry_index/r_tree/rtree_quickstart.html index 22a62ca05..d0516c114 100644 --- a/doc/html/geometry_index/r_tree/rtree_quickstart.html +++ b/doc/html/geometry_index/r_tree/rtree_quickstart.html @@ -3,7 +3,7 @@Quick Start - + @@ -116,7 +116,7 @@// find values intersecting some area defined by a box box query_box(point(0, 0), point(5, 5)); std::vector<value> result_s; -rtree.query(query_box, std::back_inserter(result_s)); +rtree.query(bgi::intersects(query_box), std::back_inserter(result_s));@@ -156,7 +156,7 @@
- More + More
More information about the R-tree implementation, other algorithms and queries diff --git a/doc/html/index.html b/doc/html/index.html index 7a78e45d9..478437542 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -3,7 +3,7 @@
Chapter 1. Geometry Index - + @@ -51,7 +51,7 @@
- + Last revised: March 01, 2013 at 02:58:06 GMT
Last revised: March 01, 2013 at 18:11:11 GMT
diff --git a/doc/rtree/query.qbk b/doc/rtree/query.qbk index e905180d6..f13e87393 100644 --- a/doc/rtree/query.qbk +++ b/doc/rtree/query.qbk @@ -13,8 +13,8 @@ Queries returns `__value__`s which meets some predicates. Currently supported are three types of predicates: * spatial predicates - defining relationship between stored Values and some Geometry, -* nearest predicates - defining relationship between stored Values and some Point, -* satisfies predicate - allows to pass user-defined UnaryPredicate (function or function object) to the query. +* nearest predicate - defining relationship between stored Values and some Point, +* user-defined unary predicate - function, function object or lambda expression checking user-defined condition. For example queries may be used to retrieve Values: @@ -24,34 +24,32 @@ For example queries may be used to retrieve Values: [section Performing a query] -There are three ways to perform a query. In the following example `__box__` is used as -the predicate, this is a default spatial predicate described in the following section. -Following queries returns `__value__`s intersecting some region defined as a `__box__`. -These three ways are: +There are three ways to perform a query presented below. All of them returns `__value__`s intersecting some +region defined as a `__box__`. Method call std::vector<__value__> returned_values; __box__ box_region(...); - rt.query(box_region, std::back_inserter(returned_values)); + rt.query(bgi::intersects(box_region), std::back_inserter(returned_values)); Function call std::vector<__value__> returned_values; __box__ box_region(...); - index::query(rt, box_region, std::back_inserter(returned_values)); + index::query(rt, bgi::intersects(box_region), std::back_inserter(returned_values)); Use of pipe operator generating a range __box__ box_region(...); - BOOST_FOREACH(__value__ & v, rt | index::adaptors::queried(box_region)) + BOOST_FOREACH(__value__ & v, rt | index::adaptors::queried(bgi::intersects(box_region))) ; // do something with v [endsect] [section Spatial queries] -Spatial query returns `__value__`s which are related somehow to a geometry or some number of geometries. +Spatial query returns `__value__`s which are related somehow to some Geometry - box, polygon, etc. Names of spatial predicates corresponds to names of __boost_geometry__ algorithms. Examples of some basic queries may be found in tables below. The query region and result `Value`s are orange. @@ -65,11 +63,9 @@ basic queries may be found in tables below. The query region and result `Value`s [[[$../images/intersects_ring.png]] [[$../images/intersects_poly.png]] [[$../images/intersects_mpoly.png]]] ] -To use a spatial predicate one may pass a geometry (which is a default case) or use one of the functions defined in -`boost::geometry::index` namespace to define it explicitly. +To use a spatial predicate one may use one of the functions defined in `boost::geometry::index` namespace. - rt.query(box, std::back_inserter(result)); // default case - intersects - rt.query(index::intersects(box), std::back_inserter(result)); // the same as default + rt.query(index::intersects(box), std::back_inserter(result)); rt.query(index::covered_by(box), std::back_inserter(result)); rt.query(index::disjont(box), std::back_inserter(result)); rt.query(index::overlaps(box), std::back_inserter(result)); @@ -86,8 +82,8 @@ All predicates may be negated, e.g.: [section Nearest neighbours queries] Nearest neighbours queries returns `__value__`s which are closest to some point in space. -Additionally it is possible to pass define how the distance to the `Value` should be calculated. -The examples of some knn queries may be found in the table below. All queries returns 5 closest `Values`. +Additionally it is possible to define how the distance to the `Value` should be calculated. +The examples of some knn queries may be found in the table below. All queries return 5 closest `Values`. The query point and Values are orange. [$../images/knn.png] @@ -134,22 +130,39 @@ a relation object generated as follows: [endsect] -[section Satisfies predicate] +[section user-defined unary predicate] -There is a unique predicate `index::satisfies(...)` taking user-defined function or function object -which checks if `__value__` should be returned by the query. It may be used to check -some specific conditions for user-defined Values. +The user may pass a `UnaryPredicate` - function, function object or lambda expression taking const reference to Value and returning bool. +This object may be passed to the query in order to check if `__value__` should be returned by the query. To do it one +may use `index::satisfies()` function like on the example below: - bool fun(__value__ const& v) + bool is_red(__value__ const& v) { return v.is_red(); } + struct is_red_o + { + template+ bool operator()(__value__ const& v) + { + return v.is_red(); + } + } + // ... - rt.query(index::intersects(box) && index::satisfies(fun), + 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 + [endsect] [section Passing a set of predicates] @@ -189,7 +202,7 @@ The most basic way is creating a temporary container for Values and insert them /* some inserting into the tree */ std::vector result; - rt1.query(Box(/*...*/), std::back_inserter(result)); + rt1.query(bgi::intersects(Box(/*...*/)), std::back_inserter(result)); RTree rt2(result.begin(), result.end()); However there are better ways. One of these methods is mentioned in the "Creation and modification" section. @@ -197,12 +210,12 @@ The insert iterator may be passed directly to the query, which will be the faste query results because temporary container won't be used. RTree rt3; - rt1.query(Box(/*...*/), bgi::inserter(rt3)); + rt1.query(bgi::intersects(Box(/*...*/))), bgi::inserter(rt3)); If you like Boost.Range you'll appreciate the third option. You may pass the result Range directly to the constructor. However in this case the temporary container is created. - RTree rt4(rt1 | bgi::adaptors::queried(Box(/*...*/))); + RTree rt4(rt1 | bgi::adaptors::queried(bgi::intersects(Box(/*...*/))))); [endsect] diff --git a/doc/src/examples/rtree/interprocess.cpp b/doc/src/examples/rtree/interprocess.cpp index 1b59451b9..4260ffdf1 100644 --- a/doc/src/examples/rtree/interprocess.cpp +++ b/doc/src/examples/rtree/interprocess.cpp @@ -89,7 +89,7 @@ int main(int argc, char *argv[]) std::cout << "Child: Querying for objects intersecting box = [(45, 45)(55, 55)]\n"; std::vector result; - unsigned k = tree->query(B(P(45, 45), P(55, 55)), std::back_inserter(result)); + unsigned k = tree->query(bgi::intersects(B(P(45, 45), P(55, 55))), std::back_inserter(result)); std::cout << "Child: Found objects:\n"; std::cout << k << "\n"; diff --git a/doc/src/examples/rtree/polygons_shared_ptr.cpp b/doc/src/examples/rtree/polygons_shared_ptr.cpp index 210fb27ad..5886fbf04 100644 --- a/doc/src/examples/rtree/polygons_shared_ptr.cpp +++ b/doc/src/examples/rtree/polygons_shared_ptr.cpp @@ -63,7 +63,7 @@ int main(void) // find values intersecting some area defined by a box box query_box(point(0, 0), point(5, 5)); std::vector result_s; - rtree.query(query_box, std::back_inserter(result_s)); + rtree.query(bgi::intersects(query_box), std::back_inserter(result_s)); // find 5 nearest values to a point std::vector result_n; diff --git a/doc/src/examples/rtree/polygons_vector.cpp b/doc/src/examples/rtree/polygons_vector.cpp index 3fa6cb51f..e64e574a1 100644 --- a/doc/src/examples/rtree/polygons_vector.cpp +++ b/doc/src/examples/rtree/polygons_vector.cpp @@ -71,7 +71,7 @@ int main(void) // find values intersecting some area defined by a box box query_box(point(0, 0), point(5, 5)); std::vector result_s; - rtree.query(query_box, std::back_inserter(result_s)); + rtree.query(bgi::intersects(query_box), std::back_inserter(result_s)); // find 5 nearest values to a point std::vector result_n; diff --git a/doc/src/examples/rtree/quick_start.cpp b/doc/src/examples/rtree/quick_start.cpp index f25b2383c..efa4b3584 100644 --- a/doc/src/examples/rtree/quick_start.cpp +++ b/doc/src/examples/rtree/quick_start.cpp @@ -57,7 +57,7 @@ int main(void) // find values intersecting some area defined by a box box query_box(point(0, 0), point(5, 5)); std::vector result_s; - rtree.query(query_box, std::back_inserter(result_s)); + rtree.query(bgi::intersects(query_box), std::back_inserter(result_s)); //] //[rtree_quickstart_nearest_query diff --git a/doc/src/examples/rtree/translator_index.cpp b/doc/src/examples/rtree/translator_index.cpp index ea629f6c2..978b7dbae 100644 --- a/doc/src/examples/rtree/translator_index.cpp +++ b/doc/src/examples/rtree/translator_index.cpp @@ -73,7 +73,7 @@ int main(void) // find values intersecting some area defined by a box box query_box(point(0, 0), point(5, 5)); std::vector result_s; - rtree.query(query_box, std::back_inserter(result_s)); + rtree.query(bgi::intersects(query_box), std::back_inserter(result_s)); // find 5 nearest values to a point std::vector result_n; diff --git a/doc/src/examples/rtree/translator_shared_ptr.cpp b/doc/src/examples/rtree/translator_shared_ptr.cpp index b40e561b5..52e26a280 100644 --- a/doc/src/examples/rtree/translator_shared_ptr.cpp +++ b/doc/src/examples/rtree/translator_shared_ptr.cpp @@ -67,7 +67,7 @@ int main(void) // find values intersecting some area defined by a box box query_box(point(0, 0), point(5, 5)); std::vector result_s; - rtree.query(query_box, std::back_inserter(result_s)); + rtree.query(bgi::intersects(query_box), std::back_inserter(result_s)); // find 5 nearest values to a point std::vector result_n; diff --git a/doc/src/examples/rtree/variants_map.cpp b/doc/src/examples/rtree/variants_map.cpp index 38fd9aafc..427c5567c 100644 --- a/doc/src/examples/rtree/variants_map.cpp +++ b/doc/src/examples/rtree/variants_map.cpp @@ -118,7 +118,7 @@ int main(void) // find values intersecting some area defined by a box box query_box(point(0, 0), point(5, 5)); std::vector result_s; - rtree.query(query_box, std::back_inserter(result_s)); + rtree.query(bgi::intersects(query_box), std::back_inserter(result_s)); // find 5 nearest values to a point std::vector result_n; diff --git a/example/benchmark.cpp b/example/benchmark.cpp index fad858aa4..12a38ff3c 100644 --- a/example/benchmark.cpp +++ b/example/benchmark.cpp @@ -91,7 +91,7 @@ int main() float x = coords[i].first; float y = coords[i].second; result.clear(); - t.query(B(P(x - 10, y - 10), P(x + 10, y + 10)), std::back_inserter(result)); + t.query(bgi::intersects(B(P(x - 10, y - 10), P(x + 10, y + 10))), std::back_inserter(result)); temp += result.size(); } dur_t time = clock_t::now() - start; diff --git a/include/boost/geometry/index/detail/predicates.hpp b/include/boost/geometry/index/detail/predicates.hpp index e58aa511b..93874aa40 100644 --- a/include/boost/geometry/index/detail/predicates.hpp +++ b/include/boost/geometry/index/detail/predicates.hpp @@ -20,8 +20,7 @@ namespace boost { namespace geometry { namespace index { namespace detail { // predicates // ------------------------------------------------------------------ // -// not needed? -struct empty {}; +//struct empty {}; template struct satisfies @@ -125,43 +124,102 @@ struct nearest unsigned count; }; +// ------------------------------------------------------------------ // +// is_predicate +// ------------------------------------------------------------------ // + +//template struct is_predicate { static const bool value = false; }; +////template <> struct is_predicate< empty > { static const bool value = true; }; +//template struct is_predicate< satisfies > { static const bool value = true; }; +//template struct is_predicate< covered_by > { static const bool value = true; }; +//template struct is_predicate< disjoint > { static const bool value = true; }; +//template struct is_predicate< intersects > { static const bool value = true; }; +//template struct is_predicate< overlaps > { static const bool value = true; }; +////template struct is_predicate< touches > { static const bool value = true; }; +//template struct is_predicate< within > { static const bool value = true; }; +//template struct is_predicate< not_covered_by > { static const bool value = true; }; +//template struct is_predicate< not_disjoint > { static const bool value = true; }; +//template struct is_predicate< not_intersects > { static const bool value = true; }; +//template struct is_predicate< not_overlaps > { static const bool value = true; }; +////template struct is_predicate< not_touches > { static const bool value = true; }; +//template struct is_predicate< not_within > { static const bool value = true; }; +//template struct is_predicate< nearest > { static const bool value = true; }; + +// ------------------------------------------------------------------ // +// predicate_check_default +// ------------------------------------------------------------------ // + +//template
+//struct predicate_check_default +//{ +// BOOST_MPL_ASSERT_MSG( +// (false), +// NOT_IMPLEMENTED_FOR_THESE_TAGS, +// (predicate_check_default)); +//}; + // ------------------------------------------------------------------ // // predicate_check // ------------------------------------------------------------------ // -template +template struct predicate_check { BOOST_MPL_ASSERT_MSG( (false), - NOT_IMPLEMENTED_FOR_THIS_TAG, + NOT_IMPLEMENTED_FOR_THIS_PREDICATE_OR_TAG, (predicate_check)); }; +// ------------------------------------------------------------------ // +// predicate_check_default for value +// ------------------------------------------------------------------ // + +//template +//struct predicate_check_default +//{ +// template +// static inline bool apply(Geometry const& g, Value const&, Indexable const& i) +// { +// return geometry::intersects(i, g); +// } +//}; +// +//template +//struct predicate_check_default +//{ +// template +// static inline bool apply(Unary const& u, Value const& v, Indexable const&) +// { +// return u(v); +// } +//}; + // ------------------------------------------------------------------ // // predicate_check for value // ------------------------------------------------------------------ // -template -struct predicate_check -{ - template - static inline bool apply(Geometry const& g, Value const&, Indexable const& i) - { - return geometry::intersects(i, g); - } -}; +//template +//struct predicate_check +//{ +// template +// static inline bool apply(GeometryOrUnary const& g, Value const& v, Indexable const& i) +// { +// return predicate_check_default< +// GeometryOrUnary, typename geometry::traits::tag ::type, bounds_tag +// >::apply(g, v, i); +// } +//}; -// not needed? -template <> -struct predicate_check -{ - template - static inline bool apply(empty const&, Value const&, Indexable const&) - { - return true; - } -}; +//template <> +//struct predicate_check +//{ +// template +// static inline bool apply(empty const&, Value const&, Indexable const&) +// { +// return true; +// } +//}; template struct predicate_check , value_tag> @@ -304,28 +362,54 @@ struct predicate_check , value_tag> }; // ------------------------------------------------------------------ // -// predicates_chec for envelope +// predicate_check_default for bounds // ------------------------------------------------------------------ // -template -struct predicate_check -{ - template - static inline bool apply(Geometry const& g, Value const&, Indexable const& i) - { - return geometry::intersects(i, g); - } -}; +//template +//struct predicate_check_default +//{ +// template +// static inline bool apply(Geometry const& g, Value const&, Indexable const& i) +// { +// return geometry::intersects(i, g); +// } +//}; +// +//template +//struct predicate_check_default +//{ +// template +// static inline bool apply(Unary const&, Value const&, Indexable const&) +// { +// return true; +// } +//}; -template <> -struct predicate_check -{ - template - static inline bool apply(Geometry const&, Value const&, Indexable const&) - { - return true; - } -}; +// ------------------------------------------------------------------ // +// predicates_chec for bounds +// ------------------------------------------------------------------ // + +//template +//struct predicate_check +//{ +// template +// static inline bool apply(GeometryOrUnary const& g, Value const& v, Indexable const& i) +// { +// return predicate_check_default< +// GeometryOrUnary, typename geometry::traits::tag ::type, bounds_tag +// >::apply(g, v, i); +// } +//}; + +//template <> +//struct predicate_check +//{ +// template +// static inline bool apply(Geometry const&, Value const&, Indexable const&) +// { +// return true; +// } +//}; template struct predicate_check , bounds_tag> @@ -481,17 +565,17 @@ struct predicates_length static const unsigned value = 1; }; -template -struct predicates_length< std::pair > -{ - static const unsigned value = 2; -}; +//template +//struct predicates_length< std::pair > +//{ +// static const unsigned value = 2; +//}; -template -struct predicates_length< boost::tuple > -{ - static const unsigned value = boost::tuples::length< boost::tuple >::value; -}; +//template +//struct predicates_length< boost::tuple > +//{ +// static const unsigned value = boost::tuples::length< boost::tuple >::value; +//}; template struct predicates_length< boost::tuples::cons > @@ -511,30 +595,30 @@ struct predicates_element static type const& get(T const& p) { return p; } }; -template -struct predicates_element< I, std::pair > -{ - BOOST_MPL_ASSERT_MSG((I < 2), INVALID_INDEX, (predicates_element)); - - typedef F type; - static type const& get(std::pair const& p) { return p.first; } -}; - -template -struct predicates_element< 1, std::pair > -{ - typedef S type; - static type const& get(std::pair const& p) { return p.second; } -}; - -template -struct predicates_element< I, boost::tuple > -{ - typedef boost::tuple predicate_type; - - typedef typename boost::tuples::element::type type; - static type const& get(predicate_type const& p) { return boost::get(p); } -}; +//template +//struct predicates_element< I, std::pair > +//{ +// BOOST_MPL_ASSERT_MSG((I < 2), INVALID_INDEX, (predicates_element)); +// +// typedef F type; +// static type const& get(std::pair const& p) { return p.first; } +//}; +// +//template +//struct predicates_element< 1, std::pair > +//{ +// typedef S type; +// static type const& get(std::pair const& p) { return p.second; } +//}; +// +//template +//struct predicates_element< I, boost::tuple > +//{ +// typedef boost::tuple predicate_type; +// +// typedef typename boost::tuples::element::type type; +// static type const& get(predicate_type const& p) { return boost::get(p); } +//}; template struct predicates_element< I, boost::tuples::cons > @@ -549,49 +633,49 @@ struct predicates_element< I, boost::tuples::cons > // predicates_check // ------------------------------------------------------------------ // -template -struct predicates_check_pair {}; - -template -struct predicates_check_pair