瀏覽代碼

Expose Rast__read_null_bits()
Fix bug in Rast__open_null_write()
Fix r.null -z (read bits, not bytes)


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@65491 15284696-431f-4ddb-bdfa-cd5b030d7da7

Glynn Clements 9 年之前
父節點
當前提交
d91e4d9b41
共有 4 個文件被更改,包括 6 次插入5 次删除
  1. 1 0
      include/defs/raster.h
  2. 2 3
      lib/raster/get_row.c
  3. 1 1
      lib/raster/open.c
  4. 2 1
      raster/r.null/main.c

+ 1 - 0
include/defs/raster.h

@@ -329,6 +329,7 @@ void Rast_get_c_row(int, CELL *, int);
 void Rast_get_f_row(int, FCELL *, int);
 void Rast_get_d_row(int, DCELL *, int);
 void Rast_get_null_value_row(int, char *, int);
+int Rast__read_null_bits(int, int, unsigned char *);
 
 /* get_row_colr.c */
 void Rast_get_row_colors(int, int, struct Colors *,

+ 2 - 3
lib/raster/get_row.c

@@ -838,11 +838,10 @@ static int read_null_bits_compressed(int null_fd, unsigned char *flags,
     return 1;
 }
 
-static int read_null_bits(int fd, int row)
+int Rast__read_null_bits(int fd, int row, unsigned char *flags)
 {
     struct fileinfo *fcb = &R__.fileinfo[fd];
     int null_fd = fcb->null_fd;
-    unsigned char *flags = fcb->null_bits;
     int cols = fcb->cellhd.cols;
     off_t offset;
     ssize_t size;
@@ -888,7 +887,7 @@ static void get_null_value_row_nomask(int fd, char *flags, int row)
     }
 
     if (row != fcb->null_cur_row) {
-	if (!read_null_bits(fd, row)) {
+	if (!Rast__read_null_bits(fd, row, fcb->null_bits)) {
 	    fcb->null_cur_row = -1;
 	    if (fcb->map_type == CELL_TYPE) {
 		/* If can't read null row, assume  that all map 0's are nulls */

+ 1 - 1
lib/raster/open.c

@@ -754,7 +754,7 @@ int Rast__open_null_write(const char *name)
 
     if (R__.compress_nulls) {
 	fcb->null_row_ptr = G_calloc(fcb->cellhd.rows + 1, sizeof(off_t));
-	G_zero(fcb->row_ptr, (fcb->cellhd.rows + 1) * sizeof(off_t));
+	G_zero(fcb->null_row_ptr, (fcb->cellhd.rows + 1) * sizeof(off_t));
 	Rast__write_null_row_ptrs(fd, fcb->null_fd);
     }
 

+ 2 - 1
raster/r.null/main.c

@@ -199,6 +199,7 @@ int main(int argc, char *argv[])
 	int in_fd;
 	/* write a file of no-nulls */
 	null_bits = Rast__allocate_null_bits(cellhd.cols);
+	Rast__init_null_bits(null_bits, cellhd.cols);
 
 	Rast_set_window(&cellhd);
 	in_fd = Rast_open_old(name, mapset);
@@ -209,7 +210,7 @@ int main(int argc, char *argv[])
 
 	for (row = 0; row < cellhd.rows; row++) {
 	    G_percent(row, cellhd.rows, 1);
-	    Rast_get_null_value_row(in_fd, (char*) null_bits, row);
+	    Rast__read_null_bits(in_fd, row, null_bits);
 	    Rast__write_null_bits(fd, null_bits);
 	}
 	G_percent(row, cellhd.rows, 1);