diff --git a/include/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp b/include/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp index 1b56f60b0b..3ac11b870a 100644 --- a/include/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp @@ -687,8 +687,14 @@ struct touch : public base_turn_handler if (! opposite(side_qi_p1, side_qk_p1)) { int const side_pk_q2 = has_pk && has_qk ? side.pk_wrt_q2() : 0; - int const side_pk_p = has_pk ? side.pk_wrt_p1() : 0; - int const side_qk_q = has_qk ? side.qk_wrt_q1() : 0; + int const side_pk_p = has_pk + ? fun::verified_side(side.pk_wrt_p1(), range_p, range_p, + umbrella_strategy, 0, 2) + : 0; + int const side_qk_q = has_qk + ? fun::verified_side(side.qk_wrt_q1(), range_q, range_q, + umbrella_strategy, 0, 2) + : 0; bool const q_turns_left = side_qk_q == 1; diff --git a/test/algorithms/buffer/buffer_multi_polygon.cpp b/test/algorithms/buffer/buffer_multi_polygon.cpp index 30bc757bc0..5cd437a49e 100644 --- a/test/algorithms/buffer/buffer_multi_polygon.cpp +++ b/test/algorithms/buffer/buffer_multi_polygon.cpp @@ -398,6 +398,15 @@ static std::string const res_8618 static std::string const res_3b4d = "MULTIPOLYGON(((8 0,9 1,9 0,8 0)),((3 4,2 4,2 5,2 6,3 6,3 4)),((3 4,4 3,3 3,3 4)),((3 8,3 9,4 9,3 8)),((0 5,0 6,1 6,0 5)),((7 3,8 4,8 3,7 3)),((5 5,6 6,6 5,5 5)))"; +// Generated by recursive_polygons_buffer, the output was invalid before the +// fix of issue 1506 (nearly collinear touch in get_turn_info) +static std::string const issue_1506_2f82 + = "MULTIPOLYGON(((1 1,1 2,2 2,1 1)),((1 3,1 4,2 4,2 3,1 3)),((4 3,5 4,5 3,4 3)),((4 3,5 2,4 2,4 3)))"; +static std::string const issue_1506_88dc + = "MULTIPOLYGON(((4 6,4 7,5 7,5 6,4 6)),((7 7,7 8,8 7,7 7)),((0 6,0 7,1 7,1 6,0 6)),((7 5,8 6,8 5,7 5)),((2 2,3 1,2 1,2 2)),((2 2,1 1,1 2,2 2)),((2 5,3 4,2 4,2 5)),((2 5,1 5,2 6,2 5)))"; +static std::string const issue_1506_6bb7 + = "MULTIPOLYGON(((0 0,0 1,1 1,1 0,0 0)),((5 8,6 9,6 8,5 8)),((2 5,3 5,3 4,2 4,2 5)),((2 5,1 5,1 6,2 5)),((4 4,4 3,3 3,4 4)),((4 4,3 4,4 5,4 4)),((3 1,4 0,3 0,3 1)),((3 1,2 0,2 1,3 1)))"; + // The buffer disappeared static std::string const issue_1428_a = "MULTIPOLYGON(((925.2271 -349.3228,925.2271 -323.3228,927.5271 -323.3228,927.5271 -294.3228,910.2271 -294.3228,910.2271 -226.6035,900.0271 -226.6035,900.0271 236.477,909.4271 245.877,900.0271 255.277,900.0271 1199.477,909.4271 1208.877,900.0271 1218.277,900.0271 1291.417,907.891 1299.281,908.05 1299.4881,908.1499 1299.7293,908.1839 1299.9881,908.1499 1300.2469,908.05 1300.4881,907.891 1300.6952,905.0271 1303.5591,905.0271 1314.5628,909.4271 1325.7903,909.4271 1343.277,911.9271 1343.277,911.9271 1349.277,925.0271 1349.277,925.0271 1340.777,925.0647 1340.4432,925.1756 1340.1262,925.3543 1339.8418,925.5918 1339.6043,925.8763 1339.4256,926.1933 1339.3146,926.5271 1339.277,926.8609 1339.3146,927.1779 1339.4256,927.4623 1339.6043,927.6998 1339.8418,927.8785 1340.1262,927.9895 1340.4432,928.0271 1340.777,928.0271 1349.277,1331.0271 1349.277,1331.0271 1340.777,1331.0647 1340.4432,1331.1756 1340.1262,1331.3543 1339.8418,1331.5918 1339.6043,1331.8763 1339.4256,1332.1933 1339.3146,1332.5271 1339.277,1332.8609 1339.3146,1333.1779 1339.4256,1333.4623 1339.6043,1333.6998 1339.8418,1333.8785 1340.1262,1333.9895 1340.4432,1334.0271 1340.777,1334.0271 1349.277,1347.1271 1349.277,1347.1271 1343.277,1349.6271 1343.277,1349.6271 1325.7903,1354.0271 1314.5628,1354.0271 1303.5591,1351.1631 1300.6952,1351.0042 1300.4881,1350.9043 1300.2469,1350.8702 1299.9881,1350.9043 1299.7293,1351.0042 1299.4881,1351.1631 1299.281,1359.0271 1291.417,1359.0271 1218.277,1349.6271 1208.877,1359.0271 1199.477,1359.0271 255.277,1349.6271 245.877,1359.0271 236.477,1359.0271 -226.6035,1348.8271 -226.6035,1348.8271 -294.3228,1331.5271 -294.3228,1331.5271 -323.3228,1333.8271 -323.3228,1333.8271 -349.3228,925.2271 -349.3228)))"; @@ -728,6 +737,20 @@ void test_all() test_one("res_8618", res_8618, join_round32, end_flat, 48.1085, 1.0); test_one("res_3b4d", res_3b4d, join_round32, end_flat, 48.4739, 1.0); + { + // Invalid before the fix of issue 1506: intersecting interiors (2f82), + // self-intersections with u/u (88dc) and c/c (6bb7). + // The counter clockwise variants of 2f82 and 6bb7 are still invalid. +#if defined(BOOST_GEOMETRY_TEST_FAILURES) + ut_settings const settings_ccw; +#else + ut_settings const settings_ccw = Clockwise ? ut_settings() : ut_settings::ignore_validity(); +#endif + test_one("issue_1506_2f82", issue_1506_2f82, join_round32, end_flat, 22.9315, 1.0, settings_ccw); + test_one("issue_1506_88dc", issue_1506_88dc, join_round32, end_flat, 47.0482, 1.0); + test_one("issue_1506_6bb7", issue_1506_6bb7, join_round32, end_flat, 40.4563, 1.0, settings_ccw); + } + test_one("issue_1428_a", issue_1428_a, join_round, end_flat, 776286.8801, 0.5); test_one("neighbouring_small", neighbouring, diff --git a/test/algorithms/overlay/multi_overlay_cases.hpp b/test/algorithms/overlay/multi_overlay_cases.hpp index 09a6e9fe26..e5491cec0b 100644 --- a/test/algorithms/overlay/multi_overlay_cases.hpp +++ b/test/algorithms/overlay/multi_overlay_cases.hpp @@ -2007,6 +2007,17 @@ static std::string issue_1471[2] = "20.0970444515398476 -0.3449179410282246)))" }; +// Two polygons sharing an edge, the first has a nearly collinear (reflex) vertex +// at the start of the shared edge. The union in reversed order was empty. +static std::string issue_1506[2] = +{ + "MULTIPOLYGON(((7.5766965679702691 55.1955384390566266,7.5769710638206007 55.1955418668735760," + "7.5776907371234223 55.1955508539257096,7.5777041477885838 55.1955510213938609," + "7.5724506758568699 55.1833987553893692,7.5766965679702691 55.1955384390566266)))", + "MULTIPOLYGON(((7.5776907371234223 55.1955508539257096,7.5769710638206007 55.1955418668735760," + "7.5786734102424926 55.1979584470965179,7.5776907371234223 55.1955508539257096)))" +}; + static std::string bug_21155501[2] = { "MULTIPOLYGON(((-8.3935546875 27.449790329784214,4.9658203125 18.729501999072138,11.8212890625 23.563987128451217,9.7119140625 25.48295117535531,9.8876953125 31.728167146023935,8.3056640625 32.99023555965106,8.5693359375 37.16031654673677,-1.8896484375 35.60371874069731,-0.5712890625 32.02670629333614,-8.9208984375 29.458731185355344,-8.3935546875 27.449790329784214)))", diff --git a/test/algorithms/set_operations/set_ops_areal_areal.cpp b/test/algorithms/set_operations/set_ops_areal_areal.cpp index 063fe2d295..38833eab33 100644 --- a/test/algorithms/set_operations/set_ops_areal_areal.cpp +++ b/test/algorithms/set_operations/set_ops_areal_areal.cpp @@ -339,6 +339,7 @@ int test_main(int, char* []) TEST_CASE(issue_1471); TEST_CASE(issue_1487); + TEST_CASE(issue_1506); TEST_CASE(clustered_near_collinear_exit); return 0;