Browse Source

lidarlib: use segmentlib

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@46266 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 14 years ago
parent
commit
f9175e5469
3 changed files with 21 additions and 24 deletions
  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/vector.h>
 #include <grass/dbmi.h>
 #include <grass/dbmi.h>
 #include <grass/raster.h>
 #include <grass/raster.h>
+#include <grass/segment.h>
 #include <grass/glocale.h>
 #include <grass/glocale.h>
 
 
 /*----------------------------------------------------------------------------------------------------------*/
 /*----------------------------------------------------------------------------------------------------------*/
@@ -112,7 +113,7 @@ struct Point *P_Read_Vector_Region_Map(struct Map_info *, /**/
 				       struct Cell_head *, /**/
 				       struct Cell_head *, /**/
 				       int *, /**/ int, /**/ int /**/);
 				       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 *, /**/
 				       struct Cell_head *, /**/
 				       struct Cell_head *, /**/
 				       int *, /**/ int /**/);
 				       int *, /**/ int /**/);
@@ -138,12 +139,11 @@ P_Sparse_Points(struct Map_info *, /**/
 		struct line_cats *, /**/
 		struct line_cats *, /**/
 		dbDriver *, /**/ double, /**/ char * /**/);
 		dbDriver *, /**/ double, /**/ char * /**/);
 
 
