3 // Copyright (c) 2021, Oracle and/or its affiliates.
5 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
7 // Licensed under the Boost Software License version 1.0.
8 // http://www.boost.org/users/license.html
10 #ifndef BOOST_GEOMETRY_STRATEGIES_LINE_INTERPOLATE_SPHERICAL_HPP
11 #define BOOST_GEOMETRY_STRATEGIES_LINE_INTERPOLATE_SPHERICAL_HPP
14 #include <boost/geometry/strategies/detail.hpp>
15 #include <boost/geometry/strategies/distance/detail.hpp>
16 #include <boost/geometry/strategies/line_interpolate/services.hpp>
18 #include <boost/geometry/strategies/spherical/distance_haversine.hpp>
19 #include <boost/geometry/strategies/spherical/line_interpolate.hpp>
22 namespace boost { namespace geometry
25 namespace strategies { namespace line_interpolate
30 typename RadiusTypeOrSphere = double,
31 typename CalculationType = void
34 : public strategies::detail::spherical_base<RadiusTypeOrSphere>
36 using base_t = strategies::detail::spherical_base<RadiusTypeOrSphere>;
39 spherical() = default;
41 template <typename RadiusOrSphere>
42 explicit spherical(RadiusOrSphere const& radius_or_sphere)
43 : base_t(radius_or_sphere)
46 template <typename Geometry1, typename Geometry2>
47 auto distance(Geometry1 const&, Geometry2 const&,
48 distance::detail::enable_if_pp_t<Geometry1, Geometry2> * = nullptr) const
50 return strategy::distance::haversine
52 typename base_t::radius_type, CalculationType
56 template <typename Geometry>
57 auto line_interpolate(Geometry const&) const
59 // NOTE: radius is ignored, but pass it just in case
60 return strategy::line_interpolate::spherical<CalculationType>(base_t::radius());
68 template <typename Geometry>
69 struct default_strategy<Geometry, spherical_equatorial_tag>
71 using type = strategies::line_interpolate::spherical<>;
75 template <typename CT, typename DS>
76 struct strategy_converter<strategy::line_interpolate::spherical<CT, DS> >
78 static auto get(strategy::line_interpolate::spherical<CT, DS> const& s)
80 typedef typename strategy::line_interpolate::spherical<CT, DS>::radius_type radius_type;
81 return strategies::line_interpolate::spherical<radius_type, CT>(s.radius());
85 } // namespace services
87 }} // namespace strategies::line_interpolate
89 }} // namespace boost::geometry
91 #endif // BOOST_GEOMETRY_STRATEGIES_LINE_INTERPOLATE_SPHERICAL_HPP