[GRASS-SVN] r46703 - grass/trunk/raster/r.univar

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jun 14 08:01:11 EDT 2011


Author: mmetz
Date: 2011-06-14 05:01:11 -0700 (Tue, 14 Jun 2011)
New Revision: 46703

Modified:
   grass/trunk/raster/r.univar/r3.univar_main.c
Log:
hopefully failsafe reading of the zonal map

Modified: grass/trunk/raster/r.univar/r3.univar_main.c
===================================================================
--- grass/trunk/raster/r.univar/r3.univar_main.c	2011-06-14 10:03:58 UTC (rev 46702)
+++ grass/trunk/raster/r.univar/r3.univar_main.c	2011-06-14 12:01:11 UTC (rev 46703)
@@ -173,7 +173,7 @@
 	else
 	    zone_info.max = dmax + 0.5;
 
-	G_debug(0, "min: %d, max: %d", zone_info.min, zone_info.max);
+	G_debug(1, "min: %d, max: %d", zone_info.min, zone_info.max);
 	zone_info.n_zones = zone_info.max - zone_info.min + 1;
 
 	use_zone = 1;
@@ -199,7 +199,6 @@
 	i++;
  
     n_zones = zone_info.n_zones;
-    G_debug(0, "%d zones", n_zones);
 
     if (n_zones == 0)
         n_zones = 1;
@@ -219,13 +218,24 @@
 	    for (x = 0; x < cols; x++) {
 		zone = 0;
 		if (zone_info.n_zones) {
-		    G3d_getValue(zmap, x, y, z, &val_d, DCELL_TYPE);
-		    if (G3d_isNullValueNum(&val_d, DCELL_TYPE))
-			continue;
-		    if (val_d < 0)
-			zone = val_d - 0.5;
-		    else
-			zone = val_d + 0.5;
+		    if (zmap_type == FCELL_TYPE) {
+			G3d_getValue(zmap, x, y, z, &val_f, FCELL_TYPE);
+			if (G3d_isNullValueNum(&val_f, FCELL_TYPE))
+			    continue;
+			if (val_f < 0)
+			    zone = val_f - 0.5;
+			else
+			    zone = val_f + 0.5;
+		    }
+		    else if (zmap_type == DCELL_TYPE) {
+			G3d_getValue(zmap, x, y, z, &val_d, DCELL_TYPE);
+			if (G3d_isNullValueNum(&val_d, DCELL_TYPE))
+			    continue;
+			if (val_d < 0)
+			    zone = val_d - 0.5;
+			else
+			    zone = val_d + 0.5;
+		    }
                     zone -= zone_info.min;
                 }
 		if (map_type == FCELL_TYPE) {



More information about the grass-commit mailing list