Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:36:47

0001 // Boost.Geometry
0002 
0003 // Copyright (c) 2021, Oracle and/or its affiliates.
0004 
0005 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0006 
0007 // Licensed under the Boost Software License version 1.0.
0008 // http://www.boost.org/users/license.html
0009 
0010 #ifndef BOOST_GEOMETRY_STRATEGIES_LINE_INTERPOLATE_SPHERICAL_HPP
0011 #define BOOST_GEOMETRY_STRATEGIES_LINE_INTERPOLATE_SPHERICAL_HPP
0012 
0013 
0014 #include <boost/geometry/strategies/detail.hpp>
0015 #include <boost/geometry/strategies/distance/detail.hpp>
0016 #include <boost/geometry/strategies/line_interpolate/services.hpp>
0017 
0018 #include <boost/geometry/strategies/spherical/distance_haversine.hpp>
0019 #include <boost/geometry/strategies/spherical/line_interpolate.hpp>
0020 
0021 
0022 namespace boost { namespace geometry
0023 {
0024 
0025 namespace strategies { namespace line_interpolate
0026 {
0027 
0028 template
0029 <
0030     typename RadiusTypeOrSphere = double,
0031     typename CalculationType = void
0032 >
0033 class spherical
0034     : public strategies::detail::spherical_base<RadiusTypeOrSphere>
0035 {
0036     using base_t = strategies::detail::spherical_base<RadiusTypeOrSphere>;
0037 
0038 public:
0039     spherical() = default;
0040 
0041     template <typename RadiusOrSphere>
0042     explicit spherical(RadiusOrSphere const& radius_or_sphere)
0043         : base_t(radius_or_sphere)
0044     {}
0045 
0046     template <typename Geometry1, typename Geometry2>
0047     auto distance(Geometry1 const&, Geometry2 const&,
0048                   distance::detail::enable_if_pp_t<Geometry1, Geometry2> * = nullptr) const
0049     {
0050         return strategy::distance::haversine
0051                 <
0052                     typename base_t::radius_type, CalculationType
0053                 >(base_t::radius());
0054     }
0055 
0056     template <typename Geometry>
0057     auto line_interpolate(Geometry const&) const
0058     {
0059         // NOTE: radius is ignored, but pass it just in case
0060         return strategy::line_interpolate::spherical<CalculationType>(base_t::radius());
0061     }
0062 };
0063 
0064 
0065 namespace services
0066 {
0067 
0068 template <typename Geometry>
0069 struct default_strategy<Geometry, spherical_equatorial_tag>
0070 {
0071     using type = strategies::line_interpolate::spherical<>;
0072 };
0073 
0074 
0075 template <typename CT, typename DS>
0076 struct strategy_converter<strategy::line_interpolate::spherical<CT, DS> >
0077 {
0078     static auto get(strategy::line_interpolate::spherical<CT, DS> const& s)
0079     {
0080         typedef typename strategy::line_interpolate::spherical<CT, DS>::radius_type radius_type;
0081         return strategies::line_interpolate::spherical<radius_type, CT>(s.radius());
0082     }
0083 };
0084 
0085 } // namespace services
0086 
0087 }} // namespace strategies::line_interpolate
0088 
0089 }} // namespace boost::geometry
0090 
0091 #endif // BOOST_GEOMETRY_STRATEGIES_LINE_INTERPOLATE_SPHERICAL_HPP