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 snprintf(buf,
sizeof(buf),
"INSERT INTO %s (ID, X, Y, Interp)",
57 snprintf(buf,
sizeof(buf),
" VALUES (");
59 snprintf(buf,
sizeof(buf),
"%d, %f, %f, ", line_num[i],
60 obs[i][0], obs[i][1]);
63 if ((*point->
x > Overlap.
E) && (*point->
x < General.
E)) {
64 if ((*point->
y > Overlap.
N) &&
65 (*point->
y < General.
N)) {
66 csi = (General.
E - *point->
x) / overlap;
67 eta = (General.
N - *point->
y) / overlap;
69 *point->
z = weight * interpolation;
71 snprintf(buf,
sizeof(buf),
"%lf", *point->
z);
73 snprintf(buf,
sizeof(buf),
")");
80 else if ((*point->
y < Overlap.
S) &&
81 (*point->
y > General.
S)) {
82 csi = (General.
E - *point->
x) / overlap;
83 eta = (*point->
y - General.
S) / overlap;
85 *point->
z = weight * interpolation;
87 snprintf(buf,
sizeof(buf),
"%lf", *point->
z);
89 snprintf(buf,
sizeof(buf),
")");
96 else if ((*point->
y <= Overlap.
N) &&
97 (*point->
y >= Overlap.
S)) {
98 weight = (General.
E - *point->
x) / overlap;
99 *point->
z = weight * interpolation;
101 snprintf(buf,
sizeof(buf),
"%lf", *point->
z);
103 snprintf(buf,
sizeof(buf),
")");
111 else if ((*point->
x < Overlap.
W) && (*point->
x > General.
W)) {
112 if ((*point->
y > Overlap.
N) &&
113 (*point->
y < General.
N)) {
114 csi = (*point->
x - General.
W) / overlap;
115 eta = (General.
N - *point->
y) / overlap;
117 *point->
z = weight * interpolation;
119 snprintf(buf,
sizeof(buf),
"%lf", *point->
z);
121 snprintf(buf,
sizeof(buf),
")");
128 else if ((*point->
y < Overlap.
S) &&
129 (*point->
y > General.
S)) {
130 csi = (*point->
x - General.
W) / overlap;
131 eta = (*point->
y - General.
S) / overlap;
133 *point->
z = weight * interpolation;
135 snprintf(buf,
sizeof(buf),
"%lf", *point->
z);
137 snprintf(buf,
sizeof(buf),
")");
144 else if ((*point->
y >= Overlap.
S) &&
145 (*point->
y <= Overlap.
N)) {
146 weight = (*point->
x - General.
W) / overlap;
147 *point->
z = weight * interpolation;
149 snprintf(buf,
sizeof(buf),
"%lf", *point->
z);
151 snprintf(buf,
sizeof(buf),
")");
159 else if ((*point->
x >= Overlap.
W) && (*point->
x <= Overlap.
E)) {
160 if ((*point->
y > Overlap.
N) &&
161 (*point->
y < General.
N)) {
162 weight = (General.
N - *point->
y) / overlap;
163 *point->
z = weight * interpolation;
165 snprintf(buf,
sizeof(buf),
"%lf", *point->
z);
167 snprintf(buf,
sizeof(buf),
")");
174 else if ((*point->
y < Overlap.
S) &&
175 (*point->
y > General.
S)) {
176 weight = (*point->
y - General.
S) / overlap;
177 *point->
z = (1 - weight) * interpolation;
179 snprintf(buf,
sizeof(buf),
"%lf", *point->
z);
181 snprintf(buf,
sizeof(buf),
")");
201 SEGMENT *out_seg,
double *param,
double passoN,
202 double passoE,
double overlap,
double mean,
int nsplx,
203 int nsply,
int nrows,
int ncols,
int bilin)
206 int col, row, startcol, endcol, startrow, endrow;
207 double X,
Y, interpolation, weight, csi, eta, dval;
210 if (Original->
north > General.
N)
211 startrow = (Original->
north - General.
N) / Original->
ns_res - 1;
215 endrow = (Original->
north - General.
S) / Original->
ns_res + 1;
221 if (General.
W > Original->
west)
222 startcol = (General.
W - Original->
west) / Original->
ew_res - 1;
225 if (General.
E > Original->
west) {
226 endcol = (General.
E - Original->
west) / Original->
ew_res + 1;
233 for (row = startrow; row < endrow; row++) {
234 for (col = startcol; col < endcol; col++) {
245 X,
Y, passoE, passoN, nsplx, nsply, Elaboration->
west,
246 Elaboration->
south, param);
249 X,
Y, passoE, passoN, nsplx, nsply, Elaboration->
west,
250 Elaboration->
south, param);
252 interpolation +=
mean;
256 dval = interpolation;
260 if ((
X > Overlap.
E) && (
X < General.
E)) {
261 if ((
Y > Overlap.
N) && (
Y < General.
N)) {
262 csi = (General.
E -
X) / overlap;
263 eta = (General.
N -
Y) / overlap;
265 interpolation *= weight;
266 dval += interpolation;
268 else if ((
Y < Overlap.
S) && (
Y > General.
S)) {
269 csi = (General.
E -
X) / overlap;
270 eta = (
Y - General.
S) / overlap;
272 interpolation *= weight;
273 dval = interpolation;
275 else if ((
Y >= Overlap.
S) &&
277 weight = (General.
E -
X) / overlap;
278 interpolation *= weight;
279 dval = interpolation;
282 else if ((
X < Overlap.
W) && (
X > General.
W)) {
283 if ((
Y > Overlap.
N) && (
Y < General.
N)) {
284 csi = (
X - General.
W) / overlap;
285 eta = (General.
N -
Y) / overlap;
287 interpolation *= weight;
288 dval += interpolation;
290 else if ((
Y < Overlap.
S) && (
Y > General.
S)) {
291 csi = (
X - General.
W) / overlap;
292 eta = (
Y - General.
S) / overlap;
294 interpolation *= weight;
295 dval += interpolation;
297 else if ((
Y >= Overlap.
S) &&
299 weight = (
X - General.
W) / overlap;
300 interpolation *= weight;
301 dval += interpolation;
304 else if ((
X >= Overlap.
W) && (
X <= Overlap.
E)) {
305 if ((
Y > Overlap.
N) && (
Y < General.
N)) {
306 weight = (General.
N -
Y) / overlap;
307 interpolation *= weight;
308 dval += interpolation;
310 else if ((
Y < Overlap.
S) && (
Y > General.
S)) {
311 weight = (
Y - General.
S) / overlap;
312 interpolation *= weight;
313 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.