File indexing completed on 2025-01-18 09:36:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_GEOMETRY_STRATEGIES_SIMPLIFY_SPHERICAL_HPP
0011 #define BOOST_GEOMETRY_STRATEGIES_SIMPLIFY_SPHERICAL_HPP
0012
0013
0014 #include <boost/geometry/strategies/detail.hpp>
0015 #include <boost/geometry/strategies/distance/comparable.hpp>
0016 #include <boost/geometry/strategies/distance/detail.hpp>
0017 #include <boost/geometry/strategies/simplify/services.hpp>
0018
0019 #include <boost/geometry/strategies/agnostic/simplify_douglas_peucker.hpp>
0020 #include <boost/geometry/strategies/spherical/distance_haversine.hpp>
0021 #include <boost/geometry/strategies/spherical/distance_cross_track.hpp>
0022 #include <boost/geometry/strategies/spherical/point_in_point.hpp>
0023
0024 #include <boost/geometry/strategy/spherical/area.hpp>
0025
0026
0027 namespace boost { namespace geometry
0028 {
0029
0030 namespace strategies { namespace simplify
0031 {
0032
0033 template
0034 <
0035 typename RadiusTypeOrSphere = double,
0036 typename CalculationType = void
0037 >
0038 class spherical
0039 : public strategies::detail::spherical_base<RadiusTypeOrSphere>
0040 {
0041 using base_t = strategies::detail::spherical_base<RadiusTypeOrSphere>;
0042
0043 public:
0044 spherical() = default;
0045
0046 template <typename RadiusOrSphere>
0047 explicit spherical(RadiusOrSphere const& radius_or_sphere)
0048 : base_t(radius_or_sphere)
0049 {}
0050
0051
0052 template <typename Geometry>
0053 auto area(Geometry const&) const
0054 {
0055 return strategy::area::spherical
0056 <
0057 typename base_t::radius_type, CalculationType
0058 >(base_t::radius());
0059 }
0060
0061
0062 template <typename Geometry1, typename Geometry2>
0063 auto distance(Geometry1 const&, Geometry2 const&,
0064 distance::detail::enable_if_pp_t<Geometry1, Geometry2> * = nullptr) const
0065 {
0066 return strategy::distance::haversine
0067 <
0068 typename base_t::radius_type, CalculationType
0069 >(base_t::radius());
0070 }
0071
0072
0073 template <typename Geometry1, typename Geometry2>
0074 auto distance(Geometry1 const&, Geometry2 const&,
0075 distance::detail::enable_if_ps_t<Geometry1, Geometry2> * = nullptr) const
0076 {
0077 return strategy::distance::cross_track
0078 <
0079 CalculationType,
0080 strategy::distance::haversine<typename base_t::radius_type, CalculationType>
0081 >(base_t::radius());
0082 }
0083
0084
0085 template <typename Geometry1, typename Geometry2>
0086 static auto relate(Geometry1 const&, Geometry2 const&,
0087 std::enable_if_t
0088 <
0089 util::is_pointlike<Geometry1>::value
0090 && util::is_pointlike<Geometry2>::value
0091 > * = nullptr)
0092 {
0093 return strategy::within::spherical_point_point();
0094 }
0095 };
0096
0097
0098 namespace services
0099 {
0100
0101 template <typename Geometry>
0102 struct default_strategy<Geometry, spherical_equatorial_tag>
0103 {
0104 using type = strategies::simplify::spherical<>;
0105 };
0106
0107 template <typename P, typename CT, typename S>
0108 struct strategy_converter
0109 <
0110 strategy::simplify::douglas_peucker
0111 <
0112 P,
0113 strategy::distance::cross_track<CT, S>
0114 >
0115 >
0116 {
0117 template <typename Strategy>
0118 static auto get(Strategy const& )
0119 {
0120 return strategies::simplify::spherical<typename S::radius_type, CT>();
0121 }
0122 };
0123
0124 template <typename P, typename CT, typename S>
0125 struct strategy_converter
0126 <
0127 strategy::simplify::douglas_peucker
0128 <
0129 P,
0130 strategy::distance::comparable::cross_track<CT, S>
0131 >
0132 >
0133 {
0134 template <typename Strategy>
0135 static auto get(Strategy const& )
0136 {
0137 return strategies::distance::detail::comparable
0138 <
0139 strategies::simplify::spherical<typename S::radius_type, CT>
0140 >();
0141 }
0142 };
0143
0144
0145 }
0146
0147 }}
0148
0149 }}
0150
0151 #endif