[GRASS-SVN] r55462 - in grass/trunk: lib/raster3d lib/raster3d/test raster3d/r3.cross.rast raster3d/r3.in.ascii raster3d/r3.in.v5d raster3d/r3.mask raster3d/r3.null raster3d/r3.out.ascii raster3d/r3.out.vtk raster3d/r3.retile raster3d/r3.stats raster3d/r3.to.rast

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Mar 19 17:14:25 PDT 2013


Author: huhabla
Date: 2013-03-19 17:14:25 -0700 (Tue, 19 Mar 2013)
New Revision: 55462

Modified:
   grass/trunk/lib/raster3d/cache.c
   grass/trunk/lib/raster3d/changeprecision.c
   grass/trunk/lib/raster3d/close.c
   grass/trunk/lib/raster3d/defaults.c
   grass/trunk/lib/raster3d/fpcompress.c
   grass/trunk/lib/raster3d/header.c
   grass/trunk/lib/raster3d/headerinfo.c
   grass/trunk/lib/raster3d/index.c
   grass/trunk/lib/raster3d/open.c
   grass/trunk/lib/raster3d/open2.c
   grass/trunk/lib/raster3d/param.c
   grass/trunk/lib/raster3d/putvalue.c
   grass/trunk/lib/raster3d/raster3d_intern.h
   grass/trunk/lib/raster3d/region.c
   grass/trunk/lib/raster3d/resample.c
   grass/trunk/lib/raster3d/retile.c
   grass/trunk/lib/raster3d/test/test_main.c
   grass/trunk/lib/raster3d/test/test_put_get_value.c
   grass/trunk/lib/raster3d/test/test_put_get_value_large_file.c
   grass/trunk/lib/raster3d/tileio.c
   grass/trunk/lib/raster3d/tileread.c
   grass/trunk/lib/raster3d/tilewrite.c
   grass/trunk/raster3d/r3.cross.rast/test.r3.cross.rast.sh
   grass/trunk/raster3d/r3.in.ascii/main.c
   grass/trunk/raster3d/r3.in.v5d/main.c
   grass/trunk/raster3d/r3.mask/main.c
   grass/trunk/raster3d/r3.null/main.c
   grass/trunk/raster3d/r3.null/test.r3.null.sh
   grass/trunk/raster3d/r3.out.ascii/test.r3.out.ascii.sh
   grass/trunk/raster3d/r3.out.vtk/test.r3.out.vtk.sh
   grass/trunk/raster3d/r3.retile/main.c
   grass/trunk/raster3d/r3.retile/test.r3.retile.sh
   grass/trunk/raster3d/r3.stats/test.r3.stats.sh
   grass/trunk/raster3d/r3.to.rast/test.r3.to.rast.sh
Log:
Removed buggy LRE compression from 3D raster library as discussed here:
http://trac.osgeo.org/grass/ticket/1752
3D raster modules have been adjusted to the API changes. Tests have been improved.


