get_turns(L,L) fixed 2x IPs generation for a special case of collinear, opposite last Ls segment

This commit is contained in:
Adam Wulkiewicz 2014-02-19 02:26:15 +01:00
parent 1e871f8ae6
commit b03601fab8
2 changed files with 21 additions and 2 deletions

View File

@ -492,7 +492,8 @@ struct get_turn_info_linear_linear
result_ignore_ip0 = !opposite ? // <=> ip_count == 1 || ip_count == 2 && !opposite
append0_last :
(append0_last && p0j);
(append0_last && (p0j || q0_last && q1i));
// NOTE: based on how collinear is calculated for opposite segments
if ( append0_first || append0_last )
{
@ -533,7 +534,9 @@ struct get_turn_info_linear_linear
result_ignore_ip1 = !opposite ? // <=> ip_count == 2 && !opposite
append1_last :
(append1_last && q1j);
(append1_last && (q1j || p1_last && p0i));
// NOTE: based on how collinear is calculated for opposite segments
// this condition is symmetric to the one above
if ( append1_first || append1_last )
{

View File

@ -207,6 +207,8 @@ void test_all()
test_geometry<ls, ls>("LINESTRING(0 0,10 0)", "LINESTRING(-1 -1,1 0,10 0,20 -1)", "mii", "txu");
test_geometry<ls, ls>("LINESTRING(0 0,10 0)", "LINESTRING(20 -1,10 0,1 0,-1 -1)", "miu", "txi");
test_geometry<ls, ls>("LINESTRING(-1 -1,1 0,10 0,20 -1)", "LINESTRING(0 0,10 0)", "mii", "tux");
test_geometry<ls, ls>("LINESTRING(20 -1,10 0,1 0,-1 -1)", "LINESTRING(0 0,10 0)", "mui", "tix");
test_geometry<ls, ls>("LINESTRING(-1 1,0 0,1 0,4 0,5 5,10 5,15 0,31 0)",
"LINESTRING(-1 -1,0 0,1 0,2 0,2.5 1,3 0,30 0)",
@ -221,6 +223,20 @@ void test_all()
"LINESTRING(30 0,3 0,2.5 1,2 0,1 0,0 0,-1 -1)",
expected("tuu")("ecc")("mii")("muu")("mii")("muu")("mii").vec);
test_geometry<ls, ls>("LINESTRING(-1 0,1 0,2 1,3 2)", "LINESTRING(4 5,3 2,1 0,0 0)", "mix", "txi", "ecc");
test_geometry<ls, ls>("LINESTRING(4 5,3 2,1 0,0 0)", "LINESTRING(-1 0,1 0,2 1,3 2)", "mxi", "tix", "ecc");
test_geometry<ls, ls>("LINESTRING(30 1,20 1,10 0,0 0)", "LINESTRING(1 1,2 0,3 1,20 1,25 1)", "mix", "tui", "muu");
test_geometry<ls, ls>("LINESTRING(1 1,2 0,3 1,20 1,25 1)", "LINESTRING(30 1,20 1,10 0,0 0)", "mxi", "tiu", "muu");
test_geometry<ls, ls>("LINESTRING(0 0,30 0)", "LINESTRING(4 0,4 1,20 1,5 0,1 0)", "muu", "mui", "mix");
test_geometry<ls, ls>("LINESTRING(4 0,4 1,20 1,5 0,1 0)", "LINESTRING(0 0,30 0)", "muu", "miu", "mxi");
test_geometry<ls, ls>("LINESTRING(30 0,0 0)", "LINESTRING(1 0,5 0,20 1,4 1,4 0,5 0)",
expected("mui")("miu")("mui")("mix").vec);
test_geometry<ls, ls>("LINESTRING(1 0,5 0,20 1,4 1,4 0,5 0)", "LINESTRING(30 0,0 0)",
expected("miu")("mui")("miu")("mxi").vec);
//if ( boost::is_same<T, double>::value )
//{
// to_svg<ls, ls>("LINESTRING(0 0,1 0,2 0,2.5 0,3 1)", "LINESTRING(0 0,2 0,2.5 0,3 1)", "test11.svg");