22 #include <grass/interpf.h>
51 double zmin,
double zmax,
52 double *zminac,
double *zmaxac,
53 double *gmin,
double *gmax,
54 double *c1min,
double *c1max,
55 double *c2min,
double *c2max,
61 double xmn, xmx, ymn, ymx, distx, disty, distxp, distyp, temp1, temp2;
64 static int cursegm = 0;
65 static double *
b =
NULL;
66 static int *indx =
NULL;
67 static double **matrix =
NULL;
68 double ew_res, ns_res;
69 static int first_time = 1;
75 int m_skip, skip_index, j, k, segtest;
95 for (i = 0; i < 4; i++) {
97 zmax, zminac, zmaxac, gmin, gmax, c1min,
98 c1max, c2min, c2max, ertot, totsegm, offset1,
120 pr = pow(2., (xmx - xmn) / smseg - 1.);
121 MINPTS = params->
kmin * (pr / (1 + params->
kmin * pr / params->
KMAX2));
126 xmx + distx, ymx + disty, 0, 0,
130 while ((npt < MINPTS) || (npt > params->
KMAX2)) {
133 _(
"Taking too long to find points for interpolation - "
134 "please change the region to area where your points are. "
135 "Continuing calculations..."));
139 if (npt > params->
KMAX2)
145 distx = distxp - fabs(distx - temp1) * 0.5;
148 disty = distyp - fabs(disty - temp2) * 0.5;
157 disty = fabs(disty - temp1) * 0.5 + distyp;
158 distx = fabs(distx - temp2) * 0.5 + distxp;
166 data->
x_orig = xmn - distx;
167 data->
y_orig = ymn - disty;
168 data->
xmax = xmx + distx;
169 data->
ymax = ymx + disty;
222 for (i = 0; i < data->
n_points; i++) {
252 for (skip_index = 0; skip_index < m_skip; skip_index++) {
266 skip_point.
x = point[skip_index].
x;
267 skip_point.
y = point[skip_index].
y;
268 skip_point.
z = point[skip_index].
z;
269 for (k = 0; k < m_skip; k++) {
270 if (k != skip_index && params->
cv) {
284 else if (segtest == 1) {
286 data->
n_points - 1, matrix, indx) < 0)
290 for (i = 0; i < data->
n_points; i++)
298 else if (segtest == 1) {
299 for (i = 0; i < data->
n_points - 1; i++)
313 if (params->
grid_calc(params, data, bitmask, zmin, zmax, zminac,
314 zmaxac, gmin, gmax, c1min, c1max, c2min,
315 c2max, ertot,
b, offset1, dnorm) < 0)
321 if (totsegm < cursegm)
322 G_debug(1,
"%d %d", totsegm, cursegm);
340 static int first_time = 1;
342 static double minside;
350 for (ii = 0; ii < n_leafs; ii++) {
struct quaddata * quad_data_new(double x_or, double y_or, double xmax, double ymax, int rows, int cols, int n_points, int kmax)
void G_percent(long, long, int)
Print percent complete messages.
void G_free(void *)
Free allocated memory.
void G_warning(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
int * G_alloc_ivector(size_t)
Vector matrix memory allocation.
void G_lubksb(double **a, int n, int *indx, double b[])
LU backward substitution.
double * G_alloc_vector(size_t)
Vector matrix memory allocation.
double ** G_alloc_matrix(int, int)
Matrix memory allocation.
int MT_region_data(struct tree_info *info, struct multtree *tree, struct quaddata *data, int MAX, int n_leafs)
double smallest_segment(struct multtree *tree, int n_leafs)
int IL_interp_segments_2d(struct interp_params *params, struct tree_info *info, struct multtree *tree, struct BM *bitmask, double zmin, double zmax, double *zminac, double *zmaxac, double *gmin, double *gmax, double *c1min, double *c1max, double *c2min, double *c2max, double *ertot, int totsegm, off_t offset1, double dnorm)
check_points_fn * check_points
matrix_create_fn * matrix_create