5 #include <grass/lidar.h>
11 double **obs,
double *param,
int *line_num,
double pe,
12 double pn,
double overlap,
int nsplx,
int nsply,
13 int num_points,
int bilin,
struct line_cats *categories,
20 double interpolation, csi, eta, weight;
27 for (i = 0; i < num_points; i++) {
35 obs[i][0], obs[i][1], pe, pn, nsplx, nsply,
36 Elaboration->
west, Elaboration->
south, param);
39 obs[i][0], obs[i][1], pe, pn, nsplx, nsply,
40 Elaboration->
west, Elaboration->
south, param);
42 interpolation +=
mean;
53 sprintf(buf,
"INSERT INTO %s (ID, X, Y, Interp)", tab_name);
56 sprintf(buf,
" VALUES (");
58 sprintf(buf,
"%d, %f, %f, ", line_num[i], obs[i][0], obs[i][1]);
61 if ((*point->
x > Overlap.
E) && (*point->
x < General.
E)) {
62 if ((*point->
y > Overlap.
N) &&
63 (*point->
y < General.
N)) {
64 csi = (General.
E - *point->
x) / overlap;
65 eta = (General.
N - *point->
y) / overlap;
67 *point->
z = weight * interpolation;
69 sprintf(buf,
"%lf", *point->
z);
78 else if ((*point->
y < Overlap.
S) &&
79 (*point->
y > General.
S)) {
80 csi = (General.
E - *point->
x) / overlap;
81 eta = (*point->
y - General.
S) / overlap;
83 *point->
z = weight * interpolation;
85 sprintf(buf,
"%lf", *point->
z);
94 else if ((*point->
y <= Overlap.
N) &&
95 (*point->
y >= Overlap.
S)) {
96 weight = (General.
E - *point->
x) / overlap;
97 *point->
z = weight * interpolation;
99 sprintf(buf,
"%lf", *point->
z);
109 else if ((*point->
x < Overlap.
W) && (*point->
x > General.
W)) {
110 if ((*point->
y > Overlap.
N) &&
111 (*point->
y < General.
N)) {
112 csi = (*point->
x - General.
W) / overlap;
113 eta = (General.
N - *point->
y) / overlap;
115 *point->
z = weight * interpolation;
117 sprintf(buf,
"%lf", *point->
z);
126 else if ((*point->
y < Overlap.
S) &&
127 (*point->
y > General.
S)) {
128 csi = (*point->
x - General.
W) / overlap;
129 eta = (*point->
y - General.
S) / overlap;
131 *point->
z = weight * interpolation;
133 sprintf(buf,
"%lf", *point->
z);
142 else if ((*point->
y >= Overlap.
S) &&
143 (*point->
y <= Overlap.
N)) {
144 weight = (*point->
x - General.
W) / overlap;
145 *point->
z = weight * interpolation;
147 sprintf(buf,
"%lf", *point->
z);
157 else if ((*point->
x >= Overlap.
W) && (*point->
x <= Overlap.
E)) {
158 if ((*point->
y > Overlap.
N) &&
159 (*point->
y < General.
N)) {
160 weight = (General.
N - *point->
y) / overlap;
161 *point->
z = weight * interpolation;
163 sprintf(buf,
"%lf", *point->
z);
172 else if ((*point->
y < Overlap.
S) &&
173 (*point->
y > General.
S)) {
174 weight = (*point->
y - General.
S) / overlap;
175 *point->
z = (1 - weight) * interpolation;
177 sprintf(buf,
"%lf", *point->
z);
199 SEGMENT *out_seg,
double *param,
double passoN,
200 double passoE,
double overlap,
double mean,
int nsplx,
201 int nsply,
int nrows,
int ncols,
int bilin)
204 int col, row, startcol, endcol, startrow, endrow;
205 double X,
Y, interpolation, weight, csi, eta, dval;
208 if (Original->
north > General.
N)
209 startrow = (Original->
north - General.
N) / Original->
ns_res - 1;
213 endrow = (Original->
north - General.
S) / Original->
ns_res + 1;
219 if (General.
W > Original->
west)
220 startcol = (General.
W - Original->
west) / Original->
ew_res - 1;
223 if (General.
E > Original->
west) {
224 endcol = (General.
E - Original->
west) / Original->
ew_res + 1;
231 for (row = startrow; row < endrow; row++) {
232 for (col = startcol; col < endcol; col++) {
243 X,
Y, passoE, passoN, nsplx, nsply, Elaboration->
west,
244 Elaboration->
south, param);
247 X,
Y, passoE, passoN, nsplx, nsply, Elaboration->
west,
248 Elaboration->
south, param);
250 interpolation +=
mean;
254 dval = interpolation;
258 if ((
X > Overlap.
E) && (
X < General.
E)) {
259 if ((
Y > Overlap.
N) && (
Y < General.
N)) {
260 csi = (General.
E -
X) / overlap;
261 eta = (General.
N -
Y) / overlap;
263 interpolation *= weight;
264 dval += interpolation;
266 else if ((
Y < Overlap.
S) && (
Y > General.
S)) {
267 csi = (General.
E -
X) / overlap;
268 eta = (
Y - General.
S) / overlap;
270 interpolation *= weight;
271 dval = interpolation;
273 else if ((
Y >= Overlap.
S) &&
275 weight = (General.
E -
X) / overlap;
276 interpolation *= weight;
277 dval = interpolation;
280 else if ((
X < Overlap.
W) && (
X > General.
W)) {
281 if ((
Y > Overlap.
N) && (
Y < General.
N)) {
282 csi = (
X - General.
W) / overlap;
283 eta = (General.
N -
Y) / overlap;
285 interpolation *= weight;
286 dval += interpolation;
288 else if ((
Y < Overlap.
S) && (
Y > General.
S)) {
289 csi = (
X - General.
W) / overlap;
290 eta = (
Y - General.
S) / overlap;
292 interpolation *= weight;
293 dval += interpolation;
295 else if ((
Y >= Overlap.
S) &&
297 weight = (
X - General.
W) / overlap;
298 interpolation *= weight;
299 dval += interpolation;
302 else if ((
X >= Overlap.
W) && (
X <= Overlap.
E)) {
303 if ((
Y > Overlap.
N) && (
Y < General.
N)) {
304 weight = (General.
N -
Y) / overlap;
305 interpolation *= weight;
306 dval += interpolation;
308 else if ((
Y < Overlap.
S) && (
Y > General.
S)) {
309 weight = (
Y - General.
S) / overlap;
310 interpolation *= weight;
311 dval = interpolation;
double dataInterpolateBicubic(double x, double y, double deltaX, double deltaY, int xNum, int yNum, double xMin, double yMin, double *parVect)
double dataInterpolateBilin(double x, double y, double deltaX, double deltaY, int xNum, int yNum, double xMin, double yMin, double *parVect)
int db_commit_transaction(dbDriver *)
Commit transaction.
int db_begin_transaction(dbDriver *)
Begin transaction.
int db_execute_immediate(dbDriver *, dbString *)
Execute SQL statements.
void db_init_string(dbString *)
Initialize dbString.
int db_append_string(dbString *, const char *)
Append string to dbString.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
double Rast_row_to_northing(double, const struct Cell_head *)
Row to northing.
double Rast_col_to_easting(double, const struct Cell_head *)
Column to easting.
int Segment_get(SEGMENT *, void *, off_t, off_t)
Get value from segment file.
int Segment_put(SEGMENT *, const void *, off_t, off_t)
void Vect_destroy_line_struct(struct line_pnts *)
Frees all memory associated with a line_pnts structure, including the structure itself.
int Vect_copy_xyz_to_pnts(struct line_pnts *, const double *, const double *, const double *, int)
Copy points from array to line_pnts structure.
off_t Vect_write_line(struct Map_info *, int, const struct line_pnts *, const struct line_cats *)
Writes a new feature.
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
int Vect_point_in_box(double, double, double, const struct bound_box *)
Tests if point is in 3D box.
#define GV_POINT
Feature types used in memory on run time (may change)
float mean(IClass_statistics *statistics, int band)
Helper function for computing mean.
void P_Sparse_Points(struct Map_info *Out, struct Cell_head *Elaboration, struct bound_box General, struct bound_box Overlap, double **obs, double *param, int *line_num, double pe, double pn, double overlap, int nsplx, int nsply, int num_points, int bilin, struct line_cats *categories, dbDriver *driver, double mean, char *tab_name)
int P_Regular_Points(struct Cell_head *Elaboration, struct Cell_head *Original, struct bound_box General, struct bound_box Overlap, SEGMENT *out_seg, double *param, double passoN, double passoE, double overlap, double mean, int nsplx, int nsply, int nrows, int ncols, int bilin)
2D/3D raster map header (used also for region)
double ew_res
Resolution - east to west cell size for 2D data.
double north
Extent coordinates (north)
double ns_res
Resolution - north to south cell size for 2D data.
double south
Extent coordinates (south)
double west
Extent coordinates (west)
Feature geometry info - coordinates.
double * y
Array of Y coordinates.
double * x
Array of X coordinates.
double * z
Array of Z coordinates.