瀏覽代碼

lidarlib: use segmentlib

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@46266 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 14 年之前
父節點
當前提交
f9175e5469
共有 3 個文件被更改,包括 21 次插入24 次删除
  1. 4 4
      lib/lidar/lidar.h
  2. 15 18
      lib/lidar/raster.c
  3. 2 2
      lib/lidar/zones.c

+ 4 - 4
lib/lidar/lidar.h

@@ -25,6 +25,7 @@
 #include <grass/vector.h>
 #include <grass/dbmi.h>
 #include <grass/raster.h>
+#include <grass/segment.h>
 #include <grass/glocale.h>
 
 /*----------------------------------------------------------------------------------------------------------*/
@@ -112,7 +113,7 @@ struct Point *P_Read_Vector_Region_Map(struct Map_info *, /**/
 				       struct Cell_head *, /**/
 				       int *, /**/ int, /**/ int /**/);
 
-struct Point *P_Read_Raster_Region_Map(double **, /**/
+struct Point *P_Read_Raster_Region_Map(SEGMENT *, /**/
 				       struct Cell_head *, /**/
 				       struct Cell_head *, /**/
 				       int *, /**/ int /**/);
@@ -138,12 +139,11 @@ P_Sparse_Points(struct Map_info *, /**/
 		struct line_cats *, /**/
 		dbDriver *, /**/ double, /**/ char * /**/);
 
-double **P_Regular_Points(struct Cell_head *, /**/
+int P_Regular_Points(struct Cell_head *, /**/
                           struct Cell_head *, /**/
 			  struct bound_box, /**/
 			  struct bound_box, /**/
-			  double **, /**/
-			  char **, /**/
+			  SEGMENT *, /**/
 			  double *, /**/
 			  double, /**/
 			  double, /**/

+ 15 - 18
lib/lidar/raster.c

@@ -187,16 +187,16 @@ P_Sparse_Points(struct Map_info *Out, struct Cell_head *Elaboration,
 
 
 /*------------------------------------------------------------------------------------------------*/
-double **P_Regular_Points(struct Cell_head *Elaboration, struct Cell_head *Original,
+int P_Regular_Points(struct Cell_head *Elaboration, struct Cell_head *Original,
                           struct bound_box General, struct bound_box Overlap,
-			  double **matrix, char **mask_matrix, double *param,
+			  SEGMENT *out_seg, double *param,
 			  double passoN, double passoE, double overlap,
 			  double mean, int nsplx, int nsply,
 			  int nrows, int ncols, int bilin)
 {
 
     int col, row, startcol, endcol, startrow, endrow;
-    double X, Y, interpolation, weight, csi, eta;
+    double X, Y, interpolation, weight, csi, eta, dval;
 
     /* G_get_window(&Original); */
     if (Original->north > General.N)
@@ -225,11 +225,6 @@ double **P_Regular_Points(struct Cell_head *Elaboration, struct Cell_head *Origi
     for (row = startrow; row < endrow; row++) {
 	for (col = startcol; col < endcol; col++) {
 
-	    if (mask_matrix) {
-		if (!mask_matrix[row][col])
-		    continue;
-	    }
-
 	    X = Rast_col_to_easting((double)(col) + 0.5, Original);
 	    Y = Rast_row_to_northing((double)(row) + 0.5, Original);
 
@@ -249,28 +244,29 @@ double **P_Regular_Points(struct Cell_head *Elaboration, struct Cell_head *Origi
 		interpolation += mean;
 
 		if (Vect_point_in_box(X, Y, interpolation, &Overlap)) {	/* (5) */
-		    matrix[row][col] = interpolation;
+		    dval = interpolation;
 		}
 		else {
+		    segment_get(out_seg, &dval, row, col);
 		    if ((X > Overlap.E) && (X < General.E)) {
 			if ((Y > Overlap.N) && (Y < General.N)) {	/* (3) */
 			    csi = (General.E - X) / overlap;
 			    eta = (General.N - Y) / overlap;
 			    weight = csi * eta;
 			    interpolation *= weight;
-			    matrix[row][col] += interpolation;
+			    dval += interpolation;
 			}
 			else if ((Y < Overlap.S) && (Y > General.S)) {	/* (1) */
 			    csi = (General.E - X) / overlap;
 			    eta = (Y - General.S) / overlap;
 			    weight = csi * eta;
 			    interpolation *= weight;
-			    matrix[row][col] = interpolation;
+			    dval = interpolation;
 			}
 			else if ((Y >= Overlap.S) && (Y <= Overlap.N)) {	/* (1) */
 			    weight = (General.E - X ) / overlap;
 			    interpolation *= weight;
-			    matrix[row][col] = interpolation;
+			    dval = interpolation;
 			}
 		    }
 		    else if ((X < Overlap.W) && (X > General.W)) {
@@ -279,36 +275,37 @@ double **P_Regular_Points(struct Cell_head *Elaboration, struct Cell_head *Origi
 			    eta = (General.N - Y) / overlap;
 			    weight = eta * csi;
 			    interpolation *= weight;
-			    matrix[row][col] += interpolation;
+			    dval += interpolation;
 			}
 			else if ((Y < Overlap.S) && (Y > General.S)) {	/* (2) */
 			    csi = (X - General.W) / overlap;
 			    eta = (Y - General.S) / overlap;
 			    weight = csi * eta;
 			    interpolation *= weight;
-			    matrix[row][col] += interpolation;
+			    dval += interpolation;
 			}
 			else if ((Y >= Overlap.S) && (Y <= Overlap.N)) {	/* (2) */
 			    weight = (X - General.W) / overlap;
 			    interpolation *= weight;
-			    matrix[row][col] += interpolation;
+			    dval += interpolation;
 			}
 		    }
 		    else if ((X >= Overlap.W) && (X <= Overlap.E)) {
 			if ((Y > Overlap.N) && (Y < General.N)) {	/* (3) */
 			    weight = (General.N - Y) / overlap;
 			    interpolation *= weight;
-			    matrix[row][col] += interpolation;
+			    dval += interpolation;
 			}
 			else if ((Y < Overlap.S) && (Y > General.S)) {	/* (1) */
 			    weight = (Y - General.S) / overlap;
 			    interpolation *= weight;
-			    matrix[row][col] = interpolation;
+			    dval = interpolation;
 			}
 		    }
 		}
+		segment_put(out_seg, &dval, row, col);
 	    }
 	}			/* END COL */
     }				/* END ROW */
-    return matrix;
+    return 1;
 }

+ 2 - 2
lib/lidar/zones.c

@@ -373,7 +373,7 @@ struct Point *P_Read_Vector_Region_Map(struct Map_info *Map,
     return obs;
 }
 
-struct Point *P_Read_Raster_Region_Map(double **matrix,
+struct Point *P_Read_Raster_Region_Map(SEGMENT *in_seg,
 				       struct Cell_head *Elaboration,
 				       struct Cell_head *Original,
 				       int *num_points, int dim_vect)
@@ -420,7 +420,7 @@ struct Point *P_Read_Raster_Region_Map(double **matrix,
     for (row = startrow; row < endrow; row++) {
 	for (col = startcol; col < endcol; col++) {
 
-	    z = matrix[row][col];
+	    segment_get(in_seg, &z, row, col);
 
 	    if (!Rast_is_d_null_value(&z)) {