GRASS GIS 8 Programmer's Manual
8.5.0dev(2024)-36359e2344
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
47
typedef
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
61
}
RASTER3D_Region
;
62
63
/*---------------------------------------------------------------------------*/
64
65
struct
RASTER3D_Map
;
66
67
typedef
void
resample_fn
(
struct
RASTER3D_Map
*,
int
,
int
,
int
,
void
*,
int
);
68
69
/*---------------------------------------------------------------------------*/
70
71
typedef
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 */
82
RASTER3D_Region
region
;
83
84
/* window for map */
85
RASTER3D_Region
window
;
86
87
/* resmapling function used for map. default is nearest neighbor */
88
resample_fn
*
resampleFun
;
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" */
95
int
tileX
,
tileY
,
tileZ
;
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 */
120
int
offset
;
121
122
/* pointer to the first index entry in file */
123
long
indexOffset
;
124
125
/* sizeof (long) of the system on which the file is/was written */
126
int
indexLongNbytes
;
127
128
/* max # bytes used in the representation of indices; this is equal to */
129
/* # bytes used in the representation of "indexOffset" */
130
int
indexNbytesUsed
;
131
132
/* pointer to the last entry in the file */
133
int
fileEndPtr
;
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" */
145
int
*
tileLength
;
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 */
156
int
currentIndex
;
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 */
168
struct
FPRange
range
;
169
170
/* some constants stored for efficiency */
171
172
/* number of bytes required to store a single value of "type" */
173
int
numLengthExtern
;
174
175
/* number of bytes required to store a single value of "typeIntern" */
176
int
numLengthIntern
;
177
178
/* see header.c for details */
179
int
clipX
,
clipY
,
clipZ
;
180
int
tileXY
,
tileSize
;
181
int
nxy
,
nTiles
;
182
183
/* mask related information */
184
185
int
useMask
;
/* 1 if mask is used; 0 otherwise */
186
187
}
RASTER3D_Map
;
188
189
/*---------------------------------------------------------------------------*/
190
191
typedef
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
224
}
RASTER3D_cache
;
225
226
/*---------------------------------------------------------------------------*/
227
228
typedef
struct
{
229
230
int
nofNames
;
231
int
*
index
;
232
char
*
active
;
233
int
lastName
;
234
int
lastIndex
;
235
int
lastIndexActive
;
236
237
}
Rast3d_cache_hash
;
238
239
/*---------------------------------------------------------------------------*/
240
241
/*Structures */
242
typedef
struct
_d_interval
{
243
double
low
,
high
;
244
int
inf
;
245
struct
_d_interval
*
next
;
246
}
d_Interval
;
247
248
typedef
struct
_d_mask
{
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
DCELL
*
array
;
261
int
sx
;
262
int
sy
;
263
int
sz
;
264
265
}
RASTER3D_Array_double
;
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 */
raster3d.h
gis.h
DCELL
double DCELL
Definition:
gis.h:629
d_Mask
struct _d_mask d_Mask
write_fn
int write_fn(int, const void *, void *)
Definition:
raster3d.h:254
read_fn
int read_fn(int, void *, void *)
Definition:
raster3d.h:255
RASTER3D_Map
struct RASTER3D_Map RASTER3D_Map
d_Interval
struct _d_interval d_Interval
resample_fn
void resample_fn(struct RASTER3D_Map *, int, int, int, void *, int)
Definition:
raster3d.h:67
raster.h
FPRange
Definition:
raster.h:218
RASTER3D_Array_double
Definition:
raster3d.h:259
RASTER3D_Array_double::sx
int sx
Definition:
raster3d.h:261
RASTER3D_Array_double::sz
int sz
Definition:
raster3d.h:263
RASTER3D_Array_double::array
DCELL * array
Definition:
raster3d.h:260
RASTER3D_Array_double::sy
int sy
Definition:
raster3d.h:262
RASTER3D_Map
Definition:
raster3d.h:71
RASTER3D_Map::index
long * index
Definition:
raster3d.h:142
RASTER3D_Map::tileX
int tileX
Definition:
raster3d.h:95
RASTER3D_Map::tileZ
int tileZ
Definition:
raster3d.h:95
RASTER3D_Map::numLengthExtern
int numLengthExtern
Definition:
raster3d.h:173
RASTER3D_Map::tileY
int tileY
Definition:
raster3d.h:95
RASTER3D_Map::precision
int precision
Definition:
raster3d.h:109
RASTER3D_Map::resampleFun
resample_fn * resampleFun
Definition:
raster3d.h:88
RASTER3D_Map::cacheFileName
char * cacheFileName
Definition:
raster3d.h:163
RASTER3D_Map::nxy
int nxy
Definition:
raster3d.h:181
RASTER3D_Map::indexLongNbytes
int indexLongNbytes
Definition:
raster3d.h:126
RASTER3D_Map::compression
int compression
Definition:
raster3d.h:111
RASTER3D_Map::fileName
char * fileName
Definition:
raster3d.h:74
RASTER3D_Map::tileXY
int tileXY
Definition:
raster3d.h:180
RASTER3D_Map::range
struct FPRange range
Definition:
raster3d.h:168
RASTER3D_Map::cachePosLast
long cachePosLast
Definition:
raster3d.h:164
RASTER3D_Map::useMask
int useMask
Definition:
raster3d.h:185
RASTER3D_Map::useRle
int useRle
Definition:
raster3d.h:114
RASTER3D_Map::clipZ
int clipZ
Definition:
raster3d.h:179
RASTER3D_Map::window
RASTER3D_Region window
Definition:
raster3d.h:85
RASTER3D_Map::region
RASTER3D_Region region
Definition:
raster3d.h:82
RASTER3D_Map::useXdr
int useXdr
Definition:
raster3d.h:116
RASTER3D_Map::currentIndex
int currentIndex
Definition:
raster3d.h:156
RASTER3D_Map::data
char * data
Definition:
raster3d.h:153
RASTER3D_Map::cache
void * cache
Definition:
raster3d.h:161
RASTER3D_Map::clipY
int clipY
Definition:
raster3d.h:179
RASTER3D_Map::tempName
char * tempName
Definition:
raster3d.h:75
RASTER3D_Map::version
int version
Definition:
raster3d.h:72
RASTER3D_Map::mapset
char * mapset
Definition:
raster3d.h:76
RASTER3D_Map::ny
int ny
Definition:
raster3d.h:98
RASTER3D_Map::indexNbytesUsed
int indexNbytesUsed
Definition:
raster3d.h:130
RASTER3D_Map::data_fd
int data_fd
Definition:
raster3d.h:103
RASTER3D_Map::useLzw
int useLzw
Definition:
raster3d.h:112
RASTER3D_Map::unit
char * unit
Definition:
raster3d.h:91
RASTER3D_Map::hasIndex
int hasIndex
Definition:
raster3d.h:136
RASTER3D_Map::type
int type
Definition:
raster3d.h:106
RASTER3D_Map::operation
int operation
Definition:
raster3d.h:79
RASTER3D_Map::clipX
int clipX
Definition:
raster3d.h:179
RASTER3D_Map::nTiles
int nTiles
Definition:
raster3d.h:181
RASTER3D_Map::tileSize
int tileSize
Definition:
raster3d.h:180
RASTER3D_Map::nz
int nz
Definition:
raster3d.h:98
RASTER3D_Map::fileEndPtr
int fileEndPtr
Definition:
raster3d.h:133
RASTER3D_Map::cacheFD
int cacheFD
Definition:
raster3d.h:162
RASTER3D_Map::vertical_unit
int vertical_unit
Definition:
raster3d.h:92
RASTER3D_Map::numLengthIntern
int numLengthIntern
Definition:
raster3d.h:176
RASTER3D_Map::nx
int nx
Definition:
raster3d.h:98
RASTER3D_Map::tileLength
int * tileLength
Definition:
raster3d.h:145
RASTER3D_Map::useCache
int useCache
Definition:
raster3d.h:160
RASTER3D_Map::indexOffset
long indexOffset
Definition:
raster3d.h:123
RASTER3D_Map::typeIntern
int typeIntern
Definition:
raster3d.h:150
RASTER3D_Map::offset
int offset
Definition:
raster3d.h:120
RASTER3D_Region
Definition:
raster3d.h:47
RASTER3D_Region::north
double north
Definition:
raster3d.h:49
RASTER3D_Region::proj
int proj
Definition:
raster3d.h:58
RASTER3D_Region::east
double east
Definition:
raster3d.h:50
RASTER3D_Region::ew_res
double ew_res
Definition:
raster3d.h:56
RASTER3D_Region::zone
int zone
Definition:
raster3d.h:59
RASTER3D_Region::cols
int cols
Definition:
raster3d.h:54
RASTER3D_Region::bottom
double bottom
Definition:
raster3d.h:51
RASTER3D_cache
Definition:
raster3d.h:191
RASTER3D_cache::eltRemoveFunData
void * eltRemoveFunData
Definition:
raster3d.h:213
RASTER3D_cache::names
int * names
Definition:
raster3d.h:197
RASTER3D_cache::nofUnlocked
int nofUnlocked
Definition:
raster3d.h:203
RASTER3D_cache::eltSize
int eltSize
Definition:
raster3d.h:195
RASTER3D_cache::hash
void * hash
Definition:
raster3d.h:221
RASTER3D_cache::autoLock
int autoLock
Definition:
raster3d.h:202
RASTER3D_cache::elts
char * elts
Definition:
raster3d.h:193
RASTER3D_cache::locks
char * locks
Definition:
raster3d.h:199
RASTER3D_cache::next
int * next
Definition:
raster3d.h:206
RASTER3D_cache::nofElts
int nofElts
Definition:
raster3d.h:194
RASTER3D_cache::eltLoadFunData
void * eltLoadFunData
Definition:
raster3d.h:218
RASTER3D_cache::minUnlocked
int minUnlocked
Definition:
raster3d.h:204
RASTER3D_cache::first
int first
Definition:
raster3d.h:207
Rast3d_cache_hash
Definition:
raster3d.h:228
Rast3d_cache_hash::lastIndex
int lastIndex
Definition:
raster3d.h:234
Rast3d_cache_hash::active
char * active
Definition:
raster3d.h:232
Rast3d_cache_hash::index
int * index
Definition:
raster3d.h:231
Rast3d_cache_hash::nofNames
int nofNames
Definition:
raster3d.h:230
Rast3d_cache_hash::lastIndexActive
int lastIndexActive
Definition:
raster3d.h:235
Rast3d_cache_hash::lastName
int lastName
Definition:
raster3d.h:233
_d_interval
Definition:
raster3d.h:242
_d_interval::low
double low
Definition:
raster3d.h:243
_d_interval::inf
int inf
Definition:
raster3d.h:244
_d_interval::next
struct _d_interval * next
Definition:
raster3d.h:245
_d_interval::high
double high
Definition:
raster3d.h:243
_d_mask
Definition:
raster3d.h:248
_d_mask::list
d_Interval * list
Definition:
raster3d.h:249
include
grass
raster3d.h
Generated on Thu Nov 21 2024 07:03:29 for GRASS GIS 8 Programmer's Manual by
1.9.1