[GRASS-SVN] r44920 - grass/branches/develbranch_6/vector/v.digit

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Jan 9 16:19:14 EST 2011


Author: marisn
Date: 2011-01-09 13:19:14 -0800 (Sun, 09 Jan 2011)
New Revision: 44920

Modified:
   grass/branches/develbranch_6/vector/v.digit/line.c
Log:
v.digit Snap to line startpoint to allow single boundary are creation (fixes #1255)

Modified: grass/branches/develbranch_6/vector/v.digit/line.c
===================================================================
--- grass/branches/develbranch_6/vector/v.digit/line.c	2011-01-09 20:27:12 UTC (rev 44919)
+++ grass/branches/develbranch_6/vector/v.digit/line.c	2011-01-09 21:19:14 UTC (rev 44920)
@@ -153,6 +153,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);
 
@@ -173,8 +174,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