raster.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. #ifndef GRASS_RASTER_H
  2. #define GRASS_RASTER_H
  3. /*** defines ***/
  4. #define RECLASS_TABLE 1
  5. #define RECLASS_RULES 2
  6. #define RECLASS_SCALE 3
  7. #define CELL_TYPE 0
  8. #define FCELL_TYPE 1
  9. #define DCELL_TYPE 2
  10. /* History */
  11. #define RECORD_LEN 80
  12. #define MAXEDLINES 50
  13. /* for G_get_raster_sample(), INTERP_TYPE */
  14. #define UNKNOWN 0
  15. #define NEAREST 1 /* nearest neighbor interpolation */
  16. #define BILINEAR 2 /* bilinear interpolation */
  17. #define CUBIC 3 /* cubic interpolation */
  18. /*** typedefs ***/
  19. typedef int CELL;
  20. typedef double DCELL;
  21. typedef float FCELL;
  22. typedef int RASTER_MAP_TYPE;
  23. /* for G_get_raster_sample() */
  24. typedef int INTERP_TYPE;
  25. /*** structures ***/
  26. struct Reclass
  27. {
  28. char *name; /* name of raster map being reclassed */
  29. char *mapset; /* mapset in which "name" is found */
  30. int type; /* type of reclass */
  31. int num; /* size of reclass table */
  32. CELL min; /* table min */
  33. CELL max; /* table max */
  34. CELL *table; /* reclass table */
  35. };
  36. struct FPReclass_table
  37. {
  38. DCELL dLow; /* domain low */
  39. DCELL dHigh; /* domain high */
  40. DCELL rLow; /* range low */
  41. DCELL rHigh; /* range high */
  42. };
  43. /* reclass structure from double to double used by r.recode to reclass */
  44. /* between types: int to double, float to int,... */
  45. struct FPReclass
  46. {
  47. int defaultDRuleSet; /* 1 if default domain rule set */
  48. int defaultRRuleSet; /* 1 if default range rule set */
  49. int infiniteLeftSet; /* 1 if negative infinite interval rule exists */
  50. int infiniteRightSet; /* 1 if positive infinite interval rule exists */
  51. int rRangeSet; /* 1 if range range (i.e. interval) is set */
  52. int maxNofRules;
  53. int nofRules;
  54. DCELL defaultDMin; /* default domain minimum value */
  55. DCELL defaultDMax; /* default domain maximum value */
  56. DCELL defaultRMin; /* default range minimum value */
  57. DCELL defaultRMax; /* default range maximum value */
  58. DCELL infiniteDLeft; /* neg infinite rule */
  59. DCELL infiniteDRight; /* neg infinite rule */
  60. DCELL infiniteRLeft; /* pos infinite rule */
  61. DCELL infiniteRRight; /* pos infinite rule */
  62. DCELL dMin; /* minimum domain values in rules */
  63. DCELL dMax; /* maximum domain values in rules */
  64. DCELL rMin; /* minimum range values in rules */
  65. DCELL rMax; /* maximum range values in rules */
  66. struct FPReclass_table *table;
  67. };
  68. struct Quant_table
  69. {
  70. DCELL dLow;
  71. DCELL dHigh;
  72. CELL cLow;
  73. CELL cHigh;
  74. };
  75. struct Quant
  76. {
  77. int truncate_only;
  78. int round_only;
  79. int defaultDRuleSet;
  80. int defaultCRuleSet;
  81. int infiniteLeftSet;
  82. int infiniteRightSet;
  83. int cRangeSet;
  84. int maxNofRules;
  85. int nofRules;
  86. DCELL defaultDMin;
  87. DCELL defaultDMax;
  88. CELL defaultCMin;
  89. CELL defaultCMax;
  90. DCELL infiniteDLeft;
  91. DCELL infiniteDRight;
  92. CELL infiniteCLeft;
  93. CELL infiniteCRight;
  94. DCELL dMin;
  95. DCELL dMax;
  96. CELL cMin;
  97. CELL cMax;
  98. struct Quant_table *table;
  99. struct
  100. {
  101. DCELL *vals;
  102. /* pointers to quant rules corresponding to the intervals btwn vals */
  103. struct Quant_table **rules;
  104. int nalloc;
  105. int active;
  106. DCELL inf_dmin;
  107. DCELL inf_dmax;
  108. CELL inf_min;
  109. CELL inf_max;
  110. /* all values smaller than inf_dmin become inf_min */
  111. /* all values larger than inf_dmax become inf_max */
  112. /* inf_min and/or inf_max can be NULL if there are no inf rules */
  113. } fp_lookup;
  114. };
  115. struct Categories
  116. {
  117. CELL ncats; /* total number of categories */
  118. CELL num; /* the highest cell values. Only exists
  119. for backwards compatibility = (CELL)
  120. max_fp_values in quant rules */
  121. char *title; /* name of data layer */
  122. char *fmt; /* printf-like format to generate labels */
  123. float m1; /* Multiplication coefficient 1 */
  124. float a1; /* Addition coefficient 1 */
  125. float m2; /* Multiplication coefficient 2 */
  126. float a2; /* Addition coefficient 2 */
  127. struct Quant q; /* rules mapping cell values to index in
  128. list of labels */
  129. char **labels; /* array of labels of size num */
  130. int *marks; /* was the value with this label was used? */
  131. int nalloc;
  132. int last_marked_rule;
  133. /* NOTE: to get a rule corresponfing to cats.labels[i], use */
  134. /* G_get_ith_c/f/d_raster_cat (pcats, i, val1, val2) */
  135. /* it calls */
  136. /* G_quant_get_ith_rule(&cats->q, i, val1, val2, &index, &index); */
  137. /* and idex ==i, because rule is added at the same time as a */
  138. /* label, and quant rules are never reordered. Olga apr,95 */
  139. };
  140. struct History
  141. {
  142. char mapid[RECORD_LEN];
  143. char title[RECORD_LEN];
  144. char mapset[RECORD_LEN];
  145. char creator[RECORD_LEN];
  146. char maptype[RECORD_LEN];
  147. char datsrc_1[RECORD_LEN];
  148. char datsrc_2[RECORD_LEN];
  149. char keywrd[RECORD_LEN];
  150. int edlinecnt;
  151. char edhist[MAXEDLINES][RECORD_LEN];
  152. };
  153. struct Cell_stats
  154. {
  155. struct Cell_stats_node
  156. {
  157. int idx;
  158. long *count;
  159. int left;
  160. int right;
  161. } *node; /* tree of values */
  162. int tlen; /* allocated tree size */
  163. int N; /* number of actual nodes in tree */
  164. int curp;
  165. long null_data_count;
  166. int curoffset;
  167. };
  168. struct Histogram
  169. {
  170. int num;
  171. struct Histogram_list
  172. {
  173. CELL cat;
  174. long count;
  175. } *list;
  176. };
  177. struct Range
  178. {
  179. CELL min;
  180. CELL max;
  181. int first_time; /* whether or not range was updated */
  182. };
  183. struct FPRange
  184. {
  185. DCELL min;
  186. DCELL max;
  187. int first_time; /* whether or not range was updated */
  188. };
  189. struct FP_stats {
  190. int geometric;
  191. int geom_abs;
  192. int flip;
  193. int count;
  194. DCELL min, max;
  195. unsigned long *stats;
  196. unsigned long total;
  197. };
  198. struct GDAL_link;
  199. struct _Color_Value_
  200. {
  201. DCELL value;
  202. unsigned char red;
  203. unsigned char grn;
  204. unsigned char blu;
  205. };
  206. struct _Color_Rule_
  207. {
  208. struct _Color_Value_ low, high;
  209. struct _Color_Rule_ *next;
  210. struct _Color_Rule_ *prev;
  211. };
  212. struct _Color_Info_
  213. {
  214. struct _Color_Rule_ *rules;
  215. int n_rules;
  216. struct
  217. {
  218. unsigned char *red;
  219. unsigned char *grn;
  220. unsigned char *blu;
  221. unsigned char *set;
  222. int nalloc;
  223. int active;
  224. } lookup;
  225. struct
  226. {
  227. DCELL *vals;
  228. /* pointers to color rules corresponding to the intervals btwn vals */
  229. struct _Color_Rule_ **rules;
  230. int nalloc;
  231. int active;
  232. } fp_lookup;
  233. DCELL min, max;
  234. };
  235. struct Colors
  236. {
  237. int version; /* set by read_colors: -1=old,1=new */
  238. DCELL shift;
  239. int invert;
  240. int is_float; /* defined on floating point raster data? */
  241. int null_set; /* the colors for null are set? */
  242. unsigned char null_red;
  243. unsigned char null_grn;
  244. unsigned char null_blu;
  245. int undef_set; /* the colors for cells not in range are set? */
  246. unsigned char undef_red;
  247. unsigned char undef_grn;
  248. unsigned char undef_blu;
  249. struct _Color_Info_ fixed;
  250. struct _Color_Info_ modular;
  251. DCELL cmin;
  252. DCELL cmax;
  253. int organizing;
  254. };
  255. typedef struct
  256. {
  257. unsigned char r, g, b, a; /* red, green, blue, and alpha */
  258. } RGBA_Color;
  259. typedef RGBA_Color RGB_Color;
  260. /* RGBA_Color alpha presets */
  261. #define RGBA_COLOR_OPAQUE 255
  262. #define RGBA_COLOR_TRANSPARENT 0
  263. #define RGBA_COLOR_NONE 0
  264. /*** prototypes ***/
  265. #include <grass/rasterdefs.h>
  266. #endif /* GRASS_RASTER_H */