File indexing completed on 2025-01-18 09:36:44
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_GEOMETRY_STRATEGIES_DISTANCE_BACKWARD_COMPATIBILITY_HPP
0011 #define BOOST_GEOMETRY_STRATEGIES_DISTANCE_BACKWARD_COMPATIBILITY_HPP
0012
0013
0014 #include <boost/geometry/strategies/distance/cartesian.hpp>
0015 #include <boost/geometry/strategies/distance/comparable.hpp>
0016 #include <boost/geometry/strategies/distance/detail.hpp>
0017 #include <boost/geometry/strategies/distance/geographic.hpp>
0018 #include <boost/geometry/strategies/distance/spherical.hpp>
0019
0020
0021 namespace boost { namespace geometry
0022 {
0023
0024 namespace strategies { namespace distance
0025 {
0026
0027 #ifndef DOXYGEN_NO_DETAIL
0028 namespace detail
0029 {
0030
0031 template
0032 <
0033 typename Strategy,
0034 typename CSTag,
0035 typename StrategyTag = typename strategy::distance::services::tag<Strategy>::type
0036 >
0037 struct custom_strategy
0038 {
0039 BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
0040 "Not implemented for this Strategy.",
0041 Strategy);
0042 };
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057 template <typename Strategy>
0058 struct custom_strategy<Strategy, cartesian_tag, strategy_tag_distance_point_point>
0059 : cartesian<>
0060 {
0061 custom_strategy(Strategy const& strategy)
0062 : m_strategy(strategy)
0063 {}
0064
0065 template <typename Geometry1, typename Geometry2>
0066 auto distance(Geometry1 const&, Geometry2 const&,
0067 enable_if_pp_t<Geometry1, Geometry2> * = nullptr) const
0068 {
0069 return m_strategy;
0070 }
0071
0072 template <typename Geometry1, typename Geometry2>
0073 auto distance(Geometry1 const&, Geometry2 const&,
0074 enable_if_ps_t<Geometry1, Geometry2> * = nullptr) const
0075 {
0076 return strategy::distance::projected_point<void, Strategy>();
0077 }
0078
0079 template <typename Geometry1, typename Geometry2>
0080 auto distance(Geometry1 const&, Geometry2 const&,
0081 enable_if_pb_t<Geometry1, Geometry2> * = nullptr) const
0082 {
0083 return strategy::distance::pythagoras_point_box<>();
0084 }
0085
0086 template <typename Geometry1, typename Geometry2>
0087 auto distance(Geometry1 const&, Geometry2 const&,
0088 enable_if_sb_t<Geometry1, Geometry2> * = nullptr) const
0089 {
0090 return strategy::distance::cartesian_segment_box<void, Strategy>();
0091 }
0092
0093 template <typename Geometry1, typename Geometry2>
0094 auto distance(Geometry1 const&, Geometry2 const&,
0095 enable_if_bb_t<Geometry1, Geometry2> * = nullptr) const
0096 {
0097 return strategy::distance::pythagoras_box_box<>();
0098 }
0099
0100 private:
0101 Strategy const& m_strategy;
0102 };
0103
0104 template <typename Strategy>
0105 struct custom_strategy<Strategy, spherical_tag, strategy_tag_distance_point_point>
0106 : detail::spherical<void, void>
0107 {
0108 custom_strategy(Strategy const& strategy)
0109 : m_strategy(strategy)
0110 {}
0111
0112 template <typename Geometry1, typename Geometry2>
0113 auto distance(Geometry1 const&, Geometry2 const&,
0114 enable_if_pp_t<Geometry1, Geometry2> * = nullptr) const
0115 {
0116 return m_strategy;
0117 }
0118
0119 template <typename Geometry1, typename Geometry2>
0120 auto distance(Geometry1 const&, Geometry2 const&,
0121 enable_if_ps_t<Geometry1, Geometry2> * = nullptr) const
0122 {
0123 return strategy::distance::cross_track<void, Strategy>(m_strategy);
0124 }
0125
0126 template <typename Geometry1, typename Geometry2>
0127 auto distance(Geometry1 const&, Geometry2 const&,
0128 enable_if_pb_t<Geometry1, Geometry2> * = nullptr) const
0129 {
0130 return strategy::distance::cross_track_point_box<void, Strategy>(m_strategy);
0131 }
0132
0133 template <typename Geometry1, typename Geometry2>
0134 auto distance(Geometry1 const&, Geometry2 const&,
0135 enable_if_sb_t<Geometry1, Geometry2> * = nullptr) const
0136 {
0137 return strategy::distance::spherical_segment_box<void, Strategy>(m_strategy);
0138 }
0139
0140 template <typename Geometry1, typename Geometry2>
0141 auto distance(Geometry1 const&, Geometry2 const&,
0142 enable_if_bb_t<Geometry1, Geometry2> * = nullptr) const
0143 {
0144 return strategy::distance::cross_track_box_box<void, Strategy>(m_strategy);
0145 }
0146
0147 private:
0148 Strategy const& m_strategy;
0149 };
0150
0151 template <typename Strategy>
0152 struct custom_strategy<Strategy, geographic_tag, strategy_tag_distance_point_point>
0153 : geographic<>
0154 {
0155 custom_strategy(Strategy const& strategy)
0156 : m_strategy(strategy)
0157 {}
0158
0159 template <typename Geometry1, typename Geometry2>
0160 auto distance(Geometry1 const&, Geometry2 const&,
0161 enable_if_pp_t<Geometry1, Geometry2> * = nullptr) const
0162 {
0163 return m_strategy;
0164 }
0165
0166 template <typename Geometry1, typename Geometry2>
0167 auto distance(Geometry1 const&, Geometry2 const&,
0168 enable_if_ps_t<Geometry1, Geometry2> * = nullptr) const
0169 {
0170 return strategy::distance::geographic_cross_track<>();
0171 }
0172
0173 template <typename Geometry1, typename Geometry2>
0174 auto distance(Geometry1 const&, Geometry2 const&,
0175 enable_if_pb_t<Geometry1, Geometry2> * = nullptr) const
0176 {
0177 return strategy::distance::geographic_cross_track_point_box<>();
0178 }
0179
0180 template <typename Geometry1, typename Geometry2>
0181 auto distance(Geometry1 const&, Geometry2 const&,
0182 enable_if_sb_t<Geometry1, Geometry2> * = nullptr) const
0183 {
0184 return strategy::distance::geographic_segment_box<>();
0185 }
0186
0187 template <typename Geometry1, typename Geometry2>
0188 auto distance(Geometry1 const&, Geometry2 const&,
0189 enable_if_bb_t<Geometry1, Geometry2> * = nullptr) const
0190 {
0191 return strategy::distance::geographic_cross_track_box_box<>();
0192 }
0193
0194 private:
0195 Strategy const& m_strategy;
0196 };
0197
0198 }
0199 #endif
0200
0201 namespace services
0202 {
0203
0204 template <typename Geometry1, typename Geometry2, typename Strategy>
0205 struct custom_strategy_converter<Geometry1, Geometry2, Strategy, cartesian_tag, cartesian_tag>
0206 {
0207 static auto get(Strategy const& strategy)
0208 {
0209 return detail::custom_strategy<Strategy, cartesian_tag>(strategy);
0210 }
0211 };
0212
0213 template <typename Geometry1, typename Geometry2, typename Strategy>
0214 struct custom_strategy_converter<Geometry1, Geometry2, Strategy, spherical_equatorial_tag, spherical_equatorial_tag>
0215 {
0216 static auto get(Strategy const& strategy)
0217 {
0218 return detail::custom_strategy<Strategy, spherical_tag>(strategy);
0219 }
0220 };
0221
0222 template <typename Geometry1, typename Geometry2, typename Strategy>
0223 struct custom_strategy_converter<Geometry1, Geometry2, Strategy, geographic_tag, geographic_tag>
0224 {
0225 static auto get(Strategy const& strategy)
0226 {
0227 return detail::custom_strategy<Strategy, geographic_tag>(strategy);
0228 }
0229 };
0230
0231
0232 }
0233
0234 }}
0235
0236 }}
0237
0238 #endif