Chris@102
|
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
|
Chris@102
|
2
|
Chris@102
|
3 // Copyright (c) 2014-2015, Oracle and/or its affiliates.
|
Chris@102
|
4
|
Chris@102
|
5 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
Chris@102
|
6
|
Chris@102
|
7 // Licensed under the Boost Software License version 1.0.
|
Chris@102
|
8 // http://www.boost.org/users/license.html
|
Chris@102
|
9
|
Chris@102
|
10 #ifndef BOOST_GEOMETRY_STRATEGIES_COMPARABLE_DISTANCE_RESULT_HPP
|
Chris@102
|
11 #define BOOST_GEOMETRY_STRATEGIES_COMPARABLE_DISTANCE_RESULT_HPP
|
Chris@102
|
12
|
Chris@102
|
13 #include <boost/mpl/always.hpp>
|
Chris@102
|
14 #include <boost/mpl/bool.hpp>
|
Chris@102
|
15 #include <boost/mpl/vector.hpp>
|
Chris@102
|
16
|
Chris@102
|
17 #include <boost/variant/variant_fwd.hpp>
|
Chris@102
|
18
|
Chris@102
|
19 #include <boost/geometry/core/point_type.hpp>
|
Chris@102
|
20
|
Chris@102
|
21 #include <boost/geometry/strategies/default_strategy.hpp>
|
Chris@102
|
22 #include <boost/geometry/strategies/distance.hpp>
|
Chris@102
|
23
|
Chris@102
|
24 #include <boost/geometry/util/compress_variant.hpp>
|
Chris@102
|
25 #include <boost/geometry/util/transform_variant.hpp>
|
Chris@102
|
26 #include <boost/geometry/util/combine_if.hpp>
|
Chris@102
|
27
|
Chris@102
|
28 #include <boost/geometry/algorithms/detail/distance/default_strategies.hpp>
|
Chris@102
|
29
|
Chris@102
|
30
|
Chris@102
|
31 namespace boost { namespace geometry
|
Chris@102
|
32 {
|
Chris@102
|
33
|
Chris@102
|
34 namespace resolve_strategy
|
Chris@102
|
35 {
|
Chris@102
|
36
|
Chris@102
|
37 template <typename Geometry1, typename Geometry2, typename Strategy>
|
Chris@102
|
38 struct comparable_distance_result
|
Chris@102
|
39 : strategy::distance::services::return_type
|
Chris@102
|
40 <
|
Chris@102
|
41 typename strategy::distance::services::comparable_type
|
Chris@102
|
42 <
|
Chris@102
|
43 Strategy
|
Chris@102
|
44 >::type,
|
Chris@102
|
45 typename point_type<Geometry1>::type,
|
Chris@102
|
46 typename point_type<Geometry2>::type
|
Chris@102
|
47 >
|
Chris@102
|
48 {};
|
Chris@102
|
49
|
Chris@102
|
50 template <typename Geometry1, typename Geometry2>
|
Chris@102
|
51 struct comparable_distance_result<Geometry1, Geometry2, default_strategy>
|
Chris@102
|
52 : comparable_distance_result
|
Chris@102
|
53 <
|
Chris@102
|
54 Geometry1,
|
Chris@102
|
55 Geometry2,
|
Chris@102
|
56 typename detail::distance::default_strategy
|
Chris@102
|
57 <
|
Chris@102
|
58 Geometry1, Geometry2
|
Chris@102
|
59 >::type
|
Chris@102
|
60 >
|
Chris@102
|
61 {};
|
Chris@102
|
62
|
Chris@102
|
63 } // namespace resolve_strategy
|
Chris@102
|
64
|
Chris@102
|
65
|
Chris@102
|
66 namespace resolve_variant
|
Chris@102
|
67 {
|
Chris@102
|
68
|
Chris@102
|
69 template <typename Geometry1, typename Geometry2, typename Strategy>
|
Chris@102
|
70 struct comparable_distance_result
|
Chris@102
|
71 : resolve_strategy::comparable_distance_result
|
Chris@102
|
72 <
|
Chris@102
|
73 Geometry1,
|
Chris@102
|
74 Geometry2,
|
Chris@102
|
75 Strategy
|
Chris@102
|
76 >
|
Chris@102
|
77 {};
|
Chris@102
|
78
|
Chris@102
|
79
|
Chris@102
|
80 template
|
Chris@102
|
81 <
|
Chris@102
|
82 typename Geometry1,
|
Chris@102
|
83 BOOST_VARIANT_ENUM_PARAMS(typename T),
|
Chris@102
|
84 typename Strategy
|
Chris@102
|
85 >
|
Chris@102
|
86 struct comparable_distance_result
|
Chris@102
|
87 <
|
Chris@102
|
88 Geometry1, boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Strategy
|
Chris@102
|
89 >
|
Chris@102
|
90 {
|
Chris@102
|
91 // A set of all variant type combinations that are compatible and
|
Chris@102
|
92 // implemented
|
Chris@102
|
93 typedef typename util::combine_if<
|
Chris@102
|
94 typename boost::mpl::vector1<Geometry1>,
|
Chris@102
|
95 typename boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types,
|
Chris@102
|
96 boost::mpl::always<boost::mpl::true_>
|
Chris@102
|
97 >::type possible_input_types;
|
Chris@102
|
98
|
Chris@102
|
99 // The (possibly variant) result type resulting from these combinations
|
Chris@102
|
100 typedef typename compress_variant<
|
Chris@102
|
101 typename transform_variant<
|
Chris@102
|
102 possible_input_types,
|
Chris@102
|
103 resolve_strategy::comparable_distance_result<
|
Chris@102
|
104 boost::mpl::first<boost::mpl::_>,
|
Chris@102
|
105 boost::mpl::second<boost::mpl::_>,
|
Chris@102
|
106 Strategy
|
Chris@102
|
107 >,
|
Chris@102
|
108 boost::mpl::back_inserter<boost::mpl::vector0<> >
|
Chris@102
|
109 >::type
|
Chris@102
|
110 >::type type;
|
Chris@102
|
111 };
|
Chris@102
|
112
|
Chris@102
|
113
|
Chris@102
|
114 // Distance arguments are commutative
|
Chris@102
|
115 template
|
Chris@102
|
116 <
|
Chris@102
|
117 BOOST_VARIANT_ENUM_PARAMS(typename T),
|
Chris@102
|
118 typename Geometry2,
|
Chris@102
|
119 typename Strategy
|
Chris@102
|
120 >
|
Chris@102
|
121 struct comparable_distance_result
|
Chris@102
|
122 <
|
Chris@102
|
123 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>,
|
Chris@102
|
124 Geometry2,
|
Chris@102
|
125 Strategy
|
Chris@102
|
126 > : public comparable_distance_result
|
Chris@102
|
127 <
|
Chris@102
|
128 Geometry2, boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Strategy
|
Chris@102
|
129 >
|
Chris@102
|
130 {};
|
Chris@102
|
131
|
Chris@102
|
132
|
Chris@102
|
133 template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Strategy>
|
Chris@102
|
134 struct comparable_distance_result
|
Chris@102
|
135 <
|
Chris@102
|
136 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>,
|
Chris@102
|
137 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>,
|
Chris@102
|
138 Strategy
|
Chris@102
|
139 >
|
Chris@102
|
140 {
|
Chris@102
|
141 // A set of all variant type combinations that are compatible and
|
Chris@102
|
142 // implemented
|
Chris@102
|
143 typedef typename util::combine_if
|
Chris@102
|
144 <
|
Chris@102
|
145 typename boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types,
|
Chris@102
|
146 typename boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types,
|
Chris@102
|
147 boost::mpl::always<boost::mpl::true_>
|
Chris@102
|
148 >::type possible_input_types;
|
Chris@102
|
149
|
Chris@102
|
150 // The (possibly variant) result type resulting from these combinations
|
Chris@102
|
151 typedef typename compress_variant<
|
Chris@102
|
152 typename transform_variant<
|
Chris@102
|
153 possible_input_types,
|
Chris@102
|
154 resolve_strategy::comparable_distance_result<
|
Chris@102
|
155 boost::mpl::first<boost::mpl::_>,
|
Chris@102
|
156 boost::mpl::second<boost::mpl::_>,
|
Chris@102
|
157 Strategy
|
Chris@102
|
158 >,
|
Chris@102
|
159 boost::mpl::back_inserter<boost::mpl::vector0<> >
|
Chris@102
|
160 >::type
|
Chris@102
|
161 >::type type;
|
Chris@102
|
162 };
|
Chris@102
|
163
|
Chris@102
|
164 } // namespace resolve_variant
|
Chris@102
|
165
|
Chris@102
|
166
|
Chris@102
|
167
|
Chris@102
|
168
|
Chris@102
|
169
|
Chris@102
|
170 /*!
|
Chris@102
|
171 \brief Meta-function defining return type of comparable_distance function
|
Chris@102
|
172 \ingroup distance
|
Chris@102
|
173 */
|
Chris@102
|
174 template
|
Chris@102
|
175 <
|
Chris@102
|
176 typename Geometry1,
|
Chris@102
|
177 typename Geometry2 = Geometry1,
|
Chris@102
|
178 typename Strategy = void
|
Chris@102
|
179 >
|
Chris@102
|
180 struct comparable_distance_result
|
Chris@102
|
181 : resolve_variant::comparable_distance_result
|
Chris@102
|
182 <
|
Chris@102
|
183 Geometry1, Geometry2, Strategy
|
Chris@102
|
184 >
|
Chris@102
|
185 {};
|
Chris@102
|
186
|
Chris@102
|
187 template <typename Geometry1, typename Geometry2>
|
Chris@102
|
188 struct comparable_distance_result<Geometry1, Geometry2, void>
|
Chris@102
|
189 : comparable_distance_result<Geometry1, Geometry2, default_strategy>
|
Chris@102
|
190 {};
|
Chris@102
|
191
|
Chris@102
|
192
|
Chris@102
|
193 }} // namespace boost::geometry
|
Chris@102
|
194
|
Chris@102
|
195
|
Chris@102
|
196 #endif // BOOST_GEOMETRY_STRATEGIES_COMPARABLE_DISTANCE_RESULT_HPP
|