File indexing completed on 2025-01-18 09:36:44
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_GEOMETRY_STRATEGIES_DISCRETE_DISTANCE_SPHERICAL_HPP
0011 #define BOOST_GEOMETRY_STRATEGIES_DISCRETE_DISTANCE_SPHERICAL_HPP
0012
0013
0014 #include <boost/geometry/strategies/detail.hpp>
0015 #include <boost/geometry/strategies/discrete_distance/services.hpp>
0016 #include <boost/geometry/strategies/distance/comparable.hpp>
0017 #include <boost/geometry/strategies/distance/detail.hpp>
0018
0019 #include <boost/geometry/strategies/spherical/distance_haversine.hpp>
0020
0021
0022 namespace boost { namespace geometry
0023 {
0024
0025 namespace strategies { namespace discrete_distance
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
0057
0058 namespace services
0059 {
0060
0061 template <typename Geometry1, typename Geometry2>
0062 struct default_strategy<Geometry1, Geometry2, spherical_equatorial_tag, spherical_equatorial_tag>
0063 {
0064 using type = strategies::discrete_distance::spherical<>;
0065 };
0066
0067
0068 template <typename R, typename CT>
0069 struct strategy_converter<strategy::distance::haversine<R, CT> >
0070 {
0071 static auto get(strategy::distance::haversine<R, CT> const& s)
0072 {
0073 return strategies::discrete_distance::spherical<R, CT>(s.radius());
0074 }
0075 };
0076
0077 template <typename R, typename CT>
0078 struct strategy_converter<strategy::distance::comparable::haversine<R, CT> >
0079 {
0080 static auto get(strategy::distance::comparable::haversine<R, CT> const& s)
0081 {
0082 return strategies::distance::detail::make_comparable(
0083 strategies::discrete_distance::spherical<R, CT>(s.radius()));
0084 }
0085 };
0086
0087 }
0088
0089 }}
0090
0091 }}
0092
0093 #endif