index.hpp 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. // Boost.Geometry Index
  2. //
  3. // R-tree strategies
  4. //
  5. // Copyright (c) 2019, Oracle and/or its affiliates.
  6. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  7. //
  8. // Use, modification and distribution is subject to the Boost Software License,
  9. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  10. // http://www.boost.org/LICENSE_1_0.txt)
  11. #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_INDEX_HPP
  12. #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_INDEX_HPP
  13. #include <boost/geometry/strategies/spherical/distance_haversine.hpp>
  14. #include <boost/geometry/strategies/spherical/distance_cross_track.hpp>
  15. #include <boost/geometry/strategies/spherical/distance_cross_track_point_box.hpp>
  16. #include <boost/geometry/strategies/spherical/distance_segment_box.hpp>
  17. #include <boost/geometry/strategies/spherical/envelope_box.hpp>
  18. #include <boost/geometry/strategies/spherical/envelope_point.hpp>
  19. #include <boost/geometry/strategies/spherical/envelope_segment.hpp>
  20. #include <boost/geometry/strategies/spherical/expand_box.hpp>
  21. #include <boost/geometry/strategies/spherical/expand_point.hpp>
  22. #include <boost/geometry/strategies/spherical/expand_segment.hpp>
  23. #include <boost/geometry/strategies/spherical/intersection.hpp>
  24. #include <boost/geometry/strategies/spherical/point_in_poly_winding.hpp>
  25. #include <boost/geometry/strategies/index.hpp>
  26. namespace boost { namespace geometry { namespace strategy { namespace index
  27. {
  28. template
  29. <
  30. typename CalculationType = void
  31. >
  32. struct spherical
  33. {
  34. typedef spherical_tag cs_tag;
  35. typedef geometry::strategy::envelope::spherical_point envelope_point_strategy_type;
  36. typedef geometry::strategy::envelope::spherical_box envelope_box_strategy_type;
  37. typedef geometry::strategy::envelope::spherical_segment
  38. <
  39. CalculationType
  40. > envelope_segment_strategy_type;
  41. static inline envelope_segment_strategy_type get_envelope_segment_strategy()
  42. {
  43. return envelope_segment_strategy_type();
  44. }
  45. typedef geometry::strategy::expand::spherical_point expand_point_strategy_type;
  46. typedef geometry::strategy::expand::spherical_box expand_box_strategy_type;
  47. typedef geometry::strategy::expand::spherical_segment
  48. <
  49. CalculationType
  50. > expand_segment_strategy_type;
  51. static inline expand_segment_strategy_type get_expand_segment_strategy()
  52. {
  53. return expand_segment_strategy_type();
  54. }
  55. typedef geometry::strategy::covered_by::spherical_point_box covered_by_point_box_strategy_type;
  56. typedef geometry::strategy::covered_by::spherical_box_box covered_by_box_box_strategy_type;
  57. typedef geometry::strategy::within::spherical_point_point within_point_point_strategy_type;
  58. //typedef geometry::strategy::within::spherical_point_box within_point_box_strategy_type;
  59. //typedef geometry::strategy::within::spherical_box_box within_box_box_strategy_type;
  60. // used in equals(Seg, Seg) but only to get_point_in_point_strategy()
  61. typedef geometry::strategy::intersection::spherical_segments
  62. <
  63. CalculationType
  64. > relate_segment_segment_strategy_type;
  65. static inline relate_segment_segment_strategy_type get_relate_segment_segment_strategy()
  66. {
  67. return relate_segment_segment_strategy_type();
  68. }
  69. // used in intersection_content
  70. typedef geometry::strategy::disjoint::spherical_box_box disjoint_box_box_strategy_type;
  71. typedef geometry::strategy::distance::comparable::haversine
  72. <
  73. double,
  74. CalculationType
  75. > comparable_distance_point_point_strategy_type;
  76. static inline comparable_distance_point_point_strategy_type get_comparable_distance_point_point_strategy()
  77. {
  78. return comparable_distance_point_point_strategy_type();
  79. }
  80. // TODO: Comparable version should be possible
  81. typedef geometry::strategy::distance::cross_track_point_box
  82. <
  83. CalculationType,
  84. geometry::strategy::distance::haversine<double, CalculationType>
  85. > comparable_distance_point_box_strategy_type;
  86. static inline comparable_distance_point_box_strategy_type get_comparable_distance_point_box_strategy()
  87. {
  88. return comparable_distance_point_box_strategy_type();
  89. }
  90. // TODO: Radius is not needed in comparable strategy
  91. typedef geometry::strategy::distance::comparable::cross_track
  92. <
  93. CalculationType,
  94. geometry::strategy::distance::comparable::haversine<double, CalculationType>
  95. > comparable_distance_point_segment_strategy_type;
  96. static inline comparable_distance_point_segment_strategy_type get_comparable_distance_point_segment_strategy()
  97. {
  98. return comparable_distance_point_segment_strategy_type();
  99. }
  100. // comparable?
  101. typedef geometry::strategy::distance::spherical_segment_box
  102. <
  103. CalculationType,
  104. geometry::strategy::distance::haversine<double, CalculationType>
  105. > comparable_distance_segment_box_strategy_type;
  106. static inline comparable_distance_segment_box_strategy_type get_comparable_distance_segment_box_strategy()
  107. {
  108. return comparable_distance_segment_box_strategy_type();
  109. }
  110. };
  111. namespace services
  112. {
  113. template <typename Geometry>
  114. struct default_strategy<Geometry, spherical_tag>
  115. {
  116. typedef spherical<> type;
  117. };
  118. template <typename Geometry>
  119. struct default_strategy<Geometry, spherical_polar_tag>
  120. {
  121. typedef spherical<> type;
  122. };
  123. template <typename Geometry>
  124. struct default_strategy<Geometry, spherical_equatorial_tag>
  125. {
  126. typedef spherical<> type;
  127. };
  128. template <typename Point1, typename Point2, typename CalculationType>
  129. struct from_strategy<within::spherical_winding<Point1, Point2, CalculationType> >
  130. {
  131. typedef strategy::index::spherical<CalculationType> type;
  132. static inline type get(within::spherical_winding<Point1, Point2, CalculationType> const&)
  133. {
  134. return type();
  135. }
  136. };
  137. // distance (MPt, MPt)
  138. template <typename RadiusType, typename CalculationType>
  139. struct from_strategy<distance::comparable::haversine<RadiusType, CalculationType> >
  140. {
  141. typedef strategy::index::spherical<CalculationType> type;
  142. static inline type get(distance::comparable::haversine<RadiusType, CalculationType> const&)
  143. {
  144. return type();
  145. }
  146. };
  147. // distance (MPt, Linear/Areal)
  148. template <typename CalculationType, typename PPStrategy>
  149. struct from_strategy<distance::comparable::cross_track<CalculationType, PPStrategy> >
  150. {
  151. typedef strategy::index::spherical<CalculationType> type;
  152. static inline type get(distance::comparable::cross_track<CalculationType, PPStrategy> const&)
  153. {
  154. return type();
  155. }
  156. };
  157. } // namespace services
  158. }}}} // namespace boost::geometry::strategy::index
  159. #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_INDEX_HPP