Skip to content

Commit 95a9b43

Browse files
committed
Merge branch 'develop' into feature/traits_make
2 parents 016691b + 20ce3d5 commit 95a9b43

File tree

14 files changed

+177
-65
lines changed

14 files changed

+177
-65
lines changed

include/boost/geometry/algorithms/area_result.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,14 @@ struct area_result
143143
: detail::area::area_result<Geometry, Strategy>
144144
{};
145145

146-
template <typename ...Ts, typename Strategy>
147-
struct area_result<boost::variant<Ts...>, Strategy>
146+
template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Strategy>
147+
struct area_result<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Strategy>
148148
: geometry::area_result
149149
<
150150
typename util::select_pack_element
151151
<
152152
detail::area::more_precise_coordinate_type,
153-
Ts...
153+
BOOST_VARIANT_ENUM_PARAMS(T)
154154
>::type,
155155
Strategy
156156
>
@@ -161,14 +161,14 @@ struct area_result<Geometry, default_strategy>
161161
: detail::area::default_area_result<Geometry>
162162
{};
163163

164-
template <typename ...Ts>
165-
struct area_result<boost::variant<Ts...>, default_strategy>
164+
template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
165+
struct area_result<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, default_strategy>
166166
: detail::area::default_area_result
167167
<
168168
typename util::select_pack_element
169169
<
170170
detail::area::more_precise_default_area_result,
171-
Ts...
171+
BOOST_VARIANT_ENUM_PARAMS(T)
172172
>::type
173173
>
174174
{};

include/boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ inline char method_char(detail::overlay::method_type const& method)
2828
case method_touch_interior : return 'm';
2929
case method_collinear : return 'c';
3030
case method_equal : return 'e';
31+
case method_start : return 's';
3132
case method_error : return '!';
3233
default : return '?';
3334
}

include/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,39 @@ struct base_turn_handler
179179
ti.operations[1].fraction = info.fractions[index].robust_rb;
180180
}
181181

182+
template <typename TurnInfo, typename IntersectionInfo, typename DirInfo>
183+
static inline void assign_point_and_correct(TurnInfo& ti,
184+
method_type method,
185+
IntersectionInfo const& info, DirInfo const& dir_info)
186+
{
187+
ti.method = method;
188+
189+
// For touch/touch interior always take the intersection point 0 (there is only one).
190+
static int const index = 0;
191+
192+
geometry::convert(info.intersections[index], ti.point);
193+
194+
for (int i = 0; i < 2; i++)
195+
{
196+
if (dir_info.arrival[i] == 1)
197+
{
198+
// The segment arrives at the intersection point, its fraction should be 1
199+
// (due to precision it might be nearly so, but not completely, in rare cases)
200+
ti.operations[i].fraction = {1, 1};
201+
}
202+
else if (dir_info.arrival[i] == -1)
203+
{
204+
// The segment leaves from the intersection point, likewise its fraction should be 0
205+
ti.operations[i].fraction = {0, 1};
206+
}
207+
else
208+
{
209+
ti.operations[i].fraction = i == 0 ? info.fractions[index].robust_ra
210+
: info.fractions[index].robust_rb;
211+
}
212+
}
213+
}
214+
182215
template <typename IntersectionInfo>
183216
static inline unsigned int non_opposite_to_index(IntersectionInfo const& info)
184217
{
@@ -344,7 +377,7 @@ struct touch_interior : public base_turn_handler
344377
SidePolicy const& side,
345378
UmbrellaStrategy const& umbrella_strategy)
346379
{
347-
assign_point(ti, method_touch_interior, intersection_info, 0);
380+
assign_point_and_correct(ti, method_touch_interior, intersection_info, dir_info);
348381

349382
// Both segments of q touch segment p somewhere in its interior
350383
// 1) We know: if q comes from LEFT or RIGHT
@@ -443,7 +476,6 @@ struct touch_interior : public base_turn_handler
443476
if (side_qk_q == side_qi_p)
444477
{
445478
both_collinear<index_p, index_q>(range_p, range_q, umbrella_strategy, 1, 2, ti);
446-
return;
447479
}
448480
else
449481
{
@@ -568,7 +600,7 @@ struct touch : public base_turn_handler
568600
SideCalculator const& side,
569601
UmbrellaStrategy const& umbrella_strategy)
570602
{
571-
assign_point(ti, method_touch, intersection_info, 0);
603+
assign_point_and_correct(ti, method_touch, intersection_info, dir_info);
572604

573605
bool const has_pk = ! range_p.is_last_segment();
574606
bool const has_qk = ! range_q.is_last_segment();
@@ -760,7 +792,7 @@ struct equal : public base_turn_handler
760792
UniqueSubRange2 const& range_q,
761793
TurnInfo& ti,
762794
IntersectionInfo const& info,
763-
DirInfo const& ,
795+
DirInfo const& ,
764796
SideCalculator const& side,
765797
UmbrellaStrategy const& umbrella_strategy)
766798
{
@@ -882,7 +914,7 @@ struct start : public base_turn_handler
882914
}
883915

884916
// Copy intersection point
885-
assign_point(ti, method_start, info, 0);
917+
assign_point_and_correct(ti, method_start, info, dir_info);
886918
return true;
887919
}
888920

