Boost.Geometry.Index
 All Classes Functions Typedefs Groups
query.hpp
1 // Boost.Geometry Index
2 //
3 // Query range adaptor
4 //
5 // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
6 //
7 // Use, modification and distribution is subject to the Boost Software License,
8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10 
11 #ifndef BOOST_GEOMETRY_INDEX_ADAPTORS_QUERY_HPP
12 #define BOOST_GEOMETRY_INDEX_ADAPTORS_QUERY_HPP
13 
18 namespace boost { namespace geometry { namespace index {
19 
20 namespace adaptors {
21 
22 namespace detail {
23 
24 template <typename Index>
25 class query_range
26 {
27  BOOST_MPL_ASSERT_MSG(
28  (false),
29  NOT_IMPLEMENTED_FOR_THIS_INDEX,
30  (query_range));
31 
32  typedef int* iterator;
33  typedef const int* const_iterator;
34 
35  template <typename Predicates>
36  inline query_range(
37  Index const&,
38  Predicates const&)
39  {}
40 
41  inline iterator begin() { return 0; }
42  inline iterator end() { return 0; }
43  inline const_iterator begin() const { return 0; }
44  inline const_iterator end() const { return 0; }
45 };
46 
47 // TODO: awulkiew - consider removing reference from predicates
48 
49 template<typename Predicates>
50 struct query
51 {
52  inline explicit query(Predicates const& pred)
53  : predicates(pred)
54  {}
55 
56  Predicates const& predicates;
57 };
58 
59 template<typename Index, typename Predicates>
60 index::adaptors::detail::query_range<Index>
61 operator|(
62  Index const& si,
63  index::adaptors::detail::query<Predicates> const& f)
64 {
65  return index::adaptors::detail::query_range<Index>(si, f.predicates);
66 }
67 
68 } // namespace detail
69 
77 template <typename Predicates>
78 detail::query<Predicates>
79 queried(Predicates const& pred)
80 {
81  return detail::query<Predicates>(pred);
82 }
83 
84 } // namespace adaptors
85 
86 }}} // namespace boost::geometry::index
87 
88 #endif // BOOST_GEOMETRY_INDEX_ADAPTORS_QUERY_HPP
rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::const_iterator end(rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > const &tree)
Returns the iterator pointing at the end of the rtree values range.
Definition: rtree.hpp:2117
rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::const_iterator begin(rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > const &tree)
Returns the iterator pointing at the begin of the rtree values range.
Definition: rtree.hpp:2084
rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator >::size_type query(rtree< Value, Parameters, IndexableGetter, EqualTo, Allocator > const &tree, Predicates const &predicates, OutIter out_it)
Finds values meeting passed predicates e.g. nearest to some Point and/or intersecting some Box...
Definition: rtree.hpp:1982
detail::query< Predicates > queried(Predicates const &pred)
The query index adaptor generator.
Definition: query.hpp:79