[GRASS-SVN] r45226 - grass/branches/releasebranch_6_4/vector/v.digit

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jan 28 05:18:52 EST 2011


Author: marisn
Date: 2011-01-28 02:18:51 -0800 (Fri, 28 Jan 2011)
New Revision: 45226

Modified:
   grass/branches/releasebranch_6_4/vector/v.digit/line.c
Log:
v.digit Snap to line startpoint to allow single boundary area creation (fixes #1255 merged from devel6 r44920)

Modified: grass/branches/releasebranch_6_4/vector/v.digit/line.c
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.digit/line.c	2011-01-28 10:08:27 UTC (rev 45225)
+++ grass/branches/releasebranch_6_4/vector/v.digit/line.c	2011-01-28 10:18:51 UTC (rev 45226)
@@ -150,6 +150,7 @@
     struct new_line *nl = closure;
     double x = D_d_to_u_col(sxn);
     double y = D_d_to_u_row(syn);
+    double dist;
 
     G_debug(3, "button = %d x = %d = %f y = %d = %f", button, sxn, x, syn, y);
 
@@ -170,8 +171,21 @@
     else {			/* GV_LINES */
 	/* Button may be 1,2,3 */
 	if (button == 1) {	/* New point */
-	    snap(&x, &y);
-	    Vect_append_point(nl->Points, x, y, 0);
+	    if (snap(&x, &y) == 0) {
+		/* If not snapping to other features, try to snap to lines start.
+		 * Allows to create area of single boundary. */
+		if (nl->Points->n_points > 2) {
+		    dist = Vect_points_distance(nl->Points->x[0], nl->Points->y[0], 0, x, y, 0, WITHOUT_Z);
+		    if (dist < get_thresh()) {
+			x = nl->Points->x[0];
+			y = nl->Points->y[0];
+		    }
+		}
+	    }
+	    if (Vect_append_point(nl->Points, x, y, 0) == -1) {
+		G_warning("Out of memory! Point not added.");
+		return 0;
+	    }
 
 	    if (nl->type == GV_LINE)
 		symb_set_driver_color(SYMB_LINE);



More information about the grass-commit mailing list