5 #include <grass/lidar.h> 11 double *param,
int *line_num,
double pe,
double pn,
12 double overlap,
int nsplx,
int nsply,
int num_points,
14 double mean,
char *tab_name)
20 double interpolation, csi, eta, weight;
27 for (i = 0; i < num_points; i++) {
34 nsply, Elaboration->
west,
35 Elaboration->
south, param);
39 nsplx, nsply, Elaboration->
west,
40 Elaboration->
south, param);
42 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],
61 if ((*point->
x > Overlap.
E) && (*point->
x < General.
E)) {
62 if ((*point->
y > Overlap.
N) && (*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) && (*point->
y > General.
S)) {
78 csi = (General.
E - *point->
x) / overlap;
79 eta = (*point->
y - General.
S) / overlap;
81 *point->
z = weight * interpolation;
83 sprintf(buf,
"%lf", *point->
z);
92 else if ((*point->
y <= Overlap.
N) && (*point->
y >= Overlap.
S)) {
93 weight = (General.
E - *point->
x) / overlap;
94 *point->
z = weight * interpolation;
96 sprintf(buf,
"%lf", *point->
z);
106 else if ((*point->
x < Overlap.
W) && (*point->
x > General.
W)) {
107 if ((*point->
y > Overlap.
N) && (*point->
y < General.
N)) {
108 csi = (*point->
x - General.
W) / overlap;
109 eta = (General.
N - *point->
y) / overlap;
111 *point->
z = weight * interpolation;
113 sprintf(buf,
"%lf", *point->
z);
122 else if ((*point->
y < Overlap.
S) && (*point->
y > General.
S)) {
123 csi = (*point->
x - General.
W) / overlap;
124 eta = (*point->
y - General.
S) / overlap;
126 *point->
z = weight * interpolation;
128 sprintf(buf,
"%lf", *point->
z);
137 else if ((*point->
y >= Overlap.
S) && (*point->
y <= Overlap.
N)) {
138 weight = (*point->
x - General.
W) / overlap;
139 *point->
z = weight * interpolation;
141 sprintf(buf,
"%lf", *point->
z);
151 else if ((*point->
x >= Overlap.
W) && (*point->
x <= Overlap.
E)){
152 if ((*point->
y > Overlap.
N) && (*point->
y < General.
N)) {
153 weight = (General.
N - *point->
y) / overlap;
154 *point->
z = weight * interpolation;
156 sprintf(buf,
"%lf", *point->
z);
165 else if ((*point->
y < Overlap.
S) && (*point->
y > General.
S)) {
166 weight = (*point->
y - General.
S) / overlap;
167 *point->
z = (1 - weight) * interpolation;
169 sprintf(buf,
"%lf", *point->
z);
192 SEGMENT *out_seg,
double *param,
193 double passoN,
double passoE,
double overlap,
194 double mean,
int nsplx,
int nsply,
195 int nrows,
int ncols,
int bilin)
198 int col, row, startcol, endcol, startrow, endrow;
199 double X,
Y, interpolation, weight, csi, eta, dval;
202 if (Original->
north > General.
N)
203 startrow = (Original->
north - General.
N) / Original->
ns_res - 1;
207 endrow = (Original->
north - General.
S) / Original->
ns_res + 1;
213 if (General.
W > Original->
west)
214 startcol = (General.
W - Original->
west) / Original->
ew_res - 1;
217 if (General.
E > Original->
west) {
218 endcol = (General.
E - Original->
west) / Original->
ew_res + 1;
225 for (row = startrow; row < endrow; row++) {
226 for (col = startcol; col < endcol; col++) {
236 nsply, Elaboration->
west,
237 Elaboration->
south, param);
241 nsply, Elaboration->
west,
242 Elaboration->
south, param);
244 interpolation +=
mean;
247 dval = interpolation;
251 if ((X > Overlap.
E) && (X < General.
E)) {
252 if ((Y > Overlap.
N) && (Y < General.
N)) {
253 csi = (General.
E -
X) / overlap;
254 eta = (General.
N -
Y) / overlap;
256 interpolation *= weight;
257 dval += interpolation;
259 else if ((Y < Overlap.
S) && (Y > General.
S)) {
260 csi = (General.
E -
X) / overlap;
261 eta = (Y - General.
S) / overlap;
263 interpolation *= weight;
264 dval = interpolation;
266 else if ((Y >= Overlap.
S) && (Y <= Overlap.
N)) {
267 weight = (General.
E -
X ) / overlap;
268 interpolation *= weight;
269 dval = interpolation;
272 else if ((X < Overlap.
W) && (X > General.
W)) {
273 if ((Y > Overlap.
N) && (Y < General.
N)) {
274 csi = (X - General.
W) / overlap;
275 eta = (General.
N -
Y) / overlap;
277 interpolation *= weight;
278 dval += interpolation;
280 else if ((Y < Overlap.
S) && (Y > General.
S)) {
281 csi = (X - General.
W) / overlap;
282 eta = (Y - General.
S) / overlap;
284 interpolation *= weight;
285 dval += interpolation;
287 else if ((Y >= Overlap.
S) && (Y <= Overlap.
N)) {
288 weight = (X - General.
W) / overlap;
289 interpolation *= weight;
290 dval += interpolation;
293 else if ((X >= Overlap.
W) && (X <= Overlap.
E)) {
294 if ((Y > Overlap.
N) && (Y < General.
N)) {
295 weight = (General.
N -
Y) / overlap;
296 interpolation *= weight;
297 dval += interpolation;
299 else if ((Y < Overlap.
S) && (Y > General.
S)) {
300 weight = (Y - General.
S) / overlap;
301 interpolation *= weight;
302 dval = interpolation;
int db_begin_transaction(dbDriver *)
Begin transaction.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
2D/3D raster map header (used also for region)
void db_init_string(dbString *)
Initialize dbString.
double dataInterpolateBilin(double x, double y, double deltaX, double deltaY, int xNum, int yNum, double xMin, double yMin, double *parVect)
double west
Extent coordinates (west)
int Vect_copy_xyz_to_pnts(struct line_pnts *, const double *, const double *, const double *, int)
Copy points from array to line_pnts structure.
int Segment_get(SEGMENT *, void *, off_t, off_t)
Get value from segment file.
#define GV_POINT
Feature types used in memory on run time (may change)
double * x
Array of X coordinates.
Feature geometry info - coordinates.
double north
Extent coordinates (north)
int db_append_string(dbString *, const char *)
Append string to dbString.
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
double south
Extent coordinates (south)
int db_execute_immediate(dbDriver *, dbString *)
Execute SQL statements.
int Segment_put(SEGMENT *, const void *, off_t, off_t)
off_t Vect_write_line(struct Map_info *, int, const struct line_pnts *, const struct line_cats *)
Writes a new feature.
double * y
Array of Y coordinates.
int Vect_point_in_box(double, double, double, const struct bound_box *)
Tests if point is in 3D box.
int db_commit_transaction(dbDriver *)
Commit transaction.
double Rast_col_to_easting(double, const struct Cell_head *)
Column to easting.
double ns_res
Resolution - north to south cell size for 2D data.
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)
double dataInterpolateBicubic(double x, double y, double deltaX, double deltaY, int xNum, int yNum, double xMin, double yMin, double *parVect)
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)
double * z
Array of Z coordinates.
float mean(IClass_statistics *statistics, int band)
Helper function for computing mean.
double ew_res
Resolution - east to west cell size for 2D data.
double Rast_row_to_northing(double, const struct Cell_head *)
Row to northing.