-double **P_Regular_Points(struct Cell_head *, /**/
+int P_Regular_Points(struct Cell_head *, /**/
                           struct Cell_head *, /**/
                           struct Cell_head *, /**/
 			  struct bound_box, /**/
 			  struct bound_box, /**/
 			  struct bound_box, /**/
 			  struct bound_box, /**/
-			  double **, /**/
-			  char **, /**/
+			  SEGMENT *, /**/
 			  double *, /**/
 			  double *, /**/
 			  double, /**/
 			  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,
                           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 passoN, double passoE, double overlap,
 			  double mean, int nsplx, int nsply,
 			  double mean, int nsplx, int nsply,
 			  int nrows, int ncols, int bilin)
 			  int nrows, int ncols, int bilin)
 {
 {
 
 
     int col, row, startcol, endcol, startrow, endrow;
     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); */
     /* G_get_window(&Original); */
     if (Original->north > General.N)
     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 (row = startrow; row < endrow; row++) {
 	for (col = startcol; col < endcol; col++) {
 	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);
 	    X = Rast_col_to_easting((double)(col) + 0.5, Original);
 	    Y = Rast_row_to_northing((double)(row) + 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;
 		interpolation += mean;
 
 
 		if (Vect_point_in_box(X, Y, interpolation, &Overlap)) {	/* (5) */
 		if (Vect_point_in_box(X, Y, interpolation, &Overlap)) {	/* (5) */
-		    matrix[row][col] = interpolation;
+		    dval = interpolation;
 		}
 		}
 		else {
 		else {
+		    segment_get(out_seg, &dval, row, col);
 		    if ((X > Overlap.E) && (X < General.E)) {
 		    if ((X > Overlap.E) && (X < General.E)) {
 			if ((Y > Overlap.N) && (Y < General.N)) {	/* (3) */
 			if ((Y > Overlap.N) && (Y < General.N)) {	/* (3) */
 			    csi = (General.E - X) / overlap;
 			    csi = (General.E - X) / overlap;
 			    eta = (General.N - Y) / overlap;
 			    eta = (General.N - Y) / overlap;
 			    weight = csi * eta;
 			    weight = csi * eta;
 			    interpolation *= weight;
 			    interpolation *= weight;
-			    matrix[row][col] += interpolation;
+			    dval += interpolation;
 			}
 			}
 			else if ((Y < Overlap.S) && (Y > General.S)) {	/* (1) */
 			else if ((Y < Overlap.S) && (Y > General.S)) {	/* (1) */
 			    csi = (General.E - X) / overlap;
 			    csi = (General.E - X) / overlap;
 			    eta = (Y - General.S) / overlap;
 			    eta = (Y - General.S) / overlap;
 			    weight = csi * eta;
 			    weight = csi * eta;
 			    interpolation *= weight;
 			    interpolation *= weight;
-			    matrix[row][col] = interpolation;
+			    dval = interpolation;
 			}
 			}
 			else if ((Y >= Overlap.S) && (Y <= Overlap.N)) {	/* (1) */
 			else if ((Y >= Overlap.S) && (Y <= Overlap.N)) {	/* (1) */
 			    weight = (General.E - X ) / overlap;
 			    weight = (General.E - X ) / overlap;
 			    interpolation *= weight;
 			    interpolation *= weight;
-			    matrix[row][col] = interpolation;
+			    dval = interpolation;
 			}
 			}
 		    }
 		    }
 		    else if ((X < Overlap.W) && (X > General.W)) {
 		    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;
 			    eta = (General.N - Y) / overlap;
 			    weight = eta * csi;
 			    weight = eta * csi;
 			    interpolation *= weight;
 			    interpolation *= weight;
-			    matrix[row][col] += interpolation;
+			    dval += interpolation;
 			}
 			}
 			else if ((Y < Overlap.S) && (Y > General.S)) {	/* (2) */
 			else if ((Y < Overlap.S) && (Y > General.S)) {	/* (2) */
 			    csi = (X - General.W) / overlap;
 			    csi = (X - General.W) / overlap;
 			    eta = (Y - General.S) / overlap;
 			    eta = (Y - General.S) / overlap;
 			    weight = csi * eta;
 			    weight = csi * eta;
 			    interpolation *= weight;
 			    interpolation *= weight;
-			    matrix[row][col] += interpolation;
+			    dval += interpolation;
 			}
 			}
 			else if ((Y >= Overlap.S) && (Y <= Overlap.N)) {	/* (2) */
 			else if ((Y >= Overlap.S) && (Y <= Overlap.N)) {	/* (2) */
 			    weight = (X - General.W) / overlap;
 			    weight = (X - General.W) / overlap;
 			    interpolation *= weight;
 			    interpolation *= weight;
-			    matrix[row][col] += interpolation;
+			    dval += interpolation;
 			}
 			}
 		    }
 		    }
 		    else if ((X >= Overlap.W) && (X <= Overlap.E)) {
 		    else if ((X >= Overlap.W) && (X <= Overlap.E)) {
 			if ((Y > Overlap.N) && (Y < General.N)) {	/* (3) */
 			if ((Y > Overlap.N) && (Y < General.N)) {	/* (3) */
 			    weight = (General.N - Y) / overlap;
 			    weight = (General.N - Y) / overlap;
 			    interpolation *= weight;
 			    interpolation *= weight;
-			    matrix[row][col] += interpolation;
+			    dval += interpolation;
 			}
 			}
 			else if ((Y < Overlap.S) && (Y > General.S)) {	/* (1) */
 			else if ((Y < Overlap.S) && (Y > General.S)) {	/* (1) */
 			    weight = (Y - General.S) / overlap;
 			    weight = (Y - General.S) / overlap;
 			    interpolation *= weight;
 			    interpolation *= weight;
-			    matrix[row][col] = interpolation;
+			    dval = interpolation;
 			}
 			}
 		    }
 		    }
 		}
 		}
+		segment_put(out_seg, &dval, row, col);
 	    }
 	    }
 	}			/* END COL */
 	}			/* END COL */
     }				/* END ROW */
     }				/* 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;
     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 *Elaboration,
 				       struct Cell_head *Original,
 				       struct Cell_head *Original,
 				       int *num_points, int dim_vect)
 				       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 (row = startrow; row < endrow; row++) {
 	for (col = startcol; col < endcol; col++) {
 	for (col = startcol; col < endcol; col++) {
 
 
-	    z = matrix[row][col];
+	    segment_get(in_seg, &z, row, col);
 
 
 	    if (!Rast_is_d_null_value(&z)) {
 	    if (!Rast_is_d_null_value(&z)) {