[GRASS-SVN] r45201 - grass/trunk/lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jan 26 14:24:13 EST 2011


Author: mmetz
Date: 2011-01-26 11:24:13 -0800 (Wed, 26 Jan 2011)
New Revision: 45201

Modified:
   grass/trunk/lib/vector/Vlib/buffer2.c
Log:
fix for #994

Modified: grass/trunk/lib/vector/Vlib/buffer2.c
===================================================================
--- grass/trunk/lib/vector/Vlib/buffer2.c	2011-01-26 19:23:35 UTC (rev 45200)
+++ grass/trunk/lib/vector/Vlib/buffer2.c	2011-01-26 19:24:13 UTC (rev 45201)
@@ -54,6 +54,7 @@
     l = LENGTH(dx, dy);
     *x = dx / l;
     *y = dy / l;
+
     return;
 }
 
@@ -62,6 +63,7 @@
 {
     *nx = x * cosa - y * sina;
     *ny = x * sina + y * cosa;
+
     return;
 }
 
@@ -73,7 +75,6 @@
 			       double dalpha, double *nx, double *ny)
 {
     double cosa = cos(dalpha);
-
     double sina = sin(dalpha);
 
     /*    double cc = cosa*cosa;
@@ -90,6 +91,7 @@
     vb = (x * (-sina) + y * cosa) * db;
     *nx = va * cosa + vb * (-sina);
     *ny = va * sina + vb * cosa;
+
     return;
 }
 
@@ -103,9 +105,7 @@
 			     double dalpha, double *px, double *py)
 {
     double cosa = cos(dalpha);
-
     double sina = sin(dalpha);
-
     double u, v, len;
 
     /* rotate (x,y) -dalpha radians */
@@ -118,6 +118,7 @@
     u *= len;
     v *= len;
     rotate_vector(u, v, cosa, sina, px, py);
+
     return;
 }
 
@@ -131,6 +132,7 @@
     *a = y2 - y1;
     *b = x1 - x2;
     *c = x2 * y1 - x1 * y2;
+
     return;
 }
 
@@ -164,6 +166,7 @@
 
     if (tol > a)
 	tol = a;
+
     return 2 * acos(1 - tol / a);
 }
 
@@ -495,7 +498,6 @@
     int v0;
     int eside;			/* side of the current edge */
     double eangle;		/* current edge angle with Ox (according to the current direction) */
-
     struct pg_vertex *vert;	/* current vertex */
     struct pg_vertex *vert0;	/* last vertex */
     struct pg_edge *edge;	/* current edge; must be edge of vert */
@@ -630,15 +632,10 @@
 				  struct line_pnts *nPoints)
 {
     int i;
-
     int flag;
-
     int v;
-
     struct pg_vertex *vert;
-
     struct pg_edge *edge;
-
     double min_x, min_angle;
 
     G_debug(3, "extract_outer_contour()");
@@ -785,6 +782,7 @@
 	    }
 	}
     }
+
     return 0;
 }
 
@@ -808,6 +806,7 @@
 
 	area += (y2 + y1) * (x2 - x1);
     }
+
     return (area > 0);
 }
 
@@ -823,6 +822,7 @@
     }
     (*arrPoints)[*count] = Points;
     (*count)++;
+
     return;
 }
 
@@ -847,7 +847,6 @@
     struct planar_graph *pg2;
     struct line_pnts *sPoints, *cPoints;
     struct line_pnts **arrPoints;
-
     int i, count = 0;
     int res, winding;
     int auto_side;
@@ -964,7 +963,6 @@
     struct planar_graph *pg;
     struct line_pnts *tPoints, *outer;
     struct line_pnts **isles;
-
     int isles_count = 0;
     int res, winding;
     int more = 8;
@@ -1023,9 +1021,7 @@
 {
     struct line_pnts *tPoints, *outer;
     struct line_pnts **isles;
-
     int isles_count = 0, n_isles;
-
     int i, isle;
     int more = 8;
     int isles_allocated = 0;
@@ -1041,7 +1037,8 @@
     /* outer contour */
     outer = Vect_new_line_struct();
     Vect_get_area_points(Map, area, outer);
-    Vect_append_point(outer, outer->x[0], outer->y[0], outer->z[0]);
+    /* does not work with zero length line segments */
+    Vect_line_prune(outer);
 
     /* inner contours */
     for (i = 0; i < n_isles; i++) {
@@ -1053,8 +1050,8 @@
 	   if (Vect_line_length(tPoints) < 2*PI*max)
 	   continue;
 	 */
-	Vect_append_point(tPoints, tPoints->x[0], tPoints->y[0],
-			  tPoints->z[0]);
+	/* does not work with zero length line segments */
+	Vect_line_prune(tPoints);
 	add_line_to_array(tPoints, &isles, &isles_count, &isles_allocated,
 			  more);
 	tPoints = Vect_new_line_struct();
@@ -1087,9 +1084,7 @@
 			struct line_pnts **oPoints)
 {
     double tx, ty;
-
     double angular_tol, angular_step, phi1;
-
     int j, nsegments;
 
     G_debug(2, "Vect_point_buffer()");



More information about the grass-commit mailing list