Modified: grass/trunk/lib/raster3d/cache.c
===================================================================
--- grass/trunk/lib/raster3d/cache.c	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/lib/raster3d/cache.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -56,8 +56,8 @@
 static int cacheWrite_readFun(int tileIndex, void *tileBuf, void *closure)
 {
     RASTER3D_Map *map = closure;
-    int index, nBytes;
-    long pos, offs, offsLast;
+    size_t index, nBytes;
+    size_t pos, offs, offsLast;
 
     pos = map->index[tileIndex];
 
@@ -135,8 +135,8 @@
 cacheWrite_writeFun(int tileIndex, const void *tileBuf, void *closure)
 {
     RASTER3D_Map *map = closure;
-    int nBytes;
-    long offs;
+    size_t nBytes;
+    size_t offs;
 
     if (map->index[tileIndex] != -1)
 	return 1;
@@ -277,8 +277,8 @@
 
 int Rast3d_flush_all_tiles(RASTER3D_Map * map)
 {
-    int tileIndex, nBytes;
-    long offs;
+    size_t tileIndex, nBytes;
+    size_t offs;
 
     if (map->operation == RASTER3D_READ_DATA) {
 	if (!Rast3d_cache_remove_all(map->cache)) {

Modified: grass/trunk/lib/raster3d/changeprecision.c
===================================================================
--- grass/trunk/lib/raster3d/changeprecision.c	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/lib/raster3d/changeprecision.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -23,7 +23,7 @@
 void Rast3d_change_precision(void *map, int precision, const char *nameOut)
 {
     void *map2;
-    int x, y, z, savePrecision, saveCompression, saveLzw, saveRle;
+    int x, y, z, savePrecision, saveCompression;
     char *data;
     RASTER3D_Region region;
     int typeIntern;
@@ -32,9 +32,8 @@
 
     saveType = Rast3d_get_file_type();
     /*   Rast3d_set_file_type (Rast3d_file_type_map (map)); */
-    Rast3d_get_compression_mode(&saveCompression, &saveLzw, &saveRle,
-			   &savePrecision);
-    Rast3d_set_compression_mode(RASTER3D_COMPRESSION, saveLzw, saveRle, precision);
+    Rast3d_get_compression_mode(&saveCompression, &savePrecision);
+    Rast3d_set_compression_mode(RASTER3D_COMPRESSION, precision);
     Rast3d_get_tile_dimension(&tileXsave, &tileYsave, &tileZsave);
     Rast3d_get_tile_dimensions_map(map, &tileX, &tileY, &tileZ);
     Rast3d_set_tile_dimension(tileX, tileY, tileZ);
@@ -48,7 +47,7 @@
 	Rast3d_fatal_error("Rast3d_change_precision: error in Rast3d_open_cell_new");
 
     Rast3d_set_file_type(saveType);
-    Rast3d_set_compression_mode(saveCompression, saveLzw, saveRle, savePrecision);
+    Rast3d_set_compression_mode(saveCompression, savePrecision);
     Rast3d_set_tile_dimension(tileXsave, tileYsave, tileZsave);
 
     data = Rast3d_alloc_tiles(map, 1);

Modified: grass/trunk/lib/raster3d/close.c
===================================================================
--- grass/trunk/lib/raster3d/close.c	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/lib/raster3d/close.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -187,7 +187,7 @@
 			     map->type,
 			     map->compression, map->useRle, map->useLzw,
 			     map->precision, map->offset, map->useXdr,
-			     map->hasIndex, map->unit, map->vertical_unit)) {
+			     map->hasIndex, map->unit, map->vertical_unit, map->version)) {
 	    G_warning(_("Unable to write header for 3D raster map <%s>"), map->fileName);
 	    return 0;
 	}

Modified: grass/trunk/lib/raster3d/defaults.c
===================================================================
--- grass/trunk/lib/raster3d/defaults.c	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/lib/raster3d/defaults.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -8,8 +8,6 @@
 #define RASTER3D_NO_DEFAULT -10
 
 #define RASTER3D_COMPRESSION_DEFAULT RASTER3D_COMPRESSION
-#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
@@ -26,12 +24,6 @@
 #define RASTER3D_COMPRESSION_ENV_VAR_YES "RASTER3D_USE_COMPRESSION"
 #define RASTER3D_COMPRESSION_ENV_VAR_NO "RASTER3D_NO_COMPRESSION"
 
-#define RASTER3D_LZW_ENV_VAR_YES "RASTER3D_USE_LZW"
-#define RASTER3D_LZW_ENV_VAR_NO "RASTER3D_NO_LZW"
-
-#define RASTER3D_RLE_ENV_VAR_YES "RASTER3D_USE_RLE"
-#define RASTER3D_RLE_ENV_VAR_NO "RASTER3D_NO_RLE"
-
 #define RASTER3D_PRECISION_ENV_VAR "RASTER3D_PRECISION"
 #define RASTER3D_PRECISION_ENV_VAR_MAX "RASTER3D_MAX_PRECISION"
 
@@ -52,9 +44,8 @@
 
 /*---------------------------------------------------------------------------*/
 
+int g3d_version = RASTER3D_MAP_VERSION;
 int g3d_do_compression = RASTER3D_NO_DEFAULT;
-int g3d_do_lzw_compression = RASTER3D_NO_DEFAULT;
-int g3d_do_rle_compression = RASTER3D_NO_DEFAULT;
 int g3d_precision = RASTER3D_NO_DEFAULT;
 int g3d_cache_default = RASTER3D_NO_DEFAULT;
 int g3d_cache_max = RASTER3D_NO_DEFAULT;
@@ -84,7 +75,7 @@
  */
 
 void
-Rast3d_set_compression_mode(int doCompress, int doLzw, int doRle, int precision)
+Rast3d_set_compression_mode(int doCompress, int precision)
 {
     if ((doCompress != RASTER3D_NO_COMPRESSION) && (doCompress != RASTER3D_COMPRESSION))
 	Rast3d_fatal_error("Rast3d_set_compression_mode: wrong value for doCompress.");
@@ -94,17 +85,9 @@
     if (doCompress == RASTER3D_NO_COMPRESSION)
 	return;
 
-    if ((doLzw != RASTER3D_NO_LZW) && (doLzw != RASTER3D_USE_LZW))
-	Rast3d_fatal_error("Rast3d_set_compression_mode: wrong value for doLzw.");
-
-    if ((doRle != RASTER3D_NO_RLE) && (doRle != RASTER3D_USE_RLE))
-	Rast3d_fatal_error("Rast3d_set_compression_mode: wrong value for doRle.");
-
     if (precision < -1)
 	Rast3d_fatal_error("Rast3d_set_compression_mode: wrong value for precision.");
 
-    g3d_do_lzw_compression = doLzw;
-    g3d_do_rle_compression = doRle;
     g3d_precision = precision;
 }
 
@@ -122,15 +105,10 @@
  */
 
 void
-Rast3d_get_compression_mode(int *doCompress, int *doLzw, int *doRle,
-		       int *precision)
+Rast3d_get_compression_mode(int *doCompress, int *precision)
 {
     if (doCompress != NULL)
 	*doCompress = g3d_do_compression;
-    if (doLzw != NULL)
-	*doLzw = g3d_do_lzw_compression;
-    if (doRle != NULL)
-	*doRle = g3d_do_rle_compression;
     if (precision != NULL)
 	*precision = g3d_precision;
 }
@@ -328,34 +306,6 @@
 	}
     }
 
-    if (g3d_do_lzw_compression == RASTER3D_NO_DEFAULT) {
-	if (NULL != getenv(RASTER3D_LZW_ENV_VAR_YES)) {
-	    g3d_do_lzw_compression = RASTER3D_USE_LZW;
-	}
-	else {
-	    if (NULL != getenv(RASTER3D_LZW_ENV_VAR_NO)) {
-		g3d_do_lzw_compression = RASTER3D_NO_LZW;
-	    }
-	    else {
-		g3d_do_lzw_compression = RASTER3D_USE_LZW_DEFAULT;
-	    }
-	}
-    }
-
-    if (g3d_do_rle_compression == RASTER3D_NO_DEFAULT) {
-	if (NULL != getenv(RASTER3D_RLE_ENV_VAR_YES)) {
-	    g3d_do_rle_compression = RASTER3D_USE_RLE;
-	}
-	else {
-	    if (NULL != getenv(RASTER3D_RLE_ENV_VAR_NO)) {
-		g3d_do_rle_compression = RASTER3D_NO_RLE;
-	    }
-	    else {
-		g3d_do_rle_compression = RASTER3D_USE_RLE_DEFAULT;
-	    }
-	}
-    }
-
     if (g3d_precision == RASTER3D_NO_DEFAULT) {
 	if (NULL != getenv(RASTER3D_PRECISION_ENV_VAR_MAX)) {
 	    g3d_precision = RASTER3D_MAX_PRECISION;

Modified: grass/trunk/lib/raster3d/fpcompress.c
===================================================================
--- grass/trunk/lib/raster3d/fpcompress.c	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/lib/raster3d/fpcompress.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -11,12 +11,6 @@
 #define XDR_FLOAT_LENGTH 4
 #define XDR_FLOAT_NOF_EXP_BYTES 1
 
-/*************
- * Only needed for transition */
-/* #define USE_LZW_COMPRESSION */
-
-/**************/
-
 /*--------------------------------------------------------------------------*/
 
 void Rast3d_fpcompress_print_binary(char *c, int numBits)
@@ -692,94 +686,25 @@
 
 /*--------------------------------------------------------------------------*/
 
-/* 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,
-			  char *compressBuf, int isFloat, int useRle,
-			  int useLzw)
+			  char *compressBuf, int isFloat)
 {
-    /* this table is used to determine the number of bits that should be used */
-    /* with G_lzw_write (), since a too large number of bits may reduce the */
-    /* compression. the values in the table are either based on experience for */
-    /* the small values, or guesses for the larger values. */
+    int status;
+    int nBytes;
+    int offsetMantissa;
 
-    int status, rleLength, nBytes, offsetMantissa;
-    char *dst, *srcStop;
-
     if (isFloat)
-	G_fpcompress_rearrangeEncodeFloats(src, nofNum, precision,
-					   compressBuf + 1,
+	G_fpcompress_rearrangeEncodeFloats((unsigned char *)src, nofNum, precision,
+			(unsigned char *)(compressBuf + 1),
 					   &nBytes, &offsetMantissa);
     else
-	G_fpcompress_rearrangeEncodeDoubles(src, nofNum, precision,
-					    compressBuf + 1,
+	G_fpcompress_rearrangeEncodeDoubles((unsigned char *)src, nofNum, precision,
+				(unsigned char *)(compressBuf + 1),
 					    &nBytes, &offsetMantissa);
 
-#ifdef USE_LZW_COMPRESSION
-    G_lzw_set_bits(9);
-#endif
-
-    if (useRle == RASTER3D_USE_RLE)
-	rleLength = Rast3d_rle_count_only(compressBuf + 1, offsetMantissa, 1);
-
-    if ((useRle == RASTER3D_USE_RLE) && (rleLength < offsetMantissa)) {
-
-	Rast3d_rle_encode(compressBuf + 1, src, offsetMantissa, 1);
-	srcStop = src + rleLength;
-	dst = compressBuf + 1 + offsetMantissa - rleLength;
-	while (src != srcStop)
-	    *dst++ = *src++;
-
-	*(compressBuf + offsetMantissa - rleLength) = 1;
-
-	if (useLzw == RASTER3D_USE_LZW)
-#ifdef USE_LZW_COMPRESSION
-	    status = G_lzw_write(fd, compressBuf + offsetMantissa - rleLength,
-				 nBytes - offsetMantissa + rleLength + 1);
-#else
-	    status = G_zlib_write(fd,
-				  (unsigned char *)(compressBuf +
-						    offsetMantissa -
-						    rleLength),
-				  nBytes - offsetMantissa + rleLength + 1);
-#endif
-	else
-#ifdef USE_LZW_COMPRESSION
-	    status =
-		G_lzw_write_noCompress(fd,
-				       compressBuf + offsetMantissa -
-				       rleLength,
-				       nBytes - offsetMantissa + rleLength +
-				       1);
-#else
-	    status = G_zlib_write_noCompress(fd,
-					     (unsigned char *)(compressBuf +
-							       offsetMantissa
-							       - rleLength),
-					     nBytes - offsetMantissa +
-					     rleLength + 1);
-#endif
-    }
-    else {
-
 	*compressBuf = 0;
-	if (useLzw == RASTER3D_USE_LZW)
-#ifdef USE_LZW_COMPRESSION
-	    status = G_lzw_write(fd, compressBuf, nBytes + 1);
-#else
-	    status =
-		G_zlib_write(fd, (unsigned char *)compressBuf, nBytes + 1);
-#endif
-	else
-#ifdef USE_LZW_COMPRESSION
-	    status = G_lzw_write_noCompress(fd, compressBuf, nBytes + 1);
-#else
-	    status =
-		G_zlib_write_noCompress(fd, (unsigned char *)compressBuf,
-					nBytes + 1);
-#endif
-    }
+	status = G_zlib_write(fd, (unsigned char *)compressBuf, nBytes + 1);
 
     if (status < 0) {
 	Rast3d_error("Rast3d_fpcompress_write_xdr_nums: write error");
@@ -792,58 +717,24 @@
 /*--------------------------------------------------------------------------*/
 
 int
-Rast3d_fpcompress_write_xdr_floats(int fd, char *src, int nofNum, int precision,
-			    char *compressBuf, int useRle, int useLzw)
-{
-    if (!Rast3d_fpcompress_write_xdr_nums(fd, src, nofNum, precision, compressBuf, 1,
-				   useRle, useLzw)) {
-	Rast3d_error
-	    ("Rast3d_fpcompress_write_xdr_floats: error in Rast3d_fpcompress_write_xdr_nums");
-	return 0;
-    }
-
-    return 1;
-}
-
-/*--------------------------------------------------------------------------*/
-
-int
-Rast3d_fpcompress_write_xdr_double(int fd, char *src, int nofNum, int precision,
-			    char *compressBuf, int useRle, int useLzw)
-{
-    if (!Rast3d_fpcompress_write_xdr_nums(fd, src, nofNum, precision, compressBuf, 0,
-				   useRle, useLzw)) {
-	Rast3d_error
-	    ("Rast3d_fpcompress_write_xdr_double: error in Rast3d_fpcompress_write_xdr_nums");
-	return 0;
-    }
-
-    return 1;
-}
-
-/*--------------------------------------------------------------------------*/
-
-int
 Rast3d_fpcompress_read_xdr_nums(int fd, char *dst, int nofNum, int fileBytes,
 			 int precision, char *compressBuf, int isFloat)
 {
-    int status, lengthEncode, lengthDecode;
+    int status;
+    int lengthEncode, lengthDecode;
     int nBytes;
     char *src, *dest, *srcStop;
-
     nBytes = (isFloat ? XDR_FLOAT_LENGTH : XDR_DOUBLE_LENGTH);
 
-#ifdef USE_LZW_COMPRESSION
-    status = G_lzw_read2(fd, compressBuf, nofNum * nBytes + 1, fileBytes);
-#else
     status = G_zlib_read(fd, fileBytes, (unsigned char *)compressBuf,
 			 nofNum * nBytes + 1);
-#endif
+
     if (status < 0) {
 	Rast3d_error("Rast3d_fpcompress_read_xdr_nums: read error");
 	return 0;
     }
 
+    /* This code is kept for backward compatibility */
     if (*compressBuf++ == 1) {
 	status--;
 	Rast3d_rle_decode(compressBuf, dst, nofNum * nBytes, 1,
@@ -868,43 +759,11 @@
     }
 
     if (isFloat)
-	G_fpcompress_rearrangeDecodeFloats(compressBuf, nofNum, precision,
-					   dst);
+	G_fpcompress_rearrangeDecodeFloats((unsigned char *)compressBuf, nofNum, precision,
+			(unsigned char *)dst);
     else
-	G_fpcompress_rearrangeDecodeDoubles(compressBuf, nofNum, precision,
-					    dst);
+	G_fpcompress_rearrangeDecodeDoubles((unsigned char *)compressBuf, nofNum, precision,
+			(unsigned char *)dst);
 
     return 1;
 }
-
-/*--------------------------------------------------------------------------*/
-
-int
-Rast3d_fpcompress_read_xdr_floats(int fd, char *dst, int nofNum, int fileBytes,
-			   int precision, char *compressBuf)
-{
-    if (!Rast3d_fpcompress_read_xdr_nums(fd, dst, nofNum, fileBytes, precision,
-				  compressBuf, 1)) {
-	Rast3d_error
-	    ("Rast3d_fpcompress_read_xdr_floats: error in Rast3d_fpcompress_read_xdr_nums");
-	return 0;
-    }
-
-    return 1;
-}
-
-/*--------------------------------------------------------------------------*/
-
-int
-Rast3d_fpcompress_read_xdr_doubles(int fd, char *dst, int nofNum, int fileBytes,
-			    int precision, char *compressBuf)
-{
-    if (!Rast3d_fpcompress_read_xdr_nums(fd, dst, nofNum, fileBytes, precision,
-				  compressBuf, 0)) {
-	Rast3d_error
-	    ("G_fpcompress_readXdrDouble: error in Rast3d_fpcompress_read_xdr_nums");
-	return 0;
-    }
-
-    return 1;
-}

Modified: grass/trunk/lib/raster3d/header.c
===================================================================
--- grass/trunk/lib/raster3d/header.c	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/lib/raster3d/header.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -28,6 +28,7 @@
 #define RASTER3D_HEADER_HASINDEX "hasIndex"
 #define RASTER3D_HEADER_UNIT "Units"
 #define RASTER3D_HEADER_VERTICAL_UNIT "VerticalUnits"
+#define RASTER3D_HEADER_VERSION "Version"
 
 /*---------------------------------------------------------------------------*/
 
@@ -39,7 +40,7 @@
 		    double *tb_res, int *tileX, int *tileY, int *tileZ,
 		    int *type, int *compression, int *useRle, int *useLzw,
 		    int *precision, int *dataOffset, int *useXdr,
-		    int *hasIndex, char **unit, int *vertical_unit)
+		    int *hasIndex, char **unit, int *vertical_unit, int *version)
 {
     int returnVal;
     int (*headerInt) (), (*headerDouble) (), (*headerValue) ();
@@ -102,8 +103,12 @@
     if(!headerInt(headerKeys, RASTER3D_HEADER_VERTICAL_UNIT, vertical_unit))
         G_warning("You are using an old raster3d data format, the vertical unit is undefined. "
                   "Please use r3.support to define the vertical unit to avoid this warning.");
+    /* New format and API changes */
+    if(!headerInt(headerKeys, RASTER3D_HEADER_VERSION, version)) {
+        G_warning("You are using an old raster3d data format, the version is undefined.");
+        *version = 1;
+    }
 
-
     if (returnVal)
 	return 1;
 
@@ -120,7 +125,8 @@
 	       double *ew_res, double *ns_res, double *tb_res, int *tileX,
 	       int *tileY, int *tileZ, int *type, int *compression,
 	       int *useRle, int *useLzw, int *precision, int *dataOffset,
-	       int *useXdr, int *hasIndex, char **unit, int *vertical_unit)
+	       int *useXdr, int *hasIndex, char **unit, int *vertical_unit,
+	       int *version)
 {
     struct Key_Value *headerKeys;
     char path[GPATH_MAX];
@@ -140,7 +146,7 @@
 			     ew_res, ns_res, tb_res,
 			     tileX, tileY, tileZ,
 			     type, compression, useRle, useLzw, precision,
-			     dataOffset, useXdr, hasIndex, unit, vertical_unit)) {
+			     dataOffset, useXdr, hasIndex, unit, vertical_unit, version)) {
 	Rast3d_error("Rast3d_read_header: error extracting header key(s) of file %s",
 		  path);
 	return 0;
@@ -158,7 +164,8 @@
 		int cols, int depths, double ew_res, double ns_res,
 		double tb_res, int tileX, int tileY, int tileZ, int type,
 		int compression, int useRle, int useLzw, int precision,
-		int dataOffset, int useXdr, int hasIndex, char *unit, int vertical_unit)
+		int dataOffset, int useXdr, int hasIndex, char *unit, int vertical_unit,
+		int version)
 {
     struct Key_Value *headerKeys;
     char path[GPATH_MAX];
@@ -173,7 +180,7 @@
 			     &tileX, &tileY, &tileZ,
 			     &type, &compression, &useRle, &useLzw,
 			     &precision, &dataOffset, &useXdr, &hasIndex,
-			     &unit, &vertical_unit)) {
+			     &unit, &vertical_unit, &version)) {
 	Rast3d_error("Rast3d_write_header: error adding header key(s) for file %s",
 		  path);
 	return 0;
@@ -205,7 +212,8 @@
                          map->type,
                          map->compression, map->useRle, map->useLzw,
                          map->precision, map->offset, map->useXdr,
-                         map->hasIndex, map->unit, map->vertical_unit)) {
+                         map->hasIndex, map->unit, map->vertical_unit,
+                         map->version)) {
         G_warning(_("Unable to write header for 3D raster map <%s>"), map->fileName);
         return 0;
     }
