GRASS GIS 8 Programmer's Manual  8.4.0dev(2024)-835afb4352
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 use? first = 1, second = 2, etc
72  */
73 
74  int smatt; /**< which floating point attr to use for smoothing? first = 1,
75  second = 2, etc */
76 
77  int kmin; /**< min number of points per segment for interpolation */
78 
79  int kmax; /**< max number of points per segment */
80 
81  char *maskmap; /**< name of mask */
82 
83  int nsizr, nsizc; /**< number of rows and columns */
84 
85  DCELL *az, *adx, *ady, *adxx, *adyy, *adxy;
86  /**< array for interpolated values */
87 
88  double fi; /**< tension */
89 
90  int KMAX2; /**< max num. of points for interp. */
91 
92  int scik1, scik2, scik3; /**< multipliers for interp. values */
93 
94  double rsm; /**< smoothing */
95 
96  char *elev, *slope, *aspect, *pcurv, *tcurv, *mcurv;
97  /**< output files */
98 
99  double dmin; /**< min distance between points */
100 
101  double x_orig, y_orig; /**< origin */
102 
103  int deriv, cv; /**< 1 if compute partial derivs */
104 
105  double theta; /**< anisotropy angle, 0=East,counter-clockwise */
106 
107  double scalex; /**< anisotropy scaling factor */
108 
109  struct TimeStamp *ts; /**< timestamp for raster files */
110 
112  /**< temp files for writing interp. values */
113 
114  bool create_devi; /**< create deviations file? */
115 
116  grid_calc_fn *grid_calc; /**< calculates grid for given segm */
117 
118  matrix_create_fn *matrix_create; /**< creates matrix for a given segm */
119 
120  check_points_fn *check_points; /**< checks interp. func. at points */
121 
122  secpar_fn *secpar; /**< calculates aspect,slope,curv. */
123 
124  interp_fn *interp; /**< radial based interp. function */
125 
126  interpder_fn *interpder; /**< interp. func. for derivatives */
127 
128  wr_temp_fn *wr_temp; /**< writes temp files */
129 
130  const char *wheresql; /**< SQL statement to select input points */
131 };
132 
133 /* distance.c */
134 double IL_dist_square(double *, double *, int);
135 
136 /* func2d.c */
137 double IL_crst(double, double);
138 int IL_crstg(double, double, double *, double *);
139 
140 /* init2d.c */
141 void IL_init_params_2d(struct interp_params *, FILE *, int, int, double, int,
142  int, char *, int, int, DCELL *, DCELL *, DCELL *,
143  DCELL *, DCELL *, DCELL *, double, int, int, int, int,
144  double, char *, char *, char *, char *, char *, char *,
145  double, double, double, int, double, double, FILE *,
146  FILE *, FILE *, FILE *, FILE *, FILE *, bool,
147  struct TimeStamp *, int, const char *);
148 
151  interpder_fn *, wr_temp_fn *);
152 /* input2d.c */
153 int IL_input_data_2d(struct interp_params *, struct tree_info *, double *,
154  double *, double *, double *, double *, double *, int *);
155 struct BM *IL_create_bitmask(struct interp_params *);
156 int translate_quad(struct multtree *, double, double, double, int);
157 
158 /* interp2d.c */
159 int IL_grid_calc_2d(struct interp_params *, struct quaddata *, struct BM *,
160  double, double, double *, double *, double *, double *,
161  double *, double *, double *, double *, double *, double *,
162  off_t, double);
163 /* matrix.c */
164 int IL_matrix_create(struct interp_params *, struct triple *, int, double **,
165  int *);
166 int IL_matrix_create_alloc(struct interp_params *, struct triple *, int,
167  double **, int *, double *);
168 /* minmax.c */
169 int min1(int, int);
170 int max1(int, int);
171 double amax1(double, double);
172 double amin1(double, double);
173 
174 /* newsegm2d.c */
176  struct multtree *, struct BM *, double, double,
177  double *, double *, double *, double *, double *,
178  double *, double *, double *, double *, int, int,
179  double);
180 /* output2d.c */
181 int IL_output_2d(struct interp_params *, struct Cell_head *, double, double,
182  double, double, double, double, double, double, double, double,
183  double, char *, double, int, int, int);
184 /* point2d.c */
185 int IL_check_at_points_2d(struct interp_params *, struct quaddata *, double *,
186  double *, double, double, struct triple);
187 /* resout2d.c */
188 /* resout2dmod.c */
189 int IL_resample_output_2d(struct interp_params *, double, double, double,
190  double, double, double, double, double, double,
191  double, double, char *, double *, struct Cell_head *,
192  struct Cell_head *, char *, int);
193 /* ressegm2d.c */
194 int IL_resample_interp_segments_2d(struct interp_params *, struct BM *, double,
195  double, double *, double *, double *,
196  double *, double *, double *, double *,
197  double *, double *, off_t, double *, int,
198  int, int, int, int, double, double, double,
199  double, int);
200 /* secpar2d.c */
201 int IL_secpar_loop_2d(struct interp_params *, int, int, int, struct BM *,
202  double *, double *, double *, double *, double *,
203  double *, int, int);
204 /* segmen2d.c */
205 double smallest_segment(struct multtree *, int);
206 int IL_interp_segments_2d(struct interp_params *, struct tree_info *,
207  struct multtree *, struct BM *, double, double,
208  double *, double *, double *, double *, double *,
209  double *, double *, double *, double *, int, off_t,
210  double);
211 /* segmen2d_parallel.c */
213  struct multtree *, struct BM *, double,
214  double, double *, double *, double *,
215  double *, double *, double *, double *,
216  double *, double *, int, off_t, double, int);
217 /* vinput2d.c */
218 int IL_vector_input_data_2d(struct interp_params *, struct Map_info *, int,
219  char *, char *, struct tree_info *, double *,
220  double *, double *, double *, double *, double *,
221  int *, double *);
222 int process_point(double, double, double, double, struct tree_info *, double,
223  double *, double *, double *, double *, double *, double *,
224  int *, int *, int *);
225 /* write2d.c */
226 int IL_write_temp_2d(struct interp_params *, int, int, off_t);
float FCELL
Definition: gis.h:627
double DCELL
Definition: gis.h:626
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 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 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
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_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
int IL_check_at_points_2d(struct interp_params *, struct quaddata *, double *, double *, double, double, struct triple)
Definition: point2d.c:52
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 check_points_fn(struct interp_params *, struct quaddata *, double *, double *, double, double, struct triple)
Definition: interpf.h:52
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:437
Vector map info.
Definition: dig_structs.h:1243
Definition: gis.h:611
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:120
double zmult
Definition: interpf.h:67
FILE * Tmp_fd_xx
Definition: interpf.h:111
FILE * Tmp_fd_xy
Definition: interpf.h:111
DCELL * az
Definition: interpf.h:85
char * pcurv
Definition: interpf.h:96
interp_fn * interp
Definition: interpf.h:124
secpar_fn * secpar
Definition: interpf.h:122
FILE * fdinp
Definition: interpf.h:69
const char * wheresql
Definition: interpf.h:130
FILE * Tmp_fd_yy
Definition: interpf.h:111
grid_calc_fn * grid_calc
Definition: interpf.h:116
double fi
Definition: interpf.h:88
double x_orig
Definition: interpf.h:101
double theta
Definition: interpf.h:105
char * maskmap
Definition: interpf.h:81
DCELL * adxy
Definition: interpf.h:85
double rsm
Definition: interpf.h:94
FILE * Tmp_fd_dx
Definition: interpf.h:111
DCELL * adyy
Definition: interpf.h:85
DCELL * adx
Definition: interpf.h:85
double y_orig
Definition: interpf.h:101
FILE * Tmp_fd_z
Definition: interpf.h:111
DCELL * ady
Definition: interpf.h:85
double dmin
Definition: interpf.h:99
char * tcurv
Definition: interpf.h:96
double scalex
Definition: interpf.h:107
struct TimeStamp * ts
Definition: interpf.h:109
char * mcurv
Definition: interpf.h:96
FILE * Tmp_fd_dy
Definition: interpf.h:111
wr_temp_fn * wr_temp
Definition: interpf.h:128
char * aspect
Definition: interpf.h:96
char * elev
Definition: interpf.h:96
char * slope
Definition: interpf.h:96
interpder_fn * interpder
Definition: interpf.h:126
DCELL * adxx
Definition: interpf.h:85
bool create_devi
Definition: interpf.h:114
matrix_create_fn * matrix_create
Definition: interpf.h:118
Feature category info.
Definition: dig_structs.h:1677
Feature geometry info - coordinates.
Definition: dig_structs.h:1651
Definition: qtree.h:52