[GRASS-SVN] r67296 - grass/trunk/lib/raster

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Dec 21 00:00:06 PST 2015


Author: mmetz
Date: 2015-12-21 00:00:06 -0800 (Mon, 21 Dec 2015)
New Revision: 67296

Modified:
   grass/trunk/lib/raster/init.c
   grass/trunk/lib/raster/open.c
Log:
rasterlib: more tests for raster compression

Modified: grass/trunk/lib/raster/init.c
===================================================================
--- grass/trunk/lib/raster/init.c	2015-12-21 07:58:36 UTC (rev 67295)
+++ grass/trunk/lib/raster/init.c	2015-12-21 08:00:06 UTC (rev 67296)
@@ -77,7 +77,7 @@
 
 static int init(void)
 {
-    char *zlib, *nulls, *ctype;
+    char *zlib, *nulls, *cname;
 
     Rast__init_window();
 
@@ -96,16 +96,29 @@
     zlib = getenv("GRASS_INT_ZLIB");
     R__.compression_type = (!zlib || atoi(zlib)) ? 2 : 1;
 
-    ctype = getenv("GRASS_COMPRESSOR");
+    cname = getenv("GRASS_COMPRESSOR");
     /* 1: RLE
      * 2: ZLIB (DEFLATE)
      * 3: LZ4
      * 4: BZIP2 */
-    if (ctype) {
+    if (cname) {
 	/* ask gislib */
-	R__.compression_type = G_get_compressor(ctype);
-	if (R__.compression_type < 1)
+	R__.compression_type = G_compressor_number(cname);
+	if (R__.compression_type < 1) {
+	    if (R__.compression_type < 0) {
+		G_warning(_("Unknown compression method <%s>, using default ZLIB"),
+		    cname);
+	    }
+	    if (R__.compression_type == 0) {
+		G_warning(_("No compression is not supported for GRASS raster maps, using default ZLIB"));
+	    }
 	    R__.compression_type = 2; /* default to ZLIB */
+	}
+	if (G_check_compressor(R__.compression_type) != 1) {
+	    G_warning(_("This GRASS version does not support %s compression, using default ZLIB"),
+		cname);
+	    R__.compression_type = 2; /* default to ZLIB */
+	}
     }
 
     nulls = getenv("GRASS_COMPRESS_NULLS");

Modified: grass/trunk/lib/raster/open.c
===================================================================
--- grass/trunk/lib/raster/open.c	2015-12-21 07:58:36 UTC (rev 67295)
+++ grass/trunk/lib/raster/open.c	2015-12-21 08:00:06 UTC (rev 67296)
@@ -230,7 +230,10 @@
 	if (cellhd.compressed == 1)
 	    cellhd.compressed = 2;
     }
-    /* TODO: test if compressor type is supported */
+    /* test if compressor type is supported */
+    if (!G_check_compressor(cellhd.compressed)) {
+	G_fatal_error(_("Compression with %s is not supported"), G_compressor_name(cellhd.compressed));
+    }
 
     if (cellhd.proj != R__.rd_window.proj)
 	G_fatal_error(_("Raster map <%s> is in different projection than current region. "
@@ -648,9 +651,9 @@
      *   allocate space to hold the row address array
      */
     fcb->cellhd = R__.wr_window;
+    
+    /* change open_mode to OPEN_NEW_UNCOMPRESSED if R__.compression_type == 0 ? */
 
-    /* TODO: test if compressor type is supported */
-
     if (open_mode == OPEN_NEW_COMPRESSED && fcb->map_type == CELL_TYPE) {
 	fcb->row_ptr = G_calloc(fcb->cellhd.rows + 1, sizeof(off_t));
 	G_zero(fcb->row_ptr, (fcb->cellhd.rows + 1) * sizeof(off_t));



More information about the grass-commit mailing list