@@ -301,11 +309,14 @@
 	       int tileY, int tileZ, int proj, int zone, double north,
 	       double south, double east, double west, double top,
 	       double bottom, int rows, int cols, int depths, double ew_res,
-	       double ns_res, double tb_res, char *unit, int vertical_unit)
+	       double ns_res, double tb_res, char *unit, int vertical_unit,
+	       int version)
 {
     if (!RASTER3D_VALID_OPERATION(operation))
 	Rast3d_fatal_error("Rast3d_fill_header: operation not valid\n");
 
+    map->version = version;
+
     map->operation = operation;
 
     map->unit = G_store(unit);
@@ -366,7 +377,7 @@
 
     if (!RASTER3D_VALID_XDR_OPTION(useXdr))
 	Rast3d_fatal_error("Rast3d_fill_header: invalid xdr option");
-    map->useXdr = useXdr;
+    map->useXdr = useXdr; 	/* Only kept for backward compatibility */
 
     map->offset = nofHeaderBytes;
 
@@ -381,8 +392,8 @@
     map->numLengthExtern = Rast3d_extern_length(map->type);
 
     map->compression = compression;
-    map->useRle = useRle;
-    map->useLzw = useLzw;
+    map->useRle = useRle;	/* Only kept for backward compatibility */
+    map->useLzw = useLzw;	/* Only kept for backward compatibility */
     map->precision = precision;
 
 #define RLE_STATUS_BYTES 2

Modified: grass/trunk/lib/raster3d/headerinfo.c
===================================================================
--- grass/trunk/lib/raster3d/headerinfo.c	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/lib/raster3d/headerinfo.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -333,8 +333,9 @@
     double rangeMin, rangeMax;
 
     printf("File %s open for %sing:\n", map->fileName,
-	   (map->operation == RASTER3D_WRITE_DATA ? "writ" :
-	    (map->operation == RASTER3D_READ_DATA ? "read" : "unknown")));
+	   (map->operation == RASTER3D_WRITE_DATA ? "writing" :
+	    (map->operation == RASTER3D_READ_DATA ? "reading" : "unknown")));
+    printf("Version %i\n", map->version);
     printf("  Fd = %d, Unit %s, Vertical Unit %s, Type: %s, ", map->data_fd,
 	   map->unit, G_get_units_name(map->vertical_unit, 1, 0),
 	   (map->type == FCELL_TYPE ? "float" :
@@ -345,7 +346,7 @@
     if (map->compression == RASTER3D_NO_COMPRESSION)
 	printf("  Compression: none\n");
     else {
-	printf("  Compression:%s%s Precision: %s",
+	printf("  Compression:%s (%s%s) Precision: %s", (map->compression ? "on" : "off"),
 	       (map->useLzw ? " lzw," : ""), (map->useRle ? " rle," : ""),
 	       (map->precision == -1 ? "all bits used\n" : "using"));
 	if (map->precision != -1)
@@ -364,9 +365,10 @@
     printf("  Region: (%f %f) (%f %f) (%f %f)\n",
 	   map->region.south, map->region.north, map->region.west,
 	   map->region.east, map->region.bottom, map->region.top);
-    printf("          (%d %d %d)\n", map->region.rows, map->region.cols,
+    printf("            (cols %5d rows %5d depths %5d)\n", map->region.cols, map->region.rows,
 	   map->region.depths);
-    printf("  Tile size (%d %d %d)\n", map->tileX, map->tileY, map->tileZ);
+    printf("  Num tiles (X    %5d Y    %5d Z      %5d)\n", map->nx, map->ny, map->nz);
+    printf("  Tile size (X    %5d Y    %5d Z      %5d)\n", map->tileX, map->tileY, map->tileZ);
     printf("  Range (");
     if (Rast3d_is_null_value_num(&rangeMin, DCELL_TYPE))
 	printf("NULL, ");

Modified: grass/trunk/lib/raster3d/index.c
===================================================================
--- grass/trunk/lib/raster3d/index.c	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/lib/raster3d/index.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -33,6 +33,14 @@
 	return 0;
     }
 
+	/* The size of the tile index array in the map file */
+	if(indexLength == map->indexLongNbytes * map->nTiles) {
+		if (read(map->data_fd, tmp, indexLength) != indexLength) {
+		Rast3d_error("Rast3d_readIndex: can't read file");
+		return 0;
+		}
+	} else
+    /* ATTENTION: RLE encoded reading is only supported for backward compatibility */
     if (indexLength < map->indexLongNbytes * map->nTiles) {	/* RLE encoded? */
 
 	if (indexLength > sizeof(long) * map->nTiles) {
@@ -56,11 +64,7 @@
 
 	if (indexLength > sizeof(long) * map->nTiles)
 	    Rast3d_free(tmp2);
-    }
-    else /* NO RLE */ if (read(map->data_fd, tmp, indexLength) != indexLength) {
-	Rast3d_error("Rast3d_readIndex: can't read file");
-	return 0;
-    }
+    } /* END RLE */
 
     Rast3d_long_decode(tmp, map->index, map->nTiles, map->indexLongNbytes);
 
@@ -77,7 +81,7 @@
 
 int Rast3d_flush_index(RASTER3D_Map * map)
 {
-    int sizeCompressed, indexLength, tileIndex;
+    int indexLength, tileIndex;
     unsigned char *tmp;
     long ldummy;
 
@@ -105,23 +109,11 @@
 
     (void)Rast3d_long_encode(map->index, tmp, map->nTiles);
 
-    sizeCompressed = Rast3d_rle_count_only(tmp, sizeof(long) * map->nTiles, 1);
-
-    if (sizeCompressed >= map->nTiles * sizeof(long)) {
 	indexLength = map->nTiles * sizeof(long);
 	if (write(map->data_fd, tmp, indexLength) != indexLength) {
 	    Rast3d_error("Rast3d_flush_index: can't write file");
 	    return 0;
 	}
-    }
-    else {
-	indexLength = sizeCompressed;
-	Rast3d_rle_encode(tmp, (char *)map->index, sizeof(long) * map->nTiles, 1);
-	if (write(map->data_fd, map->index, sizeCompressed) != sizeCompressed) {
-	    Rast3d_error("Rast3d_flush_index: can't write file");
-	    return 0;
-	}
-    }
 
     Rast3d_free(tmp);
     if (!Rast3d_readIndex(map)) {
@@ -140,8 +132,8 @@
 {
     long offset1, offset2;
 
-    offset1 = cmpIndex[*((const int *)a)];
-    offset2 = cmpIndex[*((const int *)b)];
+    offset1 = cmpIndex[*((const long *)a)];
+    offset2 = cmpIndex[*((const long *)b)];
 
     if (offset1 > offset2)
 	return 1;
@@ -155,8 +147,9 @@
 int Rast3d_init_index(RASTER3D_Map * map, int hasIndex)
 {
     int tile;
-    int i0, i1, i2, i3, i4, i5, offset, nofElts;
-    int *offsetP;
+    int i0, i1, i2, i3, i4, i5, nofElts;
+    long offset;
+    long *offsetP;
 
     map->hasIndex = hasIndex;
     map->index = Rast3d_malloc(sizeof(long) * map->nTiles);
@@ -190,7 +183,7 @@
 	return 0;
     }
 
-    offsetP = Rast3d_malloc(sizeof(int) * map->nTiles);
+    offsetP = Rast3d_malloc(sizeof(long) * map->nTiles);
     if (offsetP == NULL) {
 	Rast3d_error("Rast3d_init_index: error in Rast3d_malloc");
 	return 0;
@@ -199,7 +192,7 @@
     for (tile = 0; tile < map->nTiles; tile++)
 	offsetP[tile] = tile;
     cmpIndex = map->index;
-    qsort(offsetP, map->nTiles, sizeof(int), indexSortCompare);
+    qsort(offsetP, map->nTiles, sizeof(long), indexSortCompare);
 
     for (tile = 0; tile < map->nTiles - 1; tile++) {
 	if (map->index[offsetP[tile]] == -1) {

Modified: grass/trunk/lib/raster3d/open.c
===================================================================
--- grass/trunk/lib/raster3d/open.c	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/lib/raster3d/open.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -85,6 +85,7 @@
     int nofHeaderBytes, dataOffset, useXdr, hasIndex;
     char *ltmp, *unit;
     int vertical_unit;
+    int version;
     double north, south, east, west, top, bottom;
 
     map = Rast3d_open_cell_old_no_header(name, mapset);
@@ -105,7 +106,8 @@
 			&ew_res, &ns_res, &tb_res,
 			&tileX, &tileY, &tileZ,
 			&type, &compression, &useRle, &useLzw,
-			&precision, &dataOffset, &useXdr, &hasIndex, &unit, &vertical_unit)) {
+			&precision, &dataOffset, &useXdr, &hasIndex, &unit, &vertical_unit,
+			&version)) {
 	Rast3d_error(_("Rast3d_open_cell_old: error in Rast3d_read_header"));
 	return 0;
     }
@@ -165,7 +167,8 @@
 			nofHeaderBytes, tileX, tileY, tileZ,
 			proj, zone,
 			north, south, east, west, top, bottom,
-			rows, cols, depths, ew_res, ns_res, tb_res, unit, vertical_unit)) {
+			rows, cols, depths, ew_res, ns_res, tb_res, unit, vertical_unit,
+			version)) {
 	Rast3d_error(_("Rast3d_open_cell_old: error in Rast3d_fill_header"));
 	return (void *)NULL;
     }
@@ -297,8 +300,7 @@
     Rast3d_range_init(map);
     Rast3d_adjust_region(region);
 
-    if (!Rast3d_fill_header(map, RASTER3D_WRITE_DATA, compression,
-			g3d_do_rle_compression, g3d_do_lzw_compression,
+    if (!Rast3d_fill_header(map, RASTER3D_WRITE_DATA, compression, 0, 0,
 			g3d_file_type, precision, cache, RASTER3D_HAS_INDEX,
 			map->useXdr, typeIntern, nofHeaderBytes,
 			g3d_tile_dimension[0], g3d_tile_dimension[1],
@@ -308,7 +310,7 @@
 			region->west, region->top, region->bottom,
 			region->rows, region->cols, region->depths,
 			region->ew_res, region->ns_res, region->tb_res,
-			g3d_unit_default, g3d_vertical_unit_default)) {
+			g3d_unit_default, g3d_vertical_unit_default, RASTER3D_MAP_VERSION)) {
 	Rast3d_error(_("Rast3d_open_cell_new: error in Rast3d_fill_header"));
 	return (void *)NULL;
     }

Modified: grass/trunk/lib/raster3d/open2.c
===================================================================
--- grass/trunk/lib/raster3d/open2.c	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/lib/raster3d/open2.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -39,18 +39,18 @@
 
 
 void *Rast3d_open_new_param(const char *name, int typeIntern, int cache,
-		       RASTER3D_Region * region, int type, int doLzw, int doRle,
+		       RASTER3D_Region * region, int type, int compression,
 		       int precision, int tileX, int tileY, int tileZ)
 {
     void *map;
-    int oldCompress, oldLzw, oldRle, oldPrecision, oldTileX, oldTileY,
+    int oldCompress, oldPrecision, oldTileX, oldTileY,
 	oldTileZ;
     int oldType;
 
     Rast3d_init_defaults();
 
-    Rast3d_get_compression_mode(&oldCompress, &oldLzw, &oldRle, &oldPrecision);
-    Rast3d_set_compression_mode(oldCompress, doLzw, doRle, precision);
+    Rast3d_get_compression_mode(&oldCompress, &oldPrecision);
+    Rast3d_set_compression_mode(compression, precision);
 
     Rast3d_get_tile_dimension(&oldTileX, &oldTileY, &oldTileZ);
     Rast3d_set_tile_dimension(tileX, tileY, tileZ);
@@ -60,7 +60,7 @@
 
     map = Rast3d_open_cell_new(name, typeIntern, cache, region);
 
-    Rast3d_set_compression_mode(oldCompress, oldLzw, oldRle, oldPrecision);
+    Rast3d_set_compression_mode(oldCompress, oldPrecision);
     Rast3d_set_tile_dimension(oldTileX, oldTileY, oldTileZ);
     Rast3d_set_file_type(oldType);
 

Modified: grass/trunk/lib/raster3d/param.c
===================================================================
--- grass/trunk/lib/raster3d/param.c	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/lib/raster3d/param.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -54,15 +54,13 @@
 /*----------------------------------------------------------------------------*/
 
 int Rast3d_get_standard3d_params(int *useTypeDefault, int *type,
-			    int *useLzwDefault, int *doLzw,
-			    int *useRleDefault, int *doRle,
+			    int *useCompressionDefault, int *doCompression,
 			    int *usePrecisionDefault, int *precision,
 			    int *useDimensionDefault, int *tileX, int *tileY,
 			    int *tileZ)
 {
-    int doCompress;
 
-    *useTypeDefault = *useLzwDefault = *useRleDefault = 0;
+    *useTypeDefault = *useCompressionDefault = 0;
     *usePrecisionDefault = *useDimensionDefault = 0;
 
     Rast3d_init_defaults();
@@ -76,7 +74,7 @@
 	*useTypeDefault = 1;
     }
 
-    Rast3d_get_compression_mode(&doCompress, doLzw, doRle, precision);
+    Rast3d_get_compression_mode(doCompression, precision);
 
     if (strcmp(param->precision->answer, "default") != 0) {
 	if (strcmp(param->precision->answer, "max") == 0)
@@ -86,31 +84,19 @@
 	    Rast3d_error(_("Rast3d_get_standard3d_params: precision value invalid"));
 	    return 0;
 	}
-    }
-    else
+	}
+	else
 	*usePrecisionDefault = 1;
 
 
-    if (strcmp(param->compression->answer, "default") != 0) {
-	if (strcmp(param->compression->answer, "rle") == 0) {
-	    *doRle = RASTER3D_USE_RLE;
-	    *doLzw = RASTER3D_NO_LZW;
+	if (strcmp(param->compression->answer, "default") != 0) {
+ 		if (strcmp(param->compression->answer, "zip") == 0)
+			*doCompression = RASTER3D_COMPRESSION;
+		else
+			*doCompression = RASTER3D_NO_COMPRESSION;
+	} else {
+		*useCompressionDefault = 1;
 	}
-	else if (strcmp(param->compression->answer, "lzw") == 0) {
-	    *doRle = RASTER3D_NO_RLE;
-	    *doLzw = RASTER3D_USE_LZW;
-	}
-	else if (strcmp(param->compression->answer, "rle+lzw") == 0) {
-	    *doRle = RASTER3D_USE_RLE;
-	    *doLzw = RASTER3D_USE_LZW;
-	}
-	else {
-	    *doRle = RASTER3D_NO_RLE;
-	    *doLzw = RASTER3D_NO_LZW;
-	}
-    }
-    else
-	*useLzwDefault = *useRleDefault = 1;
 
     Rast3d_get_tile_dimension(tileX, tileY, tileZ);
     if (strcmp(param->dimension->answer, "default") != 0) {

Modified: grass/trunk/lib/raster3d/putvalue.c
===================================================================
--- grass/trunk/lib/raster3d/putvalue.c	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/lib/raster3d/putvalue.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -2,31 +2,29 @@
 #include "raster3d_intern.h"
 
 
+
 /*!
  * \brief 
  *
- * Is equivalent to Rast3d_put_value (map, x, y, z, &value, FCELL_TYPE).
+ *  Is equivalent to Rast3d_put_value (map, x, y, z, &value, FCELL_TYPE).
  *
  *  \param map
  *  \param x
  *  \param y
  *  \param z
  *  \param value
- *  \return int
+ *  \return 1 ... if successful,
+ *          0 ... otherwise.
  */
 
+
 int Rast3d_put_float(RASTER3D_Map * map, int x, int y, int z, float value)
 {
     int tileIndex, offs;
     float *tile;
 
-    if (map->typeIntern == DCELL_TYPE) {
-	if (!Rast3d_put_double(map, x, y, z, (double)value)) {
-	    Rast3d_error("Rast3d_put_float: error in Rast3d_put_double");
-	    return 0;
-	}
-	return 1;
-    }
+    if (map->typeIntern == DCELL_TYPE)
+    	return (Rast3d_put_double(map, x, y, z, (double)value));
 
     Rast3d_coord2tile_index(map, x, y, z, &tileIndex, &offs);
     tile = (float *)Rast3d_get_tile_ptr(map, tileIndex);
@@ -52,7 +50,8 @@
  *  \param y
  *  \param z
  *  \param value
- *  \return int
+ *  \return 1 ... if successful,
+ *          0 ... otherwise.
  */
 
 int Rast3d_put_double(RASTER3D_Map * map, int x, int y, int z, double value)
@@ -60,13 +59,8 @@
     int tileIndex, offs;
     double *tile;
 
-    if (map->typeIntern == FCELL_TYPE) {
-	if (!Rast3d_put_float(map, x, y, z, (float)value)) {
-	    Rast3d_error("Rast3d_put_double: error in Rast3d_put_float");
-	    return 0;
-	}
-	return 1;
-    }
+    if (map->typeIntern == FCELL_TYPE)
+    	return (Rast3d_put_float(map, x, y, z, (float)value));
 
     Rast3d_coord2tile_index(map, x, y, z, &tileIndex, &offs);
     tile = (double *)Rast3d_get_tile_ptr(map, tileIndex);
@@ -94,24 +88,16 @@
  *  \param z
  *  \param value
  *  \param type
- *  \return 1 ... if successful,  
+ *  \return 1 ... if successful,
  *          0 ... otherwise.
  */
 
 int
 Rast3d_put_value(RASTER3D_Map * map, int x, int y, int z, const void *value, int type)
 {
-    if (type == FCELL_TYPE) {
-	if (!Rast3d_put_float(map, x, y, z, *((float *)value))) {
-	    Rast3d_error("Rast3d_put_value: error in Rast3d_put_float");
-	    return 0;
-	}
-	return 1;
-    }
+    if (type == FCELL_TYPE)
+    	return (Rast3d_put_float(map, x, y, z, *((float *)value)));
 
-    if (!Rast3d_put_double(map, x, y, z, *((double *)value))) {
-	Rast3d_error("Rast3d_put_value: error in Rast3d_put_double");
-	return 0;
-    }
-    return 1;
+	return (Rast3d_put_double(map, x, y, z, *((double *)value)));
+
 }

Modified: grass/trunk/lib/raster3d/raster3d_intern.h
===================================================================
--- grass/trunk/lib/raster3d/raster3d_intern.h	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/lib/raster3d/raster3d_intern.h	2013-03-20 00:14:25 UTC (rev 55462)
@@ -5,9 +5,9 @@
 
 #define RASTER3D_LONG_LENGTH sizeof (long)
 
-#define RASTER3D_XDR_INT_LENGTH 4
-#define RASTER3D_XDR_DOUBLE_LENGTH 8
-#define RASTER3D_XDR_FLOAT_LENGTH 4
+#define RASTER3D_XDR_INT_LENGTH 4		/* Only kept for backward compatibility */
+#define RASTER3D_XDR_DOUBLE_LENGTH 8	/* Only kept for backward compatibility */
+#define RASTER3D_XDR_FLOAT_LENGTH 4		/* Only kept for backward compatibility */
 
 #define RASTER3D_IS_CORRECT_TYPE(t) (((t) == FCELL_TYPE) || ((t) == DCELL_TYPE))
 
@@ -23,9 +23,9 @@
 #define RASTER3D_HAS_INDEX 1
 #define RASTER3D_NO_INDEX 0
 
-#define RASTER3D_USE_XDR 1
-#define RASTER3D_NO_XDR 0
-
+#define RASTER3D_USE_XDR 1	/* Only kept for backward compatibility */
+#define RASTER3D_NO_XDR 0	/* Only kept for backward compatibility */
+/* Only kept for backward compatibility */
 #define RASTER3D_VALID_XDR_OPTION(o) (((o) == RASTER3D_USE_XDR) || ((o) == RASTER3D_NO_XDR))
 
 /*---------------------------------------------------------------------------*/
@@ -41,9 +41,8 @@
 
 /* global variables */
 
+extern int g3d_version; /* RASTER3D_MAP_VERSION */
 extern int g3d_do_compression;	/* RASTER3D_NO_COMPRESSION or RASTER3D_COMPRESSION */
-extern int g3d_do_lzw_compression;	/* RASTER3D_USE_LZW or RASTER3D_NO_LZW */
-extern int g3d_do_rle_compression;	/* RASTER3D_USE_RLE or RASTER3D_NO_RLE */
 extern int g3d_precision;	/* RASTER3D_ALLOW_PRECISION or RASTER3D_NO_PRECISION */
 extern int g3d_cache_default;	/* in number of tiles; 0 ==> no cache */
 extern int g3d_cache_max;	/* in bytes */

Modified: grass/trunk/lib/raster3d/region.c
===================================================================
--- grass/trunk/lib/raster3d/region.c	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/lib/raster3d/region.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -207,7 +207,23 @@
 
 void Rast3d_region_copy(RASTER3D_Region * regionDest, RASTER3D_Region * regionSrc)
 {
-    *regionDest = *regionSrc;
+	regionDest->proj = regionSrc->proj;
+	regionDest->zone = regionSrc->zone;
+
+	regionDest->north = regionSrc->north;
+	regionDest->south = regionSrc->south;
+	regionDest->east = regionSrc->east;
+	regionDest->west = regionSrc->west;
+	regionDest->top = regionSrc->top;
+	regionDest->bottom = regionSrc->bottom;
+
+	regionDest->rows = regionSrc->rows;
+	regionDest->cols = regionSrc->cols;
+	regionDest->depths = regionSrc->depths;
+
+	regionDest->ns_res = regionSrc->ns_res;
+	regionDest->ew_res = regionSrc->ew_res;
+	regionDest->tb_res = regionSrc->tb_res;
 }
 
 

Modified: grass/trunk/lib/raster3d/resample.c
===================================================================
--- grass/trunk/lib/raster3d/resample.c	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/lib/raster3d/resample.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -29,7 +29,8 @@
     int row, col, depth;
 
     /* convert (x, y, z) window coordinates into (north, east, top) */
-    Rast3d_coord2location(&(map->window), (double)x + 0.5, (double)y + 0.5, (double)z + 0.5, &north, &east, &top);
+    Rast3d_coord2location(&(map->window), (double)x + 0.5, (double)y + 0.5,
+    		(double)z + 0.5, &north, &east, &top);
 
     /* convert (north, east, top) into map region coordinates (row, col, depth) */
     Rast3d_location2coord(&(map->region), north, east, top, &col, &row, &depth);

Modified: grass/trunk/lib/raster3d/retile.c
===================================================================
--- grass/trunk/lib/raster3d/retile.c	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/lib/raster3d/retile.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -52,7 +52,7 @@
     }
     
     G_percent(1, 1, 1);
-        
+
     Rast3d_free_tiles(data);
     Rast3d_close(map2);
 }

Modified: grass/trunk/lib/raster3d/test/test_main.c
===================================================================
--- grass/trunk/lib/raster3d/test/test_main.c	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/lib/raster3d/test/test_main.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -91,13 +91,8 @@
 
     param.compression = G_define_flag();
     param.compression->key = 'l';
-    param.compression->description = _("Switch lzw compression on");
+    param.compression->description = _("Switch zip 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.");
-}
-
 /* ************************************************************************* */
 /* ************************************************************************* */
 
@@ -107,8 +102,6 @@
     int returnstat = 0, i;
     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]);
@@ -130,19 +123,12 @@
 
     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);
+    Rast3d_set_compression_mode(doCompress, RASTER3D_MAX_PRECISION);
    
     /* Initiate the defaults for testing */
     Rast3d_init_defaults();

Modified: grass/trunk/lib/raster3d/test/test_put_get_value.c
===================================================================
--- grass/trunk/lib/raster3d/test/test_put_get_value.c	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/lib/raster3d/test/test_put_get_value.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -29,7 +29,7 @@
                                  top, int col, int row, int depth, int fact);
 
 /* *************************************************************** */
