Explorar el Código

streamlined cleaning functions: percent and verbose messages

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@36493 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz hace 16 años
padre
commit
b39b7dad39
Se han modificado 3 ficheros con 27 adiciones y 3 borrados
  1. 3 2
      lib/vector/Vlib/break_lines.c
  2. 5 1
      lib/vector/Vlib/break_polygons.c
  3. 19 0
      lib/vector/Vlib/snap.c

+ 3 - 2
lib/vector/Vlib/break_lines.c

@@ -99,6 +99,9 @@ Vect_break_lines_list(struct Map_info *Map, struct ilist *List_break,
     }
     G_debug(3, "nlines =  %d", nlines);
 
+    /* TODO: It seems that lines/boundaries are not broken at intersections
+     * with points/centroids. Check if true, if yes, skip GV_POINTS
+
     /* To find intersection of two lines (Vect_line_intersection) is quite slow.
      * Fortunately usual lines/boundaries in GIS often forms a network where lines
      * are connected by end points, and touch by MBR. This function checks and occasionaly
@@ -112,8 +115,6 @@ Vect_break_lines_list(struct Map_info *Map, struct ilist *List_break,
      */
     nbreaks = 0;
 
-    G_verbose_message(_("Intersections: %5d"), nbreaks);
-
     for (iline = 0; iline < nlines; iline++) {
 	G_percent(iline, nlines, 1);
 	if (List_break) {

+ 5 - 1
lib/vector/Vlib/break_polygons.c

@@ -59,7 +59,6 @@ typedef struct
 } XPNT;
 
 /* function used by binary tree to compare items */
-extern int compare_xpnts(const void *Xpnta, const void *Xpntb);
 
 int compare_xpnts(const void *Xpnta, const void *Xpntb)
 {
@@ -134,6 +133,8 @@ Vect_break_polygons(struct Map_info *Map, int type, struct Map_info *Err)
     npoints = 1;		/* index starts from 1 ! */
     nallpoints = 0;
 
+    G_verbose_message(_("Break polygons Pass 1: select break points"));
+
     for (i = 1; i <= nlines; i++) {
 	G_percent(i, nlines, 1);
 	G_debug(3, "i =  %d", i);
@@ -249,6 +250,9 @@ Vect_break_polygons(struct Map_info *Map, int type, struct Map_info *Err)
 
     /* Second loop through lines (existing when loop is started, no need to process lines written again)
      * and break at points marked for break */
+
+    G_verbose_message(_("Break polygons Pass 2: break at selected points"));
+
     for (i = 1; i <= nlines; i++) {
 	int n_orig_points;
 

+ 19 - 0
lib/vector/Vlib/snap.c

@@ -116,9 +116,13 @@ Vect_snap_lines_list(struct Map_info *Map, struct ilist *List_lines,
     nvertices = 0;
     XPnts = NULL;
 
+    G_verbose_message(_("Snap vertices Pass 1: select points"));
+
     for (line_idx = 0; line_idx < List_lines->n_values; line_idx++) {
 	int v;
 
+	G_percent(line_idx, List_lines->n_values, 2);
+
 	line = List_lines->value[line_idx];
 
 	G_debug(3, "line =  %d", line);
@@ -160,14 +164,20 @@ Vect_snap_lines_list(struct Map_info *Map, struct ilist *List_lines,
 	    }
 	}
     }
+    G_percent(line_idx, List_lines->n_values, 2); /* finish it */
+
     npoints = point - 1;
 
     /* Go through all registered points and if not yet marked mark it as anchor and assign this anchor
      * to all not yet marked points in threshold */
+    G_verbose_message(_("Snap vertices Pass 2: assign points to snap to"));
+
     nanchors = ntosnap = 0;
     for (point = 1; point <= npoints; point++) {
 	int i;
 
+	G_percent(point, npoints, 2);
+
 	G_debug(3, "  point = %d", point);
 
 	if (XPnts[point].anchor >= 0)
@@ -213,10 +223,14 @@ Vect_snap_lines_list(struct Map_info *Map, struct ilist *List_lines,
 
     nsnapped = ncreated = 0;
 
+    G_verbose_message(_("Snap vertices Pass 3: snap to assigned points"));
+
     for (line_idx = 0; line_idx < List_lines->n_values; line_idx++) {
 	int v, spoint, anchor;
 	int changed = 0;
 
+	G_percent(line_idx, List_lines->n_values, 2);
+
 	line = List_lines->value[line_idx];
 
 	G_debug(3, "line =  %d", line);
@@ -380,6 +394,8 @@ Vect_snap_lines_list(struct Map_info *Map, struct ilist *List_lines,
 	}
     }				/* for each line */
 
+    G_percent(line_idx, List_lines->n_values, 2); /* finish it */
+
     Vect_destroy_line_struct(Points);
     Vect_destroy_line_struct(NPoints);
     Vect_destroy_cats_struct(Cats);
@@ -387,6 +403,9 @@ Vect_snap_lines_list(struct Map_info *Map, struct ilist *List_lines,
     G_free(Index);
     G_free(New);
     RTreeDestroyNode(RTree);
+
+    G_verbose_message(_("Snapped vertices: %d"), nsnapped);
+    G_verbose_message(_("New vertices: %d"), ncreated);
 }
 
 /* for qsort */