raster3dlib.dox 56 KB

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