From 5bb4c45ff53c1147007eeb77e41bebbffeee2284 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Tue, 11 Feb 2014 17:06:43 +0100 Subject: [PATCH] get_turns(L,L) fixed another case for opposite linestrings --- .../detail/overlay/get_turn_info_ll.hpp | 22 +++++++++++-------- .../overlay/get_turns_linear_linear.cpp | 5 +++++ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/overlay/get_turn_info_ll.hpp b/include/boost/geometry/algorithms/detail/overlay/get_turn_info_ll.hpp index 000514f12..7c99d6d89 100644 --- a/include/boost/geometry/algorithms/detail/overlay/get_turn_info_ll.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/get_turn_info_ll.hpp @@ -455,12 +455,13 @@ struct get_turn_info_linear_linear bool p0i, p0j, q0i, q0j; // assign false? bool p1i, p1j, q1i, q1j; // assign false? + bool opposite = result.template get<1>().opposite; + { int p_how = result.template get<1>().how_a; int q_how = result.template get<1>().how_b; int p_arrival = result.template get<1>().arrival[0]; int q_arrival = result.template get<1>().arrival[1]; - bool opposite = result.template get<1>().opposite; bool same_dirs = result.template get<1>().dir_a == 0 && result.template get<1>().dir_b == 0; handle_segment(is_p_first, is_p_last, p_how, p_arrival, @@ -474,7 +475,7 @@ struct get_turn_info_linear_linear pi, pj, pk, qi, qj, qk); } - bool result_ignore_ip = false; + bool result_ignore_ip0 = false; { BOOST_ASSERT(p0i == equals::equals_point_point(pi, result.template get<0>().intersections[0])); @@ -489,7 +490,7 @@ struct get_turn_info_linear_linear bool append0_first = enable_first && (p0_first || q0_first); bool append0_last = enable_last && (p0_last || q0_last); - result_ignore_ip = append0_last; + result_ignore_ip0 = append0_last; if ( append0_first || append0_last ) { @@ -512,6 +513,8 @@ struct get_turn_info_linear_linear } } + bool result_ignore_ip1 = false; + if ( p_operation1 != ov::operation_none ) { BOOST_ASSERT(p1i == equals::equals_point_point(pi, result.template get<0>().intersections[1])); @@ -526,7 +529,7 @@ struct get_turn_info_linear_linear bool append1_first = enable_first && (p1_first || q1_first); bool append1_last = enable_last && (p1_last || q1_last); - result_ignore_ip = result_ignore_ip || append1_last; + result_ignore_ip1 = append1_last; if ( append1_first || append1_last ) { @@ -551,7 +554,8 @@ struct get_turn_info_linear_linear } } - return result_ignore_ip; + return ip_count == 1 ? result_ignore_ip0 : + !opposite ? result_ignore_ip1 : result_ignore_ip0; } template @@ -722,8 +726,8 @@ struct get_turn_info_linear_linear bool opposite = result.template get<1>().opposite; TurnInfo tp = tp_model; - side_calculator side_calc(i2, j1, i1, i2, j2, k2); - equal::apply(i2, j1, i1, i2, j2, k2, + side_calculator side_calc(j2, j1, i1, i2, j2, k2); + equal::apply(j2, j1, i1, i2, j2, k2, tp, result.template get<0>(), result.template get<1>(), side_calc); if ( tp.both(operation_continue) ) @@ -734,8 +738,8 @@ struct get_turn_info_linear_linear else { BOOST_ASSERT(tp.combination(operation_intersection, operation_union)); - op1 = operation_blocked; - op2 = operation_union; + //op1 = operation_blocked; + //op2 = operation_union; } return true; diff --git a/test/algorithms/overlay/get_turns_linear_linear.cpp b/test/algorithms/overlay/get_turns_linear_linear.cpp index bc48ca3c8..5877453a4 100644 --- a/test/algorithms/overlay/get_turns_linear_linear.cpp +++ b/test/algorithms/overlay/get_turns_linear_linear.cpp @@ -140,6 +140,8 @@ void test_geometry(std::string const& wkt1, std::string const& wkt2, //TEST //#include +//#include +//#include template void test_all() @@ -187,6 +189,9 @@ void test_all() test_geometry("LINESTRING(1 0,2 1,3 5)", "LINESTRING(0 0,1 0,2 1,3 5,4 0)", "txu", "ecc", "tii"); test_geometry("LINESTRING(3 5,2 1,1 0)", "LINESTRING(0 0,1 0,2 1,3 5,4 0)", "tiu", "ecc", "txi"); + test_geometry("LINESTRING(0 0,10 0)", "LINESTRING(-1 -1,1 0,10 0,20 -1)", "mii", "txu"); + test_geometry("LINESTRING(0 0,10 0)", "LINESTRING(20 -1,10 0,1 0,-1 -1)", "miu", "txi"); + //if ( boost::is_same::value ) //{ // to_svg("LINESTRING(0 0,1 0,2 0,2.5 0,3 1)", "LINESTRING(0 0,2 0,2.5 0,3 1)", "test11.svg");