5 #include <grass/lidar.h>
10 double **obs,
double *param,
int *line_num,
double pe,
11 double pn,
double overlap,
int nsplx,
int nsply,
12 int num_points,
int bilin,
struct line_cats *categories,
19 double interpolation, csi, eta, weight;
26 for (i = 0; i < num_points; i++) {
34 obs[i][0], obs[i][1], pe, pn, nsplx, nsply,
35 Elaboration->
west, Elaboration->
south, param);
38 obs[i][0], obs[i][1], pe, pn, nsplx, nsply,
39 Elaboration->
west, Elaboration->
south, param);
41 interpolation +=
mean;
52 sprintf(buf,
"INSERT INTO %s (ID, X, Y, Interp)", tab_name);
55 sprintf(buf,
" VALUES (");
57 sprintf(buf,
"%d, %f, %f, ", line_num[i], obs[i][0], obs[i][1]);
60 if ((*point->
x > Overlap.
E) && (*point->
x < General.
E)) {
61 if ((*point->
y > Overlap.
N) &&
62 (*point->
y < General.
N)) {
63 csi = (General.
E - *point->
x) / overlap;
64 eta = (General.
N - *point->
y) / overlap;
66 *point->
z = weight * interpolation;
68 sprintf(buf,
"%lf", *point->
z);
77 else if ((*point->
y < Overlap.
S) &&
78 (*point->
y > General.
S)) {
79 csi = (General.
E - *point->
x) / overlap;
80 eta = (*point->
y - General.
S) / overlap;
82 *point->
z = weight * interpolation;
84 sprintf(buf,
"%lf", *point->
z);
93 else if ((*point->
y <= Overlap.
N) &&
94 (*point->
y >= Overlap.
S)) {
95 weight = (General.
E - *point->
x) / overlap;
96 *point->
z = weight * interpolation;
98 sprintf(buf,
"%lf", *point->
z);
108 else if ((*point->
x < Overlap.
W) && (*point->
x > General.
W)) {
109 if ((*point->
y > Overlap.
N) &&
110 (*point->
y < General.
N)) {
111 csi = (*point->
x - General.
W) / overlap;
112 eta = (General.
N - *point->
y) / overlap;
114 *point->
z = weight * interpolation;
116 sprintf(buf,
"%lf", *point->
z);
125 else if ((*point->
y < Overlap.
S) &&
126 (*point->
y > General.
S)) {
127 csi = (*point->
x - General.
W) / overlap;
128 eta = (*point->
y - General.
S) / overlap;
130 *point->
z = weight * interpolation;
132 sprintf(buf,
"%lf", *point->
z);
141 else if ((*point->
y >= Overlap.
S) &&
142 (*point->
y <= Overlap.
N)) {
143 weight = (*point->
x - General.
W) / overlap;
144 *point->
z = weight * interpolation;
146 sprintf(buf,
"%lf", *point->
z);
156 else if ((*point->
x >= Overlap.
W) && (*point->
x <= Overlap.
E)) {
157 if ((*point->
y > Overlap.
N) &&
158 (*point->
y < General.
N)) {
159 weight = (General.
N - *point->
y) / overlap;
160 *point->
z = weight * interpolation;
162 sprintf(buf,
"%lf", *point->
z);
171 else if ((*point->
y < Overlap.
S) &&
172 (*point->
y > General.
S)) {
173 weight = (*point->
y - General.
S) / overlap;
174 *point->
z = (1 - weight) * interpolation;
176 sprintf(buf,
"%lf", *point->
z);
197 SEGMENT *out_seg,
double *param,
double passoN,
198 double passoE,
double overlap,
double mean,
int nsplx,
199 int nsply,
int nrows,
int ncols,
int bilin)
202 int col, row, startcol, endcol, startrow, endrow;
203 double X,
Y, interpolation, weight, csi, eta, dval;
206 if (Original->
north > General.
N)
207 startrow = (Original->
north - General.
N) / Original->
ns_res - 1;
211 endrow = (Original->
north - General.
S) / Original->
ns_res + 1;
217 if (General.
W > Original->
west)
218 startcol = (General.
W - Original->
west) / Original->
ew_res - 1;
221 if (General.
E > Original->
west) {
222 endcol = (General.
E - Original->
west) / Original->
ew_res + 1;
229 for (row = startrow; row < endrow; row++) {
230 for (col = startcol; col < endcol; col++) {
241 X,
Y, passoE, passoN, nsplx, nsply, Elaboration->
west,
242 Elaboration->
south, param);
245 X,
Y, passoE, passoN, nsplx, nsply, Elaboration->
west,
246 Elaboration->
south, param);
248 interpolation +=
mean;
252 dval = interpolation;
256 if ((
X > Overlap.
E) && (
X < General.
E)) {
257 if ((
Y > Overlap.
N) && (
Y < General.
N)) {
258 csi = (General.
E -
X) / overlap;
259 eta = (General.
N -
Y) / overlap;
261 interpolation *= weight;
262 dval += interpolation;
264 else if ((
Y < Overlap.
S) && (
Y > General.
S)) {
265 csi = (General.
E -
X) / overlap;
266 eta = (
Y - General.
S) / overlap;
268 interpolation *= weight;
269 dval = interpolation;
271 else if ((
Y >= Overlap.
S) &&
273 weight = (General.
E -
X) / overlap;
274 interpolation *= weight;
275 dval = interpolation;
278 else if ((
X < Overlap.
W) && (
X > General.
W)) {
279 if ((
Y > Overlap.
N) && (
Y < General.
N)) {
280 csi = (
X - General.
W) / overlap;
281 eta = (General.
N -
Y) / overlap;
283 interpolation *= weight;
284 dval += interpolation;
286 else if ((
Y < Overlap.
S) && (
Y > General.
S)) {
287 csi = (
X - General.
W) / overlap;
288 eta = (
Y - General.
S) / overlap;
290 interpolation *= weight;
291 dval += interpolation;
293 else if ((
Y >= Overlap.
S) &&
295 weight = (
X - General.
W) / overlap;
296 interpolation *= weight;
297 dval += interpolation;
300 else if ((
X >= Overlap.
W) && (
X <= Overlap.
E)) {
301 if ((
Y > Overlap.
N) && (
Y < General.
N)) {
302 weight = (General.
N -
Y) / overlap;
303 interpolation *= weight;
304 dval += interpolation;
306 else if ((
Y < Overlap.
S) && (
Y > General.
S)) {
307 weight = (
Y - General.
S) / overlap;
308 interpolation *= weight;
309 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)
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.