-/* Perfrome the coordinate transformation tests ****************** */
+/* Perform the coordinate transformation tests ******************* */
 /* *************************************************************** */
 int unit_test_put_get_value()
 {
@@ -37,8 +37,8 @@
 
     G_message(_("\n++ Running g3d put/get value unit tests ++"));
 
-    sum += test_put_get_value_dcell();
-    sum += test_put_get_value_fcell();
+    //sum += test_put_get_value_dcell();
+    //sum += test_put_get_value_fcell();
     sum += test_put_get_value_resampling();
 
 
@@ -113,8 +113,12 @@
             }
         }
     }
+
     /* Write everything to the disk */
     Rast3d_flush_all_tiles(map);
+    Rast3d_close(map);
+
+    map = Rast3d_open_cell_old("test_put_get_value_dcell", G_mapset(), &region, DCELL_TYPE, RASTER3D_USE_CACHE_XY);
     
     /* Reread the map and compare the expected results */
     
@@ -223,7 +227,7 @@
         
     Rast3d_adjust_region(&region);
         
-    map = Rast3d_open_new_opt_tile_size("test_put_get_value_dcell", RASTER3D_USE_CACHE_XY, &region, FCELL_TYPE, 32);
+    map = Rast3d_open_new_opt_tile_size("test_put_get_value_fcell", RASTER3D_USE_CACHE_XY, &region, FCELL_TYPE, 32);
     
     /* The window is the same as the map region ... of course */
     Rast3d_set_window_map(map, &region);
