raster3dlib.dox 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752
  1. /*! \page raster3dlib GRASS 3D Raster Volume Library
  2. <!-- doxygenized from "GRASS 5 Programmer's Manual"
  3. by M. Neteler 5/2004, 8/2005
  4. -->
  5. <i>TODO: Update for this page for GRASS 7, most of the function names have been changed from camel case to gnu underscore style.</i>
  6. \tableofcontents
  7. \section raster3dlib_Overview Overview
  8. The 3D Raster Volume Library is used for the <tt>r3.*</tt> and vector
  9. volume tools. The library uses a tile cache based approach to store
  10. floating point values in arbitrary order in a volume. The coordinate
  11. system of a volume is column and row compatible to the raster library
  12. and counts from the bottom to the top of the cube.
  13. <P>
  14. Random reading and writing is supported until are tiles are flushed to the disk.
  15. In case the tiles are written to the disk, random reading is still supported.
  16. <P>
  17. The size of the tile cache in memory can be set in bytes using the environmental variable RASTER3D_MAX_CACHE_SIZE.
  18. Default size is 16777216 bytes.The number of tiles hold in memory can be specified with the environmental variable
  19. RASTER3D_DEFAULT_CACHE_SIZE. Default is 1000.
  20. \image html "raster3d_layout.png" "The volume coordinate system and tile layout of the 3D Raster Library"
  21. \section Directory_Structure Directory Structure
  22. <P>
  23. The file format consists of a mapset element <EM>grid3</EM> which contains a
  24. directory for every map. The elements for each map are
  25. <P>
  26. \verbatim
  27. 3d region file
  28. color file (color)
  29. categories file (cats)
  30. range file (range)
  31. timestamp file
  32. cell file (cell)
  33. header file (cellhd)
  34. a directory containing display files (dsp)
  35. \endverbatim
  36. <P>
  37. There is also a <EM>colr2</EM> mechanism provided. <EM>colr2</EM> color tables
  38. are stored in <EM>grid3/colr2/MAPSET/MAP</EM>.
  39. <P>
  40. Note: color, categories, and the range can be used in the same way as in <EM>2d</EM>
  41. GRASS with the exception of reading and writing. <EM>3d</EM> read and write
  42. functions have to be used for this purpose.
  43. \section Data_File_Format Data File Format
  44. <UL>
  45. <LI>Cell-values can be either double or float.
  46. </LI>
  47. <LI>Values are written in XDR-format.
  48. </LI>
  49. <LI>NULL-values are stored in an embedded fashion.
  50. </LI>
  51. <LI>The cell-values are organized in <EM>3d</EM>-tiles.
  52. </LI>
  53. <LI>The tile dimensions can be chosen when a new map is opened.
  54. </LI>
  55. <LI>Every tile of a map has the same dimension except those which overlap the
  56. region boundaries.
  57. </LI>
  58. <LI>Compression is used to store tiles.
  59. </LI>
  60. </UL>
  61. <P>
  62. The data file has the following format:
  63. <P>
  64. \verbatim
  65. xdr_int nofBytesLong;
  66. xdr_int nofBytesUsed;
  67. encoded_long indexOffset;
  68. compressed_tile[] tiles;
  69. compressed_encoded_long[] index;
  70. \endverbatim
  71. <P>
  72. \section Transportability_of_data_file Transportability of data file
  73. <P>
  74. All numbers stored in the data file are either XDR-encoded or encoded by some
  75. other method (for variables of type long only).
  76. <P>
  77. \section Tile_Data_NULL_values Tile Data NULL-values
  78. <P>
  79. RASTER3D uses the same functions as <EM>2d</EM> GRASS to set and test NULL-values. The
  80. storage in the file is different though. NULL-values are stored with a special
  81. bit-pattern if maximum precision is chosen. They are stored by adding an
  82. additional bit if the precision is smaller.
  83. <P>
  84. \section Tile_Data_Compression Tile Data Compression
  85. NOTE: RLE compression was removed because of error-prone implementation.
  86. De-compression is still available for backward compatibility.
  87. Default compression is now zip.
  88. <P>
  89. There are three methods of compression provided. The compression
  90. methods can either be those defined by default, set by environment
  91. variables or explicitly set at run-time.
  92. \verbatim
  93. Precision
  94. zlib
  95. \endverbatim
  96. <P>
  97. Precision indicates how many of the mantissa bits should be stored on
  98. file. This number can be any value between 0 and 23 for floats and
  99. between 0 and 52 for doubles. Choosing a small precision is the most
  100. effective way to achieve good compression.
  101. <P>
  102. The default and suggested setting is to use precision and zlib.
  103. <P>
  104. Additional compression is achieved by storing the extra NULL-bit in a
  105. separate bit-array. Using this scheme NULL-values need not actually be
  106. represented in the array of cell values. This array is stored together
  107. with the cell-values of the tile.
  108. \section Tile_Cache Tile Cache
  109. <P>
  110. Tiles can either be read and written directly or use an intermediate
  111. cache instead.
  112. <P>
  113. In non-cache mode the application should only use the functions
  114. <P>
  115. int Rast3d_readTile()
  116. <P>
  117. and
  118. <P>
  119. int Rast3d_writeTile()
  120. <P>
  121. to read and write tiles. The application can use one tile provided by the map
  122. structure as buffer. See <TT>Rast3d_getTilePtr()</TT>.
  123. <P>
  124. In cache mode the application can access cell-values directly by their
  125. coordinates. The corresponding functions are
  126. <P>
  127. int Rast3d_get_value()
  128. <P>
  129. and
  130. <P>
  131. int Rast3d_put_value()
  132. <P>
  133. and their corresponding typed versions.
  134. <BR>
  135. <P>
  136. If the map is new then in addition to the memory-cache a file-cache is provided.
  137. This allows the application to write the cell-values in any arbitrary order.
  138. Tiles are written (flushed) to the data-file either at closing time or if
  139. explicitly requested.
  140. <BR>
  141. <P>
  142. If the map is new <TT>Rast3d_get_value()</TT> can be used even if the tile which
  143. contains the cell has already been flushed to the data file. In this case the
  144. tile is simply read back into the memory-cache from the data file.
  145. <BR>
  146. <P>
  147. Explicitly flushing tiles can have the advantage that less disk space is
  148. occupied since tiles are stored in a uncompressed fashion in the file-cache.
  149. Flushing tiles explicitly can cause problems with accuracy though if precision
  150. is less than the maximum precision and an already flushed value is used for
  151. computations later in the program.
  152. <BR>
  153. <P>
  154. The type of the cell-values of the tiles in memory can be chosen independently
  155. of the type of the tiles in the file. Here, once again one has to consider
  156. possible problems arising from mixing different precisions.
  157. <BR>
  158. <P>
  159. As an example consider the case where the data is stored in the file with double
  160. precision and the tiles are stored in memory in single precision. Then using
  161. <TT>Rast3d_get_value()</TT> will actually return a double precision number whose precision
  162. is only 23 bits. It is therefore a good idea to use the types in the memory
  163. consistently.
  164. <BR>
  165. <P>
  166. \section Header_File Header File
  167. <P>
  168. The header file has the following format:
  169. <P>
  170. \verbatim
  171. Proj: 1
  172. Zone: 1
  173. North: 2.0000000000000
  174. South: 0.5000000000000
  175. East: 4.0000000000000
  176. West: 3.0000000000000
  177. Top: 6.0000000000000
  178. Bottom: 5.0000000000000
  179. nofRows: 30
  180. nofCols: 20
  181. nofDepths: 14
  182. e-w resol: 0.05
  183. n-s resol: 0.05
  184. t-b resol: 0.071428571
  185. TileDimensionX: 8
  186. TileDimensionY: 8
  187. TileDimensionZ: 8
  188. CellType: double
  189. useCompression: 1
  190. useRle: 1
  191. Precision: -1
  192. nofHeaderBytes: 12
  193. useXdr: 1
  194. hasIndex: 1
  195. Units: none
  196. VerticalUnits: 1
  197. \endverbatim
  198. <P>
  199. Except for the first 14 fields the entries of the header file should
  200. not be modified. The precision value -1 indicates that maximum
  201. precision is used.
  202. <BR>
  203. <P>
  204. Binary files not in RASTER3D format can be read by the library. The
  205. following actions have to be taken:
  206. <P>
  207. Make a new map directory in the <EM>grid3</EM> element of the mapset (say <EM>mymap</EM>).
  208. Copy the file into <EM>mymap/cell</EM> and generate a header file <EM>mymap/cellhd</EM>.
  209. <P>
  210. In the following example the relevant values of <EM>mymap/cellhd</EM> are shown:
  211. <P>
  212. \verbatim
  213. TileDimensionX: A
  214. TileDimensionY: B
  215. TileDimensionZ: C
  216. useCompression: 0
  217. useRle: 0
  218. Precision: -1
  219. nofHeaderBytes: X
  220. useXdr: 0
  221. hasIndex: 0
  222. \endverbatim
  223. <P>
  224. The values of <EM>A</EM>, <EM>B</EM>, and <EM>C</EM> have to be chosen
  225. according to one of the following patterns:
  226. <P>
  227. \verbatim
  228. A &gt;= 1, B == 1, C == 1, or
  229. A &gt;= nofRows, B &gt;= 1, C == 1, or
  230. A &gt;= nofRows, B &gt;= nofCols, C &gt;= 1.
  231. \endverbatim
  232. <P>
  233. A larger tile size reduces the number of tile-reads. If in the third pattern
  234. <EM>C</EM> is chosen larger than or equal to <EM>nofDepths</EM>, the entire region is
  235. considered one large tile.
  236. <P>
  237. The value <EM>nofHeaderBytes</EM> indicates the offset in the file to the first
  238. data entry.
  239. <P>
  240. For performance reasons it is a good idea to use function
  241. <TT>Rast3d_retile()</TT> before using the file in other applications.
  242. <P>
  243. \section Region_Structure Region Structure
  244. <P>
  245. \verbatim
  246. typedef struct{
  247. double north, south;
  248. double east, west;
  249. double top, bottom;
  250. int rows, cols, depths; // data dimensions in cells
  251. double ns_res, ew_res, tb_res;
  252. int proj; // Projection (see gis.h)
  253. int zone; // Projection zone (see gis.h)
  254. } RASTER3D_Region;
  255. \endverbatim
  256. <P>
  257. \section Windows Windows
  258. <P>
  259. Window capability similar to that of <EM>2d</EM> GRASS is provided (compare
  260. Region). Additional features are the window for the third dimension
  261. as well as the possibility to choose a different window for every map. The
  262. window can be specified at the time of opening an old map. It can be modified
  263. at any time later in the program. The resampling method can be the default
  264. nearest neighbor method as well as an application provided method.
  265. <BR>
  266. <P>
  267. The default <EM>3d</EM> window file is <EM>WIND3</EM> located in the mapset.
  268. Application programs should use <TT>Rast3d_useWindowParams()</TT> to allow the
  269. user to overwrite this default.
  270. <P>
  271. The window file has the following format:
  272. <P>
  273. \verbatim
  274. Proj: 1
  275. Zone: 1
  276. North: 2.0
  277. South: 0.5
  278. East: 4.0
  279. West: 3.0
  280. Top: 5.0
  281. Bottom: 6.0
  282. nofRows: 30
  283. nofCols: 20
  284. nofDepths: 14
  285. e-w resol: 0.05000000000000000
  286. n-s resol: 0.05000000000000000
  287. t-b resol: 0.07142857142857142
  288. \endverbatim
  289. <P>
  290. Note: after reading the window file the fields <EM>e-w</EM>, <EM>n-s</EM>, and <EM>t-b</EM>
  291. are recomputed internally.
  292. <P>
  293. A note about windows and caching. Caching is performed on the level of tiles
  294. read from the file. There is no caching performed on resampled data. This is
  295. different from <EM>2d</EM> GRASS since resampling for a specific value is
  296. performed every time it is being accessed.
  297. <P>
  298. \section Masks Masks
  299. <P>
  300. RASTER3D provides a mask for the <EM>3d</EM> region. The mask structure is
  301. automatically initialized at the time the first file is opened. The same
  302. structure is used for all the files. The default for every file is that the
  303. mask is turned off. If masking should be performed, the application program has
  304. to turn on masking explicitly. If masking is turned on for a file, the
  305. cell-values of a tile are automatically checked against the mask. Values which
  306. are masked out, are set to NULL.
  307. <P>
  308. Note: changing the status of masking after one or more tiles have already
  309. been read does not affect the tiles which are already stored in the cache.
  310. <P>
  311. Any arbitrary 3d raster map can be used as mask file: NULL-values are interpreted as
  312. <TT>"mask-out"</TT>, all other values are interpreted as <TT>"don't mask
  313. out"</TT>. Using <EM>r3.mask</EM> to convert a 3d raster map into a mask file instead of
  314. simply copying (or renaming) the directory will significantly reduce to amount
  315. of disk space and the access time for the mask.
  316. <P>
  317. \section Include_File Include File
  318. <P>
  319. Exported RASTER3D constants and structures can be found in <EM>raster3d.h</EM>.
  320. <P>
  321. \section RASTER3D_Defaults RASTER3D Defaults
  322. <P>
  323. There are three methods to set default variables. First, the default can be set
  324. at compile time in <EM>g3ddefault.c</EM>. This value has lowest priority.
  325. <P>
  326. Second, the default can be set via an environment variable. Third, the value
  327. can be set explicitly set at run time. This value has highest priority.
  328. <P>
  329. There are also functions provided to query the value.
  330. <P>
  331. \section Cache_Mode Cache Mode
  332. <P>
  333. \subsection Limiting_the_maximum_cache_size Limiting the maximum cache size
  334. <P>
  335. The limit is specified in bytes. It is a limit on the size of cell-data stored
  336. in the cache and does not include the support structure.
  337. <P>
  338. Default RASTER3D_CACHE_SIZE_MAX_DEFAULT. This is currently set to 16meg and can
  339. be changed at compilation time of the library.
  340. <P>
  341. Environment variable RASTER3D_MAX_CACHE_SIZE.
  342. <P>
  343. void Rast3d_setCacheLimit(int nBytes)Set cache limit
  344. <P>
  345. int Rast3d_getCacheLimit(int nBytes)Get cache limit
  346. <P>
  347. \subsection Setting_the_cache_size Setting the cache size
  348. <P>
  349. This value specifies the number of tiles stored in the cache. It is the value
  350. used if at opening time of a map RASTER3D_USE_CACHE_DEFAULT is used for the cache
  351. mode. Any other value used at opening time will supersede the default value. A
  352. default value of 0 indicates that non-cache mode should be used by default.
  353. <P>
  354. Default RASTER3D_CACHE_SIZE_DEFAULT. This is currently set to 1000 and can be
  355. changed at compilation time of the library.
  356. <P>
  357. Environment variable RASTER3D_DEFAULT_CACHE_SIZE.
  358. <P>
  359. void Rast3d_setCacheSize(int nTiles)
  360. <P>
  361. int Rast3d_getCacheSize()
  362. <P>
  363. \section Compression Compression
  364. \subsection Toggling_compression_mode Toggling compression mode
  365. <P>
  366. This value specifies whether compression should be used while writing a new
  367. map. It does not have any effect on old maps.
  368. <P>
  369. Default RASTER3D_COMPRESSION_DEFAULT. This is set to RASTER3D_COMPRESSION. This
  370. default should not be changed.
  371. <P>
  372. Environment variables RASTER3D_USE_COMPRESSION and RASTER3D_NO_COMPRESSION.
  373. <P>
  374. See functions Rast3d_setCompressionMode() (cf.
  375. Section 22.3.2.3 ) and Rast3d_getCompressionMode() (cf. Section 22.3.2.3 ).
  376. <P>
  377. \subsection Toggling_RLE_compression Toggling RLE compression
  378. NOTE: RLE compression is not used any longer, the RLE code is still present to assure backward compatibility.
  379. G_zlib_write() and G_zlib_read() are used for compression now.
  380. <P>
  381. This value specifies whether RLE compression should be used (in addition to
  382. precision).
  383. <P>
  384. Default RASTER3D_USE_RLE_DEFAULT. This is currently set to RASTER3D_USE_RLE and can
  385. be changed at compilation time of the library.
  386. <P>
  387. Environment variables RASTER3D_USE_RLE and RASTER3D_NO_RLE.
  388. <P>
  389. See functions Rast3d_setCompressionMode() (cf.
  390. Section 22.3.2.3) and Rast3d_getCompressionMode() (cf. Section 22.3.2.3).
  391. \section Setting_the_precision Setting the precision
  392. <P>
  393. This number specifies how many mantissa bits should be used when writing a cell
  394. value. The minimum value is 0. The maximum value is 23 or RASTER3D_MAX_PRECISION
  395. for type FCELL_TYPE, it is 52 or RASTER3D_MAX_PRECISION for type DCELL_TYPE.
  396. <P>
  397. Default RASTER3D_PRECISION_DEFAULT. This is set to RASTER3D_MAX_PRECISION. This
  398. default should not be changed.
  399. <P>
  400. Environment variables RASTER3D_PRECISION and RASTER3D_MAX_PRECISION.
  401. <P>
  402. void Rast3d_setCompressionMode(int doCompress, int doLzw, int doRle, int
  403. precision) <EM>doCompress</EM> should be one of RASTER3D_NO_COMPRESSION and
  404. RASTER3D_COMPRESSION, <EM>doRle</EM> should be either RASTER3D_NO_RLE or
  405. RASTER3D_USE_RLE, and <EM>precision</EM> should be either RASTER3D_MAX_PRECISION or
  406. a positive integer.
  407. <P>
  408. void Rast3d_getCompressionMode(int *doCompress, int *doLzw, int *doRle,
  409. int *precision)
  410. <P>
  411. \section Tiles Tiles
  412. \subsection Setting_the_tile_dimensions Setting the tile dimensions
  413. <P>
  414. The dimensions are specified in number of cell.
  415. <P>
  416. Defaults RASTER3D_TILE_X_DEFAULT, RASTER3D_TILE_Y_DEFAULT, and
  417. RASTER3D_TILE_Z_DEFAULT. These are currently set to 8 and can be changed at
  418. compilation time of the library.
  419. <P>
  420. Environment variables RASTER3D_TILE_DIMENSION_X, RASTER3D_TILE_DIMENSION_Y, and
  421. RASTER3D_TILE_DIMENSION_Z.
  422. <P>
  423. void Rast3d_setTileDimension(int tileX, int tileY, int tileZ)
  424. <P>
  425. void Rast3d_getTileDimension(int *tileX, int *tileY, int *tileZ)
  426. <P>
  427. \section Setting_the_tile_cell_value_type Setting the tile cell-value type
  428. <P>
  429. Specifies which type is used to write cell-values on file. This type can be
  430. chosen independently of the type used to store cell-values in memory.
  431. <P>
  432. Default RASTER3D_FILE_TYPE_DEFAULT. This is set to DCELL_TYPE. This default
  433. should not be changed.
  434. <P>
  435. Environment variables RASTER3D_WRITE_FLOAT and RASTER3D_WRITE_DOUBLE.
  436. <P>
  437. void Rast3d_setFileType(int type)
  438. <P>
  439. int Rast3d_getFileType(int type)
  440. <P>
  441. \section Setting_the_window Setting the window
  442. <P>
  443. The window is set from a <EM>3d</EM> window file.
  444. <P>
  445. The default <EM>3d</EM> window file is <EM>WIND3</EM> located in the current mapset.
  446. <P>
  447. Possible choices for <EM>3d</EM> window files are <EM>name</EM> which refers to a
  448. window file in the <EM>3d</EM> window database located at <EM>windows3d</EM> of the
  449. current mapset; or file names which are identified by a leading <EM><TT>"/"</TT></EM>
  450. or <EM><TT>"."</TT></EM>; or fully qualified
  451. names, i.e. <EM>file@mapset</EM> which refer to window files in the <EM>3d</EM> window
  452. database of mapset. Note, that names <EM>WIND3</EM> and <EM>WIND3@mapset</EM> do not
  453. specify the default window name in the (current)
  454. mapset but rather a window file in the window database of the (current) mapset.
  455. <P>
  456. Environment variable RASTER3D_DEFAULT_WINDOW3D.
  457. <P>
  458. See functions
  459. <P>
  460. <TT>Rast3d_useWindowParams()</TT>,
  461. <P>
  462. <TT>Rast3d_setWindow()</TT>, and
  463. <P>
  464. <TT>Rast3d_setWindowMap()</TT>.
  465. <P>
  466. \section Setting_the_Units Setting the Units
  467. The data untis of a map can be described using a string.
  468. The vertical units are defined in gis.h and can be spatial or temporal.
  469. <P>
  470. No environment variable.
  471. <P>
  472. \verbatim
  473. void Rast3d_set_unit (map, unit)
  474. RASTER3d_Map; // the map
  475. char *unit; // The data unit description
  476. void Rast3d_set_vertical_unit (map, unit)
  477. RASTER3d_Map; // the map
  478. char *unit; // Use the standard from units.c in lib/gis
  479. void Rast3d_set_vertical_unit2 (map, unit)
  480. RASTER3d_Map; // the map
  481. int unit; // defined in gis.h
  482. \endverbatim
  483. \section Error_Handling Error Handling: Setting the error function
  484. <P>
  485. This variable specifies the function which is invoked when an error
  486. (not a fatal error) occurs. For example setting the error function to
  487. <TT>Rast3d_fatalError</TT> simplifies debugging with dbx and also might show
  488. errors which are missed because the application does not check the
  489. return value.
  490. <P>
  491. Default <TT>Rast3d_skipError</TT>.
  492. <P>
  493. Environment variables RASTER3D_USE_FATAL_ERROR and RASTER3D_USE_PRINT_ERROR.
  494. <P>
  495. void Rast3d_setErrorFun(void (*fun)(char *))
  496. <P>
  497. The following 3 functions are possible choices for error functions.
  498. <P>
  499. void Rast3d_skipError(char (*msg)(char *)) This function ignores the
  500. error.
  501. <P>
  502. void Rast3d_printError(char (*msg)(char *)) This function prints the
  503. error message <EM>msg</EM> to <EM>stderr</EM> and returns.
  504. <P>
  505. void Rast3d_fatalError(char (*msg)(char *)) This function prints the
  506. error message <EM>msg</EM> to <EM>stderr</EM>, flushes <EM>stdout</EM>
  507. and <EM>stderr</EM>, and terminates the program with a segementation fault.
  508. <P>
  509. \section RASTER3D_Function_Index RASTER3D Function Index
  510. \subsection Opening_and_Closing_RASTER3D_Files Opening and Closing RASTER3D Files
  511. <P>
  512. void *Rast3d_openCellOld(char *name, char *mapset, RASTER3D_Region *window,
  513. int type, int cache)Opens existing g3d-file <EM>name</EM> in <EM>mapset</EM>.
  514. <P>
  515. Tiles are stored in memory with <EM>type</EM> which must be any of FCELL_TYPE,
  516. DCELL_TYPE, or RASTER3D_TILE_SAME_AS_FILE. <EM>cache</EM> specifies the
  517. cache-mode used and must be either RASTER3D_NO_CACHE, RASTER3D_USE_CACHE_DEFAULT,
  518. RASTER3D_USE_CACHE_X, RASTER3D_USE_CACHE_Y, RASTER3D_USE_CACHE_Z,
  519. RASTER3D_USE_CACHE_XY, RASTER3D_USE_CACHE_XZ, RASTER3D_USE_CACHE_YZ,
  520. RASTER3D_USE_CACHE_XYZ, the result of <TT>Rast3d_cacheSizeEncode()</TT> (cf.
  521. Section 22.4.6), or any positive integer which
  522. specifies the number of tiles buffered in the cache. <EM>window</EM> sets the
  523. window-region for the map. It is either a pointer to a window structure or
  524. RASTER3D_DEFAULT_WINDOW, which uses the window stored at initialization time or
  525. set via <TT>Rast3d_setWindow()</TT> (cf. Section 22.4.16).
  526. To modify the window for the map after it has already been opened use
  527. <TT>Rast3d_setWindowMap()</TT> (cf. Section 22.4.16).
  528. <P>
  529. Returns a pointer to the cell structure ... if successful, NULL ...
  530. otherwise.
  531. <P>
  532. void *Rast3d_openCellNew(char *name, int type, int cache, RASTER3D_Region
  533. *region)Opens new g3d-file with <EM>name</EM> in the current mapset. Tiles
  534. are stored in memory with <EM>type</EM> which must be one of FCELL_TYPE,
  535. DCELL_TYPE, or RASTER3D_TILE_SAME_AS_FILE. <EM>cache</EM> specifies the
  536. cache-mode used and must be either RASTER3D_NO_CACHE, RASTER3D_USE_CACHE_DEFAULT,
  537. RASTER3D_USE_CACHE_X, RASTER3D_USE_CACHE_Y, RASTER3D_USE_CACHE_Z,
  538. RASTER3D_USE_CACHE_XY, RASTER3D_USE_CACHE_XZ, RASTER3D_USE_CACHE_YZ,
  539. RASTER3D_USE_CACHE_XYZ, the result of <TT>Rast3d_cacheSizeEncode()</TT> (cf.
  540. Section 22.4.6), or any positive integer which
  541. specifies the number of tiles buffered in the cache. <EM>region</EM> specifies
  542. the 3d region.
  543. <P>
  544. Returns a pointer to the cell structure ... if successful,
  545. NULL ... otherwise.
  546. <P>
  547. void *Rast3d_openCellNewParam(char *name, int typeIntern, int cache,
  548. RASTER3D_Region *region, int type, int doLzw, int doRle, int precision, int tileX,
  549. int tileY, int tileZ)Opens new g3d-file with <EM>name</EM> in the current
  550. mapset. Tiles are stored in memory with <EM>typeIntern</EM> which must be one of
  551. FCELL_TYPE, DCELL_TYPE, or RASTER3D_TILE_SAME_AS_FILE. <EM>cache</EM> specifies
  552. the cache-mode used and must be either RASTER3D_NO_CACHE,
  553. RASTER3D_USE_CACHE_DEFAULT, RASTER3D_USE_CACHE_X, RASTER3D_USE_CACHE_Y,
  554. RASTER3D_USE_CACHE_Z, RASTER3D_USE_CACHE_XY, RASTER3D_USE_CACHE_XZ,
  555. RASTER3D_USE_CACHE_YZ, RASTER3D_USE_CACHE_XYZ, the result of
  556. <TT>Rast3d_cacheSizeEncode()</TT> (cf.
  557. Section 22.4.6), or any positive integer which
  558. specifies the number of tiles buffered in the cache. <EM>region</EM> specifies
  559. the 3d region.
  560. <P>
  561. In addition the properties of the new file have to be specified. It is
  562. assumed by default that compression is used. This function first sets the
  563. global default values to the specified values, and then restores the original
  564. global defaults. This function can be used in conjunction with
  565. <TT>Rast3d_setStandard3dInputParams()</TT> (cf.
  566. Section 22.4.18) and
  567. <TT>Rast3d_getStandard3dParams()</TT>.
  568. <P>
  569. Returns a pointer to the cell structure ... if successful, NULL ...
  570. otherwise.
  571. <P>
  572. int Rast3d_closeCell(void *map)Closes g3d-file. If <EM>map</EM> is new
  573. and cache-mode is used for <EM>map</EM> then every tile which is not flushed
  574. before closing is flushed.
  575. <P>
  576. Returns 1 ... if successful, 0 ... otherwise.
  577. <P>
  578. void *Rast3d_open_new_opt_tile_size(const char *name, int cache, RASTER3D_Region * region, int type, int maxSize)
  579. Opens new g3d-file with <em>name</em> in the current mapset. This method tries to compute
  580. optimal tile size based on the number of rows, cols and depths and the maximum allowed tile size in KB.
  581. Tiles are stored in memory using RASTER3D_TILE_SAME_AS_FILE method. <em>cache</em> specifies the
  582. cache-mode used and must be either RASTER3D_NO_CACHE, RASTER3D_USE_CACHE_DEFAULT,
  583. RASTER3D_USE_CACHE_X, RASTER3D_USE_CACHE_Y, RASTER3D_USE_CACHE_Z,
  584. RASTER3D_USE_CACHE_XY, RASTER3D_USE_CACHE_XZ, RASTER3D_USE_CACHE_YZ,
  585. RASTER3D_USE_CACHE_XYZ, the result of <tt>Rast3d_cache_size_encode ()</tt>
  586. (cf.{g3d:G3d.cacheSizeEncode}), or any positive integer which
  587. specifies the number of tiles buffered in the cache. <em>region</em> specifies
  588. the 3d region.
  589. The map is created using the <em>type</em> which must be of FCELL_TYPE or DCELL_TYPE.
  590. <P>
  591. Returns a pointer to the cell structure ... if successful,
  592. NULL ... otherwise.
  593. <P>
  594. \subsection Reading_and_Writing_Tiles Reading and Writing Tiles
  595. <P>
  596. These functions read or write data directly to the file (after performing the
  597. appropriate compression) without going through the cache. In order to avoid
  598. unexpected side-effects the use of these functions in cache mode is
  599. discouraged.
  600. <P>
  601. int Rast3d_readTile(void *map, char *tileIndex, int tile, int type)
  602. Reads tile with index <EM>tileIndex</EM> into the <EM>tile</EM> buffer. The cells
  603. are stored with type <EM>type</EM> which must be one of FCELL_TYPE and
  604. DCELL_TYPE. If the tile with <EM>tileIndex</EM> is not stored on the file
  605. corresponding to <EM>map</EM>, and <EM>tileIndex</EM> is a valid index <EM>tile</EM>
  606. is filled with NULL-values.
  607. <P>
  608. Returns
  609. 1 ... if successful,
  610. 0 ... otherwise.
  611. <P>
  612. int Rast3d_readTileFloat(void *map, char *tileIndex, int tile)
  613. Is equivalent to Rast3d_readTile (map, tileIndex, tile, FCELL_TYPE).
  614. <P>
  615. int Rast3d_readTileDouble(void *map, char *tileIndex, int tile)
  616. Is equivalent to Rast3d_readTile (map, tileIndex, tile, DCELL_TYPE).
  617. <P>
  618. int Rast3d_writeTile(void *map, char *tileIndex, int tile, int type)
  619. Writes tile with index <EM>tileIndex</EM> to the file corresponding to <EM>map</EM>. It is assumed that the cells in <EM>tile</EM> are of <EM>type</EM> which
  620. must be one of FCELL_TYPE and DCELL_TYPE. The actual type used to write the
  621. tile depends on the type specified at the time when <EM>map</EM> is initialized.
  622. <P>
  623. A tile can only be written once. Subsequent attempts to write the same tile
  624. are ignored.
  625. <P>
  626. Returns
  627. 1 ... if successful,
  628. 2 ... if write request was ignored,
  629. 0 ... otherwise.
  630. <P>
  631. int Rast3d_writeTileFloat(void *map, char *tileIndex, int tile)
  632. Is equivalent to <TT>Rast3d_writeTile (map, tileIndex, tile, FCELL_TYPE).</TT>
  633. <P>
  634. int Rast3d_writeTileDouble(void *map, char *tileIndex, int tile)
  635. Is equivalent to <TT>Rast3d_writeTile (map, tileIndex, tile, DCELL_TYPE).</TT>
  636. <P>
  637. \subsection Reading_and_Writing_Cells Reading and Writing Cells
  638. <P>
  639. void Rast3d_getValue(void *map, int x, int y, int z, char *value, int
  640. type) Returns in <EM>*value</EM> the cell-value of the cell with
  641. window-coordinate <EM>(x, y, z)</EM>. The value returned is of <EM>type</EM>.
  642. <P>
  643. This function invokes a fatal error if an error occurs.
  644. <P>
  645. float Rast3d_getFloat(void *map, int x, int y, int z)Is equivalent to
  646. <TT>Rast3d_getValue (map, x, y, z, &amp;value, FCELL_TYPE);</TT> return value.
  647. <P>
  648. double Rast3d_getDouble(void *map, int x, int y, int z)Is equivalent
  649. to <TT>Rast3d_getValue (map, x, y, z, &amp;value, DCELL_TYPE);</TT> return value.
  650. <P>
  651. void Rast3d_getValueRegion(void *map, int x, int y, int z, char*value,
  652. int type) Returns in <EM>*value</EM> the cell-value of the cell with
  653. region-coordinate <EM>(x, y, z)</EM>. The value returned is of <EM>type</EM>.
  654. Here <EM>region</EM> means the coordinate in the cube of data in the file, i.e.
  655. ignoring geographic coordinates.
  656. <P>
  657. This function invokes a fatal error if an error occurs.
  658. <P>
  659. float Rast3d_getFloatRegion(void *map, int x, int y, int z)Is
  660. equivalent to <TT>Rast3d_getValueRegion (map, x, y, z, &amp;value, FCELL_TYPE);</TT>
  661. return value.
  662. <P>
  663. \code
  664. Rast3d_getDoubleRegion(map, x, y, z)
  665. \endcode
  666. is equivalent to
  667. \code
  668. Rast3d_getValueRegion(map, x, y, z, &amp;value, DCELL_TYPE)
  669. \endcode
  670. <P>
  671. int Rast3d_putValue(void *map, int x, int y, int z, char *value, int
  672. type)After converting <EM>*value</EM> of <EM>type</EM> into the type specified
  673. at the initialization time (i.e. <EM>typeIntern</EM>) this function writes the
  674. value into the tile buffer corresponding to cell-coordinate <EM>(x, y, z)</EM>.
  675. <P>
  676. Returns
  677. <P>
  678. 1 ... if successful,
  679. 0 ... otherwise.
  680. <P>
  681. int Rast3d_putFloat(void *map, int x, int y, int z, char *value)Is
  682. equivalent to Rast3d_putValue (map, x, y, z, &amp;value, FCELL_TYPE).
  683. <P>
  684. int Rast3d_putDouble(void *map, int x, int y, int z, char *value) Is
  685. equivalent to Rast3d_putValue (map, x, y, z, &amp;value, DCELL_TYPE).
  686. <P>
  687. \subsection Loading_and_Removing_TilesLoading and Removing Tiles
  688. <P>
  689. char *Rast3d_getTilePtr(void *map, int tileIndex) This function
  690. returns a pointer to a tile which contains the data for the tile with index
  691. <EM>tileIndex</EM>. The type of the data stored in the tile depends on the type
  692. specified at the initialization time of <EM>map</EM>. The functionality is
  693. different depending on whether <EM>map</EM> is old or new and depending on the
  694. cache-mode of <EM>map</EM>.
  695. <BR>
  696. <P>
  697. If <EM>map</EM> is old and the cache is not used the tile with <EM>tileIndex</EM>
  698. is read from file and stored in the buffer provided by the map structure.
  699. The pointer to this buffer is returned. If the buffer already contains the
  700. tile with <EM>tileIndex</EM> reading is skipped. Data which was stored in
  701. earlier calls to <TT>Rast3d_getTilePtr</TT> is destroyed. If the tile with
  702. <EM>tileIndex</EM> is not stored on the file corresponding to <EM>map</EM>, and
  703. <EM>tileIndex</EM> is a valid index the buffer is filled with NULL-values.
  704. <BR>
  705. <P>
  706. If <EM>map</EM> is old and the cache is used the tile with <EM>tileIndex</EM> is
  707. read from file and stored in one of the cache buffers. The pointer to buffer
  708. is returned. If no free cache buffer is available an unlocked cache-buffer
  709. is freed up and the new tile is stored in its place. If the tile with
  710. <EM>tileIndex</EM> is not stored on the file corresponding to <EM>map</EM>, and
  711. <EM>tileIndex</EM> is a valid index the buffer is filled with NULL-values. If one
  712. of the cache buffers already contains the tile with <EM>tileIndex</EM> reading
  713. is skipped and the pointer to this buffer is returned.
  714. <BR>
  715. <P>
  716. If <EM>map</EM> is new and the cache is not used the functionality is the same
  717. as if <EM>map</EM> is old and the cache is not used. If the tile with
  718. <EM>tileIndex</EM> is already stored on file, it is read into the buffer, if not,
  719. the cells are set to null-values. If the buffer corresponding to the pointer
  720. is used for writing, subsequent calls to <TT>Rast3d_getTilePtr</TT> may destroy the
  721. values already stored in the buffer. Use <TT>Rast3d_flushTile</TT> to write the buffer
  722. to the file before reusing it for a different index. The use of this buffer
  723. as write buffer is discouraged.
  724. <BR>
  725. <P>
  726. If <EM>map</EM> is new and the cache is used the functionality is the same as if
  727. <EM>map</EM> is old and the cache is used with the following exception. If
  728. <EM>tileIndex</EM> is a valid index and the tile with this index is not found in
  729. the cache and is not stored on the file corresponding to <EM>map</EM>, then the
  730. file cache is queried next. If the file-cache contains the tile it is loaded
  731. into the cache (memory-cache). Only if the file-cache does not contain the
  732. tile it is filled with NULL-values. Tile contents of buffers are never
  733. destroyed. If a cache buffer needs to be freed up, and the tile stored in the
  734. buffer has not been written to the file corresponding to <EM>map</EM> yet, the
  735. tile is copied into the file-cache.
  736. <BR>
  737. <P>
  738. Care has to be taken if this function is used in non-cache mode since it is
  739. implicitly invoked every time a read or write request is issued. The only
  740. I/O-functions for which it is safe to assume that they do not invoke
  741. <TT>Rast3d_getTilePtr</TT> are <TT>Rast3d_readTile()</TT> and
  742. <TT>Rast3d_writeTile()</TT> and their corresponding type-specific versions.
  743. <P>
  744. Returns
  745. a pointer to a buffer ... if successful,
  746. NULL ... otherwise.
  747. <P>
  748. int Rast3d_tileLoad(void *map, int tileIndex)
  749. Same functionality as <TT>Rast3d_getTilePtr()</TT> but does not return the
  750. pointer.
  751. <P>
  752. Returns
  753. 1 ... if successful,
  754. 0 ... otherwise.
  755. <P>
  756. int Rast3d_removeTile(void *map, inttileIndex) Removes a tile
  757. from memory-cache if tile is in memory-cache. For new maps the
  758. application does not know whether the tile is in the memory-cache or in
  759. the file-cache. Therefore, for new maps this function should be
  760. preceded by <TT>Rast3d_tileLoad()</TT>.
  761. <P>
  762. <EM>(Question: Is this a useful function?)</EM>
  763. <P>
  764. Returns 1 ... if successful, 0 ... otherwise.
  765. <P>
  766. \subsection Write_Functions_used_in_Cache_Mode Write Functions used in Cache Mode
  767. <P>
  768. int Rast3d_flushTile(void *map, int tileIndex) Writes the tile with
  769. <EM>tileIndex</EM> to the file corresponding to <EM>map</EM> and removes the tile
  770. from the cache (in non-cache mode the buffer provided by the map-structure is
  771. written).
  772. <P>
  773. If this tile has already been written before the write request is ignored.
  774. If the tile was never referred to before the invocation of Rast3d_flushTile, a
  775. tile filled with NULL-values is written.
  776. <P>
  777. Returns
  778. 1 ... if successful,
  779. 0 ... otherwise.
  780. <P>
  781. int Rast3d_flushTileCube(void *map, int xMin, int yMin, int zMin, int
  782. xMax, int yMax, int zMax) Writes the tiles with tile-coordinates
  783. contained in the axis-parallel cube with vertices <EM>(xMin, yMin, zMin)</EM>
  784. and <EM>(xMax, yMax, zMax</EM>). Tiles which are not stored in the cache are
  785. written as NULL-tiles. Write attempts for tiles which have already been
  786. written earlier are ignored.
  787. <P>
  788. Returns
  789. 1 ... if successful,
  790. 0 ... otherwise.
  791. <P>
  792. int Rast3d_flushTilesInCube(void *map, int xMin, int yMin, int
  793. zMin, int xMax, int yMax, int zMax) Writes those tiles for which
  794. <EM>every</EM> cell has coordinate contained in the axis-parallel cube
  795. defined by the vertices with cell-coordinates <EM>(xMin, yMin, zMin)</EM>
  796. and <EM>(xMax, yMax, zMax)</EM>.
  797. <P>
  798. Tiles which are not stored in the cache are written as NULL-tiles.
  799. Write attempts for tiles which have already been written earlier are
  800. ignored.
  801. <P>
  802. Returns
  803. 1 ... if successful,
  804. 0 ... otherwise.
  805. <P>
  806. \subsection Locking_and_Unlocking_Tiles_and_CyclesLocking and Unlocking Tiles, and Cycles
  807. <P>
  808. int Rast3d_lockTile(void *map, int tileIndex) Locks tile with <EM>tileIndex</EM> in cache.
  809. If after locking fewer than the minimum number of
  810. unlocked tiles are unlocked, the lock request is ignored.
  811. <P>
  812. Returns
  813. 1 ... if successful,
  814. -1 ... if request is ignored,
  815. 0 ... otherwise.
  816. <P>
  817. int Rast3d_unlockTile(void *map, int tileIndex)
  818. Unlocks tile with <EM>tileIndex</EM>.
  819. <P>
  820. Returns
  821. 1 ... if successful,
  822. 0 ... otherwise.
  823. <P>
  824. int Rast3d_unlockAll(void *map)
  825. Unlocks every tile in cache of <EM>map</EM>.
  826. <P>
  827. Returns
  828. 1 ... if successful,
  829. 0 ... otherwise.
  830. <P>
  831. void Rast3d_autolockOn(void *map)
  832. Turns autolock mode on.
  833. <P>
  834. void Rast3d_autolockOff(void *map)
  835. Turns autolock mode Off.
  836. <P>
  837. void Rast3d_minUnlocked(void *map, int minUnlocked) Sets the minimum
  838. number of unlocked tiles to <EM>minUnlocked</EM>. This function should be used
  839. in combination with <TT>Rast3d_unlockAll()</TT> in order to avoid situations where the
  840. new minimum is larger than the actual number of unlocked tiles.
  841. <P>
  842. <EM>minUnlocked</EM> must be one of RASTER3D_USE_CACHE_X, RASTER3D_USE_CACHE_Y,
  843. RASTER3D_USE_CACHE_Z, RASTER3D_USE_CACHE_XY, RASTER3D_USE_CACHE_XZ,
  844. RASTER3D_USE_CACHE_YZ, RASTER3D_USE_CACHE_XYZ, the result of Rast3d_cacheSizeEncode()
  845. (cf. Section 22.4.6), or any positive integer
  846. which explicitly specifies the number of tiles.
  847. <P>
  848. int Rast3d_beginCycle(void *map)
  849. Starts a new cycle.
  850. <P>
  851. Returns
  852. 1 ... if successful,
  853. 0 ... otherwise.
  854. <P>
  855. int Rast3d_endCycle(void *map)
  856. Ends a cycle.
  857. <P>
  858. Returns
  859. 1 ... if successful,
  860. 0 ... otherwise.
  861. <P>
  862. int Rast3d_cacheSizeEncode(int cacheCode, int n) Returns a number
  863. which encodes multiplicity <EM>n</EM> of <EM>cacheCode</EM>. This value can be used
  864. to specify the size of the cache.
  865. <P>
  866. If <EM>cacheCode</EM> is the size (in tiles) of the cache the function returns
  867. <EM>cacheCode * n</EM>.
  868. <P>
  869. If <EM>cacheCode</EM> is RASTER3D_USE_CACHE_DEFAULT the function returns
  870. RASTER3D_USE_CACHE_DEFAULT.
  871. <P>
  872. If <EM>cacheCode</EM> is RASTER3D_USE_CACHE_??? the function returns a value
  873. encoding RASTER3D_USE_CACHE_??? and <EM>n</EM>. Here RASTER3D_USE_CACHE_??? is one
  874. of RASTER3D_USE_CACHE_X, RASTER3D_USE_CACHE_Y, RASTER3D_USE_CACHE_Z,
  875. RASTER3D_USE_CACHE_XY, RASTER3D_USE_CACHE_XZ, RASTER3D_USE_CACHE_YZ, or
  876. RASTER3D_USE_CACHE_XYZ, where e.g. RASTER3D_USE_CACHE_X specifies that the cache
  877. should store as many tiles as there exist in one row along the x-axis of the
  878. tile cube, and RASTER3D_USE_CACHE_XY specifies that the cache should store as
  879. many tiles as there exist in one slice of the tile cube with constant Z
  880. coordinate.
  881. <P>
  882. \subsection Reading_Volumes Reading Volumes
  883. <P>
  884. int Rast3d_getVolume(void *map, double originNorth, double originWest,
  885. double originBottom, double vxNorth, double vxWest, double vxBottom, double
  886. vyNorth, double vyWest, double vyBottom, double vzNorth, double vzWest,
  887. double vzBottom, int nx, int ny, int nz, char *volumeBuf, int type)
  888. Resamples the cube defined by <EM>origin</EM> and the 3 vertices <EM>vx</EM>,
  889. <EM>vy</EM>, and <EM>vz</EM> which are incident to the 3 edges adjacent to
  890. <EM>origin</EM>. The resampled cube is stored in <EM>volumeBuf</EM> which is a cube
  891. with dimensions <EM>(nx, ny, nz)</EM>.
  892. <P>
  893. The method of sampling is nearest neighbor sampling.
  894. <P>
  895. The values stored are of <EM>type</EM>.
  896. <P>
  897. Returns 1 ... if successful, 0 ... otherwise.
  898. <P>
  899. int Rast3d_getAlignedVolume(void *map, double originNorth, double
  900. originWest, double originBottom, double lengthNorth, double lengthWest,
  901. double lengthBottom, int nx, int ny, int nz, char *volumeBuf, int type)
  902. Resamples the axis-parallel cube defined by <EM>origin</EM> and the lengths of
  903. the 3 edges adjacent to <EM>origin</EM>. The resampled cube is stored in
  904. <EM>volumeBuf</EM> which is a cube with dimensions <EM>(nx, ny, nz)</EM>. The method
  905. of sampling is nearest neighbor sampling. The values stored are of <EM>type</EM>.
  906. <P>
  907. Returns 1 ... if successful, 0 ... otherwise.
  908. <P>
  909. \subsection Allocating_and_Freeing_Memory Allocating and Freeing Memory
  910. <P>
  911. void *Rast3d_malloc(int nBytes)
  912. Same as <EM>malloc (nBytes)</EM>, except that in case of error
  913. <TT>Rast3d_error()</TT> is invoked.
  914. <P>
  915. Returns
  916. a pointer ... if successful,
  917. NULL ... otherwise.
  918. <P>
  919. void *Rast3d_realloc(void *ptr, int nBytes)
  920. Same as <EM>realloc (ptr, nBytes)</EM>, except that in case of error
  921. <TT>Rast3d_error()</TT> is invoked.
  922. <P>
  923. Returns
  924. a pointer ... if successful,
  925. NULL ... otherwise.
  926. <P>
  927. void Rast3d_free(void *ptr) Same as <EM>free (ptr)</EM>.
  928. <P>
  929. char *Rast3d_allocTilesType(void *map, int nofTiles, int type)
  930. Allocates a vector of <EM>nofTiles</EM> tiles with the same dimensions
  931. as the tiles of <EM>map</EM> and large enough to store cell-values of
  932. <EM>type</EM>.
  933. <P>
  934. Returns
  935. a pointer to the vector ... if successful,
  936. NULL ... otherwise.
  937. <P>
  938. \code
  939. Rast3d_allocTiles(map, nofTiles)
  940. \endcode
  941. is equivalent to
  942. \code
  943. Rast3d_allocTilesType(map, nofTiles, Rast3d_fileTypeMap(map)).
  944. \endcode
  945. <P>
  946. void Rast3d_freeTiles(char *tiles)
  947. Is equivalent to <TT>Rast3d_free (tiles);</TT>
  948. <P>
  949. \subsection RASTER3D_Null_Value_Support RASTER3D Null Value Support
  950. <P>
  951. void Rast3d_isNullValueNum(void *n, int type)
  952. Returns 1 if the value of <EM>*n</EM> is a NULL-value. Returns 0
  953. otherwise.
  954. <P>
  955. void Rast3d_setNullValue(void *c, int nofElts, int type)
  956. Fills the vector pointed to by <EM>c</EM> with <EM>nofElts</EM> NULL-values
  957. of <EM>type</EM>.
  958. <P>
  959. void Rast3d_setNullTileType(void *map, int tile, int type)
  960. Assumes that <EM>tile</EM> is a tile with the same dimensions as the
  961. tiles of <EM>map</EM>. Fills <EM>tile</EM> with NULL-values of
  962. <EM>type</EM>.
  963. <P>
  964. void Rast3d_setNullTile(void *map, int tile)
  965. Is equivalent to Rast3d_setNullTileType (map, tile, Rast3d_fileTypeMap (map)).
  966. <P>
  967. \subsection RASTER3D_Map_Header_Information RASTER3D Map Header Information
  968. <P>
  969. void Rast3d_getCoordsMap(void *map, int *rows, int *cols, int *depths)
  970. Returns the size of the region of <EM>map</EM> in cells.
  971. <P>
  972. void Rast3d_getRegionMap(void *map, int *north, int *south, int *east,
  973. int *west, int *top, int *bottom)Returns the size of the region.
  974. <P>
  975. void Rast3d_getRegionStructMap(void *map, RASTER3D_Region *region)
  976. Returns in <EM>region</EM> the region of <EM>map</EM>.
  977. <P>
  978. void Rast3d_getTileDimensionsMap(void *map, int *x, int *y, int *z)
  979. Returns the tile dimensions used for <EM>map</EM>.
  980. <P>
  981. void Rast3d_getNofTilesMap(void *map, int *nx, int *ny, int *nz)
  982. Returns the dimensions of the tile-cube used to tile the region of <EM>map</EM>.
  983. These numbers include partial tiles.
  984. <P>
  985. int Rast3d_tileTypeMap(void *map)
  986. Returns the type in which tiles of <EM>map</EM> are stored in memory.
  987. <P>
  988. int Rast3d_fileTypeMap(void *map)
  989. Returns the type with which tiles of <EM>map</EM> are stored on file.
  990. <P>
  991. int Rast3d_tilePrecisionMap(void *map)
  992. Returns the precision used to store <EM>map</EM>.
  993. <P>
  994. int Rast3d_tileUseCacheMap(void *map)
  995. Returns 1 if <EM>map</EM> uses cache, returns 0 otherwise.
  996. <P>
  997. void Rast3d_printHeader(void *map)
  998. Prints the header information of <EM>map</EM>.
  999. <P>
  1000. \subsection RASTER3D_Tile_Math RASTER3D Tile Math
  1001. <P>
  1002. void Rast3d_tileIndex2tile(void *map, int tileIndex, int *xTile, int
  1003. *yTile, int *zTile) Converts index <EM>tileIndex</EM> into tile-coordinates
  1004. <EM>(xTile, yTile, zTile)</EM>.
  1005. <P>
  1006. int Rast3d_tile2tileIndex(void *map, int xTile, int yTile, int
  1007. zTile) Returns tile-index corresponding to tile-coordinates <EM>(xTile,
  1008. yTile, zTile)</EM>.
  1009. <P>
  1010. void Rast3d_coord2tileCoord(void *map, int x, int y, int z, int *xTile,
  1011. int *yTile, int *zTile, int *xOffs, int *yOffs, int *zOffs) Converts
  1012. cell-coordinates <EM>(x, y, z)</EM> into tile-coordinates <EM>(xTile, yTile,
  1013. zTile)</EM> and the coordinate of the cell <EM>(xOffs, yOffs, zOffs)</EM> within
  1014. the tile.
  1015. <P>
  1016. void Rast3d_tileCoordOrigin(void *map, int xTile, int yTile, int zTile,
  1017. int *x, int *y, int *z) Computes the cell-coordinates <EM>(x, y, z)</EM>
  1018. which correspond to the origin of the tile with tile-coordinates <EM>(xTile,
  1019. yTile, zTile)</EM>.
  1020. <P>
  1021. void Rast3d_tileIndexOrigin(void *map, int tileIndex, int *x, int *y,
  1022. int *z) Computes the cell-coordinates <EM>(x, y, z)</EM> which correspond to
  1023. the origin of the tile with <EM>tileIndex</EM>.
  1024. <P>
  1025. void Rast3d_coord2tileIndex(void *map, int x, int y, int z, int
  1026. *tileIndex, int *offset) Converts cell-coordinates <EM>(x, y, z)</EM> into
  1027. <EM>tileIndex</EM> and the <EM>offset</EM> of the cell within the tile.
  1028. <P>
  1029. int Rast3d_coordInRange(void *map, int x, int y, int z) Returns 1 if
  1030. cell-coordinate <EM>(x, y, z)</EM> is a coordinate inside the region. Returns 0
  1031. otherwise.
  1032. <P>
  1033. int Rast3d_tileInRange(void *map, int x, int y, int z) Returns 1 if
  1034. tile-coordinate <EM>(x, y, z)</EM> is a coordinate inside tile cube. Returns 0
  1035. otherwise.
  1036. <P>
  1037. int Rast3d_tileIndexInRange(void *map, int tileIndex)
  1038. Returns 1 if <EM>tileIndex</EM> is a valid index for <EM>map</EM>.
  1039. Returns 0 otherwise.
  1040. <P>
  1041. int Rast3d_isValidLocation(void *map, double north, double west, double
  1042. bottom) Returns 1 if region-coordinates <EM>(north, west, bottom)</EM> are
  1043. inside the region of <EM>map</EM>. Returns 0 otherwise.
  1044. <P>
  1045. void Rast3d_location2coord(void *map, double north, double west, double
  1046. bottom, int *x, *y, *z) Converts region-coordinates <EM>(north, west,
  1047. bottom)</EM> into cell-coordinates <EM>(x, y, z)</EM>.
  1048. <P>
  1049. int Rast3d_computeClippedTileDimensions(void *map, int tileIndex, int
  1050. *rows, int *cols, int *depths, int *xRedundant, int *yRedundant, int
  1051. *zRedundant) Computes the dimensions of the tile when clipped to fit the
  1052. region of <EM>map</EM>. The clipped dimensions are returned in <EM>rows</EM>,
  1053. <EM>cols</EM>, <EM>depths</EM>. The complement is returned in <EM>xRedundant</EM>,
  1054. <EM>yRedundant</EM>, and <EM>zRedundant</EM>. This function returns the number of
  1055. cells in the clipped tile.
  1056. <P>
  1057. \subsection RASTER3D_Range_Support RASTER3D Range Support
  1058. The map structure RASTER3D_Map provides storage for the range. The range of
  1059. a map is updated every time a cell is written to the file. When an old map is
  1060. opened the range is not automatically loaded. The application has to invoke
  1061. Rast3d_range_load() explicitly. Alternatively, an application can use
  1062. the Rast3d_read_range() function and FPRange structure to read the range.
  1063. Rast3d_range_min_max() is used to get the minimum and maximum values of the
  1064. map range into integer.
  1065. Rast3d_range_write() function stores the range in file and is invoked
  1066. automatically when a new map is closed.
  1067. In addition to these functions, the application can also use some of the
  1068. standard GRASS 2D raster functions to manipulate the floating point range. It
  1069. is preferred to use <tt>Rast3d_</tt> functions if possible and importantly it is
  1070. not possible to use functions for reading and writing.
  1071. \subsection RASTER3D_Color_Support RASTER3D Color Support
  1072. Applications can use the standard GRASS functions to work with colors,
  1073. e.g. Rast_get_d_color_range(). However, the file manipulations must be handled
  1074. using specialized raster 3D functions.
  1075. Rast3d_read_colors() function reads color file for a map into a Colors structure.
  1076. Rast3d_write_colors() function stores colors in color files for a map and
  1077. Rast3d_remove_color() function removes the color file.
  1078. \subsection RASTER3D_Categories_Support RASTER3D Categories Support
  1079. <P>
  1080. Applications can use the standard GRASS functions to work with categories,
  1081. except for the file manipulations.
  1082. <P>
  1083. Function Rast3d_read_cats() reads the categories file for map and
  1084. function Rast3d_write_cats() writes the
  1085. categories the Categories structure into the categories file for a map.
  1086. <P>
  1087. \subsection RASTER3D_History_Support RASTER3D History Support
  1088. <P>
  1089. Applications can use the standard GRASS functions to work with histories,
  1090. except for the file manipulations.
  1091. <P>
  1092. int Rast3d_readHistory(char *name, char *mapset, struct History *hist)
  1093. Reads the history file for map <EM>name</EM> in <EM>mapset</EM> and
  1094. stores the history in the <EM>hist</EM> structure. See <EM>G_read_history</EM>
  1095. (Raster_History_File) for details and return values.
  1096. <P>
  1097. int Rast3d_writeHistory(char *name, struct History *hist)
  1098. Writes the
  1099. history stored in the <EM>hist</EM> structure into the categories file for
  1100. map <EM>name</EM> in the current mapset. See <EM>G_write_history</EM>
  1101. (Raster_History_File) for details and return values.
  1102. <P>
  1103. \subsection RASTER3D_Mask_Support RASTER3D Mask Support
  1104. <P>
  1105. void Rast3d_maskOn(void *map) Turns on the mask for <EM>map</EM>. Do
  1106. not invoke this function after the first tile has been read since the result
  1107. might be inconsistent cell-values.
  1108. <P>
  1109. void Rast3d_maskOff(void *map) Turns off the mask for <EM>map</EM>.
  1110. This is the default. Do not invoke this function after the first tile has
  1111. been read since the result might be inconsistent cell-values.
  1112. <P>
  1113. int Rast3d_maskIsOn(void *map) Returns 1 if the mask for <EM>map</EM>
  1114. is turned on. Returns 0 otherwise.
  1115. <P>
  1116. int Rast3d_maskIsOff(void *map)
  1117. Returns 1 if the mask for <EM>map</EM> is turned off. Returns 0 otherwise.
  1118. <P>
  1119. The remaining functions in this section are for the explicit query of the mask
  1120. and the masking of individual cells or tiles. These functions are used in the
  1121. library and might have applications in situations where both the masked and
  1122. non-masked value of a cell has to be known.
  1123. <P>
  1124. int Rast3d_maskReopen(int cache)
  1125. This function should be used to adjust the cache size used for the
  1126. 3d-mask. First the open 3d-mask is closed and then opened again with
  1127. a cache size as specified with <EM>cache</EM>.
  1128. <P>
  1129. Returns
  1130. 1 ... if successful
  1131. 0 ... otherwise.
  1132. <P>
  1133. int Rast3d_maskFileExists() Returns 1 if the 3d mask file
  1134. exists.
  1135. <P>
  1136. int Rast3d_maskMapExists()
  1137. Returns 1 if the 3d mask is loaded.
  1138. <P>
  1139. char *Rast3d_maskFile()
  1140. Returns the name of the 3d mask file.
  1141. <P>
  1142. int Rast3d_isMasked(int x, int y, int z)
  1143. Returns 1 if the cell with cell-coordinates <EM>(x, y, z)</EM> is masked
  1144. out. Returns 0 otherwise.
  1145. <P>
  1146. void Rast3d_maskNum(int x, int y, int z, void *value, int type)
  1147. Replaces the value stored in <EM>value</EM> with the NULL-value if
  1148. <EM>Rast3d_isMasked (x, y, z)</EM> returns 1. Does nothing otherwise.
  1149. <EM>value</EM> is assumed to be of<EM>type</EM>.
  1150. <P>
  1151. void Rast3d_maskFloat(int x, int y, int z, float *value)
  1152. Same as <EM>Rast3d_maskNum (x, y, z, value, FCELL_TYPE)</EM>.
  1153. <P>
  1154. void Rast3d_maskDouble(int x, int y, int z, double *value)
  1155. Same as <EM>Rast3d_maskNum (x, y, z, value, DCELL_TYPE)</EM>.
  1156. <P>
  1157. void Rast3d_maskTile(void *map, int tileIndex, char *tile, int type)
  1158. Replaces the values stored in <EM>tile</EM> (with <EM>tileIndex</EM>) for
  1159. which <EM>Rast3d_isMasked</EM> returns 1 with NULL-values. Does not change
  1160. the remaining values. The values are assumed to be of <EM>type</EM>.
  1161. Whether replacement is performed or not only depends on location of the
  1162. cells of the tile and not on the status of the mask for <EM>map</EM>
  1163. (i.e. turned on or off).
  1164. <P>
  1165. \subsection RASTER3D_Window_Support RASTER3D Window Support
  1166. <P>
  1167. void Rast3d_setWindowMap(void *map, RASTER3D_Region *window)
  1168. Sets the window for <EM>map</EM> to <EM>window</EM>.
  1169. Can be used multiple times for the same map.
  1170. <P>
  1171. void Rast3d_setWindow(RASTER3D_Region *window)
  1172. Sets the default window used for every map opened later in the program.
  1173. Can be used multiple times in the same program.
  1174. <P>
  1175. void Rast3d_getWindow(RASTER3D_Region *window)
  1176. Stores the current default window in <EM>window</EM>.
  1177. <P>
  1178. void *Rast3d_windowPtr()
  1179. Returns a pointer to the current default window. This pointer should not be
  1180. (ab)used to modify the current window structure directly. It is
  1181. provided to pass a window pointer when opening a map.
  1182. <P>
  1183. int Rast3d_readWindow(RASTER3D_Region *window, char *windowName) Reads
  1184. <EM>window</EM> from the file specified by <EM>windowName</EM>. The name is
  1185. converted by the rules defined in window defaults. A NULL pointer indicates
  1186. the <EM>WIND3</EM> file in the current mapset.
  1187. <P>
  1188. Returns
  1189. 1 ... if successful
  1190. 0 ... otherwise.
  1191. <P>
  1192. int Rast3d_writeWindow(RASTER3D_Region *window, char *windowName)
  1193. Writes <EM>window</EM> to the file specified by <EM>windowName</EM>. The name
  1194. is converted by the rules defined in window defaults. A NULL pointer
  1195. indicates the <EM>WIND3</EM> file in the current mapset.
  1196. <P>
  1197. Returns
  1198. 1 ... if successful
  1199. 0 ... otherwise.
  1200. <P>
  1201. void Rast3d_useWindowParams()
  1202. Allows the window to be set at run-time via the <EM>region3</EM>
  1203. command line argument. This function has to be called before
  1204. <EM>G_parser()</EM>. See also
  1205. window defaults.
  1206. <P>
  1207. void Rast3d_setResamplingFun(void *map, void (*resampleFun)())
  1208. Sets the resampling function to be used by
  1209. Rast3d_getValue() (cf. Section 22.4.3). This function is defined
  1210. as follows:
  1211. <P>
  1212. void Rast3d_customResampleFun(void *map, int row, int col, int depth,
  1213. char *value, int type) <EM>row</EM>, <EM>col</EM>, and <EM>depth</EM> are in
  1214. region coordinates. The result is returned in <EM>value</EM> as <EM>type</EM> which
  1215. is one of FCELL_TYPE or DCELL_TYPE. Possible choices include
  1216. Rast3d_nearestNeighbor() (cf. Section22.4.16) and
  1217. Rast3d_getValueRegion() (cf. Section 22.4.3).
  1218. <P>
  1219. The default resampling function which uses nearest
  1220. neighbor resampling.
  1221. \code
  1222. Rast3d_nearestNeighbor(map, row, col, depth, value, type)
  1223. \endcode
  1224. <P>
  1225. void Rast3d_getResamplingFun(void *map, void (**resampleFun)())
  1226. Returns in <EM>resampleFun</EM> a pointer to the resampling function used by
  1227. <EM>map</EM>.
  1228. <P>
  1229. void Rast3d_getNearestNeighborFunPtr(void (**nnFunPtr)()) Returns
  1230. in <EM>nnFunPtr</EM> a pointer to Rast3d_nearestNeighbor() (cf.
  1231. Section&nbsp;<A HREF="#g3d:G3d.nearestNeighbor">22.4.16</A>).
  1232. <P>
  1233. \subsection RASTER3D_Region RASTER3D Region
  1234. <P>
  1235. void Rast3d_extract2dRegion(RASTER3D_Region *region3d, struct Cell_head
  1236. *region2d) Returns in <EM>region2d</EM> the <EM>2d</EM> portion of <EM>region3d</EM>.
  1237. <P>
  1238. void Rast3d_incorporate2dRegion(struct Cell_head *region2d, RASTER3D_Region
  1239. *region3d) Replaces the <EM>2d</EM> portion of <EM>region3d</EM> with the
  1240. values stored in <EM>region2d</EM>.
  1241. <P>
  1242. void Rast3d_adjustRegion(RASTER3D_Region *region)
  1243. Computes an adjusts the resolutions in the region structure from the region
  1244. boundaries and number of cells per dimension.
  1245. <P>
  1246. void Rast3d_adjustRegionRes(RASTER3D_Region *region)
  1247. Computes an adjusts the number of cells per dimension in the region
  1248. structure from the region boundaries and resolutions.
  1249. <P>
  1250. void Rast3d_regionCopy(RASTER3D_Region *regionDest, RASTER3D_Region *regionSrc)
  1251. Copies the values of <EM>regionSrc</EM> into <EM>regionDst</EM>.
  1252. (The unfortunate order of parameters was chosen in order to conform to the
  1253. order used in <EM>G_copy()</EM>).
  1254. <P>
  1255. void Rast3d_getRegionValue(void *map, double north, double east, double
  1256. top, char *value, int type) Returns in <EM>value</EM> the value of the <EM>map</EM>
  1257. which corresponds to region coordinates <EM>(north, east, top)</EM>. The
  1258. value is resampled using the resampling function specified for <EM>map</EM>. The
  1259. <EM>value</EM> is of <EM>type</EM>.
  1260. <P>
  1261. void Rast3d_readRegionMap(char *name, char *mapset, RASTER3D_Region *region)
  1262. Returns in <EM>region</EM> the region information for 3d cell <EM>name@mapset</EM>.
  1263. <P>
  1264. \subsection Miscellaneous_Functions Miscellaneous Functions
  1265. <P>
  1266. void Rast3d_g3dType2cellType(int g3dType) Returns the GRASS floating
  1267. point type which is equivalent to the RASTER3D type of <EM>g3dType</EM>.
  1268. <P>
  1269. void Rast3d_initDefaults() Initializes the default values described
  1270. in RASTER3D Defaults. Applications have to use this function only if they need to
  1271. query the default values before the first file (either old or new) has been
  1272. opened.
  1273. <P>
  1274. void Rast3d_setStandard3dInputParams()
  1275. Initializes a parameter
  1276. structure for the subset of command line arguments which lets the user
  1277. overwrite the default properties of the new file. Applications are
  1278. encouraged to use this function in order to provide a uniform style. The
  1279. command line arguments provided are the <EM>type</EM> of the cell values, the
  1280. <EM>precision</EM>, the properties of the <EM>compression</EM>, and the dimension
  1281. of the tiles (<EM>tiledimension</EM>). Every of these values defaults to the
  1282. value described in RASTER3D Defaults.
  1283. <P>
  1284. This function has to be used in conjunction with
  1285. Rast3d_getStandard3dInputParams() (cf.
  1286. Section 22.4.18).
  1287. <P>
  1288. int Rast3d_getStandard3dInputParams(int *useTypeDefault, *type, *useLzwDefault, *doLzw,
  1289. int *useRleDefault, *doRle, *usePrecisionDefault, *precision,
  1290. int *useDimensionDefault, *tileX, *tileY, *tileZ
  1291. Returns the properties of the new file as chosen by the user via command
  1292. line arguments. If the default is chosen the values of
  1293. <EM>useXxxxDefault</EM> is 1, it is 0 otherwise. In addition, the
  1294. corresponding parameters contain the default value if
  1295. <EM>useXxxxDefault</EM> is 1, or the value specified by the user if
  1296. <EM>useXxxxDefault</EM> is 0.
  1297. <P>
  1298. Function
  1299. Rast3d_setStandard3dInputParams() (cf. Section 22.4.18)
  1300. has to be used to initialize the internal parameter structure.
  1301. <P>
  1302. Returns
  1303. 1 ... if successful,
  1304. 0 ... otherwise.
  1305. <P>
  1306. int Rast3d_makeMapsetMapDirectory(char *mapName)
  1307. Creates the 3d mapset element for map <EM>mapName</EM>.
  1308. <P>
  1309. int Rast3d_filename(char *path, *elementName, *mapName, *mapset)
  1310. Returns in <EM>path</EM> the path for element <EM>elementName</EM> for map
  1311. <EM>mapName</EM> in <EM>mapset</EM>. Note, an error occurs if <EM>mapName</EM>
  1312. is fully qualified.
  1313. <P>
  1314. See TimeStamp_functions for a complete discussion of GRASS datetime
  1315. routines (reading, writing grid3d timestamps).
  1316. <P>
  1317. \section Sample_RASTER3D_Applications Sample RASTER3D Applications
  1318. <P>
  1319. These functions were implemented to test the library. They are not very
  1320. efficient but can be used as starting point for other
  1321. applications. Some of them might actually be useful. They are available from
  1322. GRASS 7 source code in lib/g3d/.
  1323. <P>
  1324. void Rast3d_retile(void *map, char *nameOut, int tileX, int tileY, int tileZ)
  1325. Makes a copy of <EM>map</EM> with name <EM>nameOut</EM> which has
  1326. tile dimensions <EM>tileX</EM>, <EM>tileY</EM>, <EM>tileZ</EM>.
  1327. <P>
  1328. The source code can be found in <EM>retile.c</EM>.
  1329. <P>
  1330. void Rast3d_changePrecision(void *map, int precision, char *nameOut)
  1331. Makes a copy of <EM>map</EM> with name <EM>nameOut</EM> which is
  1332. written with <EM>precision</EM>.
  1333. <P>
  1334. The source code can be found in <EM>changeprecision.c</EM>.
  1335. <P>
  1336. void Rast3d_changeType(void *map, char *nameOut)
  1337. Makes a copy of <EM>map</EM> with name <EM>nameOut</EM> in which the
  1338. cells are of type FCELL_TYPE if they are DCELL_TYPE in <EM>map</EM>,
  1339. and in DCELL_TYPE otherwise.
  1340. <P>
  1341. The source code can be found in <EM>changetype.c</EM>.
  1342. <P>
  1343. void Rast3d_compareFiles(char *f1, char *mapset1, char *f2, char *mapset2)
  1344. Compares the cell-values of file <EM>f1</EM> in mapset
  1345. <EM>mapset1</EM> and file <EM>f2</EM> in mapset <EM>mapset2</EM>.
  1346. The values are compared up to precision.
  1347. Terminates in error if the files don't match.
  1348. This function uses the more advanced features of the cache.
  1349. <P>
  1350. The source code can be found in <EM>filecompare.c</EM>.
  1351. <P>
  1352. void Rast3d_getBlock(void *map, int x0, int y0, int z0, int nx, int ny,
  1353. int nz, char *block, int type)
  1354. Copies the cells contained in the block (cube) with vertices
  1355. <EM>(x0, y0, z0)</EM> and <EM>(x0 + nx - 1, y0 + ny - 1, z0 + nz - 1)</EM>
  1356. into <EM>block</EM>. The cell-values in <EM>block</EM> are of <EM>type</EM>.
  1357. <P>
  1358. The source code can be found in <EM>getblock.c</EM>.
  1359. <P>
  1360. void Rast3d_writeAscii(void *map, char *fname)
  1361. Writes the cell-values of <EM>map</EM> in ascii format to file
  1362. <EM>fname</EM>. The values are organized by horizontal slices.
  1363. <P>
  1364. See \ref Compiling_and_Installing_GRASS_Modules for a complete
  1365. discussion of Makefiles.
  1366. Authors: Roman Waupotitsch and Michael Shapiro, Helena Mitasova,
  1367. Bill Brown, Lubos Mitas, Jaro Hofierka,
  1368. Minor modification, code cleanup and test suite by Soeren Gebbert
  1369. */