[GRASS-SVN] r51162 - grass/trunk/raster/r.watershed/seg

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Mar 26 10:19:20 EDT 2012


Author: mmetz
Date: 2012-03-26 07:19:20 -0700 (Mon, 26 Mar 2012)
New Revision: 51162

Modified:
   grass/trunk/raster/r.watershed/seg/close_maps2.c
Log:
r.watershed: add safety check

Modified: grass/trunk/raster/r.watershed/seg/close_maps2.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/close_maps2.c	2012-03-26 13:55:38 UTC (rev 51161)
+++ grass/trunk/raster/r.watershed/seg/close_maps2.c	2012-03-26 14:19:20 UTC (rev 51162)
@@ -33,9 +33,14 @@
 	max = n_basins;
 	G_debug(1, "%d basins created", max);
 	Rast_init_colors(&colors);
-	Rast_make_random_colors(&colors, 1, max);
+	if (max > 0)
+	    Rast_make_random_colors(&colors, 1, max);
+	else {
+	    G_warning(_("No basins were created. Verify threshold and region settings."));
+	    Rast_make_random_colors(&colors, 1, 2);
+	}
 
-	if (max < 1000) {
+	if (max < 1000 && max > 0) {
 	    Rast_set_c_color((CELL) 0, 0, 0, 0, &colors);
 	    r = 1;
 	    incr = 0;



More information about the grass-commit mailing list