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_AREA_SPHERICAL_HPP
11 #define BOOST_GEOMETRY_STRATEGIES_AREA_SPHERICAL_HPP
12 
13 
14 #include <boost/geometry/strategy/spherical/area.hpp>
15 #include <boost/geometry/strategy/spherical/area_box.hpp>
16 
17 #include <boost/geometry/strategies/area/services.hpp>
18 #include <boost/geometry/strategies/detail.hpp>
19 
20 
21 namespace boost { namespace geometry
22 {
23 
24 namespace strategies { namespace area
25 {
26 
27 template
28 <
29     typename RadiusTypeOrSphere = double,
30     typename CalculationType = void
31 >
32 class spherical
33     : public strategies::detail::spherical_base<RadiusTypeOrSphere>
34 {
35     using base_t = strategies::detail::spherical_base<RadiusTypeOrSphere>;
36 
37 public:
spherical()38     spherical()
39         : base_t()
40     {}
41 
42     template <typename RadiusOrSphere>
spherical(RadiusOrSphere const & radius_or_sphere)43     explicit spherical(RadiusOrSphere const& radius_or_sphere)
44         : base_t(radius_or_sphere)
45     {}
46 
47     template <typename Geometry>
area(Geometry const &,std::enable_if_t<!util::is_box<Geometry>::value> * =nullptr) const48     auto area(Geometry const&,
49               std::enable_if_t<! util::is_box<Geometry>::value> * = nullptr) const
50     {
51         return strategy::area::spherical
52             <
53                 typename base_t::radius_type, CalculationType
54             >(base_t::m_radius);
55     }
56 
57     template <typename Geometry>
area(Geometry const &,std::enable_if_t<util::is_box<Geometry>::value> * =nullptr) const58     auto area(Geometry const&,
59               std::enable_if_t<util::is_box<Geometry>::value> * = nullptr) const
60     {
61         return strategy::area::spherical_box
62             <
63                 typename base_t::radius_type, CalculationType
64             >(base_t::m_radius);
65     }
66 };
67 
68 
69 namespace services
70 {
71 
72 template <typename Geometry>
73 struct default_strategy<Geometry, spherical_tag>
74 {
75     using type = strategies::area::spherical<>;
76 };
77 
78 template <typename Geometry>
79 struct default_strategy<Geometry, spherical_equatorial_tag>
80 {
81     using type = strategies::area::spherical<>;
82 };
83 
84 template <typename Geometry>
85 struct default_strategy<Geometry, spherical_polar_tag>
86 {
87     using type = strategies::area::spherical<>;
88 };
89 
90 
91 template <typename R, typename CT>
92 struct strategy_converter<strategy::area::spherical<R, CT> >
93 {
getboost::geometry::strategies::area::services::strategy_converter94     static auto get(strategy::area::spherical<R, CT> const& strategy)
95     {
96         return strategies::area::spherical<R, CT>(strategy.model());
97     }
98 };
99 
100 
101 } // namespace services
102 
103 }} // namespace strategies::area
104 
105 }} // namespace boost::geometry
106 
107 #endif // BOOST_GEOMETRY_STRATEGIES_AREA_SPHERICAL_HPP
108