raster3d.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. #ifndef GRASS_RASTER3D_H
  2. #define GRASS_RASTER3D_H
  3. #include <grass/gis.h>
  4. #include <grass/raster.h>
  5. #define RASTER3D_TILE_SAME_AS_FILE 2
  6. #define RASTER3D_NO_COMPRESSION 0
  7. #define RASTER3D_COMPRESSION 1
  8. #define RASTER3D_USE_LZW 1
  9. #define RASTER3D_NO_LZW 0
  10. #define RASTER3D_USE_RLE 1
  11. #define RASTER3D_NO_RLE 0
  12. #define RASTER3D_MAX_PRECISION -1
  13. #define RASTER3D_NO_CACHE 0
  14. #define RASTER3D_USE_CACHE_DEFAULT -1
  15. #define RASTER3D_USE_CACHE_X -2
  16. #define RASTER3D_USE_CACHE_Y -3
  17. #define RASTER3D_USE_CACHE_Z -4
  18. #define RASTER3D_USE_CACHE_XY -5
  19. #define RASTER3D_USE_CACHE_XZ -6
  20. #define RASTER3D_USE_CACHE_YZ -7
  21. #define RASTER3D_USE_CACHE_XYZ -8
  22. #define RASTER3D_DEFAULT_WINDOW NULL
  23. #define RASTER3D_DIRECTORY "grid3"
  24. #define RASTER3D_CELL_ELEMENT "cell"
  25. #define RASTER3D_CATS_ELEMENT "cats"
  26. #define RASTER3D_RANGE_ELEMENT "range"
  27. #define RASTER3D_HEADER_ELEMENT "cellhd"
  28. #define RASTER3D_HISTORY_ELEMENT "hist"
  29. #define RASTER3D_COLOR_ELEMENT "color"
  30. #define RASTER3D_COLOR2_DIRECTORY "colr2"
  31. #define RASTER3D_MASK_MAP "RASTER3D_MASK"
  32. #define RASTER3D_WINDOW_ELEMENT "WIND3"
  33. #define RASTER3D_DEFAULT_WINDOW_ELEMENT "DEFAULT_WIND3"
  34. #define RASTER3D_WINDOW_DATABASE "windows3d"
  35. #define RASTER3D_PERMANENT_MAPSET "PERMANENT"
  36. /*---------------------------------------------------------------------------*/
  37. typedef struct
  38. {
  39. double north, south;
  40. double east, west;
  41. double top, bottom;
  42. /* dimension of data in "cells"; rows == #x; cols == #y; depths == #z */
  43. int rows, cols, depths;
  44. double ns_res, ew_res, tb_res;
  45. int proj; /* Projection (see gis.h) */
  46. int zone; /* Projection zone (see gis.h) */
  47. } RASTER3D_Region;
  48. /*---------------------------------------------------------------------------*/
  49. struct RASTER3D_Map;
  50. typedef void resample_fn(struct RASTER3D_Map *, int, int, int, void *, int);
  51. /*---------------------------------------------------------------------------*/
  52. typedef struct RASTER3D_Map
  53. {
  54. char *fileName;
  55. char *tempName;
  56. char *mapset;
  57. /* operation performed on map */
  58. int operation; /* RASTER3D_WRITE_DATA or RASTER3D_READ_DATA */
  59. /* region */
  60. RASTER3D_Region region;
  61. /* window for map */
  62. RASTER3D_Region window;
  63. /* resmapling function used for map. default is nearest neighbor */
  64. resample_fn *resampleFun;
  65. /* units */
  66. char* unit; /* space (U_METER, ...) */
  67. int vertical_unit; /* space or time (U_METER, ..., U_YEAR, ...) */
  68. /* dimension of a single tile in "cells" */
  69. int tileX, tileY, tileZ;
  70. /* # of tiles in x, y, and z direction */
  71. int nx, ny, nz;
  72. /* data file specific information */
  73. /* file descriptor */
  74. int data_fd; /* file descriptor */
  75. /* type in which data is stored on file */
  76. int type; /* DCELL_TYPE or FCELL_TYPE */
  77. /* data concering the compression */
  78. int precision; /* RASTER3D_MAX_PRECISION or, 0 .. 23 for float,
  79. 0 .. 52 for double */
  80. int compression; /* RASTER3D_NO_COMPRESSION or RASTER3D_USE_COMPRESSION */
  81. int useLzw; /* RASTER3D_USE_LZW or RASTER3D_NO_LZW */
  82. int useRle; /* RASTER3D_USE_RLE or RASTER3D_NO_RLE */
  83. int useXdr; /* RASTER3D_USE_XDR or RASTER3D_NO_XDR */
  84. /* pointer to first tile in file */
  85. int offset;
  86. /* pointer to the first index entry in file */
  87. long indexOffset;
  88. /* sizeof (long) of the system on which the file is/was written */
  89. int indexLongNbytes;
  90. /* max # bytes used in the representation of indices; this is equal to */
  91. /* # bytes used in the representation of "indexOffset" */
  92. int indexNbytesUsed;
  93. /* pointer to the last entry in the file */
  94. int fileEndPtr;
  95. /* indicates if index is stored in file; used for RASTER3D_READ_DATA only */
  96. int hasIndex; /* RASTER3D_HAS_INDEX or RASTER3D_NO_INDEX */
  97. /* information concerning internal storage of data */
  98. /* index specific information */
  99. /* index[i] == the offset of tile "i" in the data file */
  100. long *index;
  101. /* tileLength[i] == # bytes used to store tile "i" */
  102. int *tileLength;
  103. /* tile specific information */
  104. /* type in which data is stored in memory */
  105. int typeIntern; /* DCELL_TYPE or FCELL_TYPE */
  106. /* in non-cache mode the "data" array is used to store one tile */
  107. char *data;
  108. /* index of tile currently stored in "data"; -1 if none */
  109. int currentIndex;
  110. /* cache related variables */
  111. int useCache; /* 1 if cache is used */
  112. void *cache; /* pointer to cache structure */
  113. int cacheFD; /* file discriptor of cache file -- write mode only */
  114. char *cacheFileName; /* filename of cache file -- write mode only */
  115. long cachePosLast; /* position of last entry in cache file -- write */
  116. /* mode only */
  117. /* range info */
  118. struct FPRange range;
  119. /* some constants stored for efficiency */
  120. /* number of bytes required to store a single value of "type" */
  121. int numLengthExtern;
  122. /* number of bytes required to store a single value of "typeIntern" */
  123. int numLengthIntern;
  124. /* see header.c for details */
  125. int clipX, clipY, clipZ;
  126. int tileXY, tileSize;
  127. int nxy, nTiles;
  128. /* mask related information */
  129. int useMask; /* 1 if mask is used; 0 otherwise */
  130. } RASTER3D_Map;
  131. /*---------------------------------------------------------------------------*/
  132. typedef struct
  133. {
  134. char *elts; /* ptr to array of elts */
  135. int nofElts; /* size of "elts" */
  136. int eltSize; /* size of elt in "elts" */
  137. int *names; /* name[i] is the name of elts[i] */
  138. char *locks; /* lock[i] == 1 iff elts[i] is locked
  139. lock[i] == 0 iff elts[i] is unlocked but active
  140. lock[i] == 2 iff elts[i] doesn't contain valid data */
  141. int autoLock; /* 1 if auto locking is turned on */
  142. int nofUnlocked; /* nof tiles which are unlocked */
  143. int minUnlocked; /* min nof elts which have to remain unlocked. min = 1 */
  144. int *next, *prev; /* prev/next pointers for fifo */
  145. int first, last; /* index (into next) of first and last elt in fifo */
  146. /* first == -1 iff fifo is empty */
  147. int (*eltRemoveFun) (); /* callback activated if the contents of an
  148. elt needs to be removed */
  149. void *eltRemoveFunData; /* pointer to user data passed along with
  150. eltRemoveFun */
  151. int (*eltLoadFun) (); /* callback activated to load contents of an elt */
  152. void *eltLoadFunData; /* pointer to user data passed along with
  153. eltLoadFun */
  154. void *hash; /* ptr to hashTable used to relate external names to
  155. internal indices (elts) */
  156. } RASTER3D_cache;
  157. /*---------------------------------------------------------------------------*/
  158. typedef struct
  159. {
  160. int nofNames;
  161. int *index;
  162. char *active;
  163. int lastName;
  164. int lastIndex;
  165. int lastIndexActive;
  166. } Rast3d_cache_hash;
  167. /*---------------------------------------------------------------------------*/
  168. /*Structures */
  169. typedef struct _d_interval
  170. {
  171. double low, high;
  172. int inf;
  173. struct _d_interval *next;
  174. } d_Interval;
  175. typedef struct _d_mask
  176. {
  177. d_Interval *list;
  178. } d_Mask;
  179. /*---------------------------------------------------------------------------*/
  180. typedef int write_fn(int, const void *, void *);
  181. typedef int read_fn(int, void *, void *);
  182. /*---------------------------------------------------------------------------*/
  183. /*============================== Prototypes ================================*/
  184. #include <grass/defs/raster3d.h>
  185. #endif /* #ifndef GRASS_RASTER3D_H */