spherical.hpp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. // Boost.Geometry
  2. // Copyright (c) 2020-2022, Oracle and/or its affiliates.
  3. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  4. // Licensed under the Boost Software License version 1.0.
  5. // http://www.boost.org/users/license.html
  6. #ifndef BOOST_GEOMETRY_STRATEGIES_ENVELOPE_SPHERICAL_HPP
  7. #define BOOST_GEOMETRY_STRATEGIES_ENVELOPE_SPHERICAL_HPP
  8. #include <type_traits>
  9. #include <boost/geometry/strategy/spherical/envelope_box.hpp>
  10. #include <boost/geometry/strategy/spherical/envelope_boxes.hpp>
  11. #include <boost/geometry/strategy/spherical/envelope_multipoint.hpp>
  12. #include <boost/geometry/strategy/spherical/envelope_point.hpp>
  13. #include <boost/geometry/strategy/spherical/envelope_range.hpp>
  14. #include <boost/geometry/strategy/spherical/envelope_segment.hpp>
  15. #include <boost/geometry/strategies/envelope/services.hpp>
  16. #include <boost/geometry/strategies/expand/spherical.hpp>
  17. namespace boost { namespace geometry
  18. {
  19. namespace strategies { namespace envelope
  20. {
  21. #ifndef DOXYGEN_NO_DETAIL
  22. namespace detail
  23. {
  24. template <typename RadiusTypeOrSphere, typename CalculationType>
  25. struct spherical
  26. : strategies::expand::detail::spherical<RadiusTypeOrSphere, CalculationType>
  27. {
  28. spherical() = default;
  29. template <typename RadiusOrSphere>
  30. explicit spherical(RadiusOrSphere const& radius_or_sphere)
  31. : strategies::expand::detail::spherical<RadiusTypeOrSphere, CalculationType>(radius_or_sphere)
  32. {}
  33. template <typename Geometry, typename Box>
  34. static auto envelope(Geometry const&, Box const&,
  35. util::enable_if_point_t<Geometry> * = nullptr)
  36. {
  37. return strategy::envelope::spherical_point();
  38. }
  39. template <typename Geometry, typename Box>
  40. static auto envelope(Geometry const&, Box const&,
  41. util::enable_if_multi_point_t<Geometry> * = nullptr)
  42. {
  43. return strategy::envelope::spherical_multipoint();
  44. }
  45. template <typename Geometry, typename Box>
  46. static auto envelope(Geometry const&, Box const&,
  47. util::enable_if_box_t<Geometry> * = nullptr)
  48. {
  49. return strategy::envelope::spherical_box();
  50. }
  51. template <typename Geometry, typename Box>
  52. static auto envelope(Geometry const&, Box const&,
  53. util::enable_if_segment_t<Geometry> * = nullptr)
  54. {
  55. return strategy::envelope::spherical_segment<CalculationType>();
  56. }
  57. template <typename Geometry, typename Box>
  58. static auto envelope(Geometry const&, Box const&,
  59. util::enable_if_linestring_t<Geometry> * = nullptr)
  60. {
  61. return strategy::envelope::spherical_linestring<CalculationType>();
  62. }
  63. template <typename Geometry, typename Box>
  64. static auto envelope(Geometry const&, Box const&,
  65. std::enable_if_t
  66. <
  67. util::is_ring<Geometry>::value
  68. || util::is_polygon<Geometry>::value
  69. > * = nullptr)
  70. {
  71. return strategy::envelope::spherical_ring<CalculationType>();
  72. }
  73. template <typename Geometry, typename Box>
  74. static auto envelope(Geometry const&, Box const&,
  75. std::enable_if_t
  76. <
  77. util::is_multi_linestring<Geometry>::value
  78. || util::is_multi_polygon<Geometry>::value
  79. || util::is_geometry_collection<Geometry>::value
  80. > * = nullptr)
  81. {
  82. return strategy::envelope::spherical_boxes();
  83. }
  84. };
  85. } // namespace detail
  86. #endif // DOXYGEN_NO_DETAIL
  87. template <typename CalculationType = void>
  88. class spherical
  89. : public strategies::envelope::detail::spherical<void, CalculationType>
  90. {};
  91. namespace services
  92. {
  93. template <typename Geometry, typename Box>
  94. struct default_strategy<Geometry, Box, spherical_tag>
  95. {
  96. using type = strategies::envelope::spherical<>;
  97. };
  98. template <typename Geometry, typename Box>
  99. struct default_strategy<Geometry, Box, spherical_equatorial_tag>
  100. {
  101. using type = strategies::envelope::spherical<>;
  102. };
  103. template <typename Geometry, typename Box>
  104. struct default_strategy<Geometry, Box, spherical_polar_tag>
  105. {
  106. using type = strategies::envelope::spherical<>;
  107. };
  108. template <>
  109. struct strategy_converter<strategy::envelope::spherical_point>
  110. {
  111. static auto get(strategy::envelope::spherical_point const& )
  112. {
  113. return strategies::envelope::spherical<>();
  114. }
  115. };
  116. template <>
  117. struct strategy_converter<strategy::envelope::spherical_multipoint>
  118. {
  119. static auto get(strategy::envelope::spherical_multipoint const&)
  120. {
  121. return strategies::envelope::spherical<>();
  122. }
  123. };
  124. template <>
  125. struct strategy_converter<strategy::envelope::spherical_box>
  126. {
  127. static auto get(strategy::envelope::spherical_box const& )
  128. {
  129. return strategies::envelope::spherical<>();
  130. }
  131. };
  132. template <typename CT>
  133. struct strategy_converter<strategy::envelope::spherical_segment<CT> >
  134. {
  135. static auto get(strategy::envelope::spherical_segment<CT> const&)
  136. {
  137. return strategies::envelope::spherical<CT>();
  138. }
  139. };
  140. template <typename CT>
  141. struct strategy_converter<strategy::envelope::spherical<CT> >
  142. {
  143. static auto get(strategy::envelope::spherical<CT> const&)
  144. {
  145. return strategies::envelope::spherical<CT>();
  146. }
  147. };
  148. } // namespace services
  149. }} // namespace strategies::envelope
  150. }} // namespace boost::geometry
  151. #endif // BOOST_GEOMETRY_STRATEGIES_ENVELOPE_SPHERICAL_HPP