GRASS GIS 8 Programmer's Manual  8.5.0dev(2025)-565e82de51
interpf.h
Go to the documentation of this file.
1 /*
2  * modified by Brown in June 1999 - added elatt & smatt
3  * modified by Mitasova Nov. 9, 1999 - added parameter for dtens to output2d
4  */
5 
6 #include <grass/config.h>
7 #include <stdio.h>
8 #include <grass/gis.h>
9 #include <grass/raster.h>
10 #include <grass/vector.h>
11 #include <grass/bitmap.h>
12 #include <grass/dataquad.h>
13 #include <grass/qtree.h>
14 #include <grass/dbmi.h>
15 #ifdef GRASS_CMAKE_BUILD
16 #include <export/grass_interpfl_export.h>
17 #else
18 #define GRASS_INTERPFL_EXPORT
19 #endif
20 
21 /* for resample program */
22 struct fcell_triple {
23  double x;
24  double y;
26  double smooth;
27 };
28 
29 #ifdef POINT2D_C
37 #else
38 GRASS_INTERPFL_EXPORT extern struct line_pnts *Pnts;
42 GRASS_INTERPFL_EXPORT extern struct Map_info Map2;
43 GRASS_INTERPFL_EXPORT extern struct field_info *ff;
44 GRASS_INTERPFL_EXPORT extern int count;
45 #endif
46 
47 struct interp_params;
48 
49 typedef int grid_calc_fn(struct interp_params *, struct quaddata *, struct BM *,
50  double, double, double *, double *, double *, double *,
51  double *, double *, double *, double *, double *,
52  double *, off_t, double);
53 
54 typedef int matrix_create_fn(struct interp_params *, struct triple *, int,
55  double **, int *);
56 
57 typedef int check_points_fn(struct interp_params *, struct quaddata *, double *,
58  double *, double, double, struct triple *);
59 
60 typedef int secpar_fn(struct interp_params *, int, int, int, struct BM *,
61  double *, double *, double *, double *, double *,
62  double *, int, int);
63 
64 typedef double interp_fn(double, double);
65 
66 typedef int interpder_fn(double, double, double *, double *);
67 
68 typedef int wr_temp_fn(struct interp_params *, int, int, off_t);
69 
70 struct interp_params {
71 
72  double zmult; /**< multiplier for z-values */
73 
74  FILE *fdinp; /**< input stream */
75 
76  int elatt; /**< which floating point attr to
77  * use? first = 1, second = 2, etc
78  */
79 
80  int smatt; /**< which floating point attr to use
81  for smoothing? first = 1, second =
82  2, etc */
83 
84  int kmin; /**< min number of points per segment
85  for interpolation */
86 
87  int kmax; /**< max number of points per segment
88  */
89 
90  char *maskmap; /**< name of mask */
91 
92  int nsizr, nsizc; /**< number of rows and columns */
93 
94  DCELL *az, *adx, *ady, *adxx, *adyy, *adxy;
95  /**< array for interpolated values */
96 
97  double fi; /**< tension */
98 
99  int KMAX2; /**< max num. of points for interp.
100  */
101 
102  int scik1, scik2, scik3; /**< multipliers for
103  interp. values */
104 
105  double rsm; /**< smoothing */
106 
107  char *elev, *slope, *aspect, *pcurv, *tcurv, *mcurv;
108  /**< output files */
109 
110  double dmin; /**< min distance between points */
111 
112  double x_orig, y_orig; /**< origin */
113 
114  int deriv, cv; /**< 1 if compute partial derivs */
115 
116  double theta; /**< anisotropy angle,
117  0=East,counter-clockwise */
118 
119  double scalex; /**< anisotropy scaling factor */
120 
121  struct TimeStamp *ts; /**< timestamp for raster files */
122 
124  /**< temp files for writing interp. values */
125 
126  bool create_devi; /**< create deviations file? */
127 
128  grid_calc_fn *grid_calc; /**< calculates grid for given segm */
129 
130  matrix_create_fn *matrix_create; /**< creates matrix for a given segm */
131 
132  check_points_fn *check_points; /**< checks interp. func. at points */
133 
134  secpar_fn *secpar; /**< calculates aspect,slope,curv. */
135 
136  interp_fn *interp; /**< radial based interp. function */
137 
138  interpder_fn *interpder; /**< interp. func. for derivatives */
139 
140  wr_temp_fn *wr_temp; /**< writes temp files */
141 
142  const char *wheresql; /**< SQL statement to select input points */
143 };
144 
145 /* distance.c */
146 double IL_dist_square(double *, double *, int);
147 
148 /* func2d.c */
149 double IL_crst(double, double);
150 int IL_crstg(double, double, double *, double *);
151 
152 /* init2d.c */
153 void IL_init_params_2d(struct interp_params *, FILE *, int, int, double, int,
154  int, char *, int, int, DCELL *, DCELL *, DCELL *,
155  DCELL *, DCELL *, DCELL *, double, int, int, int, int,
156  double, char *, char *, char *, char *, char *, char *,
157  double, double, double, int, double, double, FILE *,
158  FILE *, FILE *, FILE *, FILE *, FILE *, bool,
159  struct TimeStamp *, int, const char *);
160 
163  interpder_fn *, wr_temp_fn *);
164 
165 /* input2d.c */
166 int IL_input_data_2d(struct interp_params *, struct tree_info *, double *,
167  double *, double *, double *, double *, double *, int *);
168 struct BM *IL_create_bitmask(struct interp_params *);
169 int translate_quad(struct multtree *, double, double, double, int);
170 
171 /* interp2d.c */
172 int IL_grid_calc_2d(struct interp_params *, struct quaddata *, struct BM *,
173  double, double, double *, double *, double *, double *,
174  double *, double *, double *, double *, double *, double *,
175  off_t, double);
176 /* matrix.c */
177 int IL_matrix_create(struct interp_params *, struct triple *, int, double **,
178  int *);
179 int IL_matrix_create_alloc(struct interp_params *, struct triple *, int,
180  double **, int *, double *);
181 /* minmax.c */
182 int min1(int, int);
183 int max1(int, int);
184 double amax1(double, double);
185 double amin1(double, double);
186 
187 /* newsegm2d.c */
189  struct multtree *, struct BM *, double, double,
190  double *, double *, double *, double *, double *,
191  double *, double *, double *, double *, int, int,
192  double);
193 /* output2d.c */
194 int IL_output_2d(struct interp_params *, struct Cell_head *, double, double,
195  double, double, double, double, double, double, double, double,
196  double, char *, double, int, int, int);
197 /* point2d.c */
198 int IL_check_at_points_2d(struct interp_params *, struct quaddata *, double *,
199  double *, double, double, struct triple *);
200 int IL_write_point_2d(struct triple, double);
201 
202 /* point2d_parallel.c */
203 int IL_check_at_points_2d_cvdev(struct interp_params *, struct quaddata *,
204  double *, double *, double, double,
205  struct triple *);
206 
207 /* resout2d.c */
208 /* resout2dmod.c */
209 int IL_resample_output_2d(struct interp_params *, double, double, double,
210  double, double, double, double, double, double,
211  double, double, char *, double *, struct Cell_head *,
212  struct Cell_head *, char *, int);
213 /* ressegm2d.c */
214 int IL_resample_interp_segments_2d(struct interp_params *, struct BM *, double,
215  double, double *, double *, double *,
216  double *, double *, double *, double *,
217  double *, double *, off_t, double *, int,
218  int, int, int, int, double, double, double,
219  double, int);
220 /* secpar2d.c */
221 int IL_secpar_loop_2d(struct interp_params *, int, int, int, struct BM *,
222  double *, double *, double *, double *, double *,
223  double *, int, int);
224 /* segmen2d.c */
225 double smallest_segment(struct multtree *, int);
226 int IL_interp_segments_2d(struct interp_params *, struct tree_info *,
227  struct multtree *, struct BM *, double, double,
228  double *, double *, double *, double *, double *,
229  double *, double *, double *, double *, int, off_t,
230  double);
231 /* segmen2d_parallel.c */
233  struct multtree *, struct BM *, double,
234  double, double *, double *, double *,
235  double *, double *, double *, double *,
236  double *, double *, int, off_t, double, int);
237 /* vinput2d.c */
238 int IL_vector_input_data_2d(struct interp_params *, struct Map_info *, int,
239  char *, char *, struct tree_info *, double *,
240  double *, double *, double *, double *, double *,
241  int *, double *);
242 int process_point(double, double, double, double, struct tree_info *, double,
243  double *, double *, double *, double *, double *, double *,
244  int *, int *, int *);
245 /* write2d.c */
246 int IL_write_temp_2d(struct interp_params *, int, int, off_t);
float FCELL
Definition: gis.h:631
double DCELL
Definition: gis.h:630
GRASS_INTERPFL_EXPORT dbString sql2
double amin1(double, double)
Definition: minmax.c:65
int IL_grid_calc_2d(struct interp_params *, struct quaddata *, struct BM *, double, double, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, off_t, double)
GRASS_INTERPFL_EXPORT dbDriver * driver2
int IL_output_2d(struct interp_params *, struct Cell_head *, double, double, double, double, double, double, double, double, double, double, double, char *, double, int, int, int)
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, off_t, double)
Definition: segmen2d.c:46
int IL_resample_interp_segments_2d(struct interp_params *, struct BM *, double, double, double *, double *, double *, double *, double *, double *, double *, double *, double *, off_t, double *, int, int, int, int, int, double, double, double, double, int)
Definition: ressegm2d.c:33
double IL_crst(double, double)
Definition: func2d.c:46
double interp_fn(double, double)
Definition: interpf.h:64
double IL_dist_square(double *, double *, int)
int IL_interp_segments_2d_parallel(struct interp_params *, struct tree_info *, struct multtree *, struct BM *, double, double, double *, double *, double *, double *, double *, double *, double *, double *, double *, int, off_t, double, int)
GRASS_INTERPFL_EXPORT struct field_info * ff
struct BM * IL_create_bitmask(struct interp_params *)
Definition: input2d.c:37
int IL_check_at_points_2d_cvdev(struct interp_params *, struct quaddata *, double *, double *, double, double, struct triple *)
A parallel version of IL_check_at_points_2d. Sperate the cross-validation/deviation computing part an...
GRASS_INTERPFL_EXPORT struct line_pnts * Pnts
int interpder_fn(double, double, double *, double *)
Definition: interpf.h:66
int secpar_fn(struct interp_params *, int, int, int, struct BM *, double *, double *, double *, double *, double *, double *, int, int)
Definition: interpf.h:60
int IL_input_data_2d(struct interp_params *, struct tree_info *, double *, double *, double *, double *, double *, double *, int *)
int IL_write_point_2d(struct triple, double)
A function to write out point and deviation at point to database.
Definition: point2d.c:164
GRASS_INTERPFL_EXPORT int count
int wr_temp_fn(struct interp_params *, int, int, off_t)
Definition: interpf.h:68
GRASS_INTERPFL_EXPORT struct line_cats * Cats2
int max1(int, int)
Definition: minmax.c:30
int IL_vector_input_data_2d(struct interp_params *, struct Map_info *, int, char *, char *, struct tree_info *, double *, double *, double *, double *, double *, double *, int *, double *)
Definition: vinput2d.c:50
int check_points_fn(struct interp_params *, struct quaddata *, double *, double *, double, double, struct triple *)
Definition: interpf.h:57
void IL_init_func_2d(struct interp_params *, grid_calc_fn *, matrix_create_fn *, check_points_fn *, secpar_fn *, interp_fn *, interpder_fn *, wr_temp_fn *)
Definition: init2d.c:106
double amax1(double, double)
Definition: minmax.c:52
int min1(int, int)
Definition: minmax.c:17
int matrix_create_fn(struct interp_params *, struct triple *, int, double **, int *)
Definition: interpf.h:54
int translate_quad(struct multtree *, double, double, double, int)
Definition: input2d.c:90
int grid_calc_fn(struct interp_params *, struct quaddata *, struct BM *, double, double, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, off_t, double)
Definition: interpf.h:49
int IL_check_at_points_2d(struct interp_params *, struct quaddata *, double *, double *, double, double, struct triple *)
Definition: point2d.c:52
int IL_write_temp_2d(struct interp_params *, int, int, off_t)
Definition: write2d.c:34
int IL_secpar_loop_2d(struct interp_params *, int, int, int, struct BM *, double *, double *, double *, double *, double *, double *, int, int)
Definition: secpar2d.c:34
int IL_crstg(double, double, double *, double *)
Definition: func2d.c:106
int process_point(double, double, double, double, struct tree_info *, double, double *, double *, double *, double *, double *, double *, int *, int *, int *)
Definition: vinput2d.c:306
void IL_init_params_2d(struct interp_params *, FILE *, int, int, double, int, int, char *, int, int, DCELL *, DCELL *, DCELL *, DCELL *, DCELL *, DCELL *, double, int, int, int, int, double, char *, char *, char *, char *, char *, char *, double, double, double, int, double, double, FILE *, FILE *, FILE *, FILE *, FILE *, FILE *, bool, struct TimeStamp *, int, const char *)
Definition: init2d.c:29
int IL_matrix_create(struct interp_params *, struct triple *, int, double **, int *)
Definition: matrix.c:37
#define GRASS_INTERPFL_EXPORT
Definition: interpf.h:18
int IL_interp_segments_new_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 IL_matrix_create_alloc(struct interp_params *, struct triple *, int, double **, int *, double *)
Creates system of linear equations from interpolated points.
Definition: matrix.c:69
double smallest_segment(struct multtree *, int)
Definition: segmen2d.c:342
int IL_resample_output_2d(struct interp_params *, double, double, double, double, double, double, double, double, double, double, double, char *, double *, struct Cell_head *, struct Cell_head *, char *, int)
GRASS_INTERPFL_EXPORT struct Map_info Map2
Definition: bitmap.h:17
2D/3D raster map header (used also for region)
Definition: gis.h:441
Vector map info.
Definition: dig_structs.h:1243
Definition: gis.h:615
FCELL z
Definition: interpf.h:25
double x
Definition: interpf.h:23
double smooth
Definition: interpf.h:26
double y
Definition: interpf.h:24
Layer (old: field) information.
Definition: dig_structs.h:131
check_points_fn * check_points
Definition: interpf.h:132
double zmult
Definition: interpf.h:72
FILE * Tmp_fd_xx
Definition: interpf.h:123
FILE * Tmp_fd_xy
Definition: interpf.h:123
DCELL * az
Definition: interpf.h:94
char * pcurv
Definition: interpf.h:107
interp_fn * interp
Definition: interpf.h:136
secpar_fn * secpar
Definition: interpf.h:134
FILE * fdinp
Definition: interpf.h:74
const char * wheresql
Definition: interpf.h:142
FILE * Tmp_fd_yy
Definition: interpf.h:123
grid_calc_fn * grid_calc
Definition: interpf.h:128
double fi
Definition: interpf.h:97
double x_orig
Definition: interpf.h:112
double theta
Definition: interpf.h:116
char * maskmap
Definition: interpf.h:90
DCELL * adxy
Definition: interpf.h:94
double rsm
Definition: interpf.h:105
FILE * Tmp_fd_dx
Definition: interpf.h:123
DCELL * adyy
Definition: interpf.h:94
DCELL * adx
Definition: interpf.h:94
double y_orig
Definition: interpf.h:112
FILE * Tmp_fd_z
Definition: interpf.h:123
DCELL * ady
Definition: interpf.h:94
double dmin
Definition: interpf.h:110
char * tcurv
Definition: interpf.h:107
double scalex
Definition: interpf.h:119
struct TimeStamp * ts
Definition: interpf.h:121
char * mcurv
Definition: interpf.h:107
FILE * Tmp_fd_dy
Definition: interpf.h:123
wr_temp_fn * wr_temp
Definition: interpf.h:140
char * aspect
Definition: interpf.h:107
char * elev
Definition: interpf.h:107
char * slope
Definition: interpf.h:107
interpder_fn * interpder
Definition: interpf.h:138
DCELL * adxx
Definition: interpf.h:94
bool create_devi
Definition: interpf.h:126
matrix_create_fn * matrix_create
Definition: interpf.h:130
Feature category info.
Definition: dig_structs.h:1677
Feature geometry info - coordinates.
Definition: dig_structs.h:1651
Definition: qtree.h:52