headerinfo.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. #include <grass/G3d.h>
  2. #include "G3d_intern.h"
  3. /*---------------------------------------------------------------------------*/
  4. /*!
  5. * \brief
  6. *
  7. * Returns the size of the region of <em>map</em> in cells.
  8. *
  9. * \param map
  10. * \param rows
  11. * \param cols
  12. * \param depths
  13. * \return void
  14. */
  15. void G3d_getCoordsMap(G3D_Map * map, int *rows, int *cols, int *depths)
  16. {
  17. *rows = map->region.rows;
  18. *cols = map->region.cols;
  19. *depths = map->region.depths;
  20. }
  21. /*---------------------------------------------------------------------------*/
  22. void G3d_getCoordsMapWindow(G3D_Map * map, int *rows, int *cols, int *depths)
  23. {
  24. *rows = map->window.rows;
  25. *cols = map->window.cols;
  26. *depths = map->window.depths;
  27. }
  28. /*---------------------------------------------------------------------------*/
  29. /*!
  30. * \brief
  31. *
  32. * Returns the dimensions of the tile-cube used to tile the region of <em>map</em>.
  33. * These numbers include partial tiles.
  34. *
  35. * \param map
  36. * \param nx
  37. * \param ny
  38. * \param nz
  39. * \return void
  40. */
  41. void G3d_getNofTilesMap(G3D_Map * map, int *nx, int *ny, int *nz)
  42. {
  43. *nx = map->nx;
  44. *ny = map->ny;
  45. *nz = map->nz;
  46. }
  47. /*---------------------------------------------------------------------------*/
  48. /*!
  49. * \brief
  50. *
  51. * Returns the size of the region.
  52. *
  53. * \param map
  54. * \param north
  55. * \param south
  56. * \param east
  57. * \param west
  58. * \param top
  59. * \param bottom
  60. * \return void
  61. */
  62. void
  63. G3d_getRegionMap(G3D_Map * map, double *north, double *south, double *east,
  64. double *west, double *top, double *bottom)
  65. {
  66. *north = map->region.north;
  67. *south = map->region.south;
  68. *east = map->region.east;
  69. *west = map->region.west;
  70. *top = map->region.top;
  71. *bottom = map->region.bottom;
  72. }
  73. /*---------------------------------------------------------------------------*/
  74. void
  75. G3d_getWindowMap(G3D_Map * map, double *north, double *south, double *east,
  76. double *west, double *top, double *bottom)
  77. {
  78. *north = map->window.north;
  79. *south = map->window.south;
  80. *east = map->window.east;
  81. *west = map->window.west;
  82. *top = map->window.top;
  83. *bottom = map->window.bottom;
  84. }
  85. /*---------------------------------------------------------------------------*/
  86. /*!
  87. * \brief
  88. *
  89. * Returns in <em>region</em> the region of <em>map</em>.
  90. *
  91. * \param map
  92. * \param region
  93. * \return void
  94. */
  95. void G3d_getRegionStructMap(G3D_Map * map, G3D_Region * region)
  96. {
  97. G3d_regionCopy(region, &(map->region));
  98. }
  99. /*---------------------------------------------------------------------------*/
  100. void G3d_getWindowStructMap(G3D_Map * map, G3D_Region * window)
  101. {
  102. G3d_regionCopy(window, &(map->window));
  103. }
  104. /*---------------------------------------------------------------------------*/
  105. /*!
  106. * \brief
  107. *
  108. * Returns the tile dimensions used for <em>map</em>.
  109. *
  110. * \param map
  111. * \param x
  112. * \param y
  113. * \param z
  114. * \return void
  115. */
  116. void G3d_getTileDimensionsMap(G3D_Map * map, int *x, int *y, int *z)
  117. {
  118. *x = map->tileX;
  119. *y = map->tileY;
  120. *z = map->tileZ;
  121. }
  122. /*---------------------------------------------------------------------------*/
  123. /*!
  124. * \brief
  125. *
  126. * Returns the type in which tiles of <em>map</em> are stored in memory.
  127. *
  128. * \param map
  129. * \return int
  130. */
  131. int G3d_tileTypeMap(G3D_Map * map)
  132. {
  133. return map->typeIntern;
  134. }
  135. /*---------------------------------------------------------------------------*/
  136. /*!
  137. * \brief
  138. *
  139. * Returns the type with which tiles of <em>map</em> are stored on file.
  140. *
  141. * \param map
  142. * \return int
  143. */
  144. int G3d_fileTypeMap(G3D_Map * map)
  145. {
  146. return map->type;
  147. }
  148. /*---------------------------------------------------------------------------*/
  149. /*!
  150. * \brief
  151. *
  152. * Returns the precision used to store <em>map</em>.
  153. *
  154. * \param map
  155. * \return int
  156. */
  157. int G3d_tilePrecisionMap(G3D_Map * map)
  158. {
  159. return map->precision;
  160. }
  161. /*---------------------------------------------------------------------------*/
  162. /*!
  163. * \brief
  164. *
  165. * Returns 1 if <em>map</em> uses cache, returns 0 otherwise.
  166. *
  167. * \param map
  168. * \return int
  169. */
  170. int G3d_tileUseCacheMap(G3D_Map * map)
  171. {
  172. return map->useCache;
  173. }
  174. /*!
  175. * \brief
  176. *
  177. * Prints the header information of <em>map</em>.
  178. *
  179. * \param map
  180. * \return void
  181. */
  182. void G3d_printHeader(G3D_Map * map)
  183. {
  184. double rangeMin, rangeMax;
  185. printf("File %s open for %sing:\n", map->fileName,
  186. (map->operation == G3D_WRITE_DATA ? "writ" :
  187. (map->operation == G3D_READ_DATA ? "read" : "unknown")));
  188. printf(" Fd = %d, Unit %s, Type: %s, ", map->data_fd,
  189. map->unit,
  190. (map->type == FCELL_TYPE ? "float" :
  191. (map->type == DCELL_TYPE ? "double" : "unknown")));
  192. printf("Type intern: %s\n",
  193. (map->typeIntern == FCELL_TYPE ? "float" :
  194. (map->typeIntern == DCELL_TYPE ? "double" : "unknown")));
  195. if (map->compression == G3D_NO_COMPRESSION)
  196. printf(" Compression: none\n");
  197. else {
  198. printf(" Compression:%s%s Precision: %s",
  199. (map->useLzw ? " lzw," : ""), (map->useRle ? " rle," : ""),
  200. (map->precision == -1 ? "all bits used\n" : "using"));
  201. if (map->precision != -1)
  202. printf(" %d bits\n", map->precision);
  203. }
  204. if (!map->useCache)
  205. printf(" Cache: none\n");
  206. else {
  207. printf(" Cache: used%s\n",
  208. (map->operation == G3D_WRITE_DATA ? ", File Cache used" : ""));
  209. }
  210. G3d_range_min_max(map, &rangeMin, &rangeMax);
  211. printf(" Region: (%f %f) (%f %f) (%f %f)\n",
  212. map->region.south, map->region.north, map->region.west,
  213. map->region.east, map->region.bottom, map->region.top);
  214. printf(" (%d %d %d)\n", map->region.rows, map->region.cols,
  215. map->region.depths);
  216. printf(" Tile size (%d %d %d)\n", map->tileX, map->tileY, map->tileZ);
  217. printf(" Range (");
  218. if (G3d_isNullValueNum(&rangeMin, DCELL_TYPE))
  219. printf("NULL, ");
  220. else
  221. printf("%f, ", (double)rangeMin);
  222. if (G3d_isNullValueNum(&rangeMax, DCELL_TYPE))
  223. printf("NULL)\n");
  224. else
  225. printf("%f)\n", (double)rangeMax);
  226. fflush(stdout);
  227. }