[GRASS-SVN] r56984 - grass/trunk/raster/r.volume

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jul 2 08:01:25 PDT 2013


Author: mmetz
Date: 2013-07-02 08:01:25 -0700 (Tue, 02 Jul 2013)
New Revision: 56984

Modified:
   grass/trunk/raster/r.volume/main.c
Log:
r.volume: fix nodata handling, add fp support

Modified: grass/trunk/raster/r.volume/main.c
===================================================================
--- grass/trunk/raster/r.volume/main.c	2013-07-02 15:01:08 UTC (rev 56983)
+++ grass/trunk/raster/r.volume/main.c	2013-07-02 15:01:25 UTC (rev 56984)
@@ -34,7 +34,8 @@
 int main(int argc, char *argv[])
 {
     /* variables   */
-    CELL *data_buf, *clump_buf;
+    DCELL *data_buf;
+    CELL *clump_buf;
     CELL i, max;
     int row, col, rows, cols;
     int out_mode, use_MASK, *n, *e;
@@ -144,7 +145,7 @@
 	count[i] = 0;
     }
 
-    data_buf = Rast_allocate_c_buf();
+    data_buf = Rast_allocate_d_buf();
     clump_buf = Rast_allocate_c_buf();
 
     /* get window size */
@@ -154,7 +155,7 @@
     /* now get the data -- first pass */
     for (row = 0; row < rows; row++) {
 	G_percent(row, rows, 2);
-	Rast_get_c_row(fd_data, data_buf, row);
+	Rast_get_d_row(fd_data, data_buf, row);
 	Rast_get_c_row(fd_clump, clump_buf, row);
 	for (col = 0; col < cols; col++) {
 	    i = clump_buf[col];
@@ -166,7 +167,8 @@
 	    if (i < 1)
 		continue;	/* ignore zeros and negs */
 	    count[i]++;
-	    sum[i] += data_buf[col];
+	    if (!Rast_is_d_null_value(&data_buf[col]))
+		sum[i] += data_buf[col];
 	}
     }
     G_percent(row, rows, 2);



More information about the grass-commit mailing list