local_proto.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. #ifndef __LOCAL_PROTO_H__
  2. #define __LOCAL_PROTO_H__
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <math.h>
  6. #include <grass/glocale.h>
  7. #include <grass/gis.h>
  8. #include <grass/raster.h>
  9. #ifdef MAIN
  10. #define GLOBAL
  11. #else
  12. #define GLOBAL extern
  13. #endif
  14. #ifndef PI2 /* PI/2 */
  15. #define PI2 (2*atan(1))
  16. #endif
  17. #ifndef PI4 /* PI/4 */
  18. #define PI4 (atan(1))
  19. #endif
  20. #ifndef PI
  21. #define PI (4*atan(1))
  22. #endif
  23. #ifndef M2PI /* 2*PI */
  24. #define M2PI (8*atan(1))
  25. #endif
  26. #ifndef GRADE
  27. #define GRADE (atan(1)/45)
  28. #endif
  29. #ifndef PI2PERCENT
  30. #define PI2PERCENT (50/atan(1))
  31. #endif
  32. #ifndef UNKNOWN
  33. #define UNKNOWN -1
  34. #endif
  35. #define DEGREE2RAD(a) ((a)/(180/PI))
  36. #define RAD2DEGREE(a) ((a)*(180/PI))
  37. #undef MIN
  38. #undef MAX
  39. #define MAX(a,b) ((a) > (b) ? (a) : (b))
  40. #define MIN(a,b) ((a) < (b) ? (a) : (b))
  41. typedef char *STRING;
  42. typedef struct
  43. {
  44. char elevname[150];
  45. RASTER_MAP_TYPE raster_type;
  46. FCELL **elev;
  47. int fd; /* file descriptor */
  48. } MAPS;
  49. typedef struct
  50. { /* struct is used both for interface and output */
  51. char *name;
  52. int required;
  53. char *description;
  54. char *gui;
  55. RASTER_MAP_TYPE out_data_type;
  56. int fd;
  57. void *buffer;
  58. } IO;
  59. typedef struct
  60. {
  61. char name[100];
  62. int fd;
  63. CELL *forms_buffer;
  64. } MULTI;
  65. typedef struct
  66. {
  67. int num_positives;
  68. int num_negatives;
  69. unsigned char positives;
  70. unsigned char negatives;
  71. int pattern[8];
  72. float elevation[8];
  73. double distance[8];
  74. double x[8], y[8]; /* cartesian coordinates of geomorphon */
  75. } PATTERN;
  76. typedef enum
  77. {
  78. ZERO, /* zero cats do not accept zero category */
  79. FL, /* flat */
  80. PK, /* peak, summit */
  81. RI, /* ridge */
  82. SH, /* shoulder */
  83. CV, /* convex slope */
  84. SL, /* slope */
  85. CN, /* concave slope */
  86. FS, /* footslope */
  87. VL, /* valley */
  88. PT, /* pit, depression */
  89. __, /* error */
  90. CNT /* counter */
  91. } FORMS;
  92. typedef struct
  93. {
  94. int cat;
  95. int r;
  96. int g;
  97. int b;
  98. char *label;
  99. } CATCOLORS;
  100. typedef struct
  101. {
  102. double cat;
  103. int r;
  104. int g;
  105. int b;
  106. char *label;
  107. } FCOLORS;
  108. /* variables */
  109. GLOBAL MAPS elevation;
  110. GLOBAL int nrows, ncols, row_radius_size, row_buffer_size;
  111. GLOBAL int search_cells, skip_cells, step_cells, start_cells;
  112. GLOBAL int num_of_steps;
  113. GLOBAL double search_distance, skip_distance, flat_distance;
  114. GLOBAL double start_distance, step_distance; /* multiresolution mode */
  115. GLOBAL double flat_threshold, flat_threshold_height;
  116. GLOBAL double H, V;
  117. GLOBAL struct Cell_head window;
  118. GLOBAL int cell_step;
  119. /* main */
  120. GLOBAL unsigned int global_ternary_codes[6562];
  121. /* memory */
  122. int open_map(MAPS * rast);
  123. int create_maps(void);
  124. int shift_buffers(int row);
  125. int get_cell(int col, float *buf_row, void *buf, RASTER_MAP_TYPE raster_type);
  126. int free_map(FCELL ** map, int n);
  127. int write_form_cat_colors(char *raster, CATCOLORS * ccolors);
  128. int write_contrast_colors(char *);
  129. /* geom */
  130. int calc_pattern(PATTERN * pattern, int row, int cur_row, int col);
  131. unsigned int ternary_rotate(unsigned int value);
  132. int determine_form(int num_plus, int num_minus);
  133. int determine_binary(int *pattern, int sign);
  134. int determine_ternary(int *pattern);
  135. int rotate(unsigned char binary);
  136. float intensity(float *elevation, int pattern_size);
  137. float exposition(float *elevation);
  138. float range(float *elevation);
  139. float variance(float *elevation, int n);
  140. int shape(PATTERN * pattern, int pattern_size, float *azimuth,
  141. float *elongation, float *width);
  142. float extends(PATTERN * pattern, int pattern_size);
  143. int radial2cartesian(PATTERN *);
  144. /* multires */
  145. int reset_multi_patterns(void);
  146. int calc_multi_patterns(int row, int cur_row, int col);
  147. int update_pattern(int k, int i,
  148. double zenith_height, double zenith_distance,
  149. double zenith_angle, double nadir_height,
  150. double nadir_distance, double nadir_angle);
  151. #endif