summaryrefslogtreecommitdiff
path: root/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp')
-rw-r--r--boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp59
1 files changed, 36 insertions, 23 deletions
diff --git a/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp b/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp
index 9484479b45..7ed93f542a 100644
--- a/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp
+++ b/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp
@@ -56,13 +56,13 @@ struct indexed_turn_operation
TurnOperation const* subject;
inline indexed_turn_operation(std::size_t ti, std::size_t oi,
- TurnOperation const& s,
+ TurnOperation const& sub,
segment_identifier const& oid)
: turn_index(ti)
, operation_index(oi)
, discarded(false)
, other_seg_id(&oid)
- , subject(&s)
+ , subject(boost::addressof(sub))
{}
};
@@ -114,6 +114,12 @@ private :
typedef typename geometry::point_type<Geometry1>::type point_type;
+ inline bool default_order(Indexed const& left, Indexed const& right) const
+ {
+ // We've nothing to sort on. Take the indexes
+ return left.turn_index < right.turn_index;
+ }
+
inline bool consider_relative_order(Indexed const& left,
Indexed const& right) const
{
@@ -148,7 +154,12 @@ private :
// If they both turn left: the most left as last
// If they both turn right: this is not relevant, but take also here most left
- return side_rj_s < side_sj_r;
+ if (side_rj_s != side_sj_r)
+ {
+ return side_rj_s < side_sj_r;
+ }
+
+ return default_order(left, right);
}
public :
@@ -157,30 +168,32 @@ public :
// but to the "indexed_turn_operation"
inline bool operator()(Indexed const& left, Indexed const& right) const
{
- segment_identifier const& sl = left.subject->seg_id;
- segment_identifier const& sr = right.subject->seg_id;
+ if (! (left.subject->seg_id == right.subject->seg_id))
+ {
+ return left.subject->seg_id < right.subject->seg_id;
+ }
+
+ // Both left and right are located on the SAME segment.
- if (sl == sr)
+ if (! (left.subject->fraction == right.subject->fraction))
{
- // Both left and right are located on the SAME segment.
- if (left.subject->fraction == right.subject->fraction)
- {
- // First check "real" intersection (crosses)
- // -> distance zero due to precision, solve it by sorting
- if (m_turn_points[left.turn_index].method == method_crosses
- && m_turn_points[right.turn_index].method == method_crosses)
- {
- return consider_relative_order(left, right);
- }
+ return left.subject->fraction < right.subject->fraction;
+ }
- // If that is not the case, cluster it later on.
- // Indicate that this is necessary.
- *m_clustered = true;
- }
+
+ // First check "real" intersection (crosses)
+ // -> distance zero due to precision, solve it by sorting
+ if (m_turn_points[left.turn_index].method == method_crosses
+ && m_turn_points[right.turn_index].method == method_crosses)
+ {
+ return consider_relative_order(left, right);
}
- return sl == sr
- ? left.subject->fraction < right.subject->fraction
- : sl < sr;
+
+ // If that is not the case, cluster it later on.
+ // Indicate that this is necessary.
+ *m_clustered = true;
+
+ return default_order(left, right);
}
};