geometry.index doc, test: added test for !satisfies(), queries docs updated.

[SVN r84216]
This commit is contained in:
Adam Wulkiewicz 2013-05-09 23:42:42 +00:00
parent cf9edb967e
commit c10a017f91
2 changed files with 35 additions and 9 deletions

View File

@ -12,8 +12,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 predicate - defining relationship between stored Values and some Point,
* spatial predicates - spatial conditions that must be met by stored Value and some Geometry,
* distance predicates - distance conditions that must be met by stored Value and some Geometry,
* user-defined unary predicate - function, function object or lambda expression checking user-defined condition.
For example queries may be used to retrieve Values:
@ -47,14 +47,14 @@ Use of pipe operator generating a range
[endsect]
[section Spatial queries]
[section Spatial predicates]
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
Queries using spatial predicates returns `__value__`s which are related somehow to some Geometry - box, polygon, etc.
Names of spatial predicates correspond 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.
[table
[[intersects(Box) - default] [covered_by(Box)] [disjoint(Box)] [overlaps(Box)] [within(Box)]]
[[intersects(Box)] [covered_by(Box)] [disjoint(Box)] [overlaps(Box)] [within(Box)]]
[[[$img/index/rtree/intersects.png]] [[$img/index/rtree/within.png]] [[$img/index/rtree/disjoint.png]] [[$img/index/rtree/overlaps.png]] [[$img/index/rtree/within.png]]]
]
@ -71,7 +71,7 @@ To use a spatial predicate one may use one of the functions defined in `boost::g
rt.query(index::overlaps(box), std::back_inserter(result));
rt.query(index::within(box), std::back_inserter(result));
All predicates may be negated, e.g.:
All spatial predicates may be negated, e.g.:
rt.query(!index::intersects(box), std::back_inserter(result));
// the same as
@ -79,7 +79,9 @@ All predicates may be negated, e.g.:
[endsect]
[section Nearest neighbours queries]
[section Distance predicates]
[heading Nearest neighbours queries]
Nearest neighbours queries returns `__value__`s which are closest to some point in space.
Additionally it is possible to define how the distance to the `Value` should be calculated.
@ -146,6 +148,19 @@ may use `index::satisfies()` function like on the example below:
std::back_inserter(result));
#endif
`satisfies()` may be negated, e.g.:
bool is_red(__value__ const& v) { return v.is_red(); }
bool is_not_red(__value__ const& v) { return !v.is_red(); }
// ...
rt.query(index::intersects(box) && index::satisfies(is_red),
std::back_inserter(result));
// the same as
rt.query(index::intersects(box) && !index::satisfies(is_not_red),
std::back_inserter(result));
[endsect]
[section Passing a set of predicates]

View File

@ -999,16 +999,27 @@ struct satisfies_obj
template <typename Rtree, typename Value>
void satisfies(Rtree const& rtree, std::vector<Value> const& input)
{
std::vector<Value> result;
std::vector<Value> result;
rtree.query(bgi::satisfies(satisfies_obj()), std::back_inserter(result));
BOOST_CHECK(result.size() == input.size());
result.clear();
rtree.query(!bgi::satisfies(satisfies_obj()), std::back_inserter(result));
BOOST_CHECK(result.size() == 0);
result.clear();
rtree.query(bgi::satisfies(satisfies_fun<Value>), std::back_inserter(result));
BOOST_CHECK(result.size() == input.size());
result.clear();
rtree.query(!bgi::satisfies(satisfies_fun<Value>), std::back_inserter(result));
BOOST_CHECK(result.size() == 0);
#ifndef BOOST_NO_CXX11_LAMBDAS
result.clear();
rtree.query(bgi::satisfies([](Value const&){ return true; }), std::back_inserter(result));
BOOST_CHECK(result.size() == input.size());
result.clear();
rtree.query(!bgi::satisfies([](Value const&){ return true; }), std::back_inserter(result));
BOOST_CHECK(result.size() == 0);
#endif
}