spherical.hpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. // Boost.Geometry
  2. // Copyright (c) 2020, 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.hpp>
  10. #include <boost/geometry/strategy/spherical/envelope_box.hpp>
  11. #include <boost/geometry/strategy/spherical/envelope_point.hpp>
  12. #include <boost/geometry/strategy/spherical/envelope_multipoint.hpp>
  13. #include <boost/geometry/strategy/spherical/envelope_segment.hpp>
  14. #include <boost/geometry/strategies/detail.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. template <typename Geometry, typename Box>
  29. static auto envelope(Geometry const&, Box const&,
  30. typename util::enable_if_point_t<Geometry> * = nullptr)
  31. {
  32. return strategy::envelope::spherical_point();
  33. }
  34. template <typename Geometry, typename Box>
  35. static auto envelope(Geometry const&, Box const&,
  36. typename util::enable_if_multi_point_t<Geometry> * = nullptr)
  37. {
  38. return strategy::envelope::spherical_multipoint();
  39. }
  40. template <typename Geometry, typename Box>
  41. static auto envelope(Geometry const&, Box const&,
  42. typename util::enable_if_box_t<Geometry> * = nullptr)
  43. {
  44. return strategy::envelope::spherical_box();
  45. }
  46. template <typename Geometry, typename Box>
  47. static auto envelope(Geometry const&, Box const&,
  48. typename util::enable_if_segment_t<Geometry> * = nullptr)
  49. {
  50. return strategy::envelope::spherical_segment<CalculationType>();
  51. }
  52. template <typename Geometry, typename Box>
  53. static auto envelope(Geometry const&, Box const&,
  54. typename util::enable_if_polysegmental_t<Geometry> * = nullptr)
  55. {
  56. return strategy::envelope::spherical<CalculationType>();
  57. }
  58. };
  59. } // namespace detail
  60. #endif // DOXYGEN_NO_DETAIL
  61. template <typename CalculationType = void>
  62. class spherical
  63. : public strategies::envelope::detail::spherical<void, CalculationType>
  64. {};
  65. namespace services
  66. {
  67. template <typename Geometry, typename Box>
  68. struct default_strategy<Geometry, Box, spherical_tag>
  69. {
  70. using type = strategies::envelope::spherical<>;
  71. };
  72. template <typename Geometry, typename Box>
  73. struct default_strategy<Geometry, Box, spherical_equatorial_tag>
  74. {
  75. using type = strategies::envelope::spherical<>;
  76. };
  77. template <typename Geometry, typename Box>
  78. struct default_strategy<Geometry, Box, spherical_polar_tag>
  79. {
  80. using type = strategies::envelope::spherical<>;
  81. };
  82. template <>
  83. struct strategy_converter<strategy::envelope::spherical_point>
  84. {
  85. static auto get(strategy::envelope::spherical_point const& )
  86. {
  87. return strategies::envelope::spherical<>();
  88. }
  89. };
  90. template <>
  91. struct strategy_converter<strategy::envelope::spherical_multipoint>
  92. {
  93. static auto get(strategy::envelope::spherical_multipoint const&)
  94. {
  95. return strategies::envelope::spherical<>();
  96. }
  97. };
  98. template <>
  99. struct strategy_converter<strategy::envelope::spherical_box>
  100. {
  101. static auto get(strategy::envelope::spherical_box const& )
  102. {
  103. return strategies::envelope::spherical<>();
  104. }
  105. };
  106. template <typename CT>
  107. struct strategy_converter<strategy::envelope::spherical_segment<CT> >
  108. {
  109. static auto get(strategy::envelope::spherical_segment<CT> const&)
  110. {
  111. return strategies::envelope::spherical<CT>();
  112. }
  113. };
  114. template <typename CT>
  115. struct strategy_converter<strategy::envelope::spherical<CT> >
  116. {
  117. static auto get(strategy::envelope::spherical<CT> const&)
  118. {
  119. return strategies::envelope::spherical<CT>();
  120. }
  121. };
  122. } // namespace services
  123. }} // namespace strategies::envelope
  124. }} // namespace boost::geometry
  125. #endif // BOOST_GEOMETRY_STRATEGIES_ENVELOPE_SPHERICAL_HPP