@@ -237,8 +241,12 @@
             }
         }
     }
+
     /* Write everything to the disk */
     Rast3d_flush_all_tiles(map);
+    Rast3d_close(map);
+
+    map = Rast3d_open_cell_old("test_put_get_value_fcell", G_mapset(), &region, DCELL_TYPE, RASTER3D_USE_CACHE_XY);
     
        /* Reread the map and compare the expected results */
     
@@ -346,19 +354,6 @@
     Rast3d_adjust_region(&region);
     
     map = Rast3d_open_new_opt_tile_size("test_put_get_value_resample", RASTER3D_USE_CACHE_XY, &region, DCELL_TYPE, 32);
-    
-    /* We modify the window for resampling tests */
-    Rast3d_region_copy(&window, &region);
-        
-    /* Double the cols, rows and depths -> 8x resolution window */
-    window.rows = 30;
-    window.cols = 20;
-    window.depths = 10;
-    
-    Rast3d_adjust_region(&window);
-    
-    /* The window is the same as the map region ... of course */
-    Rast3d_set_window_map(map, &window);
     /*
      ROWS
   1000 1500 2000 2500 3000 3500 4000 4500 5000 5500 6500 7000 7500 8000 8500 9000 north
@@ -390,8 +385,25 @@
             }
         }
     }
+
     /* Write everything to the disk */
     Rast3d_flush_all_tiles(map);
