GRASS GIS 7 Programmer's Manual
7.9.dev(2021)-e5379bbd7
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
#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.
10
*/
11
12
#define RASTER3D_TILE_SAME_AS_FILE 2
13
14
#define RASTER3D_NO_COMPRESSION 0
15
#define RASTER3D_COMPRESSION 1
16
17
#define RASTER3D_MAX_PRECISION -1
18
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
28
29
#define RASTER3D_DEFAULT_WINDOW NULL
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
47
typedef
struct
48
{
49
50
double
north,
south
;
51
double
east,
west
;
52
double
top
, bottom;
53
54
/* dimension of data in "cells"; rows == #x; cols == #y; depths == #z */
55
int
rows
, cols, depths;
56
57
double
ns_res, ew_res,
tb_res
;
58
59
int
proj
;
/* Projection (see gis.h) */
60
int
zone
;
/* Projection zone (see gis.h) */
61
62
}
RASTER3D_Region
;
63
64
/*---------------------------------------------------------------------------*/
65
66
struct
RASTER3D_Map
;
67
68
typedef
void
resample_fn
(
struct
RASTER3D_Map
*,
int
,
int
,
int
,
void
*,
int
);
69
70
/*---------------------------------------------------------------------------*/
71
72
typedef
struct
RASTER3D_Map
73
{
74
int
version
;
/* The version of the raster 3D map layout */
75
76
char
*
fileName
;
77
char
*
tempName
;
78
char
*
mapset
;
79
80
/* operation performed on map */
81
int
operation
;
/* RASTER3D_WRITE_DATA or RASTER3D_READ_DATA */
82
83
/* region */
84
RASTER3D_Region
region
;
85
86
/* window for map */
87
RASTER3D_Region
window
;
88
89
/* resmapling function used for map. default is nearest neighbor */
90
resample_fn
*
resampleFun
;
91
92
/* units */
93
char
*
unit
;
/* space (U_METER, ...) */
94
int
vertical_unit
;
/* space or time (U_METER, ..., U_YEAR, ...) */
95
96
/* dimension of a single tile in "cells" */
97
int
tileX
,
tileY
,
tileZ
;
98
99
/* # of tiles in x, y, and z direction */
100
int
nx
,
ny
,
nz
;
101
102
/* data file specific information */
103
104
/* file descriptor */
105
int
data_fd
;
/* file descriptor */
106
107
/* type in which data is stored on file */
108
int
type
;
/* DCELL_TYPE or FCELL_TYPE */
109
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 */
117
118
/* pointer to first tile in file */
119
int
offset
;
120
121
/* pointer to the first index entry in file */
122
long
indexOffset
;
123
124
/* sizeof (long) of the system on which the file is/was written */
125
int
indexLongNbytes
;
126
127
/* max # bytes used in the representation of indices; this is equal to */
128
/* # bytes used in the representation of "indexOffset" */
129
int
indexNbytesUsed
;
130
131
/* pointer to the last entry in the file */
132
int
fileEndPtr
;
133
134
/* indicates if index is stored in file; used for RASTER3D_READ_DATA only */
135
int
hasIndex
;
/* RASTER3D_HAS_INDEX or RASTER3D_NO_INDEX */
136
137
/* information concerning internal storage of data */
138
139
/* index specific information */
140
/* index[i] == the offset of tile "i" in the data file */
141
long
*
index
;
142
143
/* tileLength[i] == # bytes used to store tile "i" */
144
int
*
tileLength
;
145
146
/* tile specific information */
147
148
/* type in which data is stored in memory */
149
int
typeIntern
;
/* DCELL_TYPE or FCELL_TYPE */
150
151
/* in non-cache mode the "data" array is used to store one tile */
152
char
*
data
;
153
154
/* index of tile currently stored in "data"; -1 if none */
155
int
currentIndex
;
156
157
/* cache related variables */
158
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 */
164
/* mode only */
165
166
/* range info */
167
struct
FPRange
range
;
168
169
/* some constants stored for efficiency */
170
171
/* number of bytes required to store a single value of "type" */
172
int
numLengthExtern
;
173
174
/* number of bytes required to store a single value of "typeIntern" */
175
int
numLengthIntern
;
176
177
/* see header.c for details */
178
int
clipX
,
clipY
,
clipZ
;
179
int
tileXY
,
tileSize
;
180
int
nxy
,
nTiles
;
181
182
/* mask related information */
183
184
int
useMask
;
/* 1 if mask is used; 0 otherwise */
185
186
}
RASTER3D_Map
;
187
188
/*---------------------------------------------------------------------------*/
189
190
typedef
struct
191
{
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) ();
/* callback activated if the contents of an
211
elt needs to be removed */
212
void
*
eltRemoveFunData
;
/* pointer to user data passed along with
213
eltRemoveFun */
214
int (*eltLoadFun) ();
/* callback activated to load contents of an elt */
215
void
*
eltLoadFunData
;
/* pointer to user data passed along with
216
eltLoadFun */
217
218
void
*
hash
;
/* ptr to hashTable used to relate external names to
219
internal indices (elts) */
220
221
}
RASTER3D_cache
;
222
223
/*---------------------------------------------------------------------------*/
224
225
typedef
struct
226
{
227
228
int
nofNames
;
229
int
*
index
;
230
char
*
active
;
231
int
lastName
;
232
int
lastIndex
;
233
int
lastIndexActive
;
234
235
}
Rast3d_cache_hash
;
236
237
/*---------------------------------------------------------------------------*/
238
239
/*Structures */
240
typedef
struct
_d_interval
241
{
242
double
low
, high;
243
int
inf
;
244
struct
_d_interval
*
next
;
245
}
d_Interval
;
246
247
typedef
struct
_d_mask
248
{
249
d_Interval
*
list
;
250
}
d_Mask
;
251
252
/*---------------------------------------------------------------------------*/
253
254
typedef
int
write_fn
(
int
,
const
void
*,
void
*);
255
typedef
int
read_fn
(
int
,
void
*,
void
*);
256
257
/*---------------------------------------------------------------------------*/
258
/* for storing values of 3D raster block in a flat array */
259
typedef
struct
260
{
261
DCELL
*
array
;
262
int
sx
;
263
int
sy
;
264
int
sz
;
265
266
}
RASTER3D_Array_double
;
267
268
#define RASTER3D_ARRAY_ACCESS(arr, x, y, z) \
269
((arr)->array[(arr)->sx * (arr)->sy * (z) + (arr)->sx * (y) + (x)])
270
271
/*============================== Prototypes ================================*/
272
273
#include <
grass/defs/raster3d.h
>
274
275
#endif
/* #ifndef GRASS_RASTER3D_H */
RASTER3D_Map::numLengthIntern
int numLengthIntern
Definition:
raster3d.h:175
RASTER3D_cache::locks
char * locks
Definition:
raster3d.h:199
RASTER3D_Map::useMask
int useMask
Definition:
raster3d.h:184
RASTER3D_Map::numLengthExtern
int numLengthExtern
Definition:
raster3d.h:172
Rast3d_cache_hash::lastIndex
int lastIndex
Definition:
raster3d.h:232
Rast3d_cache_hash
Definition:
raster3d.h:225
RASTER3D_Region::proj
int proj
Definition:
raster3d.h:59
RASTER3D_Map::cache
void * cache
Definition:
raster3d.h:160
RASTER3D_Region::top
double top
Definition:
raster3d.h:52
RASTER3D_Map::useLzw
int useLzw
Definition:
raster3d.h:114
RASTER3D_Map::cachePosLast
long cachePosLast
Definition:
raster3d.h:163
d_Mask
struct _d_mask d_Mask
RASTER3D_Map::ny
int ny
Definition:
raster3d.h:100
RASTER3D_Map::nTiles
int nTiles
Definition:
raster3d.h:180
RASTER3D_Array_double
Definition:
raster3d.h:259
RASTER3D_Map::indexOffset
long indexOffset
Definition:
raster3d.h:122
RASTER3D_Region::tb_res
double tb_res
Definition:
raster3d.h:57
RASTER3D_Map::fileName
char * fileName
Definition:
raster3d.h:76
RASTER3D_Map::clipZ
int clipZ
Definition:
raster3d.h:178
RASTER3D_Map::fileEndPtr
int fileEndPtr
Definition:
raster3d.h:132
RASTER3D_cache::hash
void * hash
Definition:
raster3d.h:218
RASTER3D_Map::hasIndex
int hasIndex
Definition:
raster3d.h:135
RASTER3D_Map::type
int type
Definition:
raster3d.h:108
RASTER3D_Map::typeIntern
int typeIntern
Definition:
raster3d.h:149
DCELL
double DCELL
Definition:
gis.h:603
Rast3d_cache_hash::lastName
int lastName
Definition:
raster3d.h:231
_d_interval::low
double low
Definition:
raster3d.h:242
RASTER3D_cache::eltSize
int eltSize
Definition:
raster3d.h:195
RASTER3D_Map::operation
int operation
Definition:
raster3d.h:81
resample_fn
void resample_fn(struct RASTER3D_Map *, int, int, int, void *, int)
Definition:
raster3d.h:68
raster3d.h
RASTER3D_Map::useCache
int useCache
Definition:
raster3d.h:159
RASTER3D_Map::tileLength
int * tileLength
Definition:
raster3d.h:144
RASTER3D_Map::version
int version
Definition:
raster3d.h:74
RASTER3D_cache::nofElts
int nofElts
Definition:
raster3d.h:194
_d_mask
Definition:
raster3d.h:247
RASTER3D_Map::nxy
int nxy
Definition:
raster3d.h:180
RASTER3D_cache::nofUnlocked
int nofUnlocked
Definition:
raster3d.h:203
_d_interval
Definition:
raster3d.h:240
RASTER3D_Map::nz
int nz
Definition:
raster3d.h:100
_d_interval::inf
int inf
Definition:
raster3d.h:243
RASTER3D_Map::offset
int offset
Definition:
raster3d.h:119
_d_mask::list
d_Interval * list
Definition:
raster3d.h:249
raster.h
RASTER3D_Array_double::sz
int sz
Definition:
raster3d.h:264
gis.h
d_Interval
struct _d_interval d_Interval
RASTER3D_Map::currentIndex
int currentIndex
Definition:
raster3d.h:155
RASTER3D_Map::tempName
char * tempName
Definition:
raster3d.h:77
RASTER3D_Map
Definition:
raster3d.h:72
RASTER3D_Array_double::sx
int sx
Definition:
raster3d.h:262
RASTER3D_cache::minUnlocked
int minUnlocked
Definition:
raster3d.h:204
RASTER3D_Map::tileX
int tileX
Definition:
raster3d.h:97
RASTER3D_cache::autoLock
int autoLock
Definition:
raster3d.h:202
RASTER3D_Map::index
long * index
Definition:
raster3d.h:141
RASTER3D_Map::useXdr
int useXdr
Definition:
raster3d.h:116
RASTER3D_Region::west
double west
Definition:
raster3d.h:51
RASTER3D_Map::data
char * data
Definition:
raster3d.h:152
RASTER3D_Map::indexLongNbytes
int indexLongNbytes
Definition:
raster3d.h:125
FPRange
Definition:
raster.h:233
RASTER3D_cache
Definition:
raster3d.h:190
RASTER3D_Map::range
struct FPRange range
Definition:
raster3d.h:167
RASTER3D_Map::compression
int compression
Definition:
raster3d.h:113
write_fn
int write_fn(int, const void *, void *)
Definition:
raster3d.h:254
RASTER3D_Map::cacheFD
int cacheFD
Definition:
raster3d.h:161
RASTER3D_Map::tileXY
int tileXY
Definition:
raster3d.h:179
RASTER3D_Map::vertical_unit
int vertical_unit
Definition:
raster3d.h:94
RASTER3D_Map::data_fd
int data_fd
Definition:
raster3d.h:105
RASTER3D_Array_double::sy
int sy
Definition:
raster3d.h:263
RASTER3D_Map::unit
char * unit
Definition:
raster3d.h:93
Rast3d_cache_hash::nofNames
int nofNames
Definition:
raster3d.h:228
RASTER3D_Map::cacheFileName
char * cacheFileName
Definition:
raster3d.h:162
RASTER3D_cache::names
int * names
Definition:
raster3d.h:197
Rast3d_cache_hash::lastIndexActive
int lastIndexActive
Definition:
raster3d.h:233
RASTER3D_Map::precision
int precision
Definition:
raster3d.h:111
Rast3d_cache_hash::active
char * active
Definition:
raster3d.h:230
_d_interval::next
struct _d_interval * next
Definition:
raster3d.h:244
RASTER3D_Map::indexNbytesUsed
int indexNbytesUsed
Definition:
raster3d.h:129
RASTER3D_Map::clipY
int clipY
Definition:
raster3d.h:178
RASTER3D_Map::tileZ
int tileZ
Definition:
raster3d.h:97
RASTER3D_Map::region
RASTER3D_Region region
Definition:
raster3d.h:84
RASTER3D_Map::tileY
int tileY
Definition:
raster3d.h:97
RASTER3D_Region
Definition:
raster3d.h:47
RASTER3D_Array_double::array
DCELL * array
Definition:
raster3d.h:261
RASTER3D_Map::tileSize
int tileSize
Definition:
raster3d.h:179
read_fn
int read_fn(int, void *, void *)
Definition:
raster3d.h:255
RASTER3D_Region::rows
int rows
Definition:
raster3d.h:55
RASTER3D_Map::nx
int nx
Definition:
raster3d.h:100
RASTER3D_cache::eltRemoveFunData
void * eltRemoveFunData
Definition:
raster3d.h:212
RASTER3D_cache::elts
char * elts
Definition:
raster3d.h:193
RASTER3D_Map::mapset
char * mapset
Definition:
raster3d.h:78
RASTER3D_Map::resampleFun
resample_fn * resampleFun
Definition:
raster3d.h:90
RASTER3D_Map::clipX
int clipX
Definition:
raster3d.h:178
RASTER3D_Map::useRle
int useRle
Definition:
raster3d.h:115
RASTER3D_Region::south
double south
Definition:
raster3d.h:50
RASTER3D_Region::zone
int zone
Definition:
raster3d.h:60
RASTER3D_Map::window
RASTER3D_Region window
Definition:
raster3d.h:87
RASTER3D_Map
struct RASTER3D_Map RASTER3D_Map
Rast3d_cache_hash::index
int * index
Definition:
raster3d.h:229
RASTER3D_cache::eltLoadFunData
void * eltLoadFunData
Definition:
raster3d.h:215
include
grass
raster3d.h
Generated on Mon May 31 2021 05:21:31 for GRASS GIS 7 Programmer's Manual by
1.8.13