Преглед изворни кода

rasterlib: change name of compressed null file, set default compression method to LZ4

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@67943 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz пре 9 година
родитељ
комит
9cce81c7b2
3 измењених фајлова са 12 додато и 9 уклоњено
  1. 7 6
      lib/raster/close.c
  2. 3 2
      lib/raster/open.c
  3. 2 1
      lib/raster/put_row.c

+ 7 - 6
lib/raster/close.c

@@ -33,7 +33,8 @@
 #define FORMAT_FILE "f_format"
 #define QUANT_FILE  "f_quant"
 #define NULL_FILE   "null"
-#define NULL2_FILE  "null2"
+/* cmpressed null file */
+#define NULLC_FILE  "nullcmpr"
 
 static int close_old(int);
 static int close_new(int, int);
@@ -279,7 +280,7 @@ static int close_new_gdal(int fd, int ok)
 	G_file_name_misc(path, "cell_misc", NULL_FILE, fcb->name,
 			  G_mapset());
 	remove(path);
-	G_file_name_misc(path, "cell_misc", NULL2_FILE, fcb->name,
+	G_file_name_misc(path, "cell_misc", NULLC_FILE, fcb->name,
 			  G_mapset());
 	remove(path);
 
@@ -375,11 +376,11 @@ static int close_new(int fd, int ok)
 	G__make_mapset_element_misc("cell_misc", fcb->name);
 	G_file_name_misc(path, "cell_misc", NULL_FILE, fcb->name, G_mapset());
 	remove(path);
-	G_file_name_misc(path, "cell_misc", NULL2_FILE, fcb->name, G_mapset());
+	G_file_name_misc(path, "cell_misc", NULLC_FILE, fcb->name, G_mapset());
 	remove(path);
 
 	G_file_name_misc(path, "cell_misc",
-			 fcb->null_row_ptr ? NULL2_FILE : NULL_FILE,
+			 fcb->null_row_ptr ? NULLC_FILE : NULL_FILE,
 			 fcb->name, G_mapset());
 
 	if (fcb->null_cur_row > 0) {
@@ -502,11 +503,11 @@ void Rast__close_null(int fd)
     G__make_mapset_element_misc("cell_misc", fcb->name);
     G_file_name_misc(path, "cell_misc", NULL_FILE, fcb->name, G_mapset());
     remove(path);
-    G_file_name_misc(path, "cell_misc", NULL2_FILE, fcb->name, G_mapset());
+    G_file_name_misc(path, "cell_misc", NULLC_FILE, fcb->name, G_mapset());
     remove(path);
 
     G_file_name_misc(path, "cell_misc",
-		     fcb->null_row_ptr ? NULL2_FILE : NULL_FILE,
+		     fcb->null_row_ptr ? NULLC_FILE : NULL_FILE,
 		     fcb->name, G_mapset());
 
     if (rename(fcb->null_temp_name, path))

+ 3 - 2
lib/raster/open.c

@@ -29,7 +29,8 @@
 #include "R.h"
 #define FORMAT_FILE "f_format"
 #define NULL_FILE   "null"
-#define NULL2_FILE  "null2"
+/* cmpressed null file */
+#define NULLC_FILE  "nullcmpr"
 
 static int new_fileinfo(void)
 {
@@ -354,7 +355,7 @@ int Rast__open_old(const char *name, const char *mapset)
 	/* First, check for compressed null file */
 	fcb->null_fd = G_open_old_misc("cell_misc", NULL_FILE, r_name, r_mapset);
 	if (fcb->null_fd < 0) {
-	    fcb->null_fd = G_open_old_misc("cell_misc", NULL2_FILE, r_name, r_mapset);
+	    fcb->null_fd = G_open_old_misc("cell_misc", NULLC_FILE, r_name, r_mapset);
 	    if (fcb->null_fd >= 0) {
 		fcb->null_row_ptr = G_calloc(fcb->cellhd.rows + 1, sizeof(off_t));
 		if (Rast__read_null_row_ptrs(fd, fcb->null_fd) < 0) {

+ 2 - 1
lib/raster/put_row.c

@@ -505,7 +505,8 @@ static void write_null_bits_compressed(const unsigned char *flags,
 
     compressed_buf = G_alloca(size + 1);
 
-    nwrite = G_compress(flags, size, compressed_buf, size, fcb->cellhd.compressed);
+    /* compress null bits file with LZ4, see lib/gis/compress.h */
+    nwrite = G_compress(flags, size, compressed_buf, size, 3);
 
     if (nwrite > 0 && nwrite < size) {
 	if (write(fcb->null_fd, compressed_buf, nwrite) != nwrite)