10 #include <grass/glocale.h>
11 #include <grass/interpf.h>
12 #include <grass/gmath.h>
14 static double smallest_segment(
struct multtree *,
int);
19 double zmin,
double zmax,
20 double *zminac,
double *zmaxac,
21 double *gmin,
double *gmax,
22 double *c1min,
double *c1max,
double *c2min,
double *c2max,
39 double xmn, xmx, ymn, ymx, distx, disty, distxp, distyp, temp1, temp2;
40 int i, npt, nptprev, MAXENC;
42 static int cursegm = 0;
43 static double *
b =
NULL;
44 static int *indx =
NULL;
45 static double **matrix =
NULL;
46 double ew_res, ns_res;
47 static int first_time = 1;
53 int m_skip, skip_index, j, k, segtest;
58 smseg = smallest_segment(info->
root, 4);
73 for (i = 0; i < 4; i++) {
75 bitmask, zmin, zmax, zminac, zmaxac, gmin,
76 gmax, c1min, c1max, c2min, c2max, ertot,
77 totsegm, offset1, dnorm);
98 pr = pow(2., (xmx - xmn) / smseg - 1.);
100 params->
kmin * (pr / (1 + params->
kmin * pr / params->
KMAX2));
105 xmx + distx, ymx + disty, 0, 0,
109 while ((npt < MINPTS) || (npt > params->
KMAX2)) {
111 G_warning(_(
"Taking too long to find points for interpolation - "
112 "please change the region to area where your points are. "
113 "Continuing calculations..."));
117 if (npt > params->
KMAX2)
124 distx = distxp - fabs(distx - temp1) * 0.5;
127 disty = distyp - fabs(disty - temp2) * 0.5;
137 disty = fabs(disty - temp1) * 0.5 + distyp;
138 distx = fabs(distx - temp2) * 0.5 + distxp;
146 data->
x_orig = xmn - distx;
147 data->
y_orig = ymn - disty;
148 data->
xmax = xmx + distx;
149 data->
ymax = ymx + disty;
205 for (i = 0; i < data->
n_points; i++) {
233 for (skip_index = 0; skip_index < m_skip; skip_index++) {
237 xx = point[skip_index].
x * dnorm + data->
x_orig +
239 yy = point[skip_index].
y * dnorm + data->
y_orig +
241 zz = point[skip_index].
z;
247 skip_point.
x = point[skip_index].
x;
248 skip_point.
y = point[skip_index].
y;
249 skip_point.
z = point[skip_index].
z;
250 for (k = 0; k < m_skip; k++) {
251 if (k != skip_index && params->
cv) {
266 else if (segtest == 1) {
273 for (i = 0; i < data->
n_points; i++)
278 params->
check_points(params, data, b, ertot, zmin, dnorm,
281 else if (segtest == 1) {
282 for (i = 0; i < data->
n_points - 1; i++)
286 params->
check_points(params, data, b, ertot, zmin, dnorm,
296 if (params->
grid_calc(params, data, bitmask,
297 zmin, zmax, zminac, zmaxac, gmin, gmax,
298 c1min, c1max, c2min, c2max, ertot, b,
305 if (totsegm < cursegm)
306 G_debug(1,
"%d %d", totsegm, cursegm);
322 static double smallest_segment(
struct multtree *tree,
int n_leafs)
324 static int first_time = 1;
326 static double minside;
334 for (ii = 0; ii < n_leafs; ii++) {
335 side = smallest_segment(tree->
leafs[ii], n_leafs);
def info
Display an informational message using g.message -i
void G_free(void *buf)
Free allocated memory.
double ** G_alloc_matrix(int rows, int cols)
Matrix memory allocation.
int IL_interp_segments_2d(struct interp_params *, struct tree_info *, struct multtree *, struct BM *, double, double, double *, double *, double *, double *, double *, double *, double *, double *, double *, int, int, double)
int G_percent(long n, long d, int s)
Print percent complete messages.
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_lubksb(double **a, int n, int *indx, double b[])
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
int G_debug(int level, const char *msg,...)
Print debugging message.
int MT_region_data(struct tree_info *info, struct multtree *tree, struct quaddata *data, int MAX, int n_leafs)
int * G_alloc_ivector(size_t n)
Vector matrix memory allocation.
double * G_alloc_vector(size_t n)
Vector matrix memory allocation.