spherical.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. // Boost.Geometry
  2. // Copyright (c) 2020-2021, 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_EXPAND_SPHERICAL_HPP
  7. #define BOOST_GEOMETRY_STRATEGIES_EXPAND_SPHERICAL_HPP
  8. #include <type_traits>
  9. #include <boost/geometry/strategy/spherical/expand_box.hpp>
  10. #include <boost/geometry/strategy/spherical/expand_point.hpp>
  11. #include <boost/geometry/strategy/spherical/expand_segment.hpp>
  12. #include <boost/geometry/strategies/detail.hpp>
  13. #include <boost/geometry/strategies/expand/services.hpp>
  14. namespace boost { namespace geometry
  15. {
  16. namespace strategies { namespace expand
  17. {
  18. #ifndef DOXYGEN_NO_DETAIL
  19. namespace detail
  20. {
  21. template <typename RadiusTypeOrSphere, typename CalculationType>
  22. struct spherical
  23. : strategies::detail::spherical_base<RadiusTypeOrSphere>
  24. {
  25. spherical() = default;
  26. template <typename RadiusOrSphere>
  27. explicit spherical(RadiusOrSphere const& radius_or_sphere)
  28. : strategies::detail::spherical_base<RadiusTypeOrSphere>(radius_or_sphere)
  29. {}
  30. template <typename Box, typename Geometry>
  31. static auto expand(Box const&, Geometry const&,
  32. typename util::enable_if_point_t<Geometry> * = nullptr)
  33. {
  34. return strategy::expand::spherical_point();
  35. }
  36. template <typename Box, typename Geometry>
  37. static auto expand(Box const&, Geometry const&,
  38. typename util::enable_if_box_t<Geometry> * = nullptr)
  39. {
  40. return strategy::expand::spherical_box();
  41. }
  42. template <typename Box, typename Geometry>
  43. static auto expand(Box const&, Geometry const&,
  44. typename util::enable_if_segment_t<Geometry> * = nullptr)
  45. {
  46. return strategy::expand::spherical_segment<CalculationType>();
  47. }
  48. };
  49. } // namespace detail
  50. #endif // DOXYGEN_NO_DETAIL
  51. template <typename CalculationType = void>
  52. class spherical
  53. : public strategies::expand::detail::spherical<void, CalculationType>
  54. {};
  55. namespace services
  56. {
  57. template <typename Box, typename Geometry>
  58. struct default_strategy<Box, Geometry, spherical_tag>
  59. {
  60. using type = strategies::expand::spherical<>;
  61. };
  62. template <typename Box, typename Geometry>
  63. struct default_strategy<Box, Geometry, spherical_equatorial_tag>
  64. {
  65. using type = strategies::expand::spherical<>;
  66. };
  67. template <typename Box, typename Geometry>
  68. struct default_strategy<Box, Geometry, spherical_polar_tag>
  69. {
  70. using type = strategies::expand::spherical<>;
  71. };
  72. template <>
  73. struct strategy_converter<strategy::expand::spherical_point>
  74. {
  75. static auto get(strategy::expand::spherical_point const& )
  76. {
  77. return strategies::expand::spherical<>();
  78. }
  79. };
  80. template <>
  81. struct strategy_converter<strategy::expand::spherical_box>
  82. {
  83. static auto get(strategy::expand::spherical_box const& )
  84. {
  85. return strategies::expand::spherical<>();
  86. }
  87. };
  88. template <typename CT>
  89. struct strategy_converter<strategy::expand::spherical_segment<CT> >
  90. {
  91. static auto get(strategy::expand::spherical_segment<CT> const&)
  92. {
  93. return strategies::expand::spherical<CT>();
  94. }
  95. };
  96. } // namespace services
  97. }} // namespace strategies::envelope
  98. }} // namespace boost::geometry
  99. #endif // BOOST_GEOMETRY_STRATEGIES_EXPAND_SPHERICAL_HPP