distance_predicates.hpp 8.2 KB

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