File indexing completed on 2025-01-18 09:36:50
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #ifndef BOOST_GEOMETRY_STRATEGIES_DISTANCE_RESULT_HPP
0022 #define BOOST_GEOMETRY_STRATEGIES_DISTANCE_RESULT_HPP
0023
0024
0025 #include <boost/geometry/algorithms/detail/select_geometry_type.hpp>
0026 #include <boost/geometry/core/point_type.hpp>
0027 #include <boost/geometry/core/reverse_dispatch.hpp>
0028 #include <boost/geometry/strategies/default_strategy.hpp>
0029 #include <boost/geometry/strategies/detail.hpp>
0030 #include <boost/geometry/strategies/distance.hpp>
0031 #include <boost/geometry/strategies/distance/services.hpp>
0032 #include <boost/geometry/util/select_most_precise.hpp>
0033 #include <boost/geometry/util/sequence.hpp>
0034 #include <boost/geometry/util/type_traits.hpp>
0035
0036
0037 namespace boost { namespace geometry
0038 {
0039
0040
0041 namespace resolve_strategy
0042 {
0043
0044
0045
0046
0047
0048
0049 template
0050 <
0051 typename Geometry1, typename Geometry2, typename Strategy,
0052 bool IsUmbrella = strategies::detail::is_umbrella_strategy<Strategy>::value
0053 >
0054 struct distance_result_strategy2_type
0055 {
0056 typedef decltype(std::declval<Strategy>().distance(
0057 std::declval<Geometry1>(), std::declval<Geometry2>())) type;
0058 };
0059
0060 template <typename Geometry1, typename Geometry2, typename Strategy>
0061 struct distance_result_strategy2_type<Geometry1, Geometry2, Strategy, false>
0062 {
0063 typedef Strategy type;
0064 };
0065
0066 template
0067 <
0068 typename Geometry1, typename Geometry2, typename Strategy,
0069 bool Reverse = reverse_dispatch<Geometry1, Geometry2>::value
0070 >
0071 struct distance_result_strategy_type
0072 : distance_result_strategy2_type<Geometry1, Geometry2, Strategy>
0073 {};
0074
0075 template <typename Geometry1, typename Geometry2, typename Strategy>
0076 struct distance_result_strategy_type<Geometry1, Geometry2, Strategy, true>
0077 : distance_result_strategy_type<Geometry2, Geometry1, Strategy, false>
0078 {};
0079
0080
0081 template <typename Geometry1, typename Geometry2, typename Strategy>
0082 struct distance_result
0083 : strategy::distance::services::return_type
0084 <
0085 typename distance_result_strategy_type<Geometry1, Geometry2, Strategy>::type,
0086 typename point_type<Geometry1>::type,
0087 typename point_type<Geometry2>::type
0088 >
0089 {};
0090
0091 template <typename Geometry1, typename Geometry2>
0092 struct distance_result<Geometry1, Geometry2, default_strategy>
0093 : distance_result
0094 <
0095 Geometry1,
0096 Geometry2,
0097 typename strategies::distance::services::default_strategy
0098 <
0099 Geometry1, Geometry2
0100 >::type
0101 >
0102 {};
0103
0104
0105 }
0106
0107
0108 #ifndef DOXYGEN_NO_DETAIL
0109 namespace detail { namespace distance
0110 {
0111
0112 template <typename Strategy = geometry::default_strategy>
0113 struct more_precise_distance_result
0114 {
0115 template <typename Curr, typename Next>
0116 struct predicate
0117 : std::is_same
0118 <
0119 typename resolve_strategy::distance_result
0120 <
0121 typename util::sequence_element<0, Curr>::type,
0122 typename util::sequence_element<1, Curr>::type,
0123 Strategy
0124 >::type,
0125 typename geometry::select_most_precise
0126 <
0127 typename resolve_strategy::distance_result
0128 <
0129 typename util::sequence_element<0, Curr>::type,
0130 typename util::sequence_element<1, Curr>::type,
0131 Strategy
0132 >::type,
0133 typename resolve_strategy::distance_result
0134 <
0135 typename util::sequence_element<0, Next>::type,
0136 typename util::sequence_element<1, Next>::type,
0137 Strategy
0138 >::type
0139 >::type
0140 >
0141 {};
0142 };
0143
0144 }}
0145 #endif
0146
0147
0148 namespace resolve_dynamic
0149 {
0150
0151 template
0152 <
0153 typename Geometry1, typename Geometry2, typename Strategy,
0154 bool IsDynamicOrCollection = util::is_dynamic_geometry<Geometry1>::value
0155 || util::is_dynamic_geometry<Geometry2>::value
0156 || util::is_geometry_collection<Geometry1>::value
0157 || util::is_geometry_collection<Geometry2>::value
0158 >
0159 struct distance_result
0160 : resolve_strategy::distance_result
0161 <
0162 Geometry1,
0163 Geometry2,
0164 Strategy
0165 >
0166 {};
0167
0168
0169 template <typename Geometry1, typename Geometry2, typename Strategy>
0170 struct distance_result<Geometry1, Geometry2, Strategy, true>
0171 {
0172
0173
0174
0175
0176 using selected_types = typename detail::select_geometry_types
0177 <
0178 Geometry1, Geometry2,
0179 detail::distance::more_precise_distance_result<Strategy>::template predicate
0180 >::type;
0181
0182 using type = typename resolve_strategy::distance_result
0183 <
0184 typename util::sequence_element<0, selected_types>::type,
0185 typename util::sequence_element<1, selected_types>::type,
0186 Strategy
0187 >::type;
0188 };
0189
0190
0191 }
0192
0193
0194
0195
0196
0197
0198
0199
0200 template
0201 <
0202 typename Geometry1,
0203 typename Geometry2 = Geometry1,
0204 typename Strategy = void
0205 >
0206 struct distance_result
0207 : resolve_dynamic::distance_result<Geometry1, Geometry2, Strategy>
0208 {};
0209
0210
0211 template <typename Geometry1, typename Geometry2>
0212 struct distance_result<Geometry1, Geometry2, void>
0213 : distance_result<Geometry1, Geometry2, default_strategy>
0214 {};
0215
0216
0217 }}
0218
0219
0220 #endif