[GRASS-SVN] r46324 - grass/trunk/raster/r.out.gdal

svn_grass at osgeo.org svn_grass at osgeo.org
Tue May 17 10:58:26 EDT 2011


Author: mmetz
Date: 2011-05-17 07:58:26 -0700 (Tue, 17 May 2011)
New Revision: 46324

Modified:
   grass/trunk/raster/r.out.gdal/export_band.c
Log:
do not use Rast_get_null_value_row()

Modified: grass/trunk/raster/r.out.gdal/export_band.c
===================================================================
--- grass/trunk/raster/r.out.gdal/export_band.c	2011-05-17 13:08:32 UTC (rev 46323)
+++ grass/trunk/raster/r.out.gdal/export_band.c	2011-05-17 14:58:26 UTC (rev 46324)
@@ -63,12 +63,8 @@
 	G_warning(_("Unable to allocate buffer for reading raster map"));
 	return -1;
     }
-    char *nulls = (char *)G_malloc(cols);
 
-    if (nulls == NULL) {
-	G_warning(_("Unable to allocate buffer for reading raster map"));
-	return -1;
-    }
+    /* the following routine must be kept identical to export_band */
 
     /* Copy data form GRASS raster to GDAL raster */
     int row, col;
@@ -89,10 +85,8 @@
 	for (row = 0; row < rows; row++) {
 
 	    Rast_get_row(fd, bufer, row, maptype);
-	    Rast_get_null_value_row(fd, nulls, row);
 	    for (col = 0; col < cols; col++) {
-		if (nulls[col]) {
-		    ((FCELL *) bufer)[col] = fnullval;
+		if (Rast_is_f_null_value(&((FCELL *) bufer)[col])) {
 		    n_nulls++;
 		}
 		else {
@@ -117,9 +111,8 @@
 	for (row = 0; row < rows; row++) {
 
 	    Rast_get_row(fd, bufer, row, maptype);
-	    Rast_get_null_value_row(fd, nulls, row);
 	    for (col = 0; col < cols; col++) {
-		if (nulls[col]) {
+		if (Rast_is_d_null_value(&((DCELL *) bufer)[col])) {
 		    ((DCELL *) bufer)[col] = dnullval;
 		    n_nulls++;
 		}
@@ -145,9 +138,8 @@
 	for (row = 0; row < rows; row++) {
 
 	    Rast_get_row(fd, bufer, row, maptype);
-	    Rast_get_null_value_row(fd, nulls, row);
 	    for (col = 0; col < cols; col++) {
-		if (nulls[col]) {
+		if (Rast_is_c_null_value(&((CELL *) bufer)[col])) {
 		    ((CELL *) bufer)[col] = inullval;
 		    n_nulls++;
 		}
@@ -206,6 +198,8 @@
 	ret = -1;
     }
 
+    G_free(bufer);
+
     return ret;
 }
 
@@ -360,12 +354,8 @@
 	G_warning(_("Unable to allocate buffer for reading raster map"));
 	return -1;
     }
-    char *nulls = (char *)G_malloc(cols);
 
-    if (nulls == NULL) {
-	G_warning(_("Unable to allocate buffer for reading raster map"));
-	return -1;
-    }
+    /* the following routine must be kept identical to exact_checks */
 
     /* Copy data form GRASS raster to GDAL raster */
     int row, col;
@@ -385,9 +375,8 @@
 	for (row = 0; row < rows; row++) {
 
 	    Rast_get_row(fd, bufer, row, maptype);
-	    Rast_get_null_value_row(fd, nulls, row);
 	    for (col = 0; col < cols; col++) {
-		if (nulls[col]) {
+		if (Rast_is_f_null_value(&((FCELL *) bufer)[col])) {
 		    ((FCELL *) bufer)[col] = fnullval;
 		    if (n_nulls == 0) {
 			GDALSetRasterNoDataValue(hBand, nodataval);
@@ -415,9 +404,8 @@
 	for (row = 0; row < rows; row++) {
 
 	    Rast_get_row(fd, bufer, row, maptype);
-	    Rast_get_null_value_row(fd, nulls, row);
 	    for (col = 0; col < cols; col++) {
-		if (nulls[col]) {
+		if (Rast_is_d_null_value(&((DCELL *) bufer)[col])) {
 		    ((DCELL *) bufer)[col] = dnullval;
 		    if (n_nulls == 0) {
 			GDALSetRasterNoDataValue(hBand, nodataval);
@@ -445,9 +433,8 @@
 	for (row = 0; row < rows; row++) {
 
 	    Rast_get_row(fd, bufer, row, maptype);
-	    Rast_get_null_value_row(fd, nulls, row);
 	    for (col = 0; col < cols; col++) {
-		if (nulls[col]) {
+		if (Rast_is_c_null_value(&((CELL *) bufer)[col])) {
 		    ((CELL *) bufer)[col] = inullval;
 		    if (n_nulls == 0) {
 			GDALSetRasterNoDataValue(hBand, nodataval);
@@ -466,6 +453,8 @@
 	}
     }
 
+    G_free(bufer);
+
     return ret;
 }
 



More information about the grass-commit mailing list