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