Commit 500fe3af authored by Paul Ramsey's avatar Paul Ramsey

Basic co-linearity support. Remove touching cases from crossingdirection.


git-svn-id: http://svn.osgeo.org/postgis/[email protected] b70326c6-7e19-0410-871a-916f4a2858ee
parent 04d43077
......@@ -472,5 +472,23 @@ void testLineCrossingLongLines(void)
setPoint4d(pa52, 4, p);
CU_ASSERT( lineCrossingDirection(l51, l52) == LINE_MULTICROSS_END_LEFT );
/* One mid-point co-linear crossing */
p->x = 1.0;
p->y = 1.0;
setPoint4d(pa52, 0, p);
p->x = 0.0;
p->y = 1.5;
setPoint4d(pa52, 1, p);
p->x = 0.0;
p->y = 2.5;
setPoint4d(pa52, 2, p);
p->x = -1.0;
p->y = 3.0;
setPoint4d(pa52, 3, p);
p->x = -1.0;
p->y = 4.0;
setPoint4d(pa52, 4, p);
CU_ASSERT( lineCrossingDirection(l51, l52) == LINE_CROSS_LEFT );
}
......@@ -175,6 +175,16 @@ int lineCrossingDirection(LWLINE *l1, LWLINE *l2) {
cross_right++;
break;
}
/*
** Crossing at a co-linearity can be turned into crossing at
** a vertex by pulling the original touch point forward along
** the co-linearity.
*/
if( this_cross == SEG_COLINEAR && vertex_touch == (i-1) ) {
vertex_touch = i;
break;
}
/*
** Crossing-at-vertex will cause four segment touch interactions, two at
......@@ -223,15 +233,9 @@ int lineCrossingDirection(LWLINE *l1, LWLINE *l2) {
lwfree(q1);
lwfree(q2);
if( !cross_left && !cross_right && !first_cross && !final_cross )
if( !cross_left && !cross_right )
return LINE_NO_CROSS;
if( !cross_left && !cross_right && ( first_cross == SEG_TOUCH_RIGHT || final_cross == SEG_TOUCH_RIGHT ) )
return LINE_TOUCH_RIGHT;
if( !cross_left && !cross_right && ( first_cross == SEG_TOUCH_LEFT || final_cross == SEG_TOUCH_LEFT ) )
return LINE_TOUCH_LEFT;
if( !cross_left && cross_right == 1 )
return LINE_CROSS_RIGHT;
......
......@@ -22,9 +22,7 @@ enum CG_LINE_CROSS_TYPE {
LINE_MULTICROSS_END_LEFT = -2,
LINE_MULTICROSS_END_RIGHT = 2,
LINE_MULTICROSS_END_SAME_FIRST_LEFT = -3,
LINE_MULTICROSS_END_SAME_FIRST_RIGHT = 3,
LINE_TOUCH_LEFT = -4,
LINE_TOUCH_RIGHT = 4
LINE_MULTICROSS_END_SAME_FIRST_RIGHT = 3
};
int lineCrossingDirection(LWLINE *l1, LWLINE *l2);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment