[GRASS-SVN] r42421 - grass/branches/develbranch_6/raster/r.random
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jun 1 15:04:02 EDT 2010
Author: hamish
Date: 2010-06-01 15:04:01 -0400 (Tue, 01 Jun 2010)
New Revision: 42421
Modified:
grass/branches/develbranch_6/raster/r.random/main.c
grass/branches/develbranch_6/raster/r.random/random.c
Log:
named boolean for cover map
Modified: grass/branches/develbranch_6/raster/r.random/main.c
===================================================================
--- grass/branches/develbranch_6/raster/r.random/main.c 2010-06-01 18:48:18 UTC (rev 42420)
+++ grass/branches/develbranch_6/raster/r.random/main.c 2010-06-01 19:04:01 UTC (rev 42421)
@@ -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.cmapset = NULL;
myState.inrcover = NULL;
}
@@ -118,7 +118,7 @@
if (myState.mapset == NULL)
G_fatal_error(_("Raster map <%s> not found"), myState.inraster);
- if (myState.docover == 1) {
+ if (myState.docover == TRUE) {
myState.cmapset = G_find_cell(myState.inrcover, "");
if (myState.cmapset == NULL)
G_fatal_error(_("Raster map <%s> not found"), myState.inrcover);
Modified: grass/branches/develbranch_6/raster/r.random/random.c
===================================================================
--- grass/branches/develbranch_6/raster/r.random/random.c 2010-06-01 18:48:18 UTC (rev 42420)
+++ grass/branches/develbranch_6/raster/r.random/random.c 2010-06-01 19:04:01 UTC (rev 42421)
@@ -40,14 +40,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;
@@ -77,7 +77,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);
@@ -91,7 +91,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);
@@ -121,13 +121,14 @@
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++) {
if (G_get_raster_row
(infd, theState->buf.data.v, row, theState->buf.type) < 0)
G_fatal_error(_("Cannot read raster row [%d] from raster map <%s>"),
row, theState->inraster);
- if (theState->docover == 1) {
+ if (theState->docover == TRUE) {
if (G_get_raster_row
(cinfd, theState->cover.data.v, row,
theState->cover.type) < 0)
@@ -138,7 +139,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;
@@ -148,7 +149,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);
}
@@ -247,7 +248,7 @@
/* close files */
G_close_cell(infd);
- if (theState->docover == 1)
+ if (theState->docover == TRUE)
G_close_cell(cinfd);
if (theState->outvector) {
db_commit_transaction(driver);
More information about the grass-commit
mailing list