[GRASS-SVN] r43716 - grass/trunk/raster/r.random

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Sep 27 15:57:18 EDT 2010


Author: glynn
Date: 2010-09-27 19:57:18 +0000 (Mon, 27 Sep 2010)
New Revision: 43716

Modified:
   grass/trunk/raster/r.random/random.c
Log:
Fix bogus raster output with cover= (bug #1082)


Modified: grass/trunk/raster/r.random/random.c
===================================================================
--- grass/trunk/raster/r.random/random.c	2010-09-27 19:32:44 UTC (rev 43715)
+++ grass/trunk/raster/r.random/random.c	2010-09-27 19:57:18 UTC (rev 43716)
@@ -130,15 +130,9 @@
 	}
 
 	for (col = 0; col < ncols && nt; col++) {
-	    if (!theState->use_nulls && is_null_value(theState->buf, col))
-		continue;
-	    if (theState->docover == TRUE) {	/* skip no data cover points */
-		if (!theState->use_nulls &&
-		    is_null_value(theState->cover, col))
-		    continue;
-	    }
-
-	    if (make_rand() % nc < nt) {
+	    if ((theState->use_nulls || !is_null_value(theState->buf, col)) &&
+		(!theState->docover || theState->use_nulls || !is_null_value(theState->cover, col)) &&
+		(make_rand() % nc < nt)) {
 		nt--;
 		if (is_null_value(theState->buf, col))
 		    cpvalue(&theState->nulls, 0, &theState->buf, col);
@@ -190,14 +184,14 @@
 		    cat++;
 		}
 		G_percent((theState->nRand - nt), theState->nRand, 2);
+
+		nc--;
 	    }
 	    else {
 		set_to_null(&theState->buf, col);
 		if (theState->docover == 1)
 		    set_to_null(&theState->cover, col);
 	    }
-
-	    nc--;
 	}
 
 	while (col < ncols) {



More information about the grass-commit mailing list