[GRASS-SVN] r36192 - grass/trunk/lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Mar 3 14:14:43 EST 2009


Author: mmetz
Date: 2009-03-03 14:14:42 -0500 (Tue, 03 Mar 2009)
New Revision: 36192

Modified:
   grass/trunk/lib/vector/Vlib/build_nat.c
Log:
bugfix for Vect_attach_centroids, ticket #397

Modified: grass/trunk/lib/vector/Vlib/build_nat.c
===================================================================
--- grass/trunk/lib/vector/Vlib/build_nat.c	2009-03-03 17:45:46 UTC (rev 36191)
+++ grass/trunk/lib/vector/Vlib/build_nat.c	2009-03-03 19:14:42 UTC (rev 36192)
@@ -365,6 +365,10 @@
      * to check if original area exist, unregister centroid from previous area.
      * To simplify code, this is implemented so that centroid is always firs unregistered 
      * and if new area is found, it is registered again.
+     *
+     * This problem can be avoided altogether if properly attached centroids
+     * are skipped
+     * MM 2009
      */
 
     Vect_select_lines_by_box(Map, box, GV_CENTROID, List);
@@ -376,14 +380,15 @@
 	Line = plus->Line[centr];
 	Node = plus->Node[Line->N1];
 
-	/* Unregister centroid */
+	/* only attach unregistered and duplicate centroids because 
+	 * 1) all properly attached centroids are properly attached, really! Don't touch.
+	 * 2) Vect_find_area() below does not always return the correct area
+	 * 3) it's faster
+	 */
+	if (Line->left > 0)
+	    continue; 
+
 	orig_area = Line->left;
-	if (orig_area > 0) {
-	    if (plus->Area[orig_area] != NULL) {
-		plus->Area[orig_area]->centroid = 0;
-	    }
-	}
-	Line->left = 0;
 
 	sel_area = Vect_find_area(Map, Node->x, Node->y);
 	G_debug(3, "  centroid %d is in area %d", centr, sel_area);
@@ -396,7 +401,7 @@
 	    }
 	    else if (Area->centroid != centr) {	/* duplicate centroid */
 		/* Note: it cannot happen that Area->centroid == centr, because the centroid
-		 * was previously unregistered */
+		 * was not registered or a duplicate */
 		G_debug(3, "  duplicate centroid -> do not attach to area");
 		Line->left = -sel_area;
 	    }



More information about the grass-commit mailing list