[GRASS-SVN] r65491 - in grass/trunk: include/defs lib/raster raster/r.null

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jun 16 16:50:33 PDT 2015


Author: glynn
Date: 2015-06-16 16:50:33 -0700 (Tue, 16 Jun 2015)
New Revision: 65491

Modified:
   grass/trunk/include/defs/raster.h
   grass/trunk/lib/raster/get_row.c
   grass/trunk/lib/raster/open.c
   grass/trunk/raster/r.null/main.c
Log:
Expose Rast__read_null_bits()
Fix bug in Rast__open_null_write()
Fix r.null -z (read bits, not bytes)


Modified: grass/trunk/include/defs/raster.h
===================================================================
--- grass/trunk/include/defs/raster.h	2015-06-16 23:22:34 UTC (rev 65490)
+++ grass/trunk/include/defs/raster.h	2015-06-16 23:50:33 UTC (rev 65491)
@@ -329,6 +329,7 @@
 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 *,

Modified: grass/trunk/lib/raster/get_row.c
===================================================================
--- grass/trunk/lib/raster/get_row.c	2015-06-16 23:22:34 UTC (rev 65490)
+++ grass/trunk/lib/raster/get_row.c	2015-06-16 23:50:33 UTC (rev 65491)
@@ -838,11 +838,10 @@
     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 @@
     }
 
     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 */

Modified: grass/trunk/lib/raster/open.c
===================================================================
--- grass/trunk/lib/raster/open.c	2015-06-16 23:22:34 UTC (rev 65490)
+++ grass/trunk/lib/raster/open.c	2015-06-16 23:50:33 UTC (rev 65491)
@@ -754,7 +754,7 @@
 
     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);
     }
 

Modified: grass/trunk/raster/r.null/main.c
===================================================================
--- grass/trunk/raster/r.null/main.c	2015-06-16 23:22:34 UTC (rev 65490)
+++ grass/trunk/raster/r.null/main.c	2015-06-16 23:50:33 UTC (rev 65491)
@@ -199,6 +199,7 @@
 	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 @@
 
 	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);



More information about the grass-commit mailing list