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

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jun 1 15:25:03 EDT 2010


Author: hamish
Date: 2010-06-01 15:25:01 -0400 (Tue, 01 Jun 2010)
New Revision: 42422

Modified:
   grass/trunk/raster/r.random/main.c
   grass/trunk/raster/r.random/random.c
Log:
named boolean for cover map (merge from devbr6)

Modified: grass/trunk/raster/r.random/main.c
===================================================================
--- grass/trunk/raster/r.random/main.c	2010-06-01 19:04:01 UTC (rev 42421)
+++ grass/trunk/raster/r.random/main.c	2010-06-01 19:25:01 UTC (rev 42422)
@@ -101,11 +101,11 @@
     myState.use_nulls = flag.zero->answer;
     myState.inraster = parm.input->answer;
     if (parm.cover->answer) {
-	myState.docover = 1;
+	myState.docover = TRUE;
 	myState.inrcover = parm.cover->answer;
     }
     else {
-	myState.docover = 0;
+	myState.docover = FALSE;
 	myState.inrcover = NULL;
     }
     myState.outraster = parm.raster->answer;

Modified: grass/trunk/raster/r.random/random.c
===================================================================
--- grass/trunk/raster/r.random/random.c	2010-06-01 19:04:01 UTC (rev 42421)
+++ grass/trunk/raster/r.random/random.c	2010-06-01 19:25:01 UTC (rev 42422)
@@ -41,14 +41,14 @@
     if ((infd = theState->fd_old) < 0)
 	G_fatal_error(_("Unable to open raster map <%s>"),
 		      theState->inraster);
-    if (theState->docover == 1) {
+    if (theState->docover == TRUE) {
 	if ((cinfd = theState->fd_cold) < 0)
 	    G_fatal_error(_("Unable to open raster map <%s>"),
 			  theState->inrcover);
     }
 
     if (theState->outraster != NULL) {
-	if (theState->docover == 1)
+	if (theState->docover == TRUE)
 	    type = theState->cover.type;
 	else
 	    type = theState->buf.type;
@@ -76,7 +76,7 @@
 	Vect_map_add_dblink(&Out, 1, NULL, fi->table, "cat", fi->database,
 			    fi->driver);
 
-	if (theState->docover == 1)
+	if (theState->docover == TRUE)
 	    table = db_alloc_table(3);
 	else
 	    table = db_alloc_table(2);
@@ -90,7 +90,7 @@
 	db_set_column_name(column, "value");
 	db_set_column_sqltype(column, DB_SQL_TYPE_DOUBLE_PRECISION);
 
-	if (theState->docover == 1) {
+	if (theState->docover == TRUE) {
 	    column = db_get_table_column(table, 2);
 	    db_set_column_name(column, "covervalue");
 	    db_set_column_sqltype(column, DB_SQL_TYPE_DOUBLE_PRECISION);
@@ -120,10 +120,11 @@
 	theState->nCells - theState->nNulls;
     nt = theState->nRand;	/* Number of points to generate */
     cat = 1;
+
     /* Execute for loop for every row if nt>1 */
     for (row = 0; row < nrows && nt; row++) {
 	Rast_get_row(infd, theState->buf.data.v, row, theState->buf.type);
-	if (theState->docover == 1) {
+	if (theState->docover == TRUE) {
 	    Rast_get_row(cinfd, theState->cover.data.v, row,
 			 theState->cover.type);
 	}
@@ -131,7 +132,7 @@
 	for (col = 0; col < ncols && nt; col++) {
 	    if (!theState->use_nulls && is_null_value(theState->buf, col))
 		continue;
-	    if (theState->docover == 1) {	/* skip no data cover points */
+	    if (theState->docover == TRUE) {	/* skip no data cover points */
 		if (!theState->use_nulls &&
 		    is_null_value(theState->cover, col))
 		    continue;
@@ -141,7 +142,7 @@
 		nt--;
 		if (is_null_value(theState->buf, col))
 		    cpvalue(&theState->nulls, 0, &theState->buf, col);
-		if (theState->docover == 1) {
+		if (theState->docover == TRUE) {
 		    if (is_null_value(theState->cover, col))
 			cpvalue(&theState->cnulls, 0, &theState->cover, col);
 		}
@@ -240,7 +241,7 @@
 
     /* close files */
     Rast_close(infd);
-    if (theState->docover == 1)
+    if (theState->docover == TRUE)
 	Rast_close(cinfd);
     if (theState->outvector) {
 	db_commit_transaction(driver);



More information about the grass-commit mailing list