raster.h 7.3 KB

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