[GRASS-SVN] r46745 - grass/trunk/raster3d/r3.to.rast

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jun 20 08:35:47 EDT 2011


Author: huhabla
Date: 2011-06-20 05:35:47 -0700 (Mon, 20 Jun 2011)
New Revision: 46745

Added:
   grass/trunk/raster3d/r3.to.rast/test_raster_slice_float_00001.ref
   grass/trunk/raster3d/r3.to.rast/test_raster_slice_float_00002.ref
   grass/trunk/raster3d/r3.to.rast/test_raster_slice_float_00003.ref
   grass/trunk/raster3d/r3.to.rast/test_raster_slice_float_00004.ref
   grass/trunk/raster3d/r3.to.rast/test_raster_slice_float_00005.ref
Modified:
   grass/trunk/raster3d/r3.to.rast/main.c
   grass/trunk/raster3d/r3.to.rast/test.r3.to.rast.sh
Log:
Fixed float import bug https://trac.osgeo.org/grass/ticket/1392 
Added tests for bug reproduction.

Modified: grass/trunk/raster3d/r3.to.rast/main.c
===================================================================
--- grass/trunk/raster3d/r3.to.rast/main.c	2011-06-20 10:34:19 UTC (rev 46744)
+++ grass/trunk/raster3d/r3.to.rast/main.c	2011-06-20 12:35:47 UTC (rev 46745)
@@ -103,7 +103,8 @@
 /* ************************************************************************* */
 void g3d_to_raster(void *map, G3D_Region region, int *fd)
 {
-    double d1 = 0, f1 = 0;
+    DCELL d1 = 0;
+    FCELL f1 = 0;
     int x, y, z;
     int rows, cols, depths, typeIntern, pos = 0;
     FCELL *fcell = NULL;
@@ -137,13 +138,13 @@
                     if (G3d_isNullValueNum(&f1, FCELL_TYPE))
                         Rast_set_null_value(&fcell[x], 1, FCELL_TYPE);
                     else
-                        fcell[x] = (FCELL) f1;
+                        fcell[x] = f1;
                 } else {
                     G3d_getValue(map, x, y, z, &d1, typeIntern);
                     if (G3d_isNullValueNum(&d1, DCELL_TYPE))
                         Rast_set_null_value(&dcell[x], 1, DCELL_TYPE);
                     else
-                        dcell[x] = (DCELL) d1;
+                        dcell[x] = d1;
                 }
             }
             if (typeIntern == FCELL_TYPE)

Modified: grass/trunk/raster3d/r3.to.rast/test.r3.to.rast.sh
===================================================================
--- grass/trunk/raster3d/r3.to.rast/test.r3.to.rast.sh	2011-06-20 10:34:19 UTC (rev 46744)
+++ grass/trunk/raster3d/r3.to.rast/test.r3.to.rast.sh	2011-06-20 12:35:47 UTC (rev 46745)
@@ -8,16 +8,21 @@
 # should work for UTM and LL test locations
 g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3
 # Now create a voxel map with value = col + row + depth. 
-r3.mapcalc --o expr="volume = col() + row() + depth()"
+r3.mapcalc --o expr="volume = double(col() + row() + depth())"
 # Add null value information
 r3.mapcalc --o expr="volume_null = if(row() == 1 || row() == 5, null(), volume)"
+# Create floating point map
+r3.mapcalc --o expr="volume_null_float = float(volume_null)"
 
+
 # First we @test with identical region settings for raster and voxel data
 # Reference data for all generated @raster maps are located in the r3.to.rast source directory.
 r3.to.rast --o input=volume_null output=test_raster_slice_1
+r3.to.rast --o input=volume_null_float output=test_raster_slice_float
 
 # Export of the references
 # for i in `g.mlist type=rast pattern=test_raster_slice_1*` ; do r.out.ascii input=$i output=${i}.ref; done
+for i in `g.mlist type=rast pattern=test_raster_slice_float*` ; do r.out.ascii input=$i output=${i}.ref; done
 
 # The next @preprocess step adjusts the raster region to increase the resolution by 2
 g.region res=7.5 -p3

