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_CARTESIAN_HPP
0011 #define BOOST_GEOMETRY_STRATEGIES_DISTANCE_CARTESIAN_HPP
0012
0013
0014
0015
0016 #include <boost/geometry/strategies/cartesian/distance_projected_point.hpp>
0017 #include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp>
0018 #include <boost/geometry/strategies/cartesian/distance_pythagoras_box_box.hpp>
0019 #include <boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp>
0020 #include <boost/geometry/strategies/cartesian/distance_segment_box.hpp>
0021
0022 #include <boost/geometry/strategies/detail.hpp>
0023 #include <boost/geometry/strategies/distance/comparable.hpp>
0024 #include <boost/geometry/strategies/distance/detail.hpp>
0025 #include <boost/geometry/strategies/distance/services.hpp>
0026
0027
0028 #include <boost/geometry/strategies/relate/cartesian.hpp>
0029
0030 #include <boost/geometry/util/type_traits.hpp>
0031
0032
0033 namespace boost { namespace geometry
0034 {
0035
0036 namespace strategies { namespace distance
0037 {
0038
0039 template <typename CalculationType = void>
0040 struct cartesian
0041 : public strategies::relate::cartesian<CalculationType>
0042 {
0043 template <typename Geometry1, typename Geometry2>
0044 static auto distance(Geometry1 const&, Geometry2 const&,
0045 detail::enable_if_pp_t<Geometry1, Geometry2> * = nullptr)
0046 {
0047 return strategy::distance::pythagoras<CalculationType>();
0048 }
0049
0050 template <typename Geometry1, typename Geometry2>
0051 static auto distance(Geometry1 const&, Geometry2 const&,
0052 detail::enable_if_ps_t<Geometry1, Geometry2> * = nullptr)
0053 {
0054 return strategy::distance::projected_point
0055 <
0056 CalculationType,
0057 strategy::distance::pythagoras<CalculationType>
0058 >();
0059 }
0060
0061 template <typename Geometry1, typename Geometry2>
0062 static auto distance(Geometry1 const&, Geometry2 const&,
0063 detail::enable_if_pb_t<Geometry1, Geometry2> * = nullptr)
0064 {
0065 return strategy::distance::pythagoras_point_box<CalculationType>();
0066 }
0067
0068 template <typename Geometry1, typename Geometry2>
0069 static auto distance(Geometry1 const&, Geometry2 const&,
0070 detail::enable_if_sb_t<Geometry1, Geometry2> * = nullptr)
0071 {
0072 return strategy::distance::cartesian_segment_box
0073 <
0074 CalculationType,
0075 strategy::distance::pythagoras<CalculationType>
0076 >();
0077 }
0078
0079 template <typename Geometry1, typename Geometry2>
0080 static auto distance(Geometry1 const&, Geometry2 const&,
0081 detail::enable_if_bb_t<Geometry1, Geometry2> * = nullptr)
0082 {
0083 return strategy::distance::pythagoras_box_box<CalculationType>();
0084 }
0085 };
0086
0087
0088 namespace services
0089 {
0090
0091 template <typename Geometry1, typename Geometry2>
0092 struct default_strategy<Geometry1, Geometry2, cartesian_tag, cartesian_tag>
0093 {
0094 using type = strategies::distance::cartesian<>;
0095 };
0096
0097
0098 template <typename CT>
0099 struct strategy_converter<strategy::distance::pythagoras<CT> >
0100 {
0101 template <typename S>
0102 static auto get(S const&)
0103 {
0104 return strategies::distance::cartesian<CT>();
0105 }
0106 };
0107
0108 template <typename CT, typename PPS>
0109 struct strategy_converter<strategy::distance::projected_point<CT, PPS> >
0110 : strategy_converter<PPS>
0111 {};
0112
0113 template <typename CT>
0114 struct strategy_converter<strategy::distance::pythagoras_point_box<CT> >
0115 {
0116 static auto get(strategy::distance::pythagoras_point_box<CT> const&)
0117 {
0118 return strategies::distance::cartesian<CT>();
0119 }
0120 };
0121
0122 template <typename CT, typename PPS>
0123 struct strategy_converter<strategy::distance::cartesian_segment_box<CT, PPS> >
0124 : strategy_converter<PPS>
0125 {};
0126
0127 template <typename CT>
0128 struct strategy_converter<strategy::distance::pythagoras_box_box<CT> >
0129 {
0130 static auto get(strategy::distance::pythagoras_box_box<CT> const&)
0131 {
0132 return strategies::distance::cartesian<CT>();
0133 }
0134 };
0135
0136
0137 template <typename CT>
0138 struct strategy_converter<strategy::distance::comparable::pythagoras<CT> >
0139 {
0140 template <typename S>
0141 static auto get(S const&)
0142 {
0143 return strategies::distance::detail::make_comparable(
0144 strategies::distance::cartesian<CT>());
0145 }
0146 };
0147
0148 template <typename CT>
0149 struct strategy_converter<strategy::distance::comparable::pythagoras_point_box<CT> >
0150 {
0151 static auto get(strategy::distance::comparable::pythagoras_point_box<CT> const&)
0152 {
0153 return strategies::distance::detail::make_comparable(
0154 strategies::distance::cartesian<CT>());
0155 }
0156 };
0157
0158 template <typename CT>
0159 struct strategy_converter<strategy::distance::comparable::pythagoras_box_box<CT> >
0160 {
0161 static auto get(strategy::distance::comparable::pythagoras_box_box<CT> const&)
0162 {
0163 return strategies::distance::detail::make_comparable(
0164 strategies::distance::cartesian<CT>());
0165 }
0166 };
0167
0168
0169 }
0170
0171 }}
0172
0173 }}
0174
0175 #endif