[GRASS-SVN] r39229 - grass/branches/releasebranch_6_4/vector/v.generalize

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Sep 17 09:50:19 EDT 2009


Author: mmetz
Date: 2009-09-17 09:50:18 -0400 (Thu, 17 Sep 2009)
New Revision: 39229

Modified:
   grass/branches/releasebranch_6_4/vector/v.generalize/main.c
Log:
added warnings for corrupted areas

Modified: grass/branches/releasebranch_6_4/vector/v.generalize/main.c
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.generalize/main.c	2009-09-17 06:45:33 UTC (rev 39228)
+++ grass/branches/releasebranch_6_4/vector/v.generalize/main.c	2009-09-17 13:50:18 UTC (rev 39229)
@@ -63,7 +63,7 @@
     int look_ahead, iterations;
     int chcat;
     int ret, layer;
-    int n_areas, n_lines;
+    int n_areas, n_orig_areas, n_lines;
     double x, y;
     int simplification, mask_type;
     VARRAY *varray;
@@ -342,7 +342,6 @@
 	varray = NULL;
     }
 
-
     Vect_copy_head_data(&In, &Out);
     Vect_hist_copy(&In, &Out);
     Vect_hist_command(&Out);
@@ -436,6 +435,7 @@
     /* remove incorrect boundaries
      * they may occur only if they were generalized */
     if (mask_type & GV_BOUNDARY) {
+	int n_del = 0;
 	Vect_build_partial(&Out, GV_BUILD_ATTACH_ISLES);
 	n_lines = Vect_get_num_lines(&Out);
 	for (i = 1; i <= n_lines; i++) {
@@ -446,8 +446,14 @@
 	    if (left == 0 || right == 0) {
 		Vect_delete_line(&Out, i);
 		total_output -= Points->n_points;
+		n_del++;
 	    }
 	}
+	if (n_del)
+	    G_warning(_("%d boundaries were deleted, input areas are not preserved"), n_del);
+
+	/* make sure that clean topo is built at the end */
+	Vect_build_partial(&Out, GV_BUILD_NONE);
     }
 
 
@@ -462,6 +468,8 @@
 	    /* skip dead area */
 	    if (!Vect_area_alive(&Out, i))
 		continue;
+
+	    /* area i in Out is not necessarily equal to area i in In! */
 	    Vect_get_area_cats(&In, i, Cats);
 	    ret = Vect_get_point_in_area(&Out, i, &x, &y);
 	    if (ret < 0) {
@@ -472,12 +480,16 @@
 	    Vect_append_point(Points, x, y, 0.0);
 	    Vect_write_line(&Out, GV_CENTROID, Points, Cats);
 	}
+	G_warning(_("New centroids were calculated, attribute attachment may be changed"));
     }
 
     /* remove small areas */
     if (rs_flag->answer && simplification && (mask_type & GV_AREA)) {
 	Vect_build_partial(&Out, GV_BUILD_CENTROIDS);
 	Vect_remove_small_areas(&Out, thresh, NULL, &slide);
+
+	/* make sure that clean topo is built at the end */
+	Vect_build_partial(&Out, GV_BUILD_NONE);
     }
 
     Vect_build(&Out);
@@ -491,6 +503,12 @@
 		  total_input, total_output,
 		  (total_output * 100) / total_input);
 
+    /* warning about area corruption */
+    if (mask_type & GV_BOUNDARY && (n_orig_areas = Vect_get_num_areas(&In)) > 0) {
+	G_warning(_("Areas may have disappeared and/or area attribute attachment may have changed"));
+	G_warning(_("Try v.clean tool=prune thresh=%f"), thresh);
+    }
+
     Vect_close(&In);
     Vect_close(&Out);
 



More information about the grass-commit mailing list