[GRASS-SVN] r30560 - in grass/trunk: lib/vector/Vlib vector/v.clean

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Mar 14 06:53:44 EDT 2008


Author: martinl
Date: 2008-03-14 06:53:44 -0400 (Fri, 14 Mar 2008)
New Revision: 30560

Modified:
   grass/trunk/lib/vector/Vlib/remove_duplicates.c
   grass/trunk/vector/v.clean/main.c
Log:
v.clean+Vlib: rmdupl works also for face and kernel feature type


Modified: grass/trunk/lib/vector/Vlib/remove_duplicates.c
===================================================================
--- grass/trunk/lib/vector/Vlib/remove_duplicates.c	2008-03-14 09:47:00 UTC (rev 30559)
+++ grass/trunk/lib/vector/Vlib/remove_duplicates.c	2008-03-14 10:53:44 UTC (rev 30560)
@@ -62,9 +62,12 @@
 	*  this line and check if some of them is identical. If someone is identical
 	*  remove current line. (In each step just one line is deleted)
 	*/
-        /* TODO: 3D */
+
 	ndupl = 0;
-	if ( msgout ) fprintf (msgout, "%s: %5d", _("Duplicates"), ndupl ); 
+
+	if ( msgout )
+	    fprintf (msgout, "%s: %5d", _("Duplicates"), ndupl ); 
+
 	for ( i = 1; i <= nlines; i++ ){ 
 	    if ( !Vect_line_alive ( Map, i ) ) continue;
 
@@ -89,8 +92,11 @@
 		/* Forward */
 		forw = 1;
 	        for ( k = 0; k <  APoints->n_points; k++ ){ 
-                    if ( APoints->x[k] != BPoints->x[k] || APoints->y[k] != BPoints->y[k] ) {
-                        forw = 0; break;
+                    if ( APoints->x[k] != BPoints->x[k] ||
+			 APoints->y[k] != BPoints->y[k] ||
+			 (Vect_is_3d(Map) && APoints->z[k] != BPoints->z[k])) {
+                        forw = 0;
+			break;
 		    }	
 		}
 		
@@ -98,8 +104,10 @@
 		backw = 1;
 	        for ( k = 0; k <  APoints->n_points; k++ ){ 
                     if ( APoints->x[k] != BPoints->x[npoints - k - 1] || 
-			 APoints->y[k] != BPoints->y[npoints - k - 1] ) {
-                        backw = 0; break;
+			 APoints->y[k] != BPoints->y[npoints - k - 1] ||
+ 			 (Vect_is_3d(Map) && APoints->z[k] != BPoints->z[npoints - k - 1])) {
+			backw = 0;
+			break;
 		    }	
 		}
 		
@@ -126,8 +134,8 @@
 		ndupl++;
 		
 		if ( msgout ) {
-		    fprintf (stderr, "\r%s: %5d", _("Duplicates"), ndupl ); 
-		    fflush ( stderr );
+		    fprintf (msgout, "\r%s: %5d", _("Duplicates"), ndupl ); 
+		    fflush (msgout);
 		}
 		
 		break; /* line was deleted -> take the next one */
@@ -135,7 +143,8 @@
 	    nlines = Vect_get_num_lines (Map); /* For future when lines with cats will be rewritten */
 	    G_debug (3, "nlines =  %d\n", nlines );
 	}
-	if ( msgout ) fprintf (stderr, "\n" ); 
+	if ( msgout )
+	    fprintf (msgout, "\n"); 
 
 	return;
 }

Modified: grass/trunk/vector/v.clean/main.c
===================================================================
--- grass/trunk/vector/v.clean/main.c	2008-03-14 09:47:00 UTC (rev 30559)
+++ grass/trunk/vector/v.clean/main.c	2008-03-14 10:53:44 UTC (rev 30560)
@@ -47,7 +47,8 @@
 	in_opt = G_define_standard_option(G_OPT_V_INPUT);
 	out_opt = G_define_standard_option(G_OPT_V_OUTPUT);
 	type_opt = G_define_standard_option(G_OPT_V_TYPE);
-	
+	type_opt->options = "point,line,boundary,centroid,area,face,kernel";
+
 	err_opt = G_define_standard_option(G_OPT_V_OUTPUT);
 	err_opt->key = "error";
 	err_opt->description = _("Name of output map where errors are written");
@@ -63,7 +64,7 @@
         tool_opt->description = _("Cleaning tool");
         tool_opt->descriptions = 
 	    _("break;break lines at each intersection;"
-	      "rmdupl;remove duplicate lines (pay attention to categories!);" /* works for points too? what about other features? see lib/vector/Vlib/remove_duplicates.c */
+	      "rmdupl;remove duplicate geometry features (pay attention to categories!);"
 	      "rmdangle;remove dangles, threshold ignored if < 0;"
 	      "chdangle;change the type of boundary dangle to line, "
 	      "threshold ignored if < 0, input line type is ignored;"



More information about the grass-commit mailing list