[GRASS-SVN] r53268 - in grass/trunk/lib/raster3d: . test

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Sep 22 17:40:56 PDT 2012


Author: huhabla
Date: 2012-09-22 17:40:56 -0700 (Sat, 22 Sep 2012)
New Revision: 53268

Modified:
   grass/trunk/lib/raster3d/defaults.c
   grass/trunk/lib/raster3d/fpcompress.c
   grass/trunk/lib/raster3d/open.c
   grass/trunk/lib/raster3d/test/Makefile
   grass/trunk/lib/raster3d/test/test_g3d_lib.h
   grass/trunk/lib/raster3d/test/test_main.c
   grass/trunk/lib/raster3d/test/test_put_get_value_large_file.c
Log:
Disbaled the use of XDR and RLE when opening a new 3D raster map.
New maps are using now the non-XDR related functions for reading and writing 
and the LZW compression. RLE was disabled since it is buggy with large tiles and files.


Modified: grass/trunk/lib/raster3d/defaults.c
===================================================================
--- grass/trunk/lib/raster3d/defaults.c	2012-09-22 00:18:55 UTC (rev 53267)
+++ grass/trunk/lib/raster3d/defaults.c	2012-09-23 00:40:56 UTC (rev 53268)
@@ -8,8 +8,8 @@
 #define RASTER3D_NO_DEFAULT -10
 
 #define RASTER3D_COMPRESSION_DEFAULT RASTER3D_COMPRESSION
-#define RASTER3D_USE_LZW_DEFAULT RASTER3D_NO_LZW
-#define RASTER3D_USE_RLE_DEFAULT RASTER3D_USE_RLE
+#define RASTER3D_USE_LZW_DEFAULT RASTER3D_USE_LZW
+#define RASTER3D_USE_RLE_DEFAULT RASTER3D_NO_RLE
 #define RASTER3D_PRECISION_DEFAULT RASTER3D_MAX_PRECISION
 #define RASTER3D_CACHE_SIZE_DEFAULT 1000
 #define RASTER3D_CACHE_SIZE_MAX_DEFAULT 16777216

Modified: grass/trunk/lib/raster3d/fpcompress.c
===================================================================
--- grass/trunk/lib/raster3d/fpcompress.c	2012-09-22 00:18:55 UTC (rev 53267)
+++ grass/trunk/lib/raster3d/fpcompress.c	2012-09-23 00:40:56 UTC (rev 53268)
@@ -692,7 +692,7 @@
 
 /*--------------------------------------------------------------------------*/
 
