1
#ifndef GRASS_RASTER3D_H
2
#define GRASS_RASTER3D_H
5
#include <grass/raster.h>
7
#define RASTER3D_MAP_VERSION 2 /* Second version of the raster 3D map layout.
8
* Old maps withput version information are
9
* defined as version == 1 when reading the header.
12
#define RASTER3D_TILE_SAME_AS_FILE 2
14
#define RASTER3D_NO_COMPRESSION 0
15
#define RASTER3D_COMPRESSION 1
17
#define RASTER3D_MAX_PRECISION -1
19
#define RASTER3D_NO_CACHE 0
20
#define RASTER3D_USE_CACHE_DEFAULT -1
21
#define RASTER3D_USE_CACHE_X -2
22
#define RASTER3D_USE_CACHE_Y -3
23
#define RASTER3D_USE_CACHE_Z -4
24
#define RASTER3D_USE_CACHE_XY -5
25
#define RASTER3D_USE_CACHE_XZ -6
26
#define RASTER3D_USE_CACHE_YZ -7
27
#define RASTER3D_USE_CACHE_XYZ -8
29
#define RASTER3D_DEFAULT_WINDOW NULL
31
#define RASTER3D_DIRECTORY "grid3"
32
#define RASTER3D_CELL_ELEMENT "cell"
33
#define RASTER3D_CATS_ELEMENT "cats"
34
#define RASTER3D_RANGE_ELEMENT "range"
35
#define RASTER3D_HEADER_ELEMENT "cellhd"
36
#define RASTER3D_HISTORY_ELEMENT "hist"
37
#define RASTER3D_COLOR_ELEMENT "color"
38
#define RASTER3D_COLOR2_DIRECTORY "colr2"
39
#define RASTER3D_MASK_MAP "RASTER3D_MASK"
40
#define RASTER3D_WINDOW_ELEMENT "WIND3"
41
#define RASTER3D_DEFAULT_WINDOW_ELEMENT "DEFAULT_WIND3"
42
#define RASTER3D_WINDOW_DATABASE "windows3d"
43
#define RASTER3D_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 RASTER3D_Map *, int, int, int, void *, int);
70
/*---------------------------------------------------------------------------*/
72
typedef struct RASTER3D_Map
74
int version; /* The version of the raster 3D map layout */
80
/* operation performed on map */
81
int operation; /* RASTER3D_WRITE_DATA or RASTER3D_READ_DATA */
84
RASTER3D_Region region;
87
RASTER3D_Region window;
89
/* resmapling function used for map. default is nearest neighbor */
90
resample_fn *resampleFun;
93
char* unit; /* space (U_METER, ...) */
94
int vertical_unit; /* space or time (U_METER, ..., U_YEAR, ...) */
96
/* dimension of a single tile in "cells" */
97
int tileX, tileY, tileZ;
99
/* # of tiles in x, y, and z direction */
102
/* data file specific information */
104
/* file descriptor */
105
int data_fd; /* file descriptor */
107
/* type in which data is stored on file */
108
int type; /* DCELL_TYPE or FCELL_TYPE */
110
/* data concering the compression */
111
int precision; /* RASTER3D_MAX_PRECISION or, 0 .. 23 for float,
112
0 .. 52 for double */
113
int compression; /* RASTER3D_NO_COMPRESSION or RASTER3D_COMPRESSION */
114
int useLzw; /* RASTER3D_USE_LZW or RASTER3D_NO_LZW !!! only kept for backward compatibility */
115
int useRle; /* RASTER3D_USE_RLE or RASTER3D_NO_RLE !!! only kept for backward compatibility */
116
int useXdr; /* RASTER3D_USE_XDR or RASTER3D_NO_XDR !!! only kept for backward compatibility */
118
/* pointer to first tile in file */
121
/* pointer to the first index entry in file */
124
/* sizeof (long) of the system on which the file is/was written */
127
/* max # bytes used in the representation of indices; this is equal to */
128
/* # bytes used in the representation of "indexOffset" */
131
/* pointer to the last entry in the file */
134
/* indicates if index is stored in file; used for RASTER3D_READ_DATA only */
135
int hasIndex; /* RASTER3D_HAS_INDEX or RASTER3D_NO_INDEX */
137
/* information concerning internal storage of data */
139
/* index specific information */
140
/* index[i] == the offset of tile "i" in the data file */
143
/* tileLength[i] == # bytes used to store tile "i" */
146
/* tile specific information */
148
/* type in which data is stored in memory */
149
int typeIntern; /* DCELL_TYPE or FCELL_TYPE */
151
/* in non-cache mode the "data" array is used to store one tile */
154
/* index of tile currently stored in "data"; -1 if none */
157
/* cache related variables */
159
int useCache; /* 1 if cache is used */
160
void *cache; /* pointer to cache structure */
161
int cacheFD; /* file descriptor of cache file -- write mode only */
162
char *cacheFileName; /* filename of cache file -- write mode only */
163
long cachePosLast; /* position of last entry in cache file -- write */
167
struct FPRange range;
169
/* some constants stored for efficiency */
171
/* number of bytes required to store a single value of "type" */
174
/* number of bytes required to store a single value of "typeIntern" */
177
/* see header.c for details */
178
int clipX, clipY, clipZ;
179
int tileXY, tileSize;
182
/* mask related information */
184
int useMask; /* 1 if mask is used; 0 otherwise */
188
/*---------------------------------------------------------------------------*/
193
char *elts; /* ptr to array of elts */
194
int nofElts; /* size of "elts" */
195
int eltSize; /* size of elt in "elts" */
197
int *names; /* name[i] is the name of elts[i] */
199
char *locks; /* lock[i] == 1 iff elts[i] is locked
200
lock[i] == 0 iff elts[i] is unlocked but active
201
lock[i] == 2 iff elts[i] doesn't contain valid data */
202
int autoLock; /* 1 if auto locking is turned on */
203
int nofUnlocked; /* nof tiles which are unlocked */
204
int minUnlocked; /* min nof elts which have to remain unlocked. min = 1 */
206
int *next, *prev; /* prev/next pointers for fifo */
207
int first, last; /* index (into next) of first and last elt in fifo */
208
/* first == -1 iff fifo is empty */
210
int (*eltRemoveFun) (); /* callback activated if the contents of an
211
elt needs to be removed */
212
void *eltRemoveFunData; /* pointer to user data passed along with
214
int (*eltLoadFun) (); /* callback activated to load contents of an elt */
215
void *eltLoadFunData; /* pointer to user data passed along with
218
void *hash; /* ptr to hashTable used to relate external names to
219
internal indices (elts) */
223
/*---------------------------------------------------------------------------*/
237
/*---------------------------------------------------------------------------*/
240
typedef struct _d_interval
244
struct _d_interval *next;
247
typedef struct _d_mask
252
/*---------------------------------------------------------------------------*/
254
typedef int write_fn(int, const void *, void *);
255
typedef int read_fn(int, void *, void *);
257
/*---------------------------------------------------------------------------*/
259
/*============================== Prototypes ================================*/
261
#include <grass/defs/raster3d.h>
263
#endif /* #ifndef GRASS_RASTER3D_H */