GRASS 8 Programmer's Manual 8.6.0dev(2026)-56a9afeb9f
Loading...
Searching...
No Matches
raster3d.h
Go to the documentation of this file.
1#ifndef GRASS_RASTER3D_H
2#define GRASS_RASTER3D_H
3
4#include <grass/gis.h>
5#include <grass/raster.h>
6
7/* Second version of the raster 3D map layout. Old maps without version
8 information are defined as version == 1 when reading the header. */
9#define RASTER3D_MAP_VERSION 2
10
11#define RASTER3D_TILE_SAME_AS_FILE 2
12
13#define RASTER3D_NO_COMPRESSION 0
14#define RASTER3D_COMPRESSION 1
15
16#define RASTER3D_MAX_PRECISION -1
17
18#define RASTER3D_NO_CACHE 0
19#define RASTER3D_USE_CACHE_DEFAULT -1
20#define RASTER3D_USE_CACHE_X -2
21#define RASTER3D_USE_CACHE_Y -3
22#define RASTER3D_USE_CACHE_Z -4
23#define RASTER3D_USE_CACHE_XY -5
24#define RASTER3D_USE_CACHE_XZ -6
25#define RASTER3D_USE_CACHE_YZ -7
26#define RASTER3D_USE_CACHE_XYZ -8
27
28/* NULL pointer, now (int)0 because issues with ctypesgen */
29#define RASTER3D_DEFAULT_WINDOW 0
30
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"
44
45/*---------------------------------------------------------------------------*/
46
47typedef struct {
48
49 double north, south;
50 double east, west;
51 double top, bottom;
52
53 /* dimension of data in "cells"; rows == #x; cols == #y; depths == #z */
54 int rows, cols, depths;
55
56 double ns_res, ew_res, tb_res;
57
58 int proj; /* Projection (see gis.h) */
59 int zone; /* Projection zone (see gis.h) */
60
62
63/*---------------------------------------------------------------------------*/
64
65struct RASTER3D_Map;
66
67typedef void resample_fn(struct RASTER3D_Map *, int, int, int, void *, int);
68
69/*---------------------------------------------------------------------------*/
70
71typedef struct RASTER3D_Map {
72 int version; /* The version of the raster 3D map layout */
73
74 char *fileName;
75 char *tempName;
76 char *mapset;
77
78 /* operation performed on map */
79 int operation; /* RASTER3D_WRITE_DATA or RASTER3D_READ_DATA */
80
81 /* region */
83
84 /* window for map */
86
87 /* resmapling function used for map. default is nearest neighbor */
89
90 /* units */
91 char *unit; /* space (U_METER, ...) */
92 int vertical_unit; /* space or time (U_METER, ..., U_YEAR, ...) */
93
94 /* dimension of a single tile in "cells" */
96
97 /* # of tiles in x, y, and z direction */
98 int nx, ny, nz;
99
100 /* data file specific information */
101
102 /* file descriptor */
103 int data_fd; /* file descriptor */
104
105 /* type in which data is stored on file */
106 int type; /* DCELL_TYPE or FCELL_TYPE */
107
108 /* data concerning the compression */
109 int precision; /* RASTER3D_MAX_PRECISION or, 0 .. 23 for float,
110 0 .. 52 for double */
111 int compression; /* RASTER3D_NO_COMPRESSION or RASTER3D_COMPRESSION */
112 int useLzw; /* RASTER3D_USE_LZW or RASTER3D_NO_LZW !!! only kept for
113 backward compatibility */
114 int useRle; /* RASTER3D_USE_RLE or RASTER3D_NO_RLE !!! only kept for
115 backward compatibility */
116 int useXdr; /* RASTER3D_USE_XDR or RASTER3D_NO_XDR !!! only kept for
117 backward compatibility */
118
119 /* pointer to first tile in file */
121
122 /* pointer to the first index entry in file */
124
125 /* sizeof (long) of the system on which the file is/was written */
127
128 /* max # bytes used in the representation of indices; this is equal to */
129 /* # bytes used in the representation of "indexOffset" */
131
132 /* pointer to the last entry in the file */
134
135 /* indicates if index is stored in file; used for RASTER3D_READ_DATA only */
136 int hasIndex; /* RASTER3D_HAS_INDEX or RASTER3D_NO_INDEX */
137
138 /* information concerning internal storage of data */
139
140 /* index specific information */
141 /* index[i] == the offset of tile "i" in the data file */
142 long *index;
143
144 /* tileLength[i] == # bytes used to store tile "i" */
146
147 /* tile specific information */
148
149 /* type in which data is stored in memory */
150 int typeIntern; /* DCELL_TYPE or FCELL_TYPE */
151
152 /* in non-cache mode the "data" array is used to store one tile */
153 char *data;
154
155 /* index of tile currently stored in "data"; -1 if none */
157
158 /* cache related variables */
159
160 int useCache; /* 1 if cache is used */
161 void *cache; /* pointer to cache structure */
162 int cacheFD; /* file descriptor of cache file -- write mode only */
163 char *cacheFileName; /* filename of cache file -- write mode only */
164 long cachePosLast; /* position of last entry in cache file -- write */
165 /* mode only */
166
167 /* range info */
169
170 /* some constants stored for efficiency */
171
172 /* number of bytes required to store a single value of "type" */
174
175 /* number of bytes required to store a single value of "typeIntern" */
177
178 /* see header.c for details */
182
183 /* mask related information */
184
185 int useMask; /* 1 if mask is used; 0 otherwise */
186
188
189/*---------------------------------------------------------------------------*/
190
191typedef struct {
192
193 char *elts; /* ptr to array of elts */
194 int nofElts; /* size of "elts" */
195 int eltSize; /* size of elt in "elts" */
196
197 int *names; /* name[i] is the name of elts[i] */
198
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 */
205
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 */
209
210 int (*eltRemoveFun)(int, const void *,
211 void *); /* callback activated if the contents of an elt
212 needs to be removed */
213 void *eltRemoveFunData; /* pointer to user data passed along with
214 eltRemoveFun */
215 int (*eltLoadFun)(
216 int, void *,
217 void *); /* callback activated to load contents of an elt */
218 void *eltLoadFunData; /* pointer to user data passed along with
219 eltLoadFun */
220
221 void *hash; /* ptr to hashTable used to relate external names to
222 internal indices (elts) */
223
225
226/*---------------------------------------------------------------------------*/
227
228typedef struct {
229
231 int *index;
232 char *active;
236
238
239/*---------------------------------------------------------------------------*/
240
241/*Structures */
242typedef struct _d_interval {
243 double low, high;
244 int inf;
247
251
252/*---------------------------------------------------------------------------*/
253
254typedef int write_fn(int, const void *, void *);
255typedef int read_fn(int, void *, void *);
256
257/*---------------------------------------------------------------------------*/
258/* for storing values of 3D raster block in a flat array */
259typedef struct {
261 int sx;
262 int sy;
263 int sz;
264
266
267#define RASTER3D_ARRAY_ACCESS(arr, x, y, z) \
268 ((arr)->array[(arr)->sx * (arr)->sy * (z) + (arr)->sx * (y) + (x)])
269
270/*============================== Prototypes ================================*/
271
272#include <grass/defs/raster3d.h>
273
274#endif /* #ifndef GRASS_RASTER3D_H */
double DCELL
Definition gis.h:635
struct _d_mask d_Mask
int write_fn(int, const void *, void *)
Definition raster3d.h:254
int read_fn(int, void *, void *)
Definition raster3d.h:255
struct _d_interval d_Interval
void resample_fn(struct RASTER3D_Map *, int, int, int, void *, int)
Definition raster3d.h:67
long * index
Definition raster3d.h:142
int numLengthExtern
Definition raster3d.h:173
resample_fn * resampleFun
Definition raster3d.h:88
char * cacheFileName
Definition raster3d.h:163
int indexLongNbytes
Definition raster3d.h:126
int compression
Definition raster3d.h:111
char * fileName
Definition raster3d.h:74
struct FPRange range
Definition raster3d.h:168
long cachePosLast
Definition raster3d.h:164
RASTER3D_Region window
Definition raster3d.h:85
RASTER3D_Region region
Definition raster3d.h:82
int currentIndex
Definition raster3d.h:156
char * data
Definition raster3d.h:153
void * cache
Definition raster3d.h:161
char * tempName
Definition raster3d.h:75
char * mapset
Definition raster3d.h:76
int indexNbytesUsed
Definition raster3d.h:130
char * unit
Definition raster3d.h:91
int operation
Definition raster3d.h:79
int vertical_unit
Definition raster3d.h:92
int numLengthIntern
Definition raster3d.h:176
int * tileLength
Definition raster3d.h:145
long indexOffset
Definition raster3d.h:123
double ew_res
Definition raster3d.h:56
double bottom
Definition raster3d.h:51
void * eltRemoveFunData
Definition raster3d.h:213
void * eltLoadFunData
Definition raster3d.h:218
double low
Definition raster3d.h:243
struct _d_interval * next
Definition raster3d.h:245
double high
Definition raster3d.h:243
d_Interval * list
Definition raster3d.h:249