patch.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. ************************************************************
  3. * MODULE: r.le.patch/patch.h *
  4. * Version 5.0 Nov. 1, 2001 *
  5. * *
  6. * AUTHOR: W.L. Baker, University of Wyoming *
  7. * BAKERWL@UWYO.EDU *
  8. * *
  9. * PURPOSE: To analyze attributes of patches in a landscape *
  10. * patch.h lists include files, defines the data *
  11. * structures, and lists the modules for r.le.patch *
  12. * *
  13. * COPYRIGHT: (C) 2001 by W.L. Baker *
  14. * *
  15. * This program is free software under the GNU General *
  16. * Public License(>=v2). Read the file COPYING that comes *
  17. * with GRASS for details *
  18. * *
  19. ************************************************************/
  20. #ifndef __PATCH_H__
  21. #define __PATCH_H__
  22. #include <grass/config.h>
  23. #include <stdio.h>
  24. #include <sys/types.h>
  25. #include <time.h>
  26. #include <setjmp.h>
  27. #include <math.h>
  28. #include <ctype.h>
  29. #include <stdlib.h>
  30. #include <string.h>
  31. #include <grass/gis.h>
  32. #define SML 0.5
  33. #define MIN 2
  34. #define EQ(a, b) (a-b < 0.01 && a-b > -0.01 )
  35. #define BIG 1000000000.0
  36. #define PI M_PI
  37. extern jmp_buf jmp;
  38. typedef struct __dirdesc
  39. {
  40. int dd_fd; /* file descriptor */
  41. long dd_loc; /* buf offset of entry from last readddir() */
  42. long dd_size; /* amount of valid data in buffer */
  43. long dd_bsize; /* amount of entries read at a time */
  44. long dd_off; /* Current offset in dir (for telldir) */
  45. char *dd_buf; /* directory data buffer */
  46. } DIR;
  47. extern DIR *opendir( /* char *dirname */ );
  48. extern struct dirent *readdir( /* DIR *dirp */ );
  49. extern int closedir( /* DIR *dirp */ );
  50. typedef struct pt
  51. {
  52. int row, col;
  53. struct pt *next;
  54. } PT;
  55. typedef struct patch
  56. {
  57. double att;
  58. int num, n, s, e, w, npts;
  59. double c_row, c_col;
  60. double area, perim, long_axis;
  61. double edge, core;
  62. int *row;
  63. int *col;
  64. int twist;
  65. float omega;
  66. struct patch *next;
  67. } PATCH;
  68. struct CHOICE
  69. {
  70. char fn[GNAME_MAX], reg[GMAPSET_MAX], out[GNAME_MAX], wrum;
  71. int core2, size2, shape2, edge, fb, coremap, units;
  72. int perim2, trace, patchmap;
  73. int Mx[4];
  74. int att[9], size[9], shape[8], boundary[5], perim[8], core[11];
  75. };
  76. typedef struct reglist
  77. {
  78. int att;
  79. int n, s, e, w;
  80. struct reglist *next;
  81. } REGLIST;
  82. /** main.c **/
  83. void user_input();
  84. /** driver.c **/
  85. void patch_fore();
  86. void open_files();
  87. void read_line();
  88. void read_recl_tb();
  89. void read_para();
  90. void get_para();
  91. void free_para();
  92. void mv_driver();
  93. void read_mwind();
  94. void set_colors();
  95. void get_para_mv();
  96. int need_gp();
  97. void whole_reg_driver();
  98. void unit_driver();
  99. void run_clip(int, int, int, int, int, int, CELL **, int, float);
  100. void meter();
  101. FILE *fopen0();
  102. FILE *fopen1();
  103. FILE *fopen2();
  104. /** trace.c **/
  105. void cell_clip_drv(int, int, int, int, double **, int, float);
  106. void cell_clip(DCELL **, DCELL **, int, int, int, int, int, float, int *,
  107. int *);
  108. int is_not_empty_buffer();
  109. int center_is_not_null();
  110. void trace();
  111. PATCH *get_bd();
  112. void clockwise();
  113. void counterclockwise();
  114. int yes_nb();
  115. /** patch.c **/
  116. void df_patch();
  117. void mv_patch();
  118. double eu_dist();
  119. double eu_d();
  120. int in_group();
  121. int check_order();
  122. int index_coh();
  123. int recl_coh();
  124. void m_att();
  125. void m_core();
  126. void m_size();
  127. void m_shape();
  128. void m_perim();
  129. void m_boundary();
  130. void df_att();
  131. void df_core();
  132. void df_size();
  133. void df_shape();
  134. void df_perim();
  135. void df_boundary();
  136. void save_att();
  137. void save_core();
  138. void save_size();
  139. void save_shape();
  140. void fit();
  141. #endif /* __PATCH_H__ */