-/* IMPORTANT!!! this function changes the "src". */
+/* IMPORTANT!!! this function modifies "src" in case of run length encoding RLE. */
 
 int
 Rast3d_fpcompress_write_xdr_nums(int fd, char *src, int nofNum, int precision,

Modified: grass/trunk/lib/raster3d/open.c
===================================================================
--- grass/trunk/lib/raster3d/open.c	2012-09-22 00:18:55 UTC (rev 53267)
+++ grass/trunk/lib/raster3d/open.c	2012-09-23 00:40:56 UTC (rev 53268)
@@ -243,7 +243,8 @@
 
     Rast3d_make_mapset_map_directory(map->fileName);
 
-    map->useXdr = RASTER3D_USE_XDR;
+    /* XDR support has been removed */
+    map->useXdr = RASTER3D_NO_XDR;
 
     if (g3d_file_type == FCELL_TYPE) {
 	if (precision > 23)
@@ -266,8 +267,6 @@
 
     if (compression == RASTER3D_NO_COMPRESSION)
 	precision = RASTER3D_MAX_PRECISION;
-    if (compression == RASTER3D_COMPRESSION)
-	map->useXdr = RASTER3D_USE_XDR;
 
     if (RASTER3D_HAS_INDEX) {
 	map->indexLongNbytes = sizeof(long);

Modified: grass/trunk/lib/raster3d/test/Makefile
===================================================================
--- grass/trunk/lib/raster3d/test/Makefile	2012-09-22 00:18:55 UTC (rev 53267)
+++ grass/trunk/lib/raster3d/test/Makefile	2012-09-23 00:40:56 UTC (rev 53268)
@@ -3,7 +3,10 @@
 PGM=test.g3d.lib
 
 LIBES = $(GISLIB) $(RASTER3DLIB) $(RASTERLIB) 
-DEPENDENCIES = $(GISDEP) $(RASTER3DDEP) $(RASTERDEP) 
+DEPENDENCIES = $(GISDEP) $(RASTER3DDEP) $(RASTERDEP)
+EXTRA_INC = $(VECT_INC)
+EXTRA_CFLAGS = $(VECT_CFLAGS)
+
 include $(MODULE_TOPDIR)/include/Make/Module.make
 
 default: cmd

Modified: grass/trunk/lib/raster3d/test/test_g3d_lib.h
===================================================================
--- grass/trunk/lib/raster3d/test/test_g3d_lib.h	2012-09-22 00:18:55 UTC (rev 53267)
+++ grass/trunk/lib/raster3d/test/test_g3d_lib.h	2012-09-23 00:40:56 UTC (rev 53268)
@@ -25,6 +25,6 @@
 double compute_time_difference(struct timeval start, struct timeval end);
 int unit_test_coordinate_transform(void);
 int unit_test_put_get_value(void);
-int unit_test_put_get_value_large_file(int depths, int rows, int cols);
+int unit_test_put_get_value_large_file(int depths, int rows, int cols, int tile_size);
 
 #endif

Modified: grass/trunk/lib/raster3d/test/test_main.c
===================================================================
--- grass/trunk/lib/raster3d/test/test_main.c	2012-09-22 00:18:55 UTC (rev 53267)
+++ grass/trunk/lib/raster3d/test/test_main.c	2012-09-23 00:40:56 UTC (rev 53268)
@@ -21,8 +21,8 @@
 
 /*- Parameters and global variables -----------------------------------------*/
 typedef struct {
-    struct Option *unit, *integration, *depths, *rows, *cols;
-    struct Flag *full, *testunit, *testint;
+    struct Option *unit, *integration, *depths, *rows, *cols, *tile_size;
+    struct Flag *full, *testunit, *testint, *rle, *compression;
 } paramType;
 
 paramType param; /*Parameters */
@@ -54,22 +54,29 @@
     param.depths->type = TYPE_INTEGER;
     param.depths->required = NO;
     param.depths->answer = "20";
-    param.depths->description = _("The number of depths to be used for the large file put value test");
+    param.depths->description = _("The number of depths to be used for the large file put/get value test");
 
     param.rows = G_define_option();
     param.rows->key = "rows";
     param.rows->type = TYPE_INTEGER;
     param.rows->required = NO;
     param.rows->answer = "5400";
-    param.rows->description = _("The number of rows to be used for the large file put value test");
+    param.rows->description = _("The number of rows to be used for the large file put/get value test");
 
     param.cols = G_define_option();
     param.cols->key = "cols";
     param.cols->type = TYPE_INTEGER;
     param.cols->required = NO;
     param.cols->answer = "10800";
-    param.cols->description = _("The number of columns to be used for the large file put value test");
+    param.cols->description = _("The number of columns to be used for the large file put/get value test");
 
+    param.tile_size = G_define_option();
+    param.tile_size->key = "tile_size";
+    param.tile_size->type = TYPE_INTEGER;
+    param.tile_size->required = NO;
+    param.tile_size->answer = "32";
+    param.tile_size->description = _("The tile size in kilo bytes to be used for the large file put/get value test. Set the tile size to 2048 and the number of row*cols*depths > 130000 to reproduce the tile rle error.");
+
     param.testunit = G_define_flag();
     param.testunit->key = 'u';
     param.testunit->description = _("Run all unit tests");
@@ -82,6 +89,13 @@
     param.full->key = 'a';
     param.full->description = _("Run all unit and integration tests");
 
+    param.compression = G_define_flag();
+    param.compression->key = 'l';
+    param.compression->description = _("Switch lzw compression on");
+
+    param.rle = G_define_flag();
+    param.rle->key = 'r';
+    param.rle->description = _("Use run length encoding RLE to encode/decode single tiles. Attention RLE is buggy in case of large tiles or files.");
 }
 
 /* ************************************************************************* */
@@ -91,7 +105,10 @@
 int main(int argc, char *argv[]) {
     struct GModule *module;
     int returnstat = 0, i;
-    int depths, rows, cols;
+    int depths, rows, cols, tile_size;
+    int doCompress = RASTER3D_COMPRESSION;
+    int doLzw = RASTER3D_USE_LZW;
+    int doRle = RASTER3D_NO_RLE;
 
     /* Initialize GRASS */
     G_gisinit(argv[0]);
@@ -109,6 +126,23 @@
     depths = atoi(param.depths->answer);
     rows   = atoi(param.rows->answer);
     cols   = atoi(param.cols->answer);
+    tile_size = atoi(param.tile_size->answer);
+
+    if(param.compression->answer) {
+        doCompress = RASTER3D_COMPRESSION;
+        doLzw = RASTER3D_USE_LZW;
+    } else {
+        doCompress = RASTER3D_NO_COMPRESSION;
+        doLzw = RASTER3D_NO_LZW;
+    }
+    if(param.rle->answer) {
+        doCompress = RASTER3D_COMPRESSION;
+        doRle = RASTER3D_USE_RLE;
+    } else
+        doRle = RASTER3D_NO_RLE;
+
+    /* Set the compression mode that should be used */
+    Rast3d_set_compression_mode(doCompress, doLzw, doRle, RASTER3D_MAX_PRECISION);
    
     /* Initiate the defaults for testing */
     Rast3d_init_defaults();
@@ -117,7 +151,7 @@
     if (param.testunit->answer || param.full->answer) {
         returnstat += unit_test_coordinate_transform();
         returnstat += unit_test_put_get_value();
-        returnstat += unit_test_put_get_value_large_file(depths, rows, cols);
+        returnstat += unit_test_put_get_value_large_file(depths, rows, cols, tile_size);
     }
 
     /*Run the integration tests */
@@ -137,7 +171,7 @@
                     if (strcmp(param.unit->answers[i], "putget") == 0)
                         returnstat += unit_test_put_get_value();
                     if (strcmp(param.unit->answers[i], "large") == 0)
-                        returnstat += unit_test_put_get_value_large_file(depths, rows, cols);
+                        returnstat += unit_test_put_get_value_large_file(depths, rows, cols, tile_size);
                     
                     i++;
                 }

Modified: grass/trunk/lib/raster3d/test/test_put_get_value_large_file.c
===================================================================
--- grass/trunk/lib/raster3d/test/test_put_get_value_large_file.c	2012-09-22 00:18:55 UTC (rev 53267)
+++ grass/trunk/lib/raster3d/test/test_put_get_value_large_file.c	2012-09-23 00:40:56 UTC (rev 53268)
@@ -19,18 +19,20 @@
 #include "test_g3d_lib.h"
 #include "grass/interpf.h"
 
-static int test_large_file(int depths, int rows, int cols);
+#define EPSILON 0.000000001
 
+static int test_large_file(int depths, int rows, int cols, int tile_size);
+
 /* *************************************************************** */
 /* Perfrome the coordinate transformation tests ****************** */
 /* *************************************************************** */
-int unit_test_put_get_value_large_file(int depths, int rows, int cols)
+int unit_test_put_get_value_large_file(int depths, int rows, int cols, int tile_size)
 {
     int sum = 0;
 
     G_message(_("\n++ Running g3d put/get value large file unit tests ++"));
 
-    sum += test_large_file(depths, rows, cols);
+    sum += test_large_file(depths, rows, cols, tile_size);
 
 
     if (sum > 0)
@@ -43,7 +45,7 @@
 
 /* *************************************************************** */
 
-int test_large_file(int depths, int rows, int cols)
+int test_large_file(int depths, int rows, int cols, int tile_size)
 {
     int sum = 0; 
     int x, y, z;
@@ -72,7 +74,7 @@
         
     G_message("Creating 3D raster map");
 
-    map = Rast3d_open_new_opt_tile_size("test_put_get_value_dcell_large", RASTER3D_USE_CACHE_XY, &region, DCELL_TYPE, 2048);
+    map = Rast3d_open_new_opt_tile_size("test_put_get_value_dcell_large", RASTER3D_USE_CACHE_XY, &region, DCELL_TYPE, tile_size);
     
     /* The window is the same as the map region ... of course */
     Rast3d_set_window_map(map, &region);
@@ -83,8 +85,9 @@
         for(y = 0; y < region.rows; y++) {
             for(x = 0; x < region.cols; x++) {
                 /* Add cols, rows and depths and put this in the map */
-                value = x + y + z + x * y * z / count++;
+                value = count;
                 Rast3d_put_value(map, x, y, z, &value, DCELL_TYPE);
+                count++;
             }
         }
     }
@@ -96,7 +99,7 @@
          
     G_message("Verifying 3D raster map");
 
-    map = Rast3d_open_cell_old("test_put_get_value_dcell_large", G_mapset(), &region, DCELL_TYPE, 2048);
+    map = Rast3d_open_cell_old("test_put_get_value_dcell_large", G_mapset(), &region, DCELL_TYPE, RASTER3D_USE_CACHE_XYZ);
     
     count = 1;
     for(z = 0; z < region.depths; z++) {
@@ -105,8 +108,11 @@
             for(x = 0; x < region.cols; x++) {
                 /* Add cols, rows and depths and put this in the map */
                 Rast3d_get_value(map, x, y, z, &value, DCELL_TYPE);
-                if(value != (double)(x + y + z  + x * y * z/count++))
+                if(fabs(value - (double)(count) > EPSILON)) {
+                    /* printf("At: z %i y %i x %i -- value %.14lf != %.14lf\n", z, y, x, value, (double)(count)); */
 			sum++;
+                }
+                count++;
             }
         }
     }



More information about the grass-commit mailing list