[postgis-commits] svn - r3426 - in trunk: cunit liblwgeom

postgis-commits at postgis.refractions.net postgis-commits at postgis.refractions.net
Tue Dec 16 16:19:28 PST 2008


Author: pramsey
Date: 2008-12-16 16:19:27 -0800 (Tue, 16 Dec 2008)
New Revision: 3426

Modified:
   trunk/cunit/cu_algorithm.c
   trunk/liblwgeom/lwalgorithm.c
   trunk/liblwgeom/lwalgorithm.h
Log:
Basic co-linearity support. Remove touching cases from crossingdirection.


Modified: trunk/cunit/cu_algorithm.c
===================================================================
--- trunk/cunit/cu_algorithm.c	2008-12-16 23:43:02 UTC (rev 3425)
+++ trunk/cunit/cu_algorithm.c	2008-12-17 00:19:27 UTC (rev 3426)
@@ -472,5 +472,23 @@
 	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 );
+
 }
 

Modified: trunk/liblwgeom/lwalgorithm.c
===================================================================
--- trunk/liblwgeom/lwalgorithm.c	2008-12-16 23:43:02 UTC (rev 3425)
+++ trunk/liblwgeom/lwalgorithm.c	2008-12-17 00:19:27 UTC (rev 3426)
@@ -175,6 +175,16 @@
 				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 @@
 	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;
 		

Modified: trunk/liblwgeom/lwalgorithm.h
===================================================================
--- trunk/liblwgeom/lwalgorithm.h	2008-12-16 23:43:02 UTC (rev 3425)
+++ trunk/liblwgeom/lwalgorithm.h	2008-12-17 00:19:27 UTC (rev 3426)
@@ -22,9 +22,7 @@
 	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);



More information about the postgis-commits mailing list