interpf.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. #include <grass/config.h>
  6. #include <stdio.h>
  7. #include <grass/gis.h>
  8. #include <grass/raster.h>
  9. #include <grass/vector.h>
  10. #include <grass/bitmap.h>
  11. #include <grass/dataquad.h>
  12. #include <grass/qtree.h>
  13. #include <grass/dbmi.h>
  14. /* for resample program */
  15. struct fcell_triple
  16. {
  17. double x;
  18. double y;
  19. FCELL z;
  20. double smooth;
  21. };
  22. #ifdef POINT2D_C
  23. struct line_pnts *Pnts;
  24. struct line_cats *Cats2;
  25. dbDriver *driver2;
  26. dbString sql2;
  27. struct Map_info Map2;
  28. struct field_info *ff;
  29. int count;
  30. #else
  31. extern struct line_pnts *Pnts;
  32. extern struct line_cats *Cats2;
  33. extern dbDriver *driver2;
  34. extern dbString sql2;
  35. extern struct Map_info Map2;
  36. extern struct field_info *ff;
  37. extern int count;
  38. #endif
  39. struct interp_params;
  40. typedef int grid_calc_fn(
  41. struct interp_params *, struct quaddata *, struct BM *,
  42. double, double, double *, double *, double *, double *,
  43. double *, double *, double *, double *, double *,
  44. double *, off_t, double);
  45. typedef int matrix_create_fn(
  46. struct interp_params *, struct triple *, int, double **, int *);
  47. typedef int check_points_fn(
  48. struct interp_params *, struct quaddata *, double *,
  49. double *, double, double, struct triple);
  50. typedef int secpar_fn(
  51. struct interp_params *, int, int, int, struct BM *,
  52. double *, double *, double *, double *, double *,
  53. double *, int, int);
  54. typedef double interp_fn(double, double);
  55. typedef int interpder_fn(double, double, double *, double *);
  56. typedef int wr_temp_fn(struct interp_params *, int, int, off_t);
  57. struct interp_params
  58. {
  59. double zmult; /**< multiplier for z-values */
  60. FILE *fdinp; /**< input stream */
  61. int elatt; /**< which floating point attr to use? first = 1, second = 2, etc */
  62. int smatt; /**< which floating point attr to use for smoothing? first = 1, second = 2, etc */
  63. int kmin; /**< min number of points per segment for interpolation */
  64. int kmax; /**< max number of points per segment */
  65. char *maskmap; /**< name of mask */
  66. int nsizr, nsizc; /**< number of rows and columns */
  67. DCELL *az, *adx, *ady,
  68. *adxx, *adyy, *adxy; /**< array for interpolated values */
  69. double fi; /**< tension */
  70. int KMAX2; /**< max num. of points for interp. */
  71. int scik1, scik2, scik3; /**< multipliers for interp. values */
  72. double rsm; /**< smoothing */
  73. char *elev, *slope, *aspect,
  74. *pcurv, *tcurv, *mcurv; /**< output files */
  75. double dmin; /**< min distance between points */
  76. double x_orig, y_orig; /**< origin */
  77. int deriv, cv; /**< 1 if compute partial derivs */
  78. double theta; /**< anisotropy angle, 0=East,counter-clockwise */
  79. double scalex; /**< anisotropy scaling factor */
  80. struct TimeStamp *ts; /**< timestamp for raster files */
  81. FILE *Tmp_fd_z, *Tmp_fd_dx,
  82. *Tmp_fd_dy, *Tmp_fd_xx,
  83. *Tmp_fd_yy, *Tmp_fd_xy; /**< temp files for writing interp. values */
  84. FILE *fddevi; /**< pointer to deviations file */
  85. grid_calc_fn *grid_calc; /**< calculates grid for given segm */
  86. matrix_create_fn *matrix_create; /**< creates matrix for a given segm */
  87. check_points_fn *check_points; /**< checks interp. func. at points */
  88. secpar_fn *secpar; /**< calculates aspect,slope,curv. */
  89. interp_fn *interp; /**< radial based interp. function */
  90. interpder_fn *interpder; /**< interp. func. for derivatives */
  91. wr_temp_fn *wr_temp; /**< writes temp files */
  92. const char *wheresql; /**< SQL statement to select input points */
  93. };
  94. /* distance.c */
  95. double IL_dist_square(double *, double *, int);
  96. /* func2d.c */
  97. double IL_crst(double, double);
  98. int IL_crstg(double, double, double *, double *);
  99. /* init2d.c */
  100. void IL_init_params_2d(struct interp_params *, FILE *, int, int, double,
  101. int, int, char *, int, int,
  102. DCELL *, DCELL *, DCELL *, DCELL *, DCELL *, DCELL *,
  103. double, int, int, int, int, double,
  104. char *, char *, char *, char *, char *, char *,
  105. double, double, double, int, double, double,
  106. FILE *, FILE *, FILE *, FILE *, FILE *, FILE *, FILE *,
  107. struct TimeStamp *, int, const char *);
  108. void IL_init_func_2d(struct interp_params *, grid_calc_fn *,
  109. matrix_create_fn *, check_points_fn *, secpar_fn *,
  110. interp_fn *, interpder_fn *, wr_temp_fn *);
  111. /* input2d.c */
  112. int IL_input_data_2d(struct interp_params *, struct tree_info *, double *,
  113. double *, double *, double *, double *, double *, int *);
  114. struct BM *IL_create_bitmask(struct interp_params *);
  115. int translate_quad(struct multtree *, double, double, double, int);
  116. /* interp2d.c */
  117. int IL_grid_calc_2d(struct interp_params *, struct quaddata *, struct BM *,
  118. double, double, double *, double *, double *, double *,
  119. double *, double *, double *, double *, double *,
  120. double *, off_t, double);
  121. /* matrix.c */
  122. int IL_matrix_create(struct interp_params *, struct triple *, int, double **,
  123. int *);
  124. int IL_matrix_create_alloc(struct interp_params *, struct triple *, int, double **,
  125. int *, double *);
  126. /* minmax.c */
  127. int min1(int, int);
  128. int max1(int, int);
  129. double amax1(double, double);
  130. double amin1(double, double);
  131. /* newsegm2d.c */
  132. int IL_interp_segments_new_2d(struct interp_params *, struct tree_info *,
  133. struct multtree *, struct BM *, double, double,
  134. double *, double *, double *, double *,
  135. double *, double *, double *, double *,
  136. double *, int, int, double);
  137. /* output2d.c */
  138. int IL_output_2d(struct interp_params *, struct Cell_head *, double, double,
  139. double, double, double, double, double, double, double,
  140. double, double, char *, double, int, int, int);
  141. /* point2d.c */
  142. int IL_check_at_points_2d(struct interp_params *, struct quaddata *, double *,
  143. double *, double, double, struct triple);
  144. /* resout2d.c */
  145. /* resout2dmod.c */
  146. int IL_resample_output_2d(struct interp_params *, double, double, double,
  147. double, double, double, double, double, double,
  148. double, double, char *, double *,
  149. struct Cell_head *, struct Cell_head *, char *,
  150. int);
  151. /* ressegm2d.c */
  152. int IL_resample_interp_segments_2d(struct interp_params *, struct BM *,
  153. double, double, double *, double *,
  154. double *, double *, double *, double *,
  155. double *, double *, double *, off_t,
  156. double *, int, int, int, int, int, double,
  157. double, double, double, int);
  158. /* secpar2d.c */
  159. int IL_secpar_loop_2d(struct interp_params *, int, int, int, struct BM *,
  160. double *, double *, double *, double *, double *,
  161. double *, int, int);
  162. /* segmen2d.c */
  163. double smallest_segment(struct multtree *, int);
  164. int IL_interp_segments_2d(struct interp_params *, struct tree_info *,
  165. struct multtree *, struct BM *, double, double,
  166. double *, double *, double *, double *, double *,
  167. double *, double *, double *, double *, int, off_t,
  168. double);
  169. /* segmen2d_parallel.c */
  170. int IL_interp_segments_2d_parallel(struct interp_params *, struct tree_info *,
  171. struct multtree *, struct BM *, double, double,
  172. double *, double *, double *, double *, double *,
  173. double *, double *, double *, double *, int, off_t,
  174. double, int);
  175. /* vinput2d.c */
  176. int IL_vector_input_data_2d(struct interp_params *, struct Map_info *, int,
  177. char *, char *, struct tree_info *, double *,
  178. double *, double *, double *, double *, double *,
  179. int *, double *);
  180. int process_point(double, double, double, double, struct tree_info *, double,
  181. double *, double *, double *, double *, double *, double *,
  182. int *, int *, int *);
  183. /* write2d.c */
  184. int IL_write_temp_2d(struct interp_params *, int, int, off_t);