From 085d641dabebe3fde9839f3a07368aefcc9a98d7 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sat, 31 Oct 2015 20:06:39 +0100 Subject: [PATCH] [difference] fix colocations --- .../detail/overlay/enrich_intersection_points.hpp | 8 +++++++- .../algorithms/detail/overlay/handle_colocations.hpp | 12 +++++++++++- .../set_operations/difference/difference.cpp | 8 ++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp b/include/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp index ef11038e7..bc8428624 100644 --- a/include/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp @@ -515,6 +515,12 @@ inline void enrich_intersection_points(TurnPoints& turn_points, { check_colocations = true; } + else if (OverlayType == overlay_difference + && it->both(detail::overlay::operation_intersection)) + { + // For difference operation (u/u -> i/i) + check_colocations = true; + } else if (it->both(detail::overlay::operation_none)) { it->discarded = true; @@ -523,7 +529,7 @@ inline void enrich_intersection_points(TurnPoints& turn_points, if (check_colocations) { - detail::overlay::handle_colocations(turn_points); + detail::overlay::handle_colocations(turn_points); } // Create a map of vectors of indexed operation-types to be able diff --git a/include/boost/geometry/algorithms/detail/overlay/handle_colocations.hpp b/include/boost/geometry/algorithms/detail/overlay/handle_colocations.hpp index 336f35572..6457971d2 100644 --- a/include/boost/geometry/algorithms/detail/overlay/handle_colocations.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/handle_colocations.hpp @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -96,7 +97,7 @@ private: // This function can be extended to replace handle_tangencies: at each // colocation incoming and outgoing vectors should be inspected -template +template inline void handle_colocations(TurnPoints& turn_points) { typedef typename boost::range_value::type turn_type; @@ -210,6 +211,15 @@ inline void handle_colocations(TurnPoints& turn_points) turn.discarded = true; turn.colocated = true; } + else if (OverlayType == overlay_difference + && turn.both(operation_intersection) + && colocated_ext_int) + { + // For difference (polygon inside out) we need to + // discard i/i instead, in case of colocations + turn.discarded = true; + turn.colocated = true; + } } else { diff --git a/test/algorithms/set_operations/difference/difference.cpp b/test/algorithms/set_operations/difference/difference.cpp index 1cb69650f..4894a2a8a 100644 --- a/test/algorithms/set_operations/difference/difference.cpp +++ b/test/algorithms/set_operations/difference/difference.cpp @@ -677,16 +677,20 @@ void test_all() ***/ #ifdef BOOST_GEOMETRY_TEST_ENABLE_FAILING + test_one("ticket_11725_2", ticket_11725_2[0], ticket_11725_2[1], 2, -1, 7.5, 0, -1, 0.0); test_one("mysql_21977775", mysql_21977775[0], mysql_21977775[1], 2, -1, 160.856568913, 2, -1, 92.3565689126); +#endif + test_one("mysql_21965285", mysql_21965285[0], mysql_21965285[1], - 1, -1, 92.0, 0, -1, 0.0); -#endif + 1, -1, 92.0, + 1, -1, 14.0, + 1, -1, 92.0 + 14.0); } /*******