1 | // Boost.Geometry Index |
2 | // |
3 | // Spatial index distance predicates, calculators and checkers used in nearest neighbor query |
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_DISTANCE_PREDICATES_HPP |
12 | #define BOOST_GEOMETRY_INDEX_DISTANCE_PREDICATES_HPP |
13 | |
14 | #include <boost/geometry/index/detail/distance_predicates.hpp> |
15 | |
16 | /*! |
17 | \defgroup nearest_relations Nearest relations (boost::geometry::index::) |
18 | */ |
19 | |
20 | namespace boost { namespace geometry { namespace index { |
21 | |
22 | // relations generators |
23 | |
24 | #ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL |
25 | |
26 | /*! |
27 | \brief Generate to_nearest() relationship. |
28 | |
29 | Generate a nearest query Point and Value's Indexable relationship while calculating |
30 | distances. This function may be used to define that knn query should calculate distances |
31 | as smallest as possible between query Point and Indexable's points. In other words it |
32 | should be the distance to the nearest Indexable's point. This function may be also used |
33 | to define distances bounds which indicates that Indexable's nearest point should be |
34 | closer or further than value v. This is default relation. |
35 | |
36 | \ingroup nearest_relations |
37 | |
38 | \tparam T Type of wrapped object. This may be a Point for PointRelation or CoordinateType for |
39 | MinRelation or MaxRelation |
40 | |
41 | \param v Point or distance value. |
42 | */ |
43 | template <typename T> |
44 | detail::to_nearest<T> to_nearest(T const& v) |
45 | { |
46 | return detail::to_nearest<T>(v); |
47 | } |
48 | |
49 | /*! |
50 | \brief Generate to_centroid() relationship. |
51 | |
52 | Generate a nearest query Point and Value's Indexable relationship while calculating |
53 | distances. This function may be used to define that knn query should calculate distances |
54 | between query Point and Indexable's centroid. This function may be also used |
55 | to define distances bounds which indicates that Indexable's centroid should be |
56 | closer or further than value v. |
57 | |
58 | \ingroup nearest_relations |
59 | |
60 | \tparam T Type of wrapped object. This may be a Point for PointRelation or some CoordinateType for |
61 | MinRelation or MaxRelation |
62 | |
63 | \param v Point or distance value. |
64 | */ |
65 | template <typename T> |
66 | detail::to_centroid<T> to_centroid(T const& v) |
67 | { |
68 | return detail::to_centroid<T>(v); |
69 | } |
70 | |
71 | /*! |
72 | \brief Generate to_furthest() relationship. |
73 | |
74 | Generate a nearest query Point and Value's Indexable relationship while calculating |
75 | distances. This function may be used to define that knn query should calculate distances |
76 | as biggest as possible between query Point and Indexable's points. In other words it |
77 | should be the distance to the furthest Indexable's point. This function may be also used |
78 | to define distances bounds which indicates that Indexable's furthest point should be |
79 | closer or further than value v. |
80 | |
81 | \ingroup nearest_relations |
82 | |
83 | \tparam T Type of wrapped object. This may be a Point for PointRelation or some CoordinateType for |
84 | MinRelation or MaxRelation |
85 | |
86 | \param v Point or distance value. |
87 | */ |
88 | template <typename T> |
89 | detail::to_furthest<T> to_furthest(T const& v) |
90 | { |
91 | return detail::to_furthest<T>(v); |
92 | } |
93 | |
94 | #endif // BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL |
95 | |
96 | // distance predicates generators |
97 | |
98 | /*! |
99 | \brief Generate unbounded() distance predicate. |
100 | |
101 | Generate a distance predicate. This defines distances bounds which are used by knn query. |
102 | This function indicates that there is no distance bounds and Values should be returned |
103 | if distances between Point and Indexable are the smallest. Distance calculation is defined |
104 | by PointRelation. This is default nearest predicate. |
105 | |
106 | \ingroup distance_predicates |
107 | |
108 | \tparam PointRelation PointRelation type. |
109 | |
110 | \param pr The point relation. This may be generated by \c index::to_nearest(), |
111 | \c index::to_centroid() or \c index::to_furthest() with \c Point passed as a parameter. |
112 | */ |
113 | //template <typename PointRelation> |
114 | //inline detail::unbounded<PointRelation> |
115 | //unbounded(PointRelation const& pr) |
116 | //{ |
117 | // return detail::unbounded<PointRelation>(pr); |
118 | //} |
119 | |
120 | /*! |
121 | \brief Generate min_bounded() distance predicate. |
122 | |
123 | Generate a distance predicate. This defines distances bounds which are used by knn query. |
124 | This function indicates that Values should be returned only if distances between Point and |
125 | Indexable are greater or equal to some min_distance passed in MinRelation. Check for closest Value is |
126 | defined by PointRelation. So it is possible e.g. to return Values with centroids closest to some |
127 | Point but only if nearest points are further than some distance. |
128 | |
129 | \ingroup distance_predicates |
130 | |
131 | \tparam PointRelation PointRelation type. |
132 | \tparam MinRelation MinRelation type. |
133 | |
134 | \param pr The point relation. This may be generated by \c to_nearest(), |
135 | \c to_centroid() or \c to_furthest() with \c Point passed as a parameter. |
136 | \param minr The minimum bound relation. This may be generated by \c to_nearest(), |
137 | \c to_centroid() or \c to_furthest() with distance value passed as a parameter. |
138 | */ |
139 | //template <typename PointRelation, typename MinRelation> |
140 | //inline detail::min_bounded<PointRelation, MinRelation> |
141 | //min_bounded(PointRelation const& pr, MinRelation const& minr) |
142 | //{ |
143 | // return detail::min_bounded<PointRelation, MinRelation>(pr, minr); |
144 | //} |
145 | |
146 | /*! |
147 | \brief Generate max_bounded() distance predicate. |
148 | |
149 | Generate a distance predicate. This defines distances bounds which are used by knn query. |
150 | This function indicates that Values should be returned only if distances between Point and |
151 | Indexable are lesser or equal to some max_distance passed in MaxRelation. Check for closest Value is |
152 | defined by PointRelation. So it is possible e.g. to return Values with centroids closest to some |
153 | Point but only if nearest points are closer than some distance. |
154 | |
155 | \ingroup distance_predicates |
156 | |
157 | \tparam PointRelation PointRelation type. |
158 | \tparam MaxRelation MaxRelation type. |
159 | |
160 | \param pr The point relation. This may be generated by \c to_nearest(), |
161 | \c to_centroid() or \c to_furthest() with \c Point passed as a parameter. |
162 | \param maxr The maximum bound relation. This may be generated by \c to_nearest(), |
163 | \c to_centroid() or \c to_furthest() with distance value passed as a parameter. |
164 | */ |
165 | //template <typename PointRelation, typename MaxRelation> |
166 | //inline detail::max_bounded<PointRelation, MaxRelation> |
167 | //max_bounded(PointRelation const& pr, MaxRelation const& maxr) |
168 | //{ |
169 | // return detail::max_bounded<PointRelation, MaxRelation>(pr, maxr); |
170 | //} |
171 | |
172 | /*! |
173 | \brief Generate bounded() distance predicate. |
174 | |
175 | Generate a distance predicate. This defines distances bounds which are used by knn query. |
176 | This function indicates that Values should be returned only if distances between Point and |
177 | Indexable are greater or equal to some min_distance passed in MinRelation and lesser or equal to |
178 | some max_distance passed in MaxRelation. Check for closest Value is defined by PointRelation. |
179 | So it is possible e.g. to return Values with centroids closest to some Point but only if nearest |
180 | points are further than some distance and closer than some other distance. |
181 | |
182 | \ingroup distance_predicates |
183 | |
184 | \tparam PointRelation PointRelation type. |
185 | \tparam MinRelation MinRelation type. |
186 | \tparam MaxRelation MaxRelation type. |
187 | |
188 | \param pr The point relation. This may be generated by \c to_nearest(), |
189 | \c to_centroid() or \c to_furthest() with \c Point passed as a parameter. |
190 | \param minr The minimum bound relation. This may be generated by \c to_nearest(), |
191 | \c to_centroid() or \c to_furthest() with distance value passed as a parameter. |
192 | \param maxr The maximum bound relation. This may be generated by \c to_nearest(), |
193 | \c to_centroid() or \c to_furthest() with distance value passed as a parameter. |
194 | */ |
195 | //template <typename PointRelation, typename MinRelation, typename MaxRelation> |
196 | //inline detail::bounded<PointRelation, MinRelation, MaxRelation> |
197 | //bounded(PointRelation const& pr, MinRelation const& minr, MaxRelation const& maxr) |
198 | //{ |
199 | // return detail::bounded<PointRelation, MinRelation, MaxRelation>(pr, minr, maxr); |
200 | //} |
201 | |
202 | }}} // namespace boost::geometry::index |
203 | |
204 | #endif // BOOST_GEOMETRY_INDEX_DISTANCE_PREDICATES_HPP |
205 | |