[GRASS-SVN] r36493 - grass/trunk/lib/vector/Vlib
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Mar 27 09:24:10 EDT 2009
Author: mmetz
Date: 2009-03-27 09:24:09 -0400 (Fri, 27 Mar 2009)
New Revision: 36493
Modified:
grass/trunk/lib/vector/Vlib/break_lines.c
grass/trunk/lib/vector/Vlib/break_polygons.c
grass/trunk/lib/vector/Vlib/snap.c
Log:
streamlined cleaning functions: percent and verbose messages
Modified: grass/trunk/lib/vector/Vlib/break_lines.c
===================================================================
--- grass/trunk/lib/vector/Vlib/break_lines.c 2009-03-27 12:20:31 UTC (rev 36492)
+++ grass/trunk/lib/vector/Vlib/break_lines.c 2009-03-27 13:24:09 UTC (rev 36493)
@@ -99,6 +99,9 @@
}
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 @@
*/
nbreaks = 0;
- G_verbose_message(_("Intersections: %5d"), nbreaks);
-
for (iline = 0; iline < nlines; iline++) {
G_percent(iline, nlines, 1);
if (List_break) {
Modified: grass/trunk/lib/vector/Vlib/break_polygons.c
===================================================================
--- grass/trunk/lib/vector/Vlib/break_polygons.c 2009-03-27 12:20:31 UTC (rev 36492)
+++ grass/trunk/lib/vector/Vlib/break_polygons.c 2009-03-27 13:24:09 UTC (rev 36493)
@@ -59,7 +59,6 @@
} 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 @@
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 @@
/* 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;
Modified: grass/trunk/lib/vector/Vlib/snap.c
===================================================================
--- grass/trunk/lib/vector/Vlib/snap.c 2009-03-27 12:20:31 UTC (rev 36492)
+++ grass/trunk/lib/vector/Vlib/snap.c 2009-03-27 13:24:09 UTC (rev 36493)
@@ -116,9 +116,13 @@
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 @@
}
}
}
+ 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 @@
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 @@
}
} /* 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 @@
G_free(Index);
G_free(New);
RTreeDestroyNode(RTree);
+
+ G_verbose_message(_("Snapped vertices: %d"), nsnapped);
+ G_verbose_message(_("New vertices: %d"), ncreated);
}
/* for qsort */
More information about the grass-commit
mailing list