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