+    Rast3d_close(map);
+
+    /* We modify the window for resampling tests */
+    Rast3d_region_copy(&window, &region);
+
+    /* Double the cols, rows and depths -> 8x resolution window */
+    window.rows = 30;
+    window.cols = 20;
+    window.depths = 10;
+
+    Rast3d_adjust_region(&window);
+
+    map = Rast3d_open_cell_old("test_put_get_value_resample", G_mapset(), &region, DCELL_TYPE, RASTER3D_USE_CACHE_XY);
+
+    /* The window has the 8x resolution as the map region */
+    Rast3d_set_window_map(map, &window);
     
     /* Reread the map and compare the expected results */
     
@@ -440,7 +452,7 @@
     
     Rast3d_close(map);
     
-    G_remove("grid3", "test_put_get_value_dcell");
+    G_remove("grid3", "test_put_get_value_resample");
     
     return sum;
 }

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	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/lib/raster3d/test/test_put_get_value_large_file.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -20,6 +20,7 @@
 #include "grass/interpf.h"
 
 #define EPSILON 0.000000001
+#define RAND_VALUE_VECTOR_SIZE 1000
 
 static int test_large_file(int depths, int rows, int cols, int tile_size);
 static int test_large_file_zeros(int depths, int rows, int cols, int tile_size);
@@ -35,10 +36,12 @@
 
     G_message(_("\n++ Running g3d put/get value large file unit tests ++"));
 
+    sum += test_large_file_random(depths, rows, cols, tile_size);
+    sum += test_large_file_sparse_random(depths, rows, cols, tile_size);
     sum += test_large_file(depths, rows, cols, tile_size);
+    sum += test_large_file(depths, rows, cols, tile_size);
+    sum += test_large_file(depths, rows, cols, tile_size);
     sum += test_large_file_zeros(depths, rows, cols, tile_size);
-    sum += test_large_file_random(depths, rows, cols, tile_size);
-    sum += test_large_file_sparse_random(depths, rows, cols, tile_size);
 
 
     if (sum > 0)
@@ -80,7 +83,8 @@
         
     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, tile_size);
+    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);
@@ -105,7 +109,8 @@
          
     G_message("Verifying 3D raster map");
 
-    map = Rast3d_open_cell_old("test_put_get_value_dcell_large", G_mapset(), &region, DCELL_TYPE, RASTER3D_USE_CACHE_XYZ);
+    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++) {
@@ -115,7 +120,8 @@
                 /* Check the counter as cell value */
                 Rast3d_get_value(map, x, y, z, &value, DCELL_TYPE);
                 if(fabs(value - (double)(count) > EPSILON)) {
-                    G_message("At: z %i y %i x %i -- value %.14lf != %.14lf\n", z, y, x, value, (double)(count));
+                    G_message("At: z %i y %i x %i -- value %.14lf != %.14lf\n",
+                    		z, y, x, value, (double)(count));
 			sum++;
                 }
                 count++;
@@ -125,7 +131,7 @@
     G_percent(1, 1, 1);
     Rast3d_close(map);
     
-    //G_remove("grid3", "test_put_get_value_dcell_large");
+    G_remove("grid3", "test_put_get_value_dcell_large");
     
     return sum;
 }
@@ -162,7 +168,8 @@
 
     G_message("Creating 3D raster map filled with zeros");
 
-    map = Rast3d_open_new_opt_tile_size("test_put_get_value_dcell_large_zeros", RASTER3D_USE_CACHE_XY, &region, DCELL_TYPE, tile_size);
+    map = Rast3d_open_new_opt_tile_size("test_put_get_value_dcell_large_zeros",
+    		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);
@@ -185,7 +192,8 @@
 
     G_message("Verifying 3D raster map filled with zeros");
 
-    map = Rast3d_open_cell_old("test_put_get_value_dcell_large_zeros", G_mapset(), &region, DCELL_TYPE, RASTER3D_USE_CACHE_XYZ);
+    map = Rast3d_open_cell_old("test_put_get_value_dcell_large_zeros",
+    		G_mapset(), &region, DCELL_TYPE, RASTER3D_USE_CACHE_XY);
 
     for(z = 0; z < region.depths; z++) {
 	G_percent(z, region.depths, 1);
@@ -194,7 +202,8 @@
                 /* Check the counter as cell value */
                 Rast3d_get_value(map, x, y, z, &value, DCELL_TYPE);
                 if(value > EPSILON) {
-                    G_message("At: z %i y %i x %i -- value %.14lf != 0.0\n", z, y, x, value);
+                    G_message("At: z %i y %i x %i -- value %.14lf != 0.0\n",
+                    		z, y, x, value);
                     sum++;
                 }
             }
@@ -203,7 +212,7 @@
     G_percent(1, 1, 1);
     Rast3d_close(map);
 
-    //G_remove("grid3", "test_put_get_value_dcell_large_zeros");
+    G_remove("grid3", "test_put_get_value_dcell_large_zeros");
 
     return sum;
 }
@@ -213,9 +222,11 @@
 int test_large_file_random(int depths, int rows, int cols, int tile_size)
 {
     int sum = 0;
-    int x, y, z;
-    DCELL value, radnom_value;
+    int x, y, z, i;
+    DCELL value, random_value;
+    DCELL *random_value_vector = G_calloc(RAND_VALUE_VECTOR_SIZE, sizeof(DCELL));
 
+
     G_message("Testing DCELL put function for large files filled with random values");
 
     RASTER3D_Region region;
@@ -239,20 +250,30 @@
 
     G_message("Creating 3D raster map filled with random values");
 
-    map = Rast3d_open_new_opt_tile_size("test_put_get_value_dcell_large_random", RASTER3D_USE_CACHE_XY, &region, DCELL_TYPE, tile_size);
+    map = Rast3d_open_new_opt_tile_size("test_put_get_value_dcell_large_random",
+    		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);
 
     srand(1);
+    /* We fill the random value vector */
+    for(i = 0; i < RAND_VALUE_VECTOR_SIZE; i++) {
+    	random_value_vector[i] = (DCELL)rand();
+    }
 
+    i = 0;
+
     for(z = 0; z < region.depths; z++) {
 	G_percent(z, region.depths, 1);
         for(y = 0; y < region.rows; y++) {
             for(x = 0; x < region.cols; x++) {
               /* Put the counter as cell value */
-                value = (double)rand();
+                value = random_value_vector[i];
                 Rast3d_put_value(map, x, y, z, &value, DCELL_TYPE);
+                i++;
+                if(i == RAND_VALUE_VECTOR_SIZE)
+                	i = 0;
             }
         }
     }
@@ -264,9 +285,10 @@
 
     G_message("Verifying 3D raster map filled with random values");
 
-    map = Rast3d_open_cell_old("test_put_get_value_dcell_large_random", G_mapset(), &region, DCELL_TYPE, RASTER3D_USE_CACHE_XYZ);
+    map = Rast3d_open_cell_old("test_put_get_value_dcell_large_random",
+    		G_mapset(), &region, DCELL_TYPE, RASTER3D_USE_CACHE_XY);
 
-    srand(1);
+    i = 0;
 
     for(z = 0; z < region.depths; z++) {
 	G_percent(z, region.depths, 1);
@@ -274,19 +296,25 @@
             for(x = 0; x < region.cols; x++) {
                 /* Check the counter as cell value */
                 Rast3d_get_value(map, x, y, z, &value, DCELL_TYPE);
-                radnom_value = (DCELL)rand();
-                if(fabs(value - radnom_value) > EPSILON) {
-                    G_message("At: z %i y %i x %i -- value %.14lf != %.14lf\n", z, y, x, value, radnom_value);
+                random_value = random_value_vector[i];
+                if(fabs(value - random_value) > EPSILON) {
+                    G_message("At: z %i y %i x %i -- value %.14lf != %.14lf\n",
+                    		z, y, x, value, random_value);
                     sum++;
                 }
+                i++;
+                if(i == RAND_VALUE_VECTOR_SIZE)
+                	i = 0;
             }
         }
     }
     G_percent(1, 1, 1);
     Rast3d_close(map);
 
-    //G_remove("grid3", "test_put_get_value_dcell_large_random");
+    G_free(random_value_vector);
 
+    G_remove("grid3", "test_put_get_value_dcell_large_random");
+
     return sum;
 }
 
