9 struct bound_box General,
struct bound_box Overlap,
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,
13 dbDriver *
driver,
double mean,
char *tab_name)
19 double interpolation, csi, eta, weight;
20 struct line_pnts *point;
22 point = Vect_new_line_struct();
24 db_begin_transaction(
driver);
26 for (i = 0; i < num_points; i++) {
28 if (Vect_point_in_box(obs[i][0], obs[i][1], mean,
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;
42 Vect_copy_xyz_to_pnts(point, &obs[i][0], &obs[i][1], &interpolation,
45 if (Vect_point_in_box(obs[i][0], obs[i][1], interpolation,
47 Vect_write_line(Out, GV_POINT, point, categories);
52 sprintf(buf,
"INSERT INTO %s (ID, X, Y, Interp)", tab_name);
53 db_append_string(&sql, buf);
55 sprintf(buf,
" VALUES (");
56 db_append_string(&sql, buf);
57 sprintf(buf,
"%d, %f, %f, ", line_num[i], obs[i][0], obs[i][1]);
58 db_append_string(&sql, buf);
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);
69 db_append_string(&sql, buf);
71 db_append_string(&sql, buf);
73 if (db_execute_immediate(
driver, &sql) != DB_OK)
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);
85 db_append_string(&sql, buf);
87 db_append_string(&sql, buf);
89 if (db_execute_immediate(
driver, &sql) != DB_OK)
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);
99 db_append_string(&sql, buf);
101 db_append_string(&sql, buf);
103 if (db_execute_immediate(
driver, &sql) != DB_OK)
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);
117 db_append_string(&sql, buf);
119 db_append_string(&sql, buf);
121 if (db_execute_immediate(
driver, &sql) != DB_OK)
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);
133 db_append_string(&sql, buf);
135 db_append_string(&sql, buf);
137 if (db_execute_immediate(
driver, &sql) != DB_OK)
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);
147 db_append_string(&sql, buf);
149 db_append_string(&sql, buf);
151 if (db_execute_immediate(
driver, &sql) != DB_OK)
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);
163 db_append_string(&sql, buf);
165 db_append_string(&sql, buf);
167 if (db_execute_immediate(
driver, &sql) != DB_OK)
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);
177 db_append_string(&sql, buf);
179 db_append_string(&sql, buf);
181 if (db_execute_immediate(
driver, &sql) != DB_OK)
189 db_commit_transaction(
driver);
196 struct bound_box General,
struct bound_box Overlap,
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;
210 if (Original->north > General.S) {
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++) {
232 X = Rast_col_to_easting((
double)(col) + 0.5, Original);
233 Y = Rast_row_to_northing((
double)(row) + 0.5, Original);
235 if (Vect_point_in_box(
X,
Y, mean,
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;
250 if (Vect_point_in_box(
X,
Y, interpolation,
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;
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)