Skip to content

Commit e97b336

Browse files
committed
[get_turn_info] minor clean up of typedefs and includes
1 parent 84d3a8d commit e97b336

File tree

1 file changed

+14
-58
lines changed

1 file changed

+14
-58
lines changed

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

Lines changed: 14 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_TURN_INFO_HPP
1616
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_TURN_INFO_HPP
1717

18-
1918
#include <boost/core/ignore_unused.hpp>
2019
#include <boost/throw_exception.hpp>
2120

@@ -28,9 +27,6 @@
2827
#include <boost/geometry/algorithms/detail/overlay/get_distance_measure.hpp>
2928
#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
3029

31-
#include <boost/geometry/geometries/segment.hpp>
32-
33-
#include <boost/geometry/policies/robustness/robust_point_type.hpp>
3430
#include <boost/geometry/algorithms/detail/overlay/get_turn_info_helpers.hpp>
3531

3632
// Silence warning C4127: conditional expression is constant
@@ -131,15 +127,7 @@ struct base_turn_handler
131127
return 0;
132128
}
133129

134-
typedef typename select_coordinate_type
135-
<
136-
typename UniqueSubRange1::point_type,
137-
typename UniqueSubRange2::point_type
138-
>::type coordinate_type;
139-
140-
typedef detail::distance_measure<coordinate_type> dm_type;
141-
142-
dm_type const dm = get_distance_measure(range_p.at(range_index), range_p.at(range_index + 1), range_q.at(point_index));
130+
auto const dm = get_distance_measure(range_p.at(range_index), range_p.at(range_index + 1), range_q.at(point_index));
143131
return dm.measure == 0 ? 0 : dm.measure > 0 ? 1 : -1;
144132
}
145133

@@ -226,9 +214,8 @@ struct base_turn_handler
226214
{
227215
// TODO: use comparable distance for point-point instead - but that
228216
// causes currently cycling include problems
229-
typedef typename geometry::coordinate_type<Point1>::type ctype;
230-
ctype const dx = get<0>(a) - get<0>(b);
231-
ctype const dy = get<1>(a) - get<1>(b);
217+
auto const dx = get<0>(a) - get<0>(b);
218+
auto const dy = get<1>(a) - get<1>(b);
232219
return dx * dx + dy * dy;
233220
}
234221

@@ -260,19 +247,10 @@ struct base_turn_handler
260247
// pk/q2 is considered as collinear, but there might be
261248
// a tiny measurable difference. If so, use that.
262249
// Calculate pk // qj-qk
263-
typedef detail::distance_measure
264-
<
265-
typename select_coordinate_type
266-
<
267-
typename UniqueSubRange1::point_type,
268-
typename UniqueSubRange2::point_type
269-
>::type
270-
> dm_type;
271-
272-
const bool p_closer =
250+
bool const p_closer =
273251
ti.operations[IndexP].remaining_distance
274252
< ti.operations[IndexQ].remaining_distance;
275-
dm_type const dm
253+
auto const dm
276254
= p_closer
277255
? get_distance_measure(range_q.at(index_q - 1),
278256
range_q.at(index_q), range_p.at(index_p))
@@ -283,8 +261,7 @@ struct base_turn_handler
283261
{
284262
// Not truely collinear, distinguish for union/intersection
285263
// If p goes left (positive), take that for a union
286-
287-
bool p_left = p_closer ? dm.is_positive() : dm.is_negative();
264+
bool const p_left = p_closer ? dm.is_positive() : dm.is_negative();
288265

289266
ti.operations[IndexP].operation = p_left
290267
? operation_union : operation_intersection;
@@ -348,13 +325,8 @@ struct touch_interior : public base_turn_handler
348325
// Therefore handle it as a normal touch (two segments arrive at the
349326
// intersection point). It currently checks for zero, but even a
350327
// distance a little bit larger would do.
351-
typedef typename geometry::coordinate_type
352-
<
353-
typename UniqueSubRange::point_type
354-
>::type coor_t;
355-
356-
coor_t const location = distance_measure(info.intersections[0], non_touching_range.at(1));
357-
coor_t const zero = 0;
328+
auto const location = distance_measure(info.intersections[0], non_touching_range.at(1));
329+
decltype(location) const zero = 0;
358330
bool const result = math::equals(location, zero);
359331
return result;
360332
}
@@ -541,16 +513,8 @@ struct touch : public base_turn_handler
541513
// >----->P qj is LEFT of P1 and pi is LEFT of Q2
542514
// (the other way round is also possible)
543515

544-
typedef typename select_coordinate_type
545-
<
546-
typename UniqueSubRange1::point_type,
547-
typename UniqueSubRange2::point_type
548-
>::type coordinate_type;
549-
550-
typedef detail::distance_measure<coordinate_type> dm_type;
551-
552-
dm_type const dm_qj_p1 = get_distance_measure(range_p.at(0), range_p.at(1), range_q.at(1));
553-
dm_type const dm_pi_q2 = get_distance_measure(range_q.at(1), range_q.at(2), range_p.at(0));
516+
auto const dm_qj_p1 = get_distance_measure(range_p.at(0), range_p.at(1), range_q.at(1));
517+
auto const dm_pi_q2 = get_distance_measure(range_q.at(1), range_q.at(2), range_p.at(0));
554518

555519
if (dm_qj_p1.measure > 0 && dm_pi_q2.measure > 0)
556520
{
@@ -565,8 +529,8 @@ struct touch : public base_turn_handler
565529
return true;
566530
}
567531

568-
dm_type const dm_pj_q1 = get_distance_measure(range_q.at(0), range_q.at(1), range_p.at(1));
569-
dm_type const dm_qi_p2 = get_distance_measure(range_p.at(1), range_p.at(2), range_q.at(0));
532+
auto const dm_pj_q1 = get_distance_measure(range_q.at(0), range_q.at(1), range_p.at(1));
533+
auto const dm_qi_p2 = get_distance_measure(range_p.at(1), range_p.at(2), range_q.at(0));
570534

571535
if (dm_pj_q1.measure > 0 && dm_qi_p2.measure > 0)
572536
{
@@ -814,17 +778,9 @@ struct equal : public base_turn_handler
814778
// They turn to the same side, or continue both collinearly
815779
// Without rescaling, to check for union/intersection,
816780
// try to check side values (without any thresholds)
817-
typedef typename select_coordinate_type
818-
<
819-
typename UniqueSubRange1::point_type,
820-
typename UniqueSubRange2::point_type
821-
>::type coordinate_type;
822-
823-
typedef detail::distance_measure<coordinate_type> dm_type;
824-
825-
dm_type const dm_pk_q2
781+
auto const dm_pk_q2
826782
= get_distance_measure(range_q.at(1), range_q.at(2), range_p.at(2));
827-
dm_type const dm_qk_p2
783+
auto const dm_qk_p2
828784
= get_distance_measure(range_p.at(1), range_p.at(2), range_q.at(2));
829785

830786
if (dm_qk_p2.measure != dm_pk_q2.measure)

0 commit comments

Comments
 (0)