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

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Dec 1 20:57:39 EST 2008


Author: hamish
Date: 2008-12-01 20:57:39 -0500 (Mon, 01 Dec 2008)
New Revision: 34659

Modified:
   grass/trunk/raster/r.watershed/seg/init_vars.c
Log:
bugfix from Markus Metz: correctly prune segments to max required; alloc for sscanf (merge from devbr6)

Modified: grass/trunk/raster/r.watershed/seg/init_vars.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/init_vars.c	2008-12-02 01:55:24 UTC (rev 34658)
+++ grass/trunk/raster/r.watershed/seg/init_vars.c	2008-12-02 01:57:39 UTC (rev 34659)
@@ -11,7 +11,6 @@
     int fd, num_cseg_total, num_open_segs;
     int seg_rows, seg_cols;
     double segs_mb;
-    char *mb_opt;
 
     /* int page_block, num_cseg; */
     int max_bytes;
@@ -29,6 +28,7 @@
     /* dep_slope = 0.0; */
     max_bytes = 0;
     sides = 8;
+    segs_mb = 300;
     for (r = 1; r < argc; r++) {
 	if (sscanf(argv[r], "el=%[^\n]", ele_name) == 1)
 	    ele_flag++;
@@ -60,11 +60,7 @@
 	    ls_flag++;
 	else if (sscanf(argv[r], "ob=%[^\n]", ob_name) == 1)
 	    ob_flag++;
-	else if (sscanf(argv[r], "mb=%[^\n]", mb_opt) == 1) {
-	    if (sscanf(mb_opt, "%lf", &segs_mb) == 0) {
-		segs_mb = 300;
-	    }
-	}
+	else if (sscanf(argv[r], "mb=%lf", &segs_mb) == 1) ;
 	else if (sscanf(argv[r], "r=%[^\n]", ril_name) == 1) {
 	    if (sscanf(ril_name, "%lf", &ril_value) == 0) {
 		ril_value = -1.0;
@@ -138,8 +134,10 @@
     num_open_segs = segs_mb / 2.86;
 
     G_debug(1, "segs MB: %.0f", segs_mb);
-    G_debug(1, "seg cols: %d", seg_cols);
+    G_debug(1, "region rows: %d", nrows);
     G_debug(1, "seg rows: %d", seg_rows);
+    G_debug(1, "region cols: %d", ncols);
+    G_debug(1, "seg cols: %d", seg_cols);
 
     num_cseg_total = nrows / SROW + 1;
     G_debug(1, "   row segments:\t%d", num_cseg_total);
@@ -152,8 +150,8 @@
     G_debug(1, "  open segments:\t%d", num_open_segs);
 
     /* nonsense to have more segments open than exist */
-    if (num_open_segs > nrows)
-	num_open_segs = nrows;
+    if (num_open_segs > num_cseg_total)
+	num_open_segs = num_cseg_total;
     G_debug(1, "  open segments after adjusting:\t%d", num_open_segs);
 
     cseg_open(&alt, seg_rows, seg_cols, num_open_segs);



More information about the grass-commit mailing list