1 // Boost.Geometry
2 
3 // Copyright (c) 2020-2021, Oracle and/or its affiliates.
4 
5 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
6 
7 // Licensed under the Boost Software License version 1.0.
8 // http://www.boost.org/users/license.html
9 
10 #ifndef BOOST_GEOMETRY_STRATEGIES_EXPAND_SPHERICAL_HPP
11 #define BOOST_GEOMETRY_STRATEGIES_EXPAND_SPHERICAL_HPP
12 
13 
14 #include <type_traits>
15 
16 #include <boost/geometry/strategy/spherical/expand_box.hpp>
17 #include <boost/geometry/strategy/spherical/expand_point.hpp>
18 #include <boost/geometry/strategy/spherical/expand_segment.hpp>
19 
20 #include <boost/geometry/strategies/detail.hpp>
21 #include <boost/geometry/strategies/expand/services.hpp>
22 
23 
24 namespace boost { namespace geometry
25 {
26 
27 
28 namespace strategies { namespace expand
29 {
30 
31 
32 #ifndef DOXYGEN_NO_DETAIL
33 namespace detail
34 {
35 
36 
37 template <typename RadiusTypeOrSphere, typename CalculationType>
38 struct spherical
39     : strategies::detail::spherical_base<RadiusTypeOrSphere>
40 {
41     spherical() = default;
42 
43     template <typename RadiusOrSphere>
sphericalboost::geometry::strategies::expand::detail::spherical44     explicit spherical(RadiusOrSphere const& radius_or_sphere)
45         : strategies::detail::spherical_base<RadiusTypeOrSphere>(radius_or_sphere)
46     {}
47 
48     template <typename Box, typename Geometry>
expandboost::geometry::strategies::expand::detail::spherical49     static auto expand(Box const&, Geometry const&,
50                        typename util::enable_if_point_t<Geometry> * = nullptr)
51     {
52         return strategy::expand::spherical_point();
53     }
54 
55     template <typename Box, typename Geometry>
expandboost::geometry::strategies::expand::detail::spherical56     static auto expand(Box const&, Geometry const&,
57                        typename util::enable_if_box_t<Geometry> * = nullptr)
58     {
59         return strategy::expand::spherical_box();
60     }
61 
62     template <typename Box, typename Geometry>
expandboost::geometry::strategies::expand::detail::spherical63     static auto expand(Box const&, Geometry const&,
64                        typename util::enable_if_segment_t<Geometry> * = nullptr)
65     {
66         return strategy::expand::spherical_segment<CalculationType>();
67     }
68 };
69 
70 
71 } // namespace detail
72 #endif // DOXYGEN_NO_DETAIL
73 
74 
75 template <typename CalculationType = void>
76 class spherical
77     : public strategies::expand::detail::spherical<void, CalculationType>
78 {};
79 
80 
81 namespace services
82 {
83 
84 template <typename Box, typename Geometry>
85 struct default_strategy<Box, Geometry, spherical_tag>
86 {
87     using type = strategies::expand::spherical<>;
88 };
89 
90 template <typename Box, typename Geometry>
91 struct default_strategy<Box, Geometry, spherical_equatorial_tag>
92 {
93     using type = strategies::expand::spherical<>;
94 };
95 
96 template <typename Box, typename Geometry>
97 struct default_strategy<Box, Geometry, spherical_polar_tag>
98 {
99     using type = strategies::expand::spherical<>;
100 };
101 
102 
103 template <>
104 struct strategy_converter<strategy::expand::spherical_point>
105 {
getboost::geometry::strategies::expand::services::strategy_converter106     static auto get(strategy::expand::spherical_point const& )
107     {
108         return strategies::expand::spherical<>();
109     }
110 };
111 
112 template <>
113 struct strategy_converter<strategy::expand::spherical_box>
114 {
getboost::geometry::strategies::expand::services::strategy_converter115     static auto get(strategy::expand::spherical_box const& )
116     {
117         return strategies::expand::spherical<>();
118     }
119 };
120 
121 template <typename CT>
122 struct strategy_converter<strategy::expand::spherical_segment<CT> >
123 {
getboost::geometry::strategies::expand::services::strategy_converter124     static auto get(strategy::expand::spherical_segment<CT> const&)
125     {
126         return strategies::expand::spherical<CT>();
127     }
128 };
129 
130 
131 } // namespace services
132 
133 }} // namespace strategies::envelope
134 
135 }} // namespace boost::geometry
136 
137 #endif // BOOST_GEOMETRY_STRATEGIES_EXPAND_SPHERICAL_HPP
138