raster3d.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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;
  67. /* dimension of a single tile in "cells" */
  68. int tileX, tileY, tileZ;
  69. /* # of tiles in x, y, and z direction */
  70. int nx, ny, nz;
  71. /* data file specific information */
  72. /* file descriptor */
  73. int data_fd; /* file descriptor */
  74. /* type in which data is stored on file */
  75. int type; /* DCELL_TYPE or FCELL_TYPE */
  76. /* data concering the compression */
  77. int precision; /* RASTER3D_MAX_PRECISION or, 0 .. 23 for float,
  78. 0 .. 52 for double */
  79. int compression; /* RASTER3D_NO_COMPRESSION or RASTER3D_USE_COMPRESSION */
  80. int useLzw; /* RASTER3D_USE_LZW or RASTER3D_NO_LZW */
  81. int useRle; /* RASTER3D_USE_RLE or RASTER3D_NO_RLE */
  82. int useXdr; /* RASTER3D_USE_XDR or RASTER3D_NO_XDR */
  83. /* pointer to first tile in file */
  84. int offset;
  85. /* pointer to the first index entry in file */
  86. long indexOffset;
  87. /* sizeof (long) of the system on which the file is/was written */
  88. int indexLongNbytes;
  89. /* max # bytes used in the representation of indices; this is equal to */
  90. /* # bytes used in the representation of "indexOffset" */
  91. int indexNbytesUsed;
  92. /* pointer to the last entry in the file */
  93. int fileEndPtr;
  94. /* indicates if index is stored in file; used for RASTER3D_READ_DATA only */
  95. int hasIndex; /* RASTER3D_HAS_INDEX or RASTER3D_NO_INDEX */
  96. /* information concerning internal storage of data */
  97. /* index specific information */
  98. /* index[i] == the offset of tile "i" in the data file */
  99. long *index;
  100. /* tileLength[i] == # bytes used to store tile "i" */
  101. int *tileLength;
  102. /* tile specific information */
  103. /* type in which data is stored in memory */
  104. int typeIntern; /* DCELL_TYPE or FCELL_TYPE */
  105. /* in non-cache mode the "data" array is used to store one tile */
  106. char *data;
  107. /* index of tile currently stored in "data"; -1 if none */
  108. int currentIndex;
  109. /* cache related variables */
  110. int useCache; /* 1 if cache is used */
  111. void *cache; /* pointer to cache structure */
  112. int cacheFD; /* file discriptor of cache file -- write mode only */
  113. char *cacheFileName; /* filename of cache file -- write mode only */
  114. long cachePosLast; /* position of last entry in cache file -- write */
  115. /* mode only */
  116. /* range info */
  117. struct FPRange range;
  118. /* some constants stored for efficiency */
  119. /* number of bytes required to store a single value of "type" */
  120. int numLengthExtern;
  121. /* number of bytes required to store a single value of "typeIntern" */
  122. int numLengthIntern;
  123. /* see header.c for details */
  124. int clipX, clipY, clipZ;
  125. int tileXY, tileSize;
  126. int nxy, nTiles;
  127. /* mask related information */
  128. int useMask; /* 1 if mask is used; 0 otherwise */
  129. } RASTER3D_Map;
  130. /*---------------------------------------------------------------------------*/
  131. typedef struct
  132. {
  133. char *elts; /* ptr to array of elts */
  134. int nofElts; /* size of "elts" */
  135. int eltSize; /* size of elt in "elts" */
  136. int *names; /* name[i] is the name of elts[i] */
  137. char *locks; /* lock[i] == 1 iff elts[i] is locked
  138. lock[i] == 0 iff elts[i] is unlocked but active
  139. lock[i] == 2 iff elts[i] doesn't contain valid data */
  140. int autoLock; /* 1 if auto locking is turned on */
  141. int nofUnlocked; /* nof tiles which are unlocked */
  142. int minUnlocked; /* min nof elts which have to remain unlocked. min = 1 */
  143. int *next, *prev; /* prev/next pointers for fifo */
  144. int first, last; /* index (into next) of first and last elt in fifo */
  145. /* first == -1 iff fifo is empty */
  146. int (*eltRemoveFun) (); /* callback activated if the contents of an
  147. elt needs to be removed */
  148. void *eltRemoveFunData; /* pointer to user data passed along with
  149. eltRemoveFun */
  150. int (*eltLoadFun) (); /* callback activated to load contents of an elt */
  151. void *eltLoadFunData; /* pointer to user data passed along with
  152. eltLoadFun */
  153. void *hash; /* ptr to hashTable used to relate external names to
  154. internal indices (elts) */
  155. } RASTER3D_cache;
  156. /*---------------------------------------------------------------------------*/
  157. typedef struct
  158. {
  159. int nofNames;
  160. int *index;
  161. char *active;
  162. int lastName;
  163. int lastIndex;
  164. int lastIndexActive;
  165. } Rast3d_cache_hash;
  166. /*---------------------------------------------------------------------------*/
  167. /*Structures */
  168. typedef struct _d_interval
  169. {
  170. double low, high;
  171. int inf;
  172. struct _d_interval *next;
  173. } d_Interval;
  174. typedef struct _d_mask
  175. {
  176. d_Interval *list;
  177. } d_Mask;
  178. /*---------------------------------------------------------------------------*/
  179. typedef int write_fn(int, const void *, void *);
  180. typedef int read_fn(int, void *, void *);
  181. /*---------------------------------------------------------------------------*/
  182. /*============================== Prototypes ================================*/
  183. #include <grass/defs/raster3d.h>
  184. #endif /* #ifndef GRASS_RASTER3D_H */