[GRASS-SVN] r43484 - grass/trunk/lib/lidar

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Sep 17 08:56:40 EDT 2010


Author: mmetz
Date: 2010-09-17 12:56:40 +0000 (Fri, 17 Sep 2010)
New Revision: 43484

Modified:
   grass/trunk/lib/lidar/lidar.h
   grass/trunk/lib/lidar/zones.c
Log:
read raster and check masked cells in one go

Modified: grass/trunk/lib/lidar/lidar.h
===================================================================
--- grass/trunk/lib/lidar/lidar.h	2010-09-16 16:11:13 UTC (rev 43483)
+++ grass/trunk/lib/lidar/lidar.h	2010-09-17 12:56:40 UTC (rev 43484)
@@ -113,6 +113,7 @@
 				       int *, /**/ int, /**/ int /**/);
 
 struct Point *P_Read_Raster_Region_Map(double **, /**/
+				       char **, /**/
 				       struct Cell_head *, /**/
 				       struct Cell_head *, /**/
 				       int *, /**/ int *, /**/ int /**/);

Modified: grass/trunk/lib/lidar/zones.c
===================================================================
--- grass/trunk/lib/lidar/zones.c	2010-09-16 16:11:13 UTC (rev 43483)
+++ grass/trunk/lib/lidar/zones.c	2010-09-17 12:56:40 UTC (rev 43484)
@@ -384,13 +384,13 @@
     return obs;
 }
 
-struct Point *P_Read_Raster_Region_Map(double **matrix,
+struct Point *P_Read_Raster_Region_Map(double **matrix, char **mask_matrix,
 				       struct Cell_head *Elaboration,
 				       struct Cell_head *Original,
 				       int *num_points, int *num_nulls, int dim_vect)
 {
     int col, row, startcol, endcol, startrow, endrow, nrows, ncols;
-    int pippo, npoints, nnulls;
+    int pippo, npoints, nnulls, all_masked = 0;
     double x, y, z;
     struct Point *obs;
     struct bound_box elaboration_box;
@@ -404,6 +404,9 @@
     npoints = nnulls = 0;
     nrows = Original->rows;
     ncols = Original->cols;
+    
+    if (mask_matrix)
+	all_masked = 1;
 
     if (Original->north > Elaboration->north)
 	startrow = (Original->north - Elaboration->north) / Original->ns_res - 1;
@@ -434,6 +437,12 @@
 	    z = matrix[row][col];
 
 	    if (!Rast_is_d_null_value(&z)) {
+
+		if (mask_matrix && all_masked) {
+		    if (mask_matrix[row][col])
+			all_masked = 0;
+		}
+
 		x = Rast_col_to_easting((double)(col) + 0.5, Original);
 		y = Rast_row_to_northing((double)(row) + 0.5, Original);
 
@@ -460,8 +469,12 @@
 	}
     }
 
+    /* num_nulls indicates how many points to interpolate */
+    if (all_masked)
+	*num_nulls = 0;
+    else
+	*num_nulls = nnulls;
     *num_points = npoints;
-    *num_nulls = nnulls;
     return obs;
 }
 



More information about the grass-commit mailing list