@@ -295,8 +323,9 @@
 int test_large_file_sparse_random(int depths, int rows, int cols, int tile_size)
 {
     int sum = 0;
-    int x, y, z;
-    DCELL value, radnom_value;
+    int x, y, z, i;
+    DCELL value, random_value;
+    DCELL *random_value_vector = G_calloc(RAND_VALUE_VECTOR_SIZE, sizeof(DCELL));
 
     G_message("Testing DCELL put function for large files filled with sparse random values");
 
@@ -321,31 +350,44 @@
 
     G_message("Creating 3D raster map filled with sparse random values");
 
-    map = Rast3d_open_new_opt_tile_size("test_put_get_value_dcell_large_sparse_random", RASTER3D_USE_CACHE_XY, &region, DCELL_TYPE, tile_size);
+    map = Rast3d_open_new_opt_tile_size("test_put_get_value_dcell_large_sparse_random",
+    		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);
 
     srand(1);
 
+    /* We fill the random value vector */
+    for(i = 0; i < RAND_VALUE_VECTOR_SIZE; i++) {
+    	/* Put the counter as cell value */
+        value = (DCELL)rand();
+        value /= RAND_MAX;
+        if(value <= 0.7)
+        	value = 0.0;
+        else if(value <= 0.8)
+        	value = 1.0;
+        else if(value <= 0.9)
+        	value = 2.0;
+        else if(value <= 1.0)
+        	value = 3.0;
+        else
+        	value = 4.0;
+    	random_value_vector[i] = value;
+    }
+
+    i = 0;
+
     for(z = 0; z < region.depths; z++) {
 	G_percent(z, region.depths, 1);
         for(y = 0; y < region.rows; y++) {
             for(x = 0; x < region.cols; x++) {
-              /* Put the counter as cell value */
-                value = (DCELL)rand();
-                value /= RAND_MAX;
-                if(value <= 0.7)
-                	value = 0.0;
-                else if(value <= 0.8)
-                	value = 1.0;
-                else if(value <= 0.9)
-                	value = 2.0;
-                else if(value <= 1.0)
-                	value = 3.0;
-                else
-                	value = 4.0;
-                Rast3d_put_value(map, x, y, z, &value, DCELL_TYPE);
+                /* Put the counter as cell value */
+                  value = random_value_vector[i];
+                  Rast3d_put_value(map, x, y, z, &value, DCELL_TYPE);
+                  i++;
+                  if(i == RAND_VALUE_VECTOR_SIZE)
+                  	i = 0;
             }
         }
     }
@@ -357,9 +399,10 @@
 
     G_message("Verifying 3D raster map filled with sparse random values");
 
-    map = Rast3d_open_cell_old("test_put_get_value_dcell_large_sparse_random", G_mapset(), &region, DCELL_TYPE, RASTER3D_USE_CACHE_XYZ);
+    map = Rast3d_open_cell_old("test_put_get_value_dcell_large_sparse_random",
+    		G_mapset(), &region, DCELL_TYPE, RASTER3D_USE_CACHE_XY);
 
-    srand(1);
+    i = 0;
 
     for(z = 0; z < region.depths; z++) {
 	G_percent(z, region.depths, 1);
@@ -367,30 +410,24 @@
             for(x = 0; x < region.cols; x++) {
                 /* Check the counter as cell value */
                 Rast3d_get_value(map, x, y, z, &value, DCELL_TYPE);
-                radnom_value = (DCELL)rand();
-                radnom_value /= RAND_MAX;
-                if(radnom_value <= 0.7)
-                	radnom_value = 0.0;
-                else if(radnom_value <= 0.8)
-                	radnom_value = 1.0;
-                else if(radnom_value <= 0.9)
-                	radnom_value = 2.0;
-                else if(radnom_value <= 1.0)
-                	radnom_value = 3.0;
-                else
-                	radnom_value = 4.0;
-                if(fabs(value - radnom_value) > EPSILON) {
-                    G_message("At: z %i y %i x %i -- value %.14lf != %.14lf\n", z, y, x, value, radnom_value);
+                if(fabs(value - random_value_vector[i]) > EPSILON) {
+                    G_message("At: z %i y %i x %i -- value %.14lf != %.14lf\n",
+                    		z, y, x, value, random_value);
                     sum++;
                 }
+                i++;
+                if(i == RAND_VALUE_VECTOR_SIZE)
+                	i = 0;
             }
         }
     }
     G_percent(1, 1, 1);
     Rast3d_close(map);
 
-    //G_remove("grid3", "test_put_get_value_dcell_large_sparse_random");
+    G_free(random_value_vector);
 
+    G_remove("grid3", "test_put_get_value_dcell_large_sparse_random");
+
     return sum;
 }
 

Modified: grass/trunk/lib/raster3d/tileio.c
===================================================================
--- grass/trunk/lib/raster3d/tileio.c	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/lib/raster3d/tileio.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -93,6 +93,7 @@
 	return ptr;
     }
 
+
     if (map->currentIndex == tileIndex)
 	return map->data;
 
@@ -102,6 +103,7 @@
 	return NULL;
     }
 
+
     return map->data;
 }
 

Modified: grass/trunk/lib/raster3d/tileread.c
===================================================================
--- grass/trunk/lib/raster3d/tileread.c	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/lib/raster3d/tileread.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -88,7 +88,7 @@
 
 static int Rast3d_readTileUncompressed(RASTER3D_Map * map, int tileIndex, int nofNum)
 {
-    int nofBytes;
+    size_t nofBytes;
 
     nofBytes = nofNum * map->numLengthExtern;
     nofBytes = RASTER3D_MIN(nofBytes, map->fileEndPtr - map->index[tileIndex]);
@@ -139,7 +139,7 @@
  *  \param tile
  *  \param type
  *  \return 1 ... if successful,
- *          0 ... otherwise.
+ *          0 ... otherwise
  */
 
 int Rast3d_read_tile(RASTER3D_Map * map, int tileIndex, void *tile, int type)

Modified: grass/trunk/lib/raster3d/tilewrite.c
===================================================================
--- grass/trunk/lib/raster3d/tilewrite.c	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/lib/raster3d/tilewrite.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -84,8 +84,7 @@
 static int Rast3d_writeTileCompressed(RASTER3D_Map * map, int nofNum)
 {
     if (!Rast3d_fpcompress_write_xdr_nums(map->data_fd, xdr, nofNum, map->precision,
-				   tmpCompress, map->type == FCELL_TYPE,
-				   map->useRle, map->useLzw)) {
+				   tmpCompress, map->type == FCELL_TYPE)) {
 	Rast3d_error
 	    ("Rast3d_writeTileCompressed: error in Rast3d_fpcompress_write_xdr_nums");
 	return 0;
@@ -130,7 +129,7 @@
     int rows, cols, depths, xRedundant, yRedundant, zRedundant, nofNum;
 
     /* valid tileIndex ? */
-    if ((tileIndex >= map->nTiles) || (tileIndex < 0))
+    if ((tileIndex > map->nTiles) || (tileIndex < 0))
 	Rast3d_fatal_error("Rast3d_write_tile: tileIndex out of range");
 
     /* already written ? */
@@ -155,7 +154,7 @@
 
     if (!Rast3d_tile2xdrTile(map, tile, rows, cols, depths,
 			  xRedundant, yRedundant, zRedundant, nofNum, type)) {
-	Rast3d_error("Rast3d_writeTileCompressed: error in Rast3d_tile2xdrTile");
+	Rast3d_error("Rast3d_write_tile: error in Rast3d_tile2xdrTile");
 	return 0;
     }
 
@@ -165,9 +164,10 @@
 	    return 0;
 	}
     }
-    else if (!Rast3d_writeTileCompressed(map, nofNum)) {
-	Rast3d_error("Rast3d_write_tile: error in Rast3d_writeTileCompressed");
-	return 0;
+    else { if (!Rast3d_writeTileCompressed(map, nofNum)) {
+			Rast3d_error("Rast3d_write_tile: error in Rast3d_writeTileCompressed");
+			return 0;
+    	}
     }
 
     /* compute the length */

Modified: grass/trunk/raster3d/r3.cross.rast/test.r3.cross.rast.sh
===================================================================
--- grass/trunk/raster3d/r3.cross.rast/test.r3.cross.rast.sh	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/raster3d/r3.cross.rast/test.r3.cross.rast.sh	2013-03-20 00:14:25 UTC (rev 55462)
@@ -33,5 +33,13 @@
 r3.cross.rast --o input=volume_null elevation=elev_NAN output=test_cross_section_slice_NAN
 r3.cross.rast --o input=volume_null elevation=elev_cross output=test_cross_section_result
 
-# Export of the references
-for i in `g.mlist type=rast pattern=test_cross_section_*` ; do r.out.ascii input=$i output=${i}.txt; done
+# Export of the text files
+for i in `g.mlist type=rast pattern=test_cross_section_*` ; do 
+    r.out.ascii input=$i output=${i}.txt; 
+done
+
+# Comparison of references and text files
+for i in `ls *.ref` ; do 
+    diff $i "`basename $i .ref`.txt" ; 
+done
+rm *.txt

Modified: grass/trunk/raster3d/r3.in.ascii/main.c
===================================================================
--- grass/trunk/raster3d/r3.in.ascii/main.c	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/raster3d/r3.in.ascii/main.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -278,11 +278,6 @@
                 /* Write the data */
                 Rast3d_put_double(map, col, row, depth, value);
             }