@@ -1060,23 +1092,15 @@ private :
10601092
1 -1 -1 CXO3 ux
10611093
*/
10621094

1063-
template
1064-
<
1065-
unsigned int Index,
1066-
typename IntersectionInfo
1067-
>
1068-
static inline bool set_tp(int side_rk_r, bool handle_robustness,
1069-
int side_rk_s,
1070-
TurnInfo& tp, IntersectionInfo const& intersection_info)
1095+
template <unsigned int Index, typename IntersectionInfo>
1096+
static inline bool set_tp(int side_rk_r, TurnInfo& tp,
1097+
IntersectionInfo const& intersection_info)
10711098
{
10721099
BOOST_STATIC_ASSERT(Index <= 1);
10731100

1074-
boost::ignore_unused(handle_robustness, side_rk_s);
1075-
10761101
operation_type blocked = operation_blocked;
10771102
switch(side_rk_r)
10781103
{
1079-
10801104
case 1 :
10811105
// Turning left on opposite collinear: intersection
10821106
tp.operations[Index].operation = operation_intersection;
@@ -1168,7 +1192,7 @@ private :
11681192
// If P arrives within Q, there is a turn dependent on P
11691193
if ( p_arrival == 1
11701194
&& ! range_p.is_last_segment()
1171-
&& set_tp<0>(side.pk_wrt_p1(), true, side.pk_wrt_q1(), tp, info.i_info()) )
1195+
&& set_tp<0>(side.pk_wrt_p1(), tp, info.i_info()) )
11721196
{
11731197
turn_transformer(tp);
11741198

@@ -1178,7 +1202,7 @@ private :
11781202
// If Q arrives within P, there is a turn dependent on Q
11791203
if ( q_arrival == 1
11801204
&& ! range_q.is_last_segment()
1181-
&& set_tp<1>(side.qk_wrt_q1(), false, side.qk_wrt_p1(), tp, info.i_info()) )
1205+
&& set_tp<1>(side.qk_wrt_q1(), tp, info.i_info()) )
11821206
{
11831207
turn_transformer(tp);
11841208

@@ -1237,7 +1261,7 @@ struct only_convert : public base_turn_handler
12371261
template<typename TurnInfo, typename IntersectionInfo>
12381262
static inline void apply(TurnInfo& ti, IntersectionInfo const& intersection_info)
12391263
{
1240-
assign_point(ti, method_none, intersection_info, 0); // was collinear
1264+
assign_point(ti, method_none, intersection_info, 0);
12411265
ti.operations[0].operation = operation_continue;
12421266
ti.operations[1].operation = operation_continue;
12431267
}

include/boost/geometry/geometries/variant.hpp

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,30 @@
2727
namespace boost { namespace geometry
2828
{
2929

30+
namespace detail
31+
{
32+
33+
template <typename ...>
34+
struct parameter_pack_first_type {};
35+
36+
template <typename T, typename ... Ts>
37+
struct parameter_pack_first_type<T, Ts...>
38+
{
39+
typedef T type;
40+
};
41+
42+
} // namespace detail
43+
3044

31-
template <typename T, typename ...Ts>
32-
struct point_type<boost::variant<T, Ts...> >
33-
: point_type<T>
45+
template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
46+
struct point_type<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
47+
: point_type
48+
<
49+
typename detail::parameter_pack_first_type
50+
<
51+
BOOST_VARIANT_ENUM_PARAMS(T)
52+
>::type
53+
>
3454
{};
3555

3656

include/boost/geometry/srs/projections/dpar.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ template <typename Variant, typename T>
6565
struct find_type_index
6666
{};
6767

68-
template <typename ...Types, typename T>
69-
struct find_type_index<boost::variant<Types...>, T>
70-
: find_type_index_impl<T, 0, Types...>
68+
template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename T>
69+
struct find_type_index<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, T>
70+
: find_type_index_impl<T, 0, BOOST_VARIANT_ENUM_PARAMS(T)>
7171
{};
7272

7373

include/boost/geometry/strategies/comparable_distance_result.hpp

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,16 @@ struct comparable_distance_result
132132
{};
133133

134134

135-
template <typename Geometry1, typename ...Ts, typename Strategy>
136-
struct comparable_distance_result<Geometry1, boost::variant<Ts...>, Strategy>
135+
template
136+
<
137+
typename Geometry1,
138+
BOOST_VARIANT_ENUM_PARAMS(typename T),
139+
typename Strategy
140+
>
141+
struct comparable_distance_result
142+
<
143+
Geometry1, boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Strategy
144+
>
137145
{
138146
// Select the most precise distance strategy result type
139147
// for all variant type combinations.
@@ -142,7 +150,7 @@ struct comparable_distance_result<Geometry1, boost::variant<Ts...>, Strategy>
142150
typedef typename util::select_combination_element
143151
<
144152
util::type_sequence<Geometry1>,
145-
util::type_sequence<Ts...>,
153+
util::type_sequence<BOOST_VARIANT_ENUM_PARAMS(T)>,
146154
detail::distance::more_precise_comparable_distance_result
147155
<
148156
Strategy
@@ -159,19 +167,34 @@ struct comparable_distance_result<Geometry1, boost::variant<Ts...>, Strategy>
159167

160168

161169
// Distance arguments are commutative
162-
template <typename ...Ts, typename Geometry2, typename Strategy>
163-
struct comparable_distance_result<boost::variant<Ts...>, Geometry2, Strategy>
170+
template
171+
<
172+
BOOST_VARIANT_ENUM_PARAMS(typename T),
173+
typename Geometry2,
174+
typename Strategy
175+
>
176+
struct comparable_distance_result
177+
<
178+
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Geometry2, Strategy
179+
>
164180
: public comparable_distance_result
165181
<
166-
Geometry2, boost::variant<Ts...>, Strategy
182+
Geometry2, boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Strategy
167183
>
168184
{};
169185

170186

171-
template <typename ...Ts, typename ...Us, typename Strategy>
187+
template
188+
<
189+
BOOST_VARIANT_ENUM_PARAMS(typename T),
190+
BOOST_VARIANT_ENUM_PARAMS(typename U),
191+
typename Strategy
192+
>
172193
struct comparable_distance_result
173194
<
174-
boost::variant<Ts...>, boost::variant<Us...>, Strategy
195+
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>,
196+
boost::variant<BOOST_VARIANT_ENUM_PARAMS(U)>,
197+
Strategy
175198
>
176199
{
177200
// Select the most precise distance strategy result type
@@ -180,8 +203,8 @@ struct comparable_distance_result
180203
// but is_implemented is not ready for prime time.
181204
typedef typename util::select_combination_element
182205
<
183-
util::type_sequence<Ts...>,
184-
util::type_sequence<Us...>,
206+
util::type_sequence<BOOST_VARIANT_ENUM_PARAMS(T)>,
207+
util::type_sequence<BOOST_VARIANT_ENUM_PARAMS(U)>,
185208
detail::distance::more_precise_comparable_distance_result
186209
<
187210
Strategy

include/boost/geometry/strategies/default_length_result.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ struct default_length_result
7979
: resolve_strategy::default_length_result<Geometry>
8080
{};
8181

82-
template <typename ...Ts>
83-
struct default_length_result<boost::variant<Ts...> >
84-
: resolve_strategy::default_length_result<Ts...>
82+
template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
83+
struct default_length_result<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
84+
: resolve_strategy::default_length_result<BOOST_VARIANT_ENUM_PARAMS(T)>
8585
{};
8686

8787
} // namespace resolve_variant

0 commit comments

Comments
 (0)