raster.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. #ifndef GRASS_RASTER_H
  2. #define GRASS_RASTER_H
  3. #include <grass/gis.h>
  4. /*** defines ***/
  5. #define RECLASS_TABLE 1
  6. #define RECLASS_RULES 2
  7. #define RECLASS_SCALE 3
  8. #define CELL_TYPE 0
  9. #define FCELL_TYPE 1
  10. #define DCELL_TYPE 2
  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 RASTER_MAP_TYPE;
  18. /* for G_get_raster_sample() */
  19. typedef int INTERP_TYPE;
  20. /*** structures ***/
  21. struct Reclass
  22. {
  23. char *name; /* name of raster map being reclassed */
  24. char *mapset; /* mapset in which "name" is found */
  25. int type; /* type of reclass */
  26. int num; /* size of reclass table */
  27. CELL min; /* table min */
  28. CELL max; /* table max */
  29. CELL *table; /* reclass table */
  30. };
  31. struct FPReclass_table
  32. {
  33. DCELL dLow; /* domain low */
  34. DCELL dHigh; /* domain high */
  35. DCELL rLow; /* range low */
  36. DCELL rHigh; /* range high */
  37. };
  38. /* reclass structure from double to double used by r.recode to reclass */
  39. /* between types: int to double, float to int,... */
  40. struct FPReclass
  41. {
  42. int defaultDRuleSet; /* 1 if default domain rule set */
  43. int defaultRRuleSet; /* 1 if default range rule set */
  44. int infiniteLeftSet; /* 1 if negative infinite interval rule exists */
  45. int infiniteRightSet; /* 1 if positive infinite interval rule exists */
  46. int rRangeSet; /* 1 if range range (i.e. interval) is set */
  47. int maxNofRules;
  48. int nofRules;
  49. DCELL defaultDMin; /* default domain minimum value */
  50. DCELL defaultDMax; /* default domain maximum value */
  51. DCELL defaultRMin; /* default range minimum value */
  52. DCELL defaultRMax; /* default range maximum value */
  53. DCELL infiniteDLeft; /* neg infinite rule */
  54. DCELL infiniteDRight; /* neg infinite rule */
  55. DCELL infiniteRLeft; /* pos infinite rule */
  56. DCELL infiniteRRight; /* pos infinite rule */
  57. DCELL dMin; /* minimum domain values in rules */
  58. DCELL dMax; /* maximum domain values in rules */
  59. DCELL rMin; /* minimum range values in rules */
  60. DCELL rMax; /* maximum range values in rules */
  61. struct FPReclass_table *table;
  62. };
  63. struct Quant_table
  64. {
  65. DCELL dLow;
  66. DCELL dHigh;
  67. CELL cLow;
  68. CELL cHigh;
  69. };
  70. struct Quant
  71. {
  72. int truncate_only;
  73. int round_only;
  74. int defaultDRuleSet;
  75. int defaultCRuleSet;
  76. int infiniteLeftSet;
  77. int infiniteRightSet;
  78. int cRangeSet;
  79. int maxNofRules;
  80. int nofRules;
  81. DCELL defaultDMin;
  82. DCELL defaultDMax;
  83. CELL defaultCMin;
  84. CELL defaultCMax;
  85. DCELL infiniteDLeft;
  86. DCELL infiniteDRight;
  87. CELL infiniteCLeft;
  88. CELL infiniteCRight;
  89. DCELL dMin;
  90. DCELL dMax;
  91. CELL cMin;
  92. CELL cMax;
  93. struct Quant_table *table;
  94. struct
  95. {
  96. DCELL *vals;
  97. /* pointers to quant rules corresponding to the intervals btwn vals */
  98. struct Quant_table **rules;
  99. int nalloc;
  100. int active;
  101. DCELL inf_dmin;
  102. DCELL inf_dmax;
  103. CELL inf_min;
  104. CELL inf_max;
  105. /* all values smaller than inf_dmin become inf_min */
  106. /* all values larger than inf_dmax become inf_max */
  107. /* inf_min and/or inf_max can be NULL if there are no inf rules */
  108. } fp_lookup;
  109. };
  110. struct Categories
  111. {
  112. CELL ncats; /* total number of categories */
  113. CELL num; /* the highest cell values. Only exists
  114. for backwards compatibility = (CELL)
  115. max_fp_values in quant rules */
  116. char *title; /* name of data layer */
  117. char *fmt; /* printf-like format to generate labels */
  118. float m1; /* Multiplication coefficient 1 */
  119. float a1; /* Addition coefficient 1 */
  120. float m2; /* Multiplication coefficient 2 */
  121. float a2; /* Addition coefficient 2 */
  122. struct Quant q; /* rules mapping cell values to index in
  123. list of labels */
  124. char **labels; /* array of labels of size num */
  125. int *marks; /* was the value with this label was used? */
  126. int nalloc;
  127. int last_marked_rule;
  128. /* NOTE: to get a rule corresponfing to cats.labels[i], use */
  129. /* G_get_ith_c/f/d_raster_cat (pcats, i, val1, val2) */
  130. /* it calls */
  131. /* G_quant_get_ith_rule(&cats->q, i, val1, val2, &index, &index); */
  132. /* and idex ==i, because rule is added at the same time as a */
  133. /* label, and quant rules are never reordered. Olga apr,95 */
  134. };
  135. /*! \brief Raster history info (metadata)
  136. See History structure for implementation issues.
  137. */
  138. enum History_field
  139. {
  140. /*! \brief Raster name */
  141. HIST_MAPID,
  142. /*! \brief Raster title */
  143. HIST_TITLE,
  144. /*! \brief Raster mapset */
  145. HIST_MAPSET,
  146. /*! \brief User who creater raster map */
  147. HIST_CREATOR,
  148. /*! \brief Map type (always "raster") */
  149. HIST_MAPTYPE,
  150. /*! \brief Description of original data source (two lines) */
  151. HIST_DATSRC_1,
  152. HIST_DATSRC_2,
  153. /*! \brief One-line data description */
  154. HIST_KEYWRD,
  155. /*! \brief Number of fields to be defined in History structure */
  156. HIST_NUM_FIELDS,
  157. };
  158. /*! \brief Raster history info (metadata) */
  159. struct History
  160. {
  161. /*! \brief Array of fields (see \ref History_field for details) */
  162. char *fields[HIST_NUM_FIELDS];
  163. /*! \brief Number of lines in lines array */
  164. int nlines;
  165. /*! \brief Lines array */
  166. char **lines;
  167. };
  168. struct Cell_stats
  169. {
  170. struct Cell_stats_node
  171. {
  172. int idx;
  173. long *count;
  174. int left;
  175. int right;
  176. } *node; /* tree of values */
  177. int tlen; /* allocated tree size */
  178. int N; /* number of actual nodes in tree */
  179. int curp;
  180. long null_data_count;
  181. int curoffset;
  182. };
  183. struct Histogram
  184. {
  185. int num;
  186. struct Histogram_list
  187. {
  188. CELL cat;
  189. long count;
  190. } *list;
  191. };
  192. struct Range
  193. {
  194. CELL min;
  195. CELL max;
  196. int first_time; /* whether or not range was updated */
  197. };
  198. struct FPRange
  199. {
  200. DCELL min;
  201. DCELL max;
  202. int first_time; /* whether or not range was updated */
  203. };
  204. struct FP_stats {
  205. int geometric;
  206. int geom_abs;
  207. int flip;
  208. int count;
  209. DCELL min, max;
  210. unsigned long *stats;
  211. unsigned long total;
  212. };
  213. struct GDAL_link;
  214. typedef struct
  215. {
  216. unsigned char r, g, b, a; /* red, green, blue, and alpha */
  217. } RGBA_Color;
  218. typedef RGBA_Color RGB_Color;
  219. /* RGBA_Color alpha presets */
  220. #define RGBA_COLOR_OPAQUE 255
  221. #define RGBA_COLOR_TRANSPARENT 0
  222. #define RGBA_COLOR_NONE 0
  223. /*** prototypes ***/
  224. #include <grass/defs/raster.h>
  225. #endif /* GRASS_RASTER_H */