6
#define G3D_TILE_SAME_AS_FILE 2
8
#define G3D_NO_COMPRESSION 0
9
#define G3D_COMPRESSION 1
17
#define G3D_MAX_PRECISION -1
19
#define G3D_NO_CACHE 0
20
#define G3D_USE_CACHE_DEFAULT -1
21
#define G3D_USE_CACHE_X -2
22
#define G3D_USE_CACHE_Y -3
23
#define G3D_USE_CACHE_Z -4
24
#define G3D_USE_CACHE_XY -5
25
#define G3D_USE_CACHE_XZ -6
26
#define G3D_USE_CACHE_YZ -7
27
#define G3D_USE_CACHE_XYZ -8
29
#define G3D_DEFAULT_WINDOW NULL
31
#define G3D_DIRECTORY "grid3"
32
#define G3D_CELL_ELEMENT "cell"
33
#define G3D_CATS_ELEMENT "cats"
34
#define G3D_RANGE_ELEMENT "range"
35
#define G3D_HEADER_ELEMENT "cellhd"
36
#define G3D_HISTORY_ELEMENT "hist"
37
#define G3D_COLOR_ELEMENT "color"
38
#define G3D_COLOR2_DIRECTORY "colr2"
39
#define G3D_MASK_MAP "G3D_MASK"
40
#define G3D_WINDOW_ELEMENT "WIND3"
41
#define G3D_DEFAULT_WINDOW_ELEMENT "DEFAULT_WIND3"
42
#define G3D_WINDOW_DATABASE "windows3d"
43
#define G3D_PERMANENT_MAPSET "PERMANENT"
45
/*---------------------------------------------------------------------------*/
54
/* dimension of data in "cells"; rows == #x; cols == #y; depths == #z */
55
int rows, cols, depths;
57
double ns_res, ew_res, tb_res;
59
int proj; /* Projection (see gis.h) */
60
int zone; /* Projection zone (see gis.h) */
64
/*---------------------------------------------------------------------------*/
68
typedef void resample_fn(struct G3D_Map *, int, int, int, void *, int);
70
/*---------------------------------------------------------------------------*/
72
typedef struct G3D_Map
79
/* operation performed on map */
80
int operation; /* G3D_WRITE_DATA or G3D_READ_DATA */
88
/* resmapling function used for map. default is nearest neighbor */
89
resample_fn *resampleFun;
94
/* dimension of a single tile in "cells" */
95
int tileX, tileY, tileZ;
97
/* # of tiles in x, y, and z direction */
100
/* data file specific information */
102
/* file descriptor */
103
int data_fd; /* file descriptor */
105
/* type in which data is stored on file */
106
int type; /* DCELL_TYPE or FCELL_TYPE */
108
/* data concering the compression */
109
int precision; /* G3D_MAX_PRECISION or, 0 .. 23 for float,
110
0 .. 52 for double */
111
int compression; /* G3D_NO_COMPRESSION or G3D_USE_COMPRESSION */
112
int useLzw; /* G3D_USE_LZW or G3D_NO_LZW */
113
int useRle; /* G3D_USE_RLE or G3D_NO_RLE */
114
int useXdr; /* G3D_USE_XDR or G3D_NO_XDR */
116
/* pointer to first tile in file */
119
/* pointer to the first index entry in file */
122
/* sizeof (long) of the system on which the file is/was written */
125
/* max # bytes used in the representation of indices; this is equal to */
126
/* # bytes used in the representation of "indexOffset" */
129
/* pointer to the last entry in the file */
132
/* indicates if index is stored in file; used for G3D_READ_DATA only */
133
int hasIndex; /* G3D_HAS_INDEX or G3D_NO_INDEX */
135
/* information concerning internal storage of data */
137
/* index specific information */
138
/* index[i] == the offset of tile "i" in the data file */
141
/* tileLength[i] == # bytes used to store tile "i" */
144
/* tile specific information */
146
/* type in which data is stored in memory */
147
int typeIntern; /* DCELL_TYPE or FCELL_TYPE */
149
/* in non-cache mode the "data" array is used to store one tile */
152
/* index of tile currently stored in "data"; -1 if none */
155
/* cache related variables */
157
int useCache; /* 1 if cache is used */
158
void *cache; /* pointer to cache structure */
159
int cacheFD; /* file discriptor of cache file -- write mode only */
160
char *cacheFileName; /* filename of cache file -- write mode only */
161
long cachePosLast; /* position of last entry in cache file -- write */
165
struct FPRange range;
167
/* some constants stored for efficiency */
169
/* number of bytes required to store a single value of "type" */
172
/* number of bytes required to store a single value of "typeIntern" */
175
/* see header.c for details */
176
int clipX, clipY, clipZ;
177
int tileXY, tileSize;
180
/* mask related information */
182
int useMask; /* 1 if mask is used; 0 otherwise */
186
/*---------------------------------------------------------------------------*/
191
char *elts; /* ptr to array of elts */
192
int nofElts; /* size of "elts" */
193
int eltSize; /* size of elt in "elts" */
195
int *names; /* name[i] is the name of elts[i] */
197
char *locks; /* lock[i] == 1 iff elts[i] is locked
198
lock[i] == 0 iff elts[i] is unlocked but active
199
lock[i] == 2 iff elts[i] doesn't contain valid data */
200
int autoLock; /* 1 if auto locking is turned on */
201
int nofUnlocked; /* nof tiles which are unlocked */
202
int minUnlocked; /* min nof elts which have to remain unlocked. min = 1 */
204
int *next, *prev; /* prev/next pointers for fifo */
205
int first, last; /* index (into next) of first and last elt in fifo */
206
/* first == -1 iff fifo is empty */
208
int (*eltRemoveFun) (); /* callback activated if the contents of an
209
elt needs to be removed */
210
void *eltRemoveFunData; /* pointer to user data passed along with
212
int (*eltLoadFun) (); /* callback activated to load contents of an elt */
213
void *eltLoadFunData; /* pointer to user data passed along with
216
void *hash; /* ptr to hashTable used to relate external names to
217
internal indices (elts) */
221
/*---------------------------------------------------------------------------*/
235
/*---------------------------------------------------------------------------*/
237
typedef int write_fn(int, const void *, void *);
238
typedef int read_fn(int, void *, void *);
240
/*---------------------------------------------------------------------------*/
242
/* grass/src/libes/g3d/cache.c */
243
void G3d_cache_reset(G3D_cache *);
244
void G3d_cache_dispose(G3D_cache *);
245
void *G3d_cache_new(int, int, int, write_fn *, void *, read_fn *, void *);
246
void G3d_cache_set_removeFun(G3D_cache *, write_fn *, void *);
247
void G3d_cache_set_loadFun(G3D_cache *, read_fn *, void *);
248
void *G3d_cache_new_read(int, int, int, read_fn *, void *);
249
int G3d_cache_lock(G3D_cache *, int);
250
void G3d_cache_lock_intern(G3D_cache *, int);
251
int G3d_cache_unlock(G3D_cache *, int);
252
int G3d_cache_unlock_all(G3D_cache *);
253
int G3d_cache_lock_all(G3D_cache *);
254
void G3d_cache_autolock_on(G3D_cache *);
255
void G3d_cache_autolock_off(G3D_cache *);
256
void G3d_cache_set_minUnlock(G3D_cache *, int);
257
int G3d_cache_remove_elt(G3D_cache *, int);
258
int G3d_cache_flush(G3D_cache *, int);
259
int G3d_cache_remove_all(G3D_cache *);
260
int G3d_cache_flush_all(G3D_cache *);
261
void *G3d_cache_elt_ptr(G3D_cache *, int);
262
int G3d_cache_load(G3D_cache *, int);
263
int G3d_cache_get_elt(G3D_cache *, int, void *);
264
int G3d_cache_put_elt(G3D_cache *, int, const void *);
266
/* grass/src/libes/g3d/cachehash.c */
267
void G3d_cache_hash_reset(G3d_cache_hash *);
268
void G3d_cache_hash_dispose(G3d_cache_hash *);
269
void *G3d_cache_hash_new(int);
270
void G3d_cache_hash_remove_name(G3d_cache_hash *, int);
271
void G3d_cache_hash_load_name(G3d_cache_hash *, int, int);
272
int G3d_cache_hash_name2index(G3d_cache_hash *, int);
274
/* grass/src/libes/g3d/changeprecision.c */
275
void G3d_changePrecision(void *, int, const char *);
277
/* grass/src/libes/g3d/changetype.c */
278
void G3d_changeType(void *, const char *);
280
/* grass/src/libes/g3d/filecompare.c */
281
void G3d_compareFiles(const char *, const char *, const char *, const char *);
283
/* grass/src/libes/g3d/filename.c */
284
void G3d_filename(char *, const char *, const char *, const char *);
286
/* grass/src/libes/g3d/find_grid3.c */
287
char *G_find_grid3(const char *, const char *);
289
/* grass/src/libes/g3d/fpcompress.c */
290
void G_fpcompress_printBinary(char *, int);
291
void G_fpcompress_dissectXdrDouble(unsigned char *);
292
int G_fpcompress_writeXdrNums(int, char *, int, int, char *, int, int, int);
293
int G_fpcompress_writeXdrFloats(int, char *, int, int, char *, int, int);
294
int G_fpcompress_writeXdrDouble(int, char *, int, int, char *, int, int);
295
int G_fpcompress_readXdrNums(int, char *, int, int, int, char *, int);
296
int G_fpcompress_readXdrFloats(int, char *, int, int, int, char *);
297
int G_fpcompress_readXdrDoubles(int, char *, int, int, int, char *);
299
/* grass/src/libes/g3d/g3dalloc.c */
300
void *G3d_malloc(int);
301
void *G3d_realloc(void *, int);
302
void G3d_free(void *);
304
/* grass/src/libes/g3d/g3dcache.c */
305
int G3d_initCache(G3D_Map *, int);
306
int G3d_disposeCache(G3D_Map *);
307
int G3d_flushAllTiles(G3D_Map *);
309
/* grass/src/libes/g3d/g3dcats.c */
310
int G3d_writeCats(const char *, struct Categories *);
311
int G3d_readCats(const char *, const char *, struct Categories *);
313
/* grass/src/libes/g3d/g3dclose.c */
314
int G3d_closeCell(G3D_Map *);
316
/* grass/src/libes/g3d/g3dcolor.c */
317
int G3d_removeColor(const char *);
318
int G3d_readColors(const char *, const char *, struct Colors *);
319
int G3d_writeColors(const char *, const char *, struct Colors *);
321
/* grass/src/libes/g3d/g3ddefaults.c */
322
void G3d_setCompressionMode(int, int, int, int);
323
void G3d_getCompressionMode(int *, int *, int *, int *);
324
void G3d_setCacheSize(int);
325
int G3d_getCacheSize(void);
326
void G3d_setCacheLimit(int);
327
int G3d_getCacheLimit(void);
328
void G3d_setFileType(int);
329
int G3d_getFileType(void);
330
void G3d_setTileDimension(int, int, int);
331
void G3d_getTileDimension(int *, int *, int *);
332
void G3d_setErrorFun(void (*)(const char *));
333
void G3d_setUnit(const char *);
334
void G3d_initDefaults(void);
336
/* grass/src/libes/g3d/g3ddoubleio.c */
337
int G3d_writeDoubles(int, int, const double *, int);
338
int G3d_readDoubles(int, int, double *, int);
340
/* grass/src/libes/g3d/g3derror.c */
341
void G3d_skipError(const char *);
342
void G3d_printError(const char *);
343
void G3d_fatalError(const char *, ...) __attribute__ ((format(printf, 1, 2)))
344
__attribute__ ((noreturn));
345
void G3d_fatalError_noargs(const char *) __attribute__ ((noreturn));
346
void G3d_error(const char *, ...) __attribute__ ((format(printf, 1, 2)));
348
/* grass/src/libes/g3d/g3dfpxdr.c */
349
int G3d_isXdrNullNum(const void *, int);
350
int G3d_isXdrNullFloat(const float *);
351
int G3d_isXdrNullDouble(const double *);
352
void G3d_setXdrNullNum(void *, int);
353
void G3d_setXdrNullDouble(double *);
354
void G3d_setXdrNullFloat(float *);
355
int G3d_initFpXdr(G3D_Map *, int);
356
int G3d_initCopyToXdr(G3D_Map *, int);
357
int G3d_copyToXdr(const void *, int);
358
int G3d_initCopyFromXdr(G3D_Map *, int);
359
int G3d_copyFromXdr(int, void *);
361
/* grass/src/libes/g3d/g3dhistory.c */
362
int G3d_writeHistory(const char *, struct History *);
363
int G3d_readHistory(const char *, const char *, struct History *);
365
/* grass/src/libes/g3d/g3dintio.c */
366
int G3d_writeInts(int, int, const int *, int);
367
int G3d_readInts(int, int, int *, int);
369
/* grass/src/libes/g3d/g3dkeys.c */
370
int G3d_keyGetInt(struct Key_Value *, const char *, int *);
371
int G3d_keyGetDouble(struct Key_Value *, const char *, double *);
372
int G3d_keyGetString(struct Key_Value *, const char *, char **);
373
int G3d_keyGetValue(struct Key_Value *, const char *, char *, char *, int,
375
int G3d_keySetInt(struct Key_Value *, const char *, const int *);
376
int G3d_keySetDouble(struct Key_Value *, const char *, const double *);
377
int G3d_keySetString(struct Key_Value *, const char *, char *const *);
378
int G3d_keySetValue(struct Key_Value *, const char *, const char *,
379
const char *, int, int, const int *);
380
/* grass/src/libes/g3d/g3dlong.c */
381
int G3d_longEncode(long *, unsigned char *, int);
382
void G3d_longDecode(unsigned char *, long *, int, int);
384
/* grass/src/libes/g3d/g3dmapset.c */
385
void G3d_makeMapsetMapDirectory(const char *);
387
/* grass/src/libes/g3d/g3dmask.c */
388
int G3d_maskClose(void);
389
int G3d_maskFileExists(void);
390
int G3d_maskOpenOld(void);
391
int G3d_maskReopen(int);
392
int G3d_isMasked(G3D_Map *, int, int, int);
393
void G3d_maskNum(G3D_Map *, int, int, int, void *, int);
394
void G3d_maskFloat(G3D_Map *, int, int, int, float *);
395
void G3d_maskDouble(G3D_Map *, int, int, int, double *);
396
void G3d_maskTile(G3D_Map *, int, void *, int);
397
void G3d_maskOn(G3D_Map *);
398
void G3d_maskOff(G3D_Map *);
399
int G3d_maskIsOn(G3D_Map *);
400
int G3d_maskIsOff(G3D_Map *);
401
const char *G3d_maskFile(void);
402
int G3d_maskMapExists(void);
404
/* grass/src/libes/g3d/g3dmisc.c */
405
int G3d_g3dType2cellType(int);
406
void G3d_copyFloat2Double(const float *, int, double *, int, int);
407
void G3d_copyDouble2Float(const double *, int, float *, int, int);
408
void G3d_copyValues(const void *, int, int, void *, int, int, int);
410
int G3d_externLength(int);
412
/* grass/src/libes/g3d/g3dnull.c */
413
int G3d_isNullValueNum(const void *, int);
414
void G3d_setNullValue(void *, int, int);
416
/* grass/src/libes/g3d/g3dopen2.c */
417
/* grass/src/libes/g3d/g3dopen.c */
418
void *G3d_openCellOldNoHeader(const char *, const char *);
419
void *G3d_openCellOld(const char *, const char *, G3D_Region *, int, int);
420
void *G3d_openCellNew(const char *, int, int, G3D_Region *);
422
/* grass/src/libes/g3d/g3dparam.c */
423
void G3d_setStandard3dInputParams(void);
424
int G3d_getStandard3dParams(int *, int *, int *, int *, int *, int *, int *,
425
int *, int *, int *, int *, int *);
426
void G3d_setWindowParams(void);
427
char *G3d_getWindowParams(void);
429
/* grass/src/libes/g3d/g3drange.c */
430
void G3d_range_updateFromTile(G3D_Map *, const void *, int, int, int, int,
432
int G3d_readRange(const char *, const char *, struct FPRange *);
433
int G3d_range_load(G3D_Map *);
434
void G3d_range_min_max(G3D_Map *, double *, double *);
435
int G3d_range_write(G3D_Map *);
436
int G3d_range_init(G3D_Map *);
438
/* grass/src/libes/g3d/g3dregion.c */
439
void G3d_getRegionValue(G3D_Map *, double, double, double, void *, int);
440
void G3d_adjustRegion(G3D_Region *);
441
void G3d_regionCopy(G3D_Region *, G3D_Region *);
442
void G3d_incorporate2dRegion(struct Cell_head *, G3D_Region *);
443
void G3d_regionFromToCellHead(struct Cell_head *, G3D_Region *);
444
void G3d_adjustRegionRes(G3D_Region *);
445
void G3d_extract2dRegion(G3D_Region *, struct Cell_head *);
446
void G3d_regionToCellHead(G3D_Region *, struct Cell_head *);
447
int G3d_readRegionMap(const char *, const char *, G3D_Region *);
449
/* grass/src/libes/g3d/g3dresample.c */
450
void G3d_nearestNeighbor(G3D_Map *, int, int, int, void *, int);
451
void G3d_setResamplingFun(G3D_Map *, void (*)());
452
void G3d_getResamplingFun(G3D_Map *, void (**)());
453
void G3d_getNearestNeighborFunPtr(void (**)());
455
/* grass/src/libes/g3d/g3dvolume.c */
456
void G3d_getVolumeA(void *, double[2][2][2][3], int, int, int, void *, int);
457
void G3d_getVolume(void *, double, double, double, double, double, double,
458
double, double, double, double, double, double, int, int,
460
void G3d_getAlignedVolume(void *, double, double, double, double, double,
461
double, int, int, int, void *, int);
462
void G3d_makeAlignedVolumeFile(void *, const char *, double, double, double,
463
double, double, double, int, int, int);
464
/* grass/src/libes/g3d/g3dwindow.c */
465
void G3d_getValue(G3D_Map *, int, int, int, void *, int);
466
float G3d_getFloat(G3D_Map *, int, int, int);
467
double G3d_getDouble(G3D_Map *, int, int, int);
468
G3D_Region *G3d_windowPtr(void);
469
void G3d_setWindow(G3D_Region *);
470
void G3d_setWindowMap(G3D_Map *, G3D_Region *);
471
void G3d_getWindow(G3D_Region *);
473
/* grass/src/libes/g3d/g3dwindowio.c */
474
void G3d_useWindowParams(void);
475
int G3d_readWindow(G3D_Region *, const char *);
477
/* int G3d_writeWindow (G3D_Region *, char *); */
478
/* grass/src/libes/g3d/getblock.c */
479
void G3d_getBlockNocache(G3D_Map *, int, int, int, int, int, int, void *,
481
void G3d_getBlock(G3D_Map *, int, int, int, int, int, int, void *, int);
483
/* grass/src/libes/g3d/header.c */
484
int G3d_readHeader(G3D_Map *, int *, int *, double *, double *, double *,
485
double *, double *, double *, int *, int *, int *,
486
double *, double *, double *, int *, int *, int *, int *,
487
int *, int *, int *, int *, int *, int *, int *, char **);
488
int G3d_writeHeader(G3D_Map *, int, int, double, double, double, double,
489
double, double, int, int, int, double, double, double,
490
int, int, int, int, int, int, int, int, int, int, int,
492
int G3d_cacheSizeEncode(int, int);
493
int G3d__computeCacheSize(G3D_Map *, int);
494
int G3d_fillHeader(G3D_Map *, int, int, int, int, int, int, int, int, int,
495
int, int, int, int, int, int, int, double, double, double,
496
double, double, double, int, int, int, double, double,
498
/* grass/src/libes/g3d/headerinfo.c */
499
void G3d_getCoordsMap(G3D_Map *, int *, int *, int *);
500
void G3d_getCoordsMapWindow(G3D_Map *, int *, int *, int *);
501
void G3d_getNofTilesMap(G3D_Map *, int *, int *, int *);
502
void G3d_getRegionMap(G3D_Map *, double *, double *, double *, double *,
504
void G3d_getWindowMap(G3D_Map *, double *, double *, double *, double *,
506
void G3d_getTileDimensionsMap(G3D_Map *, int *, int *, int *);
507
int G3d_tileTypeMap(G3D_Map *);
508
int G3d_fileTypeMap(G3D_Map *);
509
int G3d_tilePrecisionMap(G3D_Map *);
510
int G3d_tileUseCacheMap(G3D_Map *);
511
void G3d_printHeader(G3D_Map *);
512
void G3d_getRegionStructMap(G3D_Map *, G3D_Region *);
514
/* grass/src/libes/g3d/index.c */
515
int G3d_flushIndex(G3D_Map *);
516
int G3d_initIndex(G3D_Map *, int);
518
/* grass/src/libes/g3d/retile.c */
519
void G3d_retile(void *, const char *, int, int, int);
521
/* grass/src/libes/g3d/rle.c */
522
int G_rle_count_only(char *, int, int);
523
void G_rle_encode(char *, char *, int, int);
524
void G_rle_decode(char *, char *, int, int, int *, int *);
526
/* grass/src/libes/g3d/tilealloc.c */
527
void *G3d_allocTilesType(G3D_Map *, int, int);
528
void *G3d_allocTiles(G3D_Map *, int);
529
void G3d_freeTiles(void *);
531
/* grass/src/libes/g3d/tileio.c */
532
void *G3d_getTilePtr(G3D_Map *, int);
533
int G3d_tileLoad(G3D_Map *, int);
534
int G3d__removeTile(G3D_Map *, int);
535
float G3d_getFloatRegion(G3D_Map *, int, int, int);
536
double G3d_getDoubleRegion(G3D_Map *, int, int, int);
537
void G3d_getValueRegion(G3D_Map *, int, int, int, void *, int);
539
/* grass/src/libes/g3d/tilemath.c */
540
void G3d_tileIndex2tile(G3D_Map *, int, int *, int *, int *);
541
int G3d_tile2tileIndex(G3D_Map *, int, int, int);
542
void G3d_tileCoordOrigin(G3D_Map *, int, int, int, int *, int *, int *);
543
void G3d_tileIndexOrigin(G3D_Map *, int, int *, int *, int *);
544
void G3d_coord2tileCoord(G3D_Map *, int, int, int, int *, int *, int *, int *,
546
void G3d_coord2tileIndex(G3D_Map *, int, int, int, int *, int *);
547
int G3d_coordInRange(G3D_Map *, int, int, int);
548
int G3d_tileIndexInRange(G3D_Map *, int);
549
int G3d_tileInRange(G3D_Map *, int, int, int);
550
int G3d_computeClippedTileDimensions(G3D_Map *, int, int *, int *, int *,
551
int *, int *, int *);
552
int G3d_isValidLocation(G3D_Map *, double, double, double);
553
void G3d_location2coord(G3D_Map *, double, double, double, int *, int *,
555
/* grass/src/libes/g3d/tilenull.c */
556
void G3d_setNullTileType(G3D_Map *, void *, int);
557
void G3d_setNullTile(G3D_Map *, void *);
559
/* grass/src/libes/g3d/tileread.c */
560
int G3d_readTile(G3D_Map *, int, void *, int);
561
int G3d_readTileFloat(G3D_Map *, int, void *);
562
int G3d_readTileDouble(G3D_Map *, int, void *);
563
int G3d_lockTile(G3D_Map *, int);
564
int G3d_unlockTile(G3D_Map *, int);
565
int G3d_unlockAll(G3D_Map *);
566
void G3d_autolockOn(G3D_Map *);
567
void G3d_autolockOff(G3D_Map *);
568
void G3d_minUnlocked(G3D_Map *, int);
569
int G3d_beginCycle(G3D_Map *);
570
int G3d_endCycle(G3D_Map *);
572
/* grass/src/libes/g3d/tilewrite.c */
573
int G3d_writeTile(G3D_Map *, int, const void *, int);
574
int G3d_writeTileFloat(G3D_Map *, int, const void *);
575
int G3d_writeTileDouble(G3D_Map *, int, const void *);
576
int G3d_flushTile(G3D_Map *, int);
577
int G3d_flushTileCube(G3D_Map *, int, int, int, int, int, int);
578
int G3d_flushTilesInCube(G3D_Map *, int, int, int, int, int, int);
579
int G3d_putFloat(G3D_Map *, int, int, int, float);
580
int G3d_putDouble(G3D_Map *, int, int, int, double);
581
int G3d_putValue(G3D_Map *, int, int, int, const void *, int);
583
/* grass/src/libes/g3d/writeascii.c */
584
void G3d_writeAscii(void *, const char *);
586
#endif /* #ifndef GRASS_G3D_H */