[GRASS-SVN] r56280 - grass/trunk/vector/v.generalize

svn_grass at osgeo.org svn_grass at osgeo.org
Thu May 16 13:55:33 PDT 2013


Author: mmetz
Date: 2013-05-16 13:55:33 -0700 (Thu, 16 May 2013)
New Revision: 56280

Modified:
   grass/trunk/vector/v.generalize/main.c
   grass/trunk/vector/v.generalize/smoothing.c
Log:
v.generalize: make loop support the default for smoothing

Modified: grass/trunk/vector/v.generalize/main.c
===================================================================
--- grass/trunk/vector/v.generalize/main.c	2013-05-16 15:47:52 UTC (rev 56279)
+++ grass/trunk/vector/v.generalize/main.c	2013-05-16 20:55:33 UTC (rev 56280)
@@ -228,8 +228,8 @@
 
     loop_support_flag = G_define_flag();
     loop_support_flag->key = 'l';
-    loop_support_flag->label = _("Loop support");
-    loop_support_flag->description = _("Modify end points of lines forming a closed loop");
+    loop_support_flag->label = _("Disable loop support");
+    loop_support_flag->description = _("Do not modify end points of lines forming a closed loop");
 
     notab_flag = G_define_standard_flag(G_FLG_V_TABLE);
     notab_flag->description = _("Do not copy attributes");
@@ -455,7 +455,7 @@
 	    Vect_append_points(Points, APoints, GV_FORWARD);
 	    
 	    loop_support = 0;
-	    if (loop_support_flag->answer) {
+	    if (!loop_support_flag->answer) {
 		int n1, n2;
 
 		Vect_get_line_nodes(&Out, i, &n1, &n2);

Modified: grass/trunk/vector/v.generalize/smoothing.c
===================================================================
--- grass/trunk/vector/v.generalize/smoothing.c	2013-05-16 15:47:52 UTC (rev 56279)
+++ grass/trunk/vector/v.generalize/smoothing.c	2013-05-16 20:55:33 UTC (rev 56280)
@@ -54,7 +54,7 @@
         Points->y[0] == Points->y[n - 1] &&
         (Points->z[0] == Points->z[n - 1] || with_z == 0) && loop_support){
         is_loop = 1;
-	count = n + look_ahead;
+	count = n;
     }
 
     res = G_malloc(sizeof(POINT) * n);
@@ -111,7 +111,6 @@
 int sliding_averaging(struct line_pnts *Points, double slide, int look_ahead, 
                       int loop_support, int with_z)
 {
-
     int n, half, i;
     double sc;
     POINT p, tmp, s;
@@ -219,10 +218,10 @@
         Points->y[0] == Points->y[n - 1] &&
         (Points->z[0] == Points->z[n - 1] || with_z == 0) && loop_support){
         is_loop = 1;
-        count = n + half;
+        count = n + half - 1;
     }
 
-    if (look_ahead % 2 == 0) {
+    if ((look_ahead & 1) == 0) {
 	G_fatal_error(_("Look ahead parameter must be odd"));
 	return n;
     }
@@ -433,15 +432,10 @@
     point = last = &head;
 
     if (!is_loop) {
-	/* length of p[0]..p[i+1] */
-	i = 0;
 	point_assign(Points, 0, with_z, &p0, 0);
 	point_assign(Points, 1, with_z, &p1, 0);
-	/* length of line 0..i */
-	length_begin = 0;
 	/* length of line from point 0 to i+1 */
 	length = point_dist(p0, p1);
-	next = 0;
 	/* tangent at p0, p1 */
 	point_subtract(p1, p0, &t0);
 	refine_tangent(&t0);
@@ -450,34 +444,31 @@
 	refine_tangent(&t1);
     }
     else {
-	/* length of p[0]..p[i+1] */
-	i = 0;
 	point_assign(Points, n - 2, with_z, &p0, 0);
 	point_assign(Points, 0, with_z, &p1, 0);
-	/* length of line 0..i */
-	length_begin = 0;
-	/* length of line from point 0 to i+1 */
+	/* length of line from point n - 2 to 0 = n - 1 */
 	length = point_dist(p0, p1);
-	next = 0;
-	/* tangent at pn-2, p1 */
+	/* tangent at p0, p1 */
 	point_assign(Points, 1, with_z, &tmp, 0);
 	point_subtract(tmp, p0, &t0);
 	refine_tangent(&t0);
 
 	point_assign(Points, 0, with_z, &p0, 0);
 	point_assign(Points, 1, with_z, &p1, 0);
-	/* length of line 0..i */
-	length_begin = 0;
-	/* length of line from point 0 to i+1 */
+	/* length of line from point 0 to 1 */
 	length = point_dist(p0, p1);
-	next = 0;
 	/* tangent at p0, p2 */
 	point_assign(Points, 2, with_z, &tmp, 0);
 	point_subtract(tmp, p0, &t1);
 	refine_tangent(&t1);
     }
+
+    /* length of line 0..i */
+    length_begin = 0;
+    next = 0;
     
     /* we always operate on the segment point[i]..point[i+1] */
+    i = 0;
     while (i < n - 1) {
 	if (next > length || (length - length_begin < GRASS_EPSILON)) {	/* segmet i..i+1 is finished or too short */
 	    i++;
@@ -637,8 +628,8 @@
     else {
 	/* loop: point 0 and point n - 1 are identical */
 
-	/* repeat last and first points at the beginning and end
-	 * of each vector respectively */
+	/* repeat last and first points at the beginning and
+	 * end of each vector respectively */
 
 	/* add points from n - plus - 1 to n - 2 */
 	for (i = 0, j = n - plus - 1; i < plus; i++, j++) {



More information about the grass-commit mailing list