File indexing completed on 2025-01-18 09:36:47
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_GEOMETRY_STRATEGIES_LENGTH_SPHERICAL_HPP
0011 #define BOOST_GEOMETRY_STRATEGIES_LENGTH_SPHERICAL_HPP
0012
0013
0014 #include <boost/geometry/strategies/detail.hpp>
0015 #include <boost/geometry/strategies/distance/detail.hpp>
0016 #include <boost/geometry/strategies/length/services.hpp>
0017
0018 #include <boost/geometry/strategies/spherical/distance_haversine.hpp>
0019
0020
0021 namespace boost { namespace geometry
0022 {
0023
0024 namespace strategies { namespace length
0025 {
0026
0027 template
0028 <
0029 typename RadiusTypeOrSphere = double,
0030 typename CalculationType = void
0031 >
0032 class spherical
0033 : public strategies::detail::spherical_base<RadiusTypeOrSphere>
0034 {
0035 using base_t = strategies::detail::spherical_base<RadiusTypeOrSphere>;
0036
0037 public:
0038 spherical() = default;
0039
0040 template <typename RadiusOrSphere>
0041 explicit spherical(RadiusOrSphere const& radius_or_sphere)
0042 : base_t(radius_or_sphere)
0043 {}
0044
0045 template <typename Geometry1, typename Geometry2>
0046 auto distance(Geometry1 const&, Geometry2 const&,
0047 distance::detail::enable_if_pp_t<Geometry1, Geometry2> * = nullptr) const
0048 {
0049 return strategy::distance::haversine
0050 <
0051 typename base_t::radius_type, CalculationType
0052 >(base_t::radius());
0053 }
0054 };
0055
0056
0057 namespace services
0058 {
0059
0060 template <typename Geometry>
0061 struct default_strategy<Geometry, spherical_equatorial_tag>
0062 {
0063 using type = strategies::length::spherical<>;
0064 };
0065
0066
0067 template <typename R, typename CT>
0068 struct strategy_converter<strategy::distance::haversine<R, CT> >
0069 {
0070 static auto get(strategy::distance::haversine<R, CT> const& s)
0071 {
0072 return strategies::length::spherical<R, CT>(s.radius());
0073 }
0074 };
0075
0076
0077 }
0078
0079 }}
0080
0081 }}
0082
0083 #endif