Added: grass/trunk/raster3d/r3.to.rast/test_raster_slice_float_00001.ref
===================================================================
--- grass/trunk/raster3d/r3.to.rast/test_raster_slice_float_00001.ref	                        (rev 0)
+++ grass/trunk/raster3d/r3.to.rast/test_raster_slice_float_00001.ref	2011-06-20 12:35:47 UTC (rev 46745)
@@ -0,0 +1,14 @@
+north: 80
+south: 0
+east: 120
+west: 0
+rows: 8
+cols: 12
+* * * * * * * * * * * * 
+4 5 6 7 8 9 10 11 12 13 14 15 
+5 6 7 8 9 10 11 12 13 14 15 16 
+6 7 8 9 10 11 12 13 14 15 16 17 
+* * * * * * * * * * * * 
+8 9 10 11 12 13 14 15 16 17 18 19 
+9 10 11 12 13 14 15 16 17 18 19 20 
+10 11 12 13 14 15 16 17 18 19 20 21 

Added: grass/trunk/raster3d/r3.to.rast/test_raster_slice_float_00002.ref
===================================================================
--- grass/trunk/raster3d/r3.to.rast/test_raster_slice_float_00002.ref	                        (rev 0)
+++ grass/trunk/raster3d/r3.to.rast/test_raster_slice_float_00002.ref	2011-06-20 12:35:47 UTC (rev 46745)
@@ -0,0 +1,14 @@
+north: 80
+south: 0
+east: 120
+west: 0
+rows: 8
+cols: 12
+* * * * * * * * * * * * 
+5 6 7 8 9 10 11 12 13 14 15 16 
+6 7 8 9 10 11 12 13 14 15 16 17 
+7 8 9 10 11 12 13 14 15 16 17 18 
+* * * * * * * * * * * * 
+9 10 11 12 13 14 15 16 17 18 19 20 
+10 11 12 13 14 15 16 17 18 19 20 21 
+11 12 13 14 15 16 17 18 19 20 21 22 

Added: grass/trunk/raster3d/r3.to.rast/test_raster_slice_float_00003.ref
===================================================================
--- grass/trunk/raster3d/r3.to.rast/test_raster_slice_float_00003.ref	                        (rev 0)
+++ grass/trunk/raster3d/r3.to.rast/test_raster_slice_float_00003.ref	2011-06-20 12:35:47 UTC (rev 46745)
@@ -0,0 +1,14 @@
+north: 80
+south: 0
+east: 120
+west: 0
+rows: 8
+cols: 12
+* * * * * * * * * * * * 
+6 7 8 9 10 11 12 13 14 15 16 17 
+7 8 9 10 11 12 13 14 15 16 17 18 
+8 9 10 11 12 13 14 15 16 17 18 19 
+* * * * * * * * * * * * 
+10 11 12 13 14 15 16 17 18 19 20 21 
+11 12 13 14 15 16 17 18 19 20 21 22 
+12 13 14 15 16 17 18 19 20 21 22 23 

Added: grass/trunk/raster3d/r3.to.rast/test_raster_slice_float_00004.ref
===================================================================
--- grass/trunk/raster3d/r3.to.rast/test_raster_slice_float_00004.ref	                        (rev 0)
+++ grass/trunk/raster3d/r3.to.rast/test_raster_slice_float_00004.ref	2011-06-20 12:35:47 UTC (rev 46745)
@@ -0,0 +1,14 @@
+north: 80
+south: 0
+east: 120
+west: 0
+rows: 8
+cols: 12
+* * * * * * * * * * * * 
+7 8 9 10 11 12 13 14 15 16 17 18 
+8 9 10 11 12 13 14 15 16 17 18 19 
+9 10 11 12 13 14 15 16 17 18 19 20 
+* * * * * * * * * * * * 
+11 12 13 14 15 16 17 18 19 20 21 22 
+12 13 14 15 16 17 18 19 20 21 22 23 
+13 14 15 16 17 18 19 20 21 22 23 24 

Added: grass/trunk/raster3d/r3.to.rast/test_raster_slice_float_00005.ref
===================================================================
--- grass/trunk/raster3d/r3.to.rast/test_raster_slice_float_00005.ref	                        (rev 0)
+++ grass/trunk/raster3d/r3.to.rast/test_raster_slice_float_00005.ref	2011-06-20 12:35:47 UTC (rev 46745)
@@ -0,0 +1,14 @@
+north: 80
+south: 0
+east: 120
+west: 0
+rows: 8
+cols: 12
+* * * * * * * * * * * * 
+8 9 10 11 12 13 14 15 16 17 18 19 
+9 10 11 12 13 14 15 16 17 18 19 20 
+10 11 12 13 14 15 16 17 18 19 20 21 
+* * * * * * * * * * * * 
+12 13 14 15 16 17 18 19 20 21 22 23 
+13 14 15 16 17 18 19 20 21 22 23 24 
+14 15 16 17 18 19 20 21 22 23 24 25 



More information about the grass-commit mailing list