index.hpp 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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_GEOGRAPHIC_INDEX_HPP
  12. #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_INDEX_HPP
  13. #include <boost/geometry/strategies/geographic/distance.hpp>
  14. #include <boost/geometry/strategies/geographic/distance_andoyer.hpp> // backward compatibility
  15. #include <boost/geometry/strategies/geographic/distance_cross_track.hpp>
  16. #include <boost/geometry/strategies/geographic/distance_cross_track_point_box.hpp>
  17. #include <boost/geometry/strategies/geographic/distance_segment_box.hpp>
  18. #include <boost/geometry/strategies/geographic/distance_thomas.hpp> // backward compatibility
  19. #include <boost/geometry/strategies/geographic/distance_vincenty.hpp> // backward compatibility
  20. #include <boost/geometry/strategies/geographic/envelope_segment.hpp>
  21. #include <boost/geometry/strategies/geographic/expand_segment.hpp>
  22. #include <boost/geometry/strategies/geographic/intersection.hpp>
  23. #include <boost/geometry/strategies/geographic/point_in_poly_winding.hpp>
  24. #include <boost/geometry/strategies/spherical/index.hpp>
  25. namespace boost { namespace geometry { namespace strategy { namespace index
  26. {
  27. template
  28. <
  29. typename FormulaPolicy = strategy::andoyer,
  30. typename Spheroid = geometry::srs::spheroid<double>,
  31. typename CalculationType = void
  32. >
  33. struct geographic
  34. : spherical<CalculationType>
  35. {
  36. typedef geographic_tag cs_tag;
  37. typedef geometry::strategy::envelope::geographic_segment
  38. <
  39. FormulaPolicy, Spheroid, CalculationType
  40. > envelope_segment_strategy_type;
  41. inline envelope_segment_strategy_type get_envelope_segment_strategy() const
  42. {
  43. return envelope_segment_strategy_type(m_spheroid);
  44. }
  45. typedef geometry::strategy::expand::geographic_segment
  46. <
  47. FormulaPolicy, Spheroid, CalculationType
  48. > expand_segment_strategy_type;
  49. inline expand_segment_strategy_type get_expand_segment_strategy() const
  50. {
  51. return expand_segment_strategy_type(m_spheroid);
  52. }
  53. // used in equals(Seg, Seg) but only to get_point_in_point_strategy()
  54. typedef geometry::strategy::intersection::geographic_segments
  55. <
  56. FormulaPolicy,
  57. // If index::geographic formula is derived from intersection::geographic_segments
  58. // formula with different Order this may cause an inconsistency
  59. strategy::default_order<FormulaPolicy>::value,
  60. Spheroid,
  61. CalculationType
  62. > relate_segment_segment_strategy_type;
  63. inline relate_segment_segment_strategy_type get_relate_segment_segment_strategy() const
  64. {
  65. return relate_segment_segment_strategy_type(m_spheroid);
  66. }
  67. typedef geometry::strategy::distance::geographic
  68. <
  69. FormulaPolicy, Spheroid, CalculationType
  70. > comparable_distance_point_point_strategy_type;
  71. inline comparable_distance_point_point_strategy_type get_comparable_distance_point_point_strategy() const
  72. {
  73. return comparable_distance_point_point_strategy_type(m_spheroid);
  74. }
  75. typedef geometry::strategy::distance::geographic_cross_track_point_box
  76. <
  77. FormulaPolicy, Spheroid, CalculationType
  78. > comparable_distance_point_box_strategy_type;
  79. inline comparable_distance_point_box_strategy_type get_comparable_distance_point_box_strategy() const
  80. {
  81. return comparable_distance_point_box_strategy_type(m_spheroid);
  82. }
  83. typedef geometry::strategy::distance::geographic_cross_track
  84. <
  85. FormulaPolicy, Spheroid, CalculationType
  86. > comparable_distance_point_segment_strategy_type;
  87. inline comparable_distance_point_segment_strategy_type get_comparable_distance_point_segment_strategy() const
  88. {
  89. return comparable_distance_point_segment_strategy_type(m_spheroid);
  90. }
  91. typedef geometry::strategy::distance::geographic_segment_box
  92. <
  93. FormulaPolicy, Spheroid, CalculationType
  94. > comparable_distance_segment_box_strategy_type;
  95. inline comparable_distance_segment_box_strategy_type get_comparable_distance_segment_box_strategy() const
  96. {
  97. return comparable_distance_segment_box_strategy_type(m_spheroid);
  98. }
  99. geographic()
  100. : m_spheroid()
  101. {}
  102. explicit geographic(Spheroid const& spheroid)
  103. : m_spheroid(spheroid)
  104. {}
  105. public:
  106. Spheroid m_spheroid;
  107. };
  108. namespace services
  109. {
  110. template <typename Geometry>
  111. struct default_strategy<Geometry, geographic_tag>
  112. {
  113. typedef geographic<> type;
  114. };
  115. // within and relate (MPt, Mls/MPoly)
  116. template <typename Point1, typename Point2, typename Formula, typename Spheroid, typename CalculationType>
  117. struct from_strategy<within::geographic_winding<Point1, Point2, Formula, Spheroid, CalculationType> >
  118. {
  119. typedef strategy::index::geographic<Formula, Spheroid, CalculationType> type;
  120. static inline type get(within::geographic_winding<Point1, Point2, Formula, Spheroid, CalculationType> const& strategy)
  121. {
  122. return type(strategy.model());
  123. }
  124. };
  125. // distance (MPt, MPt)
  126. template <typename Formula, typename Spheroid, typename CalculationType>
  127. struct from_strategy<distance::geographic<Formula, Spheroid, CalculationType> >
  128. {
  129. typedef strategy::index::geographic<Formula, Spheroid, CalculationType> type;
  130. static inline type get(distance::geographic<Formula, Spheroid, CalculationType> const& strategy)
  131. {
  132. return type(strategy.model());
  133. }
  134. };
  135. template <typename Spheroid, typename CalculationType>
  136. struct from_strategy<distance::andoyer<Spheroid, CalculationType> >
  137. {
  138. typedef strategy::index::geographic<strategy::andoyer, Spheroid, CalculationType> type;
  139. static inline type get(distance::andoyer<Spheroid, CalculationType> const& strategy)
  140. {
  141. return type(strategy.model());
  142. }
  143. };
  144. template <typename Spheroid, typename CalculationType>
  145. struct from_strategy<distance::thomas<Spheroid, CalculationType> >
  146. {
  147. typedef strategy::index::geographic<strategy::thomas, Spheroid, CalculationType> type;
  148. static inline type get(distance::thomas<Spheroid, CalculationType> const& strategy)
  149. {
  150. return type(strategy.model());
  151. }
  152. };
  153. template <typename Spheroid, typename CalculationType>
  154. struct from_strategy<distance::vincenty<Spheroid, CalculationType> >
  155. {
  156. typedef strategy::index::geographic<strategy::vincenty, Spheroid, CalculationType> type;
  157. static inline type get(distance::vincenty<Spheroid, CalculationType> const& strategy)
  158. {
  159. return type(strategy.model());
  160. }
  161. };
  162. // distance (MPt, Linear/Areal)
  163. template <typename Formula, typename Spheroid, typename CalculationType>
  164. struct from_strategy<distance::geographic_cross_track<Formula, Spheroid, CalculationType> >
  165. {
  166. typedef strategy::index::geographic<Formula, Spheroid, CalculationType> type;
  167. static inline type get(distance::geographic_cross_track<Formula, Spheroid, CalculationType> const& strategy)
  168. {
  169. return type(strategy.model());
  170. }
  171. };
  172. } // namespace services
  173. }}}} // namespace boost::geometry::strategy::index
  174. #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_INDEX_HPP