-
-        if (!Rast3d_flush_tiles_in_cube(map,
-                                  0, 0, MAX(0, depth - tileZ),
-                                  region->rows - 1, region->cols - 1, depth))
-            fatalError("asciiTog3d: error flushing tiles");
     }
 
     if (fscanf(fp, "%lf", &value) == 1) {
@@ -306,7 +301,7 @@
     char *input, *output;
     int convertNull;
     char nullValue[256];
-    int useTypeDefault, type, useLzwDefault, doLzw, useRleDefault, doRle;
+    int useTypeDefault, type, useCompressionDefault, doCompression;
     int usePrecisionDefault, precision, useDimensionDefault, tileX, tileY,
         tileZ;
     RASTER3D_Region region;
@@ -332,8 +327,7 @@
 
     getParams(&input, &output, &convertNull, nullValue);
     if (!Rast3d_get_standard3d_params(&useTypeDefault, &type,
-                                 &useLzwDefault, &doLzw,
-                                 &useRleDefault, &doRle,
+                                 &useCompressionDefault, &doCompression,
                                  &usePrecisionDefault, &precision,
                                  &useDimensionDefault, &tileX, &tileY,
                                  &tileZ))
@@ -346,7 +340,7 @@
     /*Open the new RASTER3D map */
     map = Rast3d_open_new_param(output, RASTER3D_TILE_SAME_AS_FILE, RASTER3D_USE_CACHE_XY,
                            &region,
-                           type, doLzw, doRle, precision, tileX, tileY,
+                           type, doCompression, precision, tileX, tileY,
                            tileZ);
 
     if (map == NULL)

Modified: grass/trunk/raster3d/r3.in.v5d/main.c
===================================================================
--- grass/trunk/raster3d/r3.in.v5d/main.c	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/raster3d/r3.in.v5d/main.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -179,7 +179,7 @@
     char *input, *output;
     int convertNull;
     double nullValue;
-    int useTypeDefault, type, useLzwDefault, doLzw, useRleDefault, doRle;
+    int useTypeDefault, type, useCompressionDefault, doCompression;
     int usePrecisionDefault, precision, useDimensionDefault, tileX, tileY,
 	tileZ;
     RASTER3D_Region region;
@@ -202,8 +202,7 @@
 
     getParams(&input, &output, &convertNull, &nullValue);
     if (!Rast3d_get_standard3d_params(&useTypeDefault, &type,
-				 &useLzwDefault, &doLzw,
-				 &useRleDefault, &doRle,
+				 &useCompressionDefault, &doCompression,
 				 &usePrecisionDefault, &precision,
 				 &useDimensionDefault, &tileX, &tileY,
 				 &tileZ))

Modified: grass/trunk/raster3d/r3.mask/main.c
===================================================================
--- grass/trunk/raster3d/r3.mask/main.c	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/raster3d/r3.mask/main.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -67,7 +67,7 @@
     Rast3d_get_tile_dimensions_map(map, &tileX, &tileY, &tileZ);
 
     mask = Rast3d_open_new_param(Rast3d_mask_file(), FCELL_TYPE, cacheSize,
-			    &region, FCELL_TYPE, RASTER3D_NO_LZW, RASTER3D_USE_RLE, 0,
+			    &region, FCELL_TYPE, RASTER3D_COMPRESSION, 0,
 			    tileX, tileY, tileZ);
 
     if (mask == NULL)

Modified: grass/trunk/raster3d/r3.null/main.c
===================================================================
--- grass/trunk/raster3d/r3.null/main.c	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/raster3d/r3.null/main.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -111,11 +111,11 @@
     Rast3d_get_region_struct_map(map, &region);
     Rast3d_get_tile_dimensions_map(map, &tileX, &tileY, &tileZ);
 
-    Rast3d_get_compression_mode(&doCompress, &doLzw, &doRle, &precision);
+    Rast3d_get_compression_mode(&doCompress, &precision);
 
     mapOut = Rast3d_open_new_param(name, DCELL_TYPE, RASTER3D_USE_CACHE_XY,
 			      &region, Rast3d_file_type_map(map),
-			      doLzw, doRle, Rast3d_tile_precision_map(map), tileX,
+			      doCompress, Rast3d_tile_precision_map(map), tileX,
 			      tileY, tileZ);
     if (mapOut == NULL)
 	Rast3d_fatal_error(_("modifyNull: error opening tmp file"));

Modified: grass/trunk/raster3d/r3.null/test.r3.null.sh
===================================================================
--- grass/trunk/raster3d/r3.null/test.r3.null.sh	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/raster3d/r3.null/test.r3.null.sh	2013-03-20 00:14:25 UTC (rev 55462)
@@ -31,11 +31,11 @@
 r3.null map=test_volume_double_null_2 null=-10.5
 
 # Commands to export the references 
-# r3.out.ascii dp=3 input=test_volume_float_1 output=test_volume_float_1.ref
-# r3.out.ascii dp=3 input=test_volume_float_2 output=test_volume_float_2.ref
-# r3.out.ascii dp=3 input=test_volume_float_null_1 output=test_volume_float_null_1.ref
-# r3.out.ascii dp=3 input=test_volume_float_null_2 output=test_volume_float_null_2.ref
-# r3.out.ascii dp=3 input=test_volume_double_1 output=test_volume_double_1.ref
-# r3.out.ascii dp=3 input=test_volume_double_2 output=test_volume_double_2.ref
-# r3.out.ascii dp=3 input=test_volume_double_null_1 output=test_volume_double_null_1.ref
-# r3.out.ascii dp=3 input=test_volume_double_null_2 output=test_volume_double_null_2.ref
+r3.out.ascii dp=3 input=test_volume_float_1 output=test_volume_float_1.txt
+r3.out.ascii dp=3 input=test_volume_float_2 output=test_volume_float_2.txt
+r3.out.ascii dp=3 input=test_volume_float_null_1 output=test_volume_float_null_1.txt
+r3.out.ascii dp=3 input=test_volume_float_null_2 output=test_volume_float_null_2.txt
+r3.out.ascii dp=3 input=test_volume_double_1 output=test_volume_double_1.txt
+r3.out.ascii dp=3 input=test_volume_double_2 output=test_volume_double_2.txt
+r3.out.ascii dp=3 input=test_volume_double_null_1 output=test_volume_double_null_1.txt
+r3.out.ascii dp=3 input=test_volume_double_null_2 output=test_volume_double_null_2.txt

Modified: grass/trunk/raster3d/r3.out.ascii/test.r3.out.ascii.sh
===================================================================
--- grass/trunk/raster3d/r3.out.ascii/test.r3.out.ascii.sh	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/raster3d/r3.out.ascii/test.r3.out.ascii.sh	2013-03-20 00:14:25 UTC (rev 55462)
@@ -63,7 +63,7 @@
 # Different precision and null values than default
 r3.in.ascii --o output=test_double_nsbt_null input=test_double_nsbt_null_prec5.txt nv=-1000
 r3.in.ascii --o output=test_double_nsbt_null input=test_double_sntb_null_prec8.txt nv=-2000
-# AImport grass6 legacy data
+# Import grass6 legacy data
 r3.in.ascii --o output=test_double_nsbt_null input=test_double_nsbt_null_grass6_comp_1.txt
 
 # In this @preprocess step for the last test we create a large region and 
@@ -77,4 +77,10 @@
 r3.out.ascii --o input=volume_double_null_large output=test_double_nsbt_null_large.txt dp=0 null=*
 r3.in.ascii --o output=test_double_nsbt_null_large input=test_double_nsbt_null_large.txt nv=*
 # Just for the logs
-r3.info test_double_nsbt_null_large
\ No newline at end of file
+r3.info test_double_nsbt_null_large
+
+# Show differences between references and created text files
+for i in `ls *.ref` ; do 
+    diff $i "`basename $i .ref`.txt" ; 
+done
+rm *.txt

Modified: grass/trunk/raster3d/r3.out.vtk/test.r3.out.vtk.sh
===================================================================
--- grass/trunk/raster3d/r3.out.vtk/test.r3.out.vtk.sh	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/raster3d/r3.out.vtk/test.r3.out.vtk.sh	2013-03-20 00:14:25 UTC (rev 55462)
@@ -35,4 +35,10 @@
 # The third @test uses raster maps to create volume data with an elevation surface
 # The maximum elevation should be in the south. Reference @files are present for validation.
 r3.out.vtk -s --o top=elev_top bottom=elev_bottom input=volume_null output=test_volume_null_1_cells_elevation.vtk dp=3 null=0
-r3.out.vtk -sp --o top=elev_top bottom=elev_bottom input=volume_null output=test_volume_null_1_points_elevation.vtk dp=3 null=0
\ No newline at end of file
+r3.out.vtk -sp --o top=elev_top bottom=elev_bottom input=volume_null output=test_volume_null_1_points_elevation.vtk dp=3 null=0
+
+# Comparison of references and vtk files
+for i in `ls *.ref` ; do 
+    diff $i "`basename $i .ref`.vtk" ; 
+done
+rm *.vtk

Modified: grass/trunk/raster3d/r3.retile/main.c
===================================================================
--- grass/trunk/raster3d/r3.retile/main.c	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/raster3d/r3.retile/main.c	2013-03-20 00:14:25 UTC (rev 55462)
@@ -32,14 +32,9 @@
 paramType param; /*Parameters */
 
 /*- prototypes --------------------------------------------------------------*/
-void fatal_error(void *map, int *fd, int depths, char *errorMsg); /*Simple Error message */
-void set_params(); /*Fill the paramType structure */
-void g3d_to_raster(void *map, RASTER3D_Region region, int *fd); /*Write the raster */
-int open_output_map(const char *name, int res_type); /*opens the outputmap */
-void close_output_map(int fd); /*close the map */
+static void fatal_error(void *map, int *fd, int depths, char *errorMsg); /*Simple Error message */
+static void set_params(); /*Fill the paramType structure */
 
-
-
 /* ************************************************************************* */
 /* Error handling ********************************************************** */
 

Modified: grass/trunk/raster3d/r3.retile/test.r3.retile.sh
===================================================================
--- grass/trunk/raster3d/r3.retile/test.r3.retile.sh	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/raster3d/r3.retile/test.r3.retile.sh	2013-03-20 00:14:25 UTC (rev 55462)
@@ -39,3 +39,9 @@
 for map in `g.mlist type=rast3d pattern=test_retile_map_*` ; do
   r3.out.ascii input=${map} output=${map}.txt dp=0
 done
+
+# Comparison of references and text files
+for i in `ls *.ref` ; do 
+    diff $i "`basename $i .ref`.txt" ; 
+done
+rm *.txt

Modified: grass/trunk/raster3d/r3.stats/test.r3.stats.sh
===================================================================
--- grass/trunk/raster3d/r3.stats/test.r3.stats.sh	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/raster3d/r3.stats/test.r3.stats.sh	2013-03-20 00:14:25 UTC (rev 55462)
@@ -28,3 +28,9 @@
 r3.stats input=volume_double_null nsteps=18 > test_volume_double_stats_18.txt
 r3.stats input=volume_double_null nsteps=22 > test_volume_double_stats_22.txt
 r3.stats -e input=volume_double_null > test_volume_double_stats_e.txt
+
+# Comparison of references and text files
+for i in `ls *.ref` ; do 
+    diff $i "`basename $i .ref`.txt" ; 
+done
+rm *.txt

Modified: grass/trunk/raster3d/r3.to.rast/test.r3.to.rast.sh
===================================================================
--- grass/trunk/raster3d/r3.to.rast/test.r3.to.rast.sh	2013-03-19 21:31:16 UTC (rev 55461)
+++ grass/trunk/raster3d/r3.to.rast/test.r3.to.rast.sh	2013-03-20 00:14:25 UTC (rev 55462)
@@ -21,7 +21,7 @@
 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_1*` ; do r.out.ascii input=$i output=${i}.txt; done
 for i in `g.mlist type=rast pattern=test_raster_slice_float*` ; do r.out.ascii input=$i output=${i}.txt; done
 
 # The next @preprocess step adjusts the raster region to increase the resolution by 2
@@ -43,3 +43,9 @@
 
 # Export of the references
 for i in `g.mlist type=rast pattern=test_raster_slice_3*` ; do r.out.ascii input=$i output=${i}.txt; done
+
+# Comparison of references and text files
+for i in `ls *.ref` ; do 
+    diff $i "`basename $i .ref`.txt" ; 
+done
+rm *.txt



More information about the grass-commit mailing list