[GRASS-SVN] r48327 - grass/trunk/vector/v.clean

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Sep 17 05:31:21 EDT 2011


Author: mmetz
Date: 2011-09-17 02:31:21 -0700 (Sat, 17 Sep 2011)
New Revision: 48327

Modified:
   grass/trunk/vector/v.clean/main.c
   grass/trunk/vector/v.clean/v.clean.html
Log:
add new flag to combine tools with recommended follow-up tools

Modified: grass/trunk/vector/v.clean/main.c
===================================================================
--- grass/trunk/vector/v.clean/main.c	2011-09-16 23:05:45 UTC (rev 48326)
+++ grass/trunk/vector/v.clean/main.c	2011-09-17 09:31:21 UTC (rev 48327)
@@ -32,7 +32,7 @@
     struct GModule *module;
     struct Option *in_opt, *field_opt, *out_opt, *type_opt, *tool_opt, *thresh_opt,
 	*err_opt;
-    struct Flag *no_build_flag;
+    struct Flag *no_build_flag, *combine_flag;
     int *tools, ntools, atools;
     double *threshs;
     int level;
@@ -119,6 +119,11 @@
     no_build_flag->description =
 	_("Don't build topology for the output vector");
 
+    combine_flag = G_define_flag();
+    combine_flag->key = 'c';
+    combine_flag->description =
+	_("Combine tools with recommended follow-up tools.");
+
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
@@ -329,6 +334,10 @@
 	case TOOL_BREAK:
 	    G_message(_("Tool: Break lines at intersections"));
 	    Vect_break_lines(&Out, otype, pErr);
+	    if (combine_flag->answer) {
+		G_message(_("Tool: Remove duplicates"));
+		Vect_remove_duplicates(&Out, otype, pErr);
+	    }
 	    break;
 	case TOOL_RMDUPL:
 	    G_message(_("Tool: Remove duplicates"));
@@ -357,10 +366,27 @@
 	case TOOL_SNAP:
 	    G_message(_("Tool: Snap line to vertex in threshold"));
 	    Vect_snap_lines(&Out, otype, threshs[i], pErr);
+	    if (combine_flag->answer) {
+		int nmod;
+
+		do {
+		    G_message(_("Tool: Break lines at intersections"));
+		    Vect_break_lines(&Out, otype, pErr);
+		    G_message(_("Tool: Remove duplicates"));
+		    Vect_remove_duplicates(&Out, otype, pErr);
+		    G_message(_("Tool: Remove small angles at nodes"));
+		    nmod =
+			Vect_clean_small_angles_at_nodes(&Out, otype, pErr);
+		} while (nmod > 0);
+	    }
 	    break;
 	case TOOL_BPOL:
 	    G_message(_("Tool: Break polygons"));
 	    Vect_break_polygons(&Out, otype, pErr);
+	    if (combine_flag->answer) {
+		G_message(_("Tool: Remove duplicates"));
+		Vect_remove_duplicates(&Out, otype, pErr);
+	    }
 	    break;
 	case TOOL_PRUNE:
 	    G_message(_("Tool: Prune lines/boundaries"));
@@ -373,8 +399,23 @@
 	    break;
 	case TOOL_RMSA:
 	    G_message(_("Tool: Remove small angles at nodes"));
-	    count =
-		Vect_clean_small_angles_at_nodes(&Out, otype, pErr);
+	    if (!combine_flag->answer) {
+		count =
+		    Vect_clean_small_angles_at_nodes(&Out, otype, pErr);
+	    }
+	    else {
+		int nmod;
+
+		while ((nmod =
+		          Vect_clean_small_angles_at_nodes(&Out, otype, pErr)) > 0) {
+		    count += nmod;
+		    G_message(_("Tool: Break lines at intersections"));
+		    Vect_break_lines(&Out, otype, pErr);
+		    G_message(_("Tool: Remove duplicates"));
+		    Vect_remove_duplicates(&Out, otype, pErr);
+		    G_message(_("Tool: Remove small angles at nodes"));
+		}
+	    }
 	    break;
 	case TOOL_RMLINE:
 	    G_message(_("Tool: Remove all lines and boundaries of zero length"));

Modified: grass/trunk/vector/v.clean/v.clean.html
===================================================================
--- grass/trunk/vector/v.clean/v.clean.html	2011-09-16 23:05:45 UTC (rev 48326)
+++ grass/trunk/vector/v.clean/v.clean.html	2011-09-17 09:31:21 UTC (rev 48327)
@@ -14,7 +14,8 @@
 is broken at 1.0.
 <p>
 Breaking lines should be followed by removing duplicates, e.g. 
-<em>v.clean tool=break,rmdupl</em>.
+<em>v.clean tool=break,rmdupl</em>. If the <em>-c</em> flag is used with 
+<em>v.clean tool=break</em>, duplicates are automatically removed.
 
 <h3>Remove duplicate geometry features</h3>
 <em>tool=rmdupl</em>
@@ -97,12 +98,16 @@
 than <em>thresh</em>. If there is no other vertex within <em>thresh</em>, 
 no snapping will be done. The <em>type</em> option can have a strong 
 influence on the result. A too large threshold and <em>type=boundary</em>
-can severely damage area topology.
+can severely damage area topology, beyond repair.
 <p>
-Snapped boundaries may need to be cleaned with <em>rmdangle,break,rmdupl</em>.
+Snapped boundaries may need to be cleaned with <em>break,rmdupl,rmsa</em>. 
+If the <em>-c</em> flag is used with <em>v.clean tool=snap</em>, the 
+sequence of <em>break,rmdupl,rmsa</em> is automatically repeated after 
+snapping until no more small angles a left. Additional cleaning with e.g.
+<em>tool=rmdangle</em>may be necessary.
 
 <h3>Remove duplicate area centroids</h3>
-<em>tool=rmdupl</em>
+<em>tool=rmdac</em>
 <p>
 Threshold does not apply, use dummy value if <em>v.clean</em> is 
 run with several tools.
@@ -124,7 +129,9 @@
 does not break collapsed loops. The <em>bpol</em> tool is faster than 
 the <em>break</em> tool but needs more memory.
 <p>
-The <em>bpol</em> tool should be followed by <em>rmdupl</em>.
+The <em>bpol</em> tool should be followed by <em>rmdupl</em>. If the 
+<em>-c</em> flag is used with <em>v.clean tool=bpol</em>, duplicates are 
+automatically removed.
 
 <h3>Remove vertices in threshold from lines and boundaries</h3>
 <em>tool=prune</em>
@@ -174,7 +181,12 @@
 </td></tr>
 </table>
 <p>
-The <em>rmsa</em> tool should be followed by <em>break,rmdupl</em>.
+The <em>rmsa</em> tool should be followed by <em>break,rmdupl</em>. The 
+<em>rmsa</em> tool followed by <em>break,rmdupl</em> may need to be run 
+more than once to remove all small angles. If the <em>-c</em> flag is 
+used with <em>v.clean tool=rmsa</em>, the sequence of 
+<em>rmsa,break,rmdupl</em> is automatically repeated until no more small 
+angles a left.
 
 <h2>NOTES</h2>
 



More information about the grass-commit mailing list