GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-602118adcc
raster3d/header.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <sys/types.h>
4 #include <unistd.h>
5 #include <grass/raster3d.h>
6 #include <grass/glocale.h>
7 #include "raster3d_intern.h"
8 
9 /*---------------------------------------------------------------------------*/
10 
13 void *xdr;
15 
16 /*---------------------------------------------------------------------------*/
17 
18 #define RASTER3D_HEADER_TILEX "TileDimensionX"
19 #define RASTER3D_HEADER_TILEY "TileDimensionY"
20 #define RASTER3D_HEADER_TILEZ "TileDimensionZ"
21 #define RASTER3D_HEADER_TYPE "CellType"
22 #define RASTER3D_HEADER_COMPRESSION "useCompression"
23 #define RASTER3D_HEADER_USERLE "useRle"
24 #define RASTER3D_HEADER_USELZW "useLzw"
25 #define RASTER3D_HEADER_PRECISION "Precision"
26 #define RASTER3D_HEADER_DATA_OFFSET "nofHeaderBytes"
27 #define RASTER3D_HEADER_USEXDR "useXdr"
28 #define RASTER3D_HEADER_HASINDEX "hasIndex"
29 #define RASTER3D_HEADER_UNIT "Units"
30 #define RASTER3D_HEADER_VERTICAL_UNIT "VerticalUnits"
31 #define RASTER3D_HEADER_VERSION "Version"
32 
33 /*---------------------------------------------------------------------------*/
34 
35 static int Rast3d__readHeader(
36  struct Key_Value *headerKeys, int *proj, int *zone, double *north,
37  double *south, double *east, double *west, double *top, double *bottom,
38  int *rows, int *cols, int *depths, double *ew_res, double *ns_res,
39  double *tb_res, int *tileX, int *tileY, int *tileZ, int *type,
40  int *compression, int *useRle, int *useLzw, int *precision, int *dataOffset,
41  int *useXdr, int *hasIndex, char **unit, int *vertical_unit, int *version)
42 {
43  int returnVal;
44  int (*headerInt)(struct Key_Value *, const char *, int *),
45  (*headerDouble)(struct Key_Value *, const char *, double *),
46  (*headerValue)(struct Key_Value *, const char *, char *, char *, int,
47  int, int *);
48  int (*headerString)(struct Key_Value *, const char *, char **);
49 
50  headerDouble = Rast3d_key_get_double;
51  headerInt = Rast3d_key_get_int;
52  headerString = Rast3d_key_get_string;
53  headerValue = Rast3d_key_get_value;
54 
55  returnVal = 1;
56  returnVal &= headerInt(headerKeys, RASTER3D_REGION_PROJ, proj);
57  returnVal &= headerInt(headerKeys, RASTER3D_REGION_ZONE, zone);
58 
59  returnVal &= headerDouble(headerKeys, RASTER3D_REGION_NORTH, north);
60  returnVal &= headerDouble(headerKeys, RASTER3D_REGION_SOUTH, south);
61  returnVal &= headerDouble(headerKeys, RASTER3D_REGION_EAST, east);
62  returnVal &= headerDouble(headerKeys, RASTER3D_REGION_WEST, west);
63  returnVal &= headerDouble(headerKeys, RASTER3D_REGION_TOP, top);
64  returnVal &= headerDouble(headerKeys, RASTER3D_REGION_BOTTOM, bottom);
65 
66  returnVal &= headerInt(headerKeys, RASTER3D_REGION_ROWS, rows);
67  returnVal &= headerInt(headerKeys, RASTER3D_REGION_COLS, cols);
68  returnVal &= headerInt(headerKeys, RASTER3D_REGION_DEPTHS, depths);
69 
70  returnVal &= headerDouble(headerKeys, RASTER3D_REGION_NSRES, ns_res);
71  returnVal &= headerDouble(headerKeys, RASTER3D_REGION_EWRES, ew_res);
72  returnVal &= headerDouble(headerKeys, RASTER3D_REGION_TBRES, tb_res);
73 
74  returnVal &= headerInt(headerKeys, RASTER3D_HEADER_TILEX, tileX);
75  returnVal &= headerInt(headerKeys, RASTER3D_HEADER_TILEY, tileY);
76  returnVal &= headerInt(headerKeys, RASTER3D_HEADER_TILEZ, tileZ);
77 
78  returnVal &= headerValue(headerKeys, RASTER3D_HEADER_TYPE, "double",
79  "float", DCELL_TYPE, FCELL_TYPE, type);
80  returnVal &= headerValue(headerKeys, RASTER3D_HEADER_COMPRESSION, "0", "1",
81  0, 1, compression);
82  returnVal &=
83  headerValue(headerKeys, RASTER3D_HEADER_USERLE, "0", "1", 0, 1, useRle);
84  returnVal &=
85  headerValue(headerKeys, RASTER3D_HEADER_USELZW, "0", "1", 0, 1, useLzw);
86 
87  returnVal &= headerInt(headerKeys, RASTER3D_HEADER_PRECISION, precision);
88  returnVal &= headerInt(headerKeys, RASTER3D_HEADER_DATA_OFFSET, dataOffset);
89 
90  returnVal &=
91  headerValue(headerKeys, RASTER3D_HEADER_USEXDR, "0", "1", 0, 1, useXdr);
92  returnVal &= headerValue(headerKeys, RASTER3D_HEADER_HASINDEX, "0", "1", 0,
93  1, hasIndex);
94  returnVal &= headerString(headerKeys, RASTER3D_HEADER_UNIT, unit);
95  /* New format and API changes */
96  if (!headerInt(headerKeys, RASTER3D_HEADER_VERTICAL_UNIT, vertical_unit))
97  G_warning("You are using an old raster3d data format, the vertical "
98  "unit is undefined. "
99  "Please use r3.support to define the vertical unit to avoid "
100  "this warning.");
101  /* New format and API changes */
102  if (!headerInt(headerKeys, RASTER3D_HEADER_VERSION, version)) {
103  G_warning("You are using an old raster3d data format, the version is "
104  "undefined.");
105  *version = 1;
106  }
107 
108  if (returnVal)
109  return 1;
110 
111  Rast3d_error("Rast3d_readWriteHeader: error reading/writing header");
112  return 0;
113 }
114 
115 static int Rast3d__writeHeader(
116  struct Key_Value *headerKeys, int *proj, int *zone, double *north,
117  double *south, double *east, double *west, double *top, double *bottom,
118  int *rows, int *cols, int *depths, double *ew_res, double *ns_res,
119  double *tb_res, int *tileX, int *tileY, int *tileZ, int *type,
120  int *compression, int *useRle, int *useLzw, int *precision, int *dataOffset,
121  int *useXdr, int *hasIndex, char **unit, int *vertical_unit, int *version)
122 {
123  int returnVal;
124  int (*headerInt)(struct Key_Value *, const char *, const int *),
125  (*headerDouble)(struct Key_Value *, const char *, const double *),
126  (*headerValue)(struct Key_Value *, const char *, const char *,
127  const char *, int, int, const int *);
128  int (*headerString)(struct Key_Value *, const char *, char *const *);
129 
130  headerDouble = Rast3d_key_set_double;
131  headerInt = Rast3d_key_set_int;
132  headerString = Rast3d_key_set_string;
133  headerValue = Rast3d_key_set_value;
134 
135  returnVal = 1;
136  returnVal &= headerInt(headerKeys, RASTER3D_REGION_PROJ, proj);
137  returnVal &= headerInt(headerKeys, RASTER3D_REGION_ZONE, zone);
138 
139  returnVal &= headerDouble(headerKeys, RASTER3D_REGION_NORTH, north);
140  returnVal &= headerDouble(headerKeys, RASTER3D_REGION_SOUTH, south);
141  returnVal &= headerDouble(headerKeys, RASTER3D_REGION_EAST, east);
142  returnVal &= headerDouble(headerKeys, RASTER3D_REGION_WEST, west);
143  returnVal &= headerDouble(headerKeys, RASTER3D_REGION_TOP, top);
144  returnVal &= headerDouble(headerKeys, RASTER3D_REGION_BOTTOM, bottom);
145 
146  returnVal &= headerInt(headerKeys, RASTER3D_REGION_ROWS, rows);
147  returnVal &= headerInt(headerKeys, RASTER3D_REGION_COLS, cols);
148  returnVal &= headerInt(headerKeys, RASTER3D_REGION_DEPTHS, depths);
149 
150  returnVal &= headerDouble(headerKeys, RASTER3D_REGION_NSRES, ns_res);
151  returnVal &= headerDouble(headerKeys, RASTER3D_REGION_EWRES, ew_res);
152  returnVal &= headerDouble(headerKeys, RASTER3D_REGION_TBRES, tb_res);
153 
154  returnVal &= headerInt(headerKeys, RASTER3D_HEADER_TILEX, tileX);
155  returnVal &= headerInt(headerKeys, RASTER3D_HEADER_TILEY, tileY);
156  returnVal &= headerInt(headerKeys, RASTER3D_HEADER_TILEZ, tileZ);
157 
158  returnVal &= headerValue(headerKeys, RASTER3D_HEADER_TYPE, "double",
159  "float", DCELL_TYPE, FCELL_TYPE, type);
160  returnVal &= headerValue(headerKeys, RASTER3D_HEADER_COMPRESSION, "0", "1",
161  0, 1, compression);
162  returnVal &=
163  headerValue(headerKeys, RASTER3D_HEADER_USERLE, "0", "1", 0, 1, useRle);
164  returnVal &=
165  headerValue(headerKeys, RASTER3D_HEADER_USELZW, "0", "1", 0, 1, useLzw);
166 
167  returnVal &= headerInt(headerKeys, RASTER3D_HEADER_PRECISION, precision);
168  returnVal &= headerInt(headerKeys, RASTER3D_HEADER_DATA_OFFSET, dataOffset);
169 
170  returnVal &=
171  headerValue(headerKeys, RASTER3D_HEADER_USEXDR, "0", "1", 0, 1, useXdr);
172  returnVal &= headerValue(headerKeys, RASTER3D_HEADER_HASINDEX, "0", "1", 0,
173  1, hasIndex);
174  returnVal &= headerString(headerKeys, RASTER3D_HEADER_UNIT, unit);
175  /* New format and API changes */
176  if (!headerInt(headerKeys, RASTER3D_HEADER_VERTICAL_UNIT, vertical_unit))
177  G_warning("You are using an old raster3d data format, the vertical "
178  "unit is undefined. "
179  "Please use r3.support to define the vertical unit to avoid "
180  "this warning.");
181  /* New format and API changes */
182  if (!headerInt(headerKeys, RASTER3D_HEADER_VERSION, version)) {
183  G_warning("You are using an old raster3d data format, the version is "
184  "undefined.");
185  *version = 1;
186  }
187 
188  if (returnVal)
189  return 1;
190 
191  Rast3d_error("Rast3d_readWriteHeader: error reading/writing header");
192  return 0;
193 }
194 
195 /*---------------------------------------------------------------------------*/
196 
197 int Rast3d_read_header(RASTER3D_Map *map, int *proj, int *zone, double *north,
198  double *south, double *east, double *west, double *top,
199  double *bottom, int *rows, int *cols, int *depths,
200  double *ew_res, double *ns_res, double *tb_res,
201  int *tileX, int *tileY, int *tileZ, int *type,
202  int *compression, int *useRle, int *useLzw,
203  int *precision, int *dataOffset, int *useXdr,
204  int *hasIndex, char **unit, int *vertical_unit,
205  int *version)
206 {
207  struct Key_Value *headerKeys;
208  char path[GPATH_MAX];
209 
211  if (access(path, R_OK) != 0) {
212  Rast3d_error("Rast3d_read_header: unable to find [%s]", path);
213  return 0;
214  }
215 
216  headerKeys = G_read_key_value_file(path);
217 
218  if (!Rast3d__readHeader(headerKeys, proj, zone, north, south, east, west,
219  top, bottom, rows, cols, depths, ew_res, ns_res,
220  tb_res, tileX, tileY, tileZ, type, compression,
221  useRle, useLzw, precision, dataOffset, useXdr,
222  hasIndex, unit, vertical_unit, version)) {
223  Rast3d_error(
224  "Rast3d_read_header: error extracting header key(s) of file %s",
225  path);
226  return 0;
227  }
228 
229  G_free_key_value(headerKeys);
230  return 1;
231 }
232 
233 /*---------------------------------------------------------------------------*/
234 
235 int Rast3d_write_header(RASTER3D_Map *map, int proj, int zone, double north,
236  double south, double east, double west, double top,
237  double bottom, int rows, int cols, int depths,
238  double ew_res, double ns_res, double tb_res, int tileX,
239  int tileY, int tileZ, int type, int compression,
240  int useRle, int useLzw, int precision, int dataOffset,
241  int useXdr, int hasIndex, char *unit, int vertical_unit,
242  int version)
243 {
244  struct Key_Value *headerKeys;
245  char path[GPATH_MAX];
246 
247  headerKeys = G_create_key_value();
248 
249  if (!Rast3d__writeHeader(
250  headerKeys, &proj, &zone, &north, &south, &east, &west, &top,
251  &bottom, &rows, &cols, &depths, &ew_res, &ns_res, &tb_res, &tileX,
252  &tileY, &tileZ, &type, &compression, &useRle, &useLzw, &precision,
253  &dataOffset, &useXdr, &hasIndex, &unit, &vertical_unit, &version)) {
254  Rast3d_error(
255  "Rast3d_write_header: error adding header key(s) for file %s",
256  path);
257  return 0;
258  }
259 
262  G_write_key_value_file(path, headerKeys);
263 
264  G_free_key_value(headerKeys);
265 
266  return 1;
267 }
268 
269 /*---------------------------------------------------------------------------*/
270 
272 {
273  if (!Rast3d_write_header(
274  map, map->region.proj, map->region.zone, map->region.north,
275  map->region.south, map->region.east, map->region.west,
276  map->region.top, map->region.bottom, map->region.rows,
277  map->region.cols, map->region.depths, map->region.ew_res,
278  map->region.ns_res, map->region.tb_res, map->tileX, map->tileY,
279  map->tileZ, map->type, map->compression, map->useRle, map->useLzw,
280  map->precision, map->offset, map->useXdr, map->hasIndex, map->unit,
281  map->vertical_unit, map->version)) {
282  G_warning(_("Unable to write header for 3D raster map <%s>"),
283  map->fileName);
284  return 0;
285  }
286  return 1;
287 }
288 
289 /*---------------------------------------------------------------------------*/
290 
291 /*!
292  * \brief
293  *
294  * Returns a number
295  * which encodes multiplicity <em>n</em> of <em>cacheCode</em>. This value can
296  * be used to specify the size of the cache. If <em>cacheCode</em> is the size
297  * (in tiles) of the cache the function returns <em>cacheCode * n</em>. If
298  * <em>cacheCode</em> is RASTER3D_USE_CACHE_DEFAULT the function returns
299  * RASTER3D_USE_CACHE_DEFAULT.
300  * If <em>cacheCode</em> is RASTER3D_USE_CACHE_??? the function returns a value
301  * encoding RASTER3D_USE_CACHE_??? and <em>n</em>. Here RASTER3D_USE_CACHE_???
302  * is one of RASTER3D_USE_CACHE_X, RASTER3D_USE_CACHE_Y, RASTER3D_USE_CACHE_Z,
303  * RASTER3D_USE_CACHE_XY, RASTER3D_USE_CACHE_XZ, RASTER3D_USE_CACHE_YZ, or
304  * RASTER3D_USE_CACHE_XYZ, where e.g. RASTER3D_USE_CACHE_X specifies that the
305  * cache should store as many tiles as there exist in one row along the x-axis
306  * of the tile cube, and RASTER3D_USE_CACHE_XY specifies that the cache should
307  * store as many tiles as there exist in one slice of the tile cube with
308  * constant Z coordinate.
309  *
310  * \param cacheCode
311  * \param n
312  * \return int
313  */
314 
315 int Rast3d_cache_size_encode(int cacheCode, int n)
316 {
317  if (cacheCode >= RASTER3D_NO_CACHE)
318  return cacheCode * n;
319  if (cacheCode == RASTER3D_USE_CACHE_DEFAULT)
320  return cacheCode;
321 
322  if (cacheCode < RASTER3D_USE_CACHE_XYZ)
323  Rast3d_fatal_error("Rast3d_cache_size_encode: invalid cache code");
324 
325  return n * (-10) + cacheCode;
326 }
327 
328 /*---------------------------------------------------------------------------*/
329 
330 int Rast3d__compute_cache_size(RASTER3D_Map *map, int cacheCode)
331 {
332  int n, size;
333 
334  if (cacheCode >= RASTER3D_NO_CACHE)
335  return cacheCode;
336  if (cacheCode == RASTER3D_USE_CACHE_DEFAULT)
337  return RASTER3D_MIN(g3d_cache_default, map->nTiles);
338 
339  n = -(cacheCode / 10);
340  n = RASTER3D_MAX(1, n);
341  cacheCode = -((-cacheCode) % 10);
342 
343  if (cacheCode == RASTER3D_USE_CACHE_X)
344  size = map->nx * n;
345  else if (cacheCode == RASTER3D_USE_CACHE_Y)
346  size = map->ny * n;
347  else if (cacheCode == RASTER3D_USE_CACHE_Z)
348  size = map->nz * n;
349  else if (cacheCode == RASTER3D_USE_CACHE_XY)
350  size = map->nxy * n;
351  else if (cacheCode == RASTER3D_USE_CACHE_XZ)
352  size = map->nx * map->nz * n;
353  else if (cacheCode == RASTER3D_USE_CACHE_YZ)
354  size = map->ny * map->nz * n;
355  else if (cacheCode == RASTER3D_USE_CACHE_XYZ)
356  size = map->nTiles;
357  else
358  Rast3d_fatal_error("Rast3d__compute_cache_size: invalid cache code");
359 
360  return RASTER3D_MIN(size, map->nTiles);
361 }
362 
363 /*---------------------------------------------------------------------------*/
364 
365 /* this function does actually more than filling the header fields of the */
366 /* RASTER3D-Map structure. It also allocates memory for compression and xdr, */
367 /* and initializes the index and cache. This function should be taken apart. */
368 
369 int Rast3d_fill_header(RASTER3D_Map *map, int operation, int compression,
370  int useRle, int useLzw, int type, int precision,
371  int cache, int hasIndex, int useXdr, int typeIntern,
372  int nofHeaderBytes, int tileX, int tileY, int tileZ,
373  int proj, int zone, double north, double south,
374  double east, double west, double top, double bottom,
375  int rows, int cols, int depths, double ew_res,
376  double ns_res, double tb_res, char *unit,
377  int vertical_unit, int version)
378 {
379  if (!RASTER3D_VALID_OPERATION(operation))
380  Rast3d_fatal_error("Rast3d_fill_header: operation not valid\n");
381 
382  map->version = version;
383 
384  map->operation = operation;
385 
386  map->unit = G_store(unit);
387  map->vertical_unit = vertical_unit;
388 
389  map->region.proj = proj;
390  map->region.zone = zone;
391 
392  map->region.north = north;
393  map->region.south = south;
394  map->region.east = east;
395  map->region.west = west;
396  map->region.top = top;
397  map->region.bottom = bottom;
398 
399  map->region.rows = rows;
400  map->region.cols = cols;
401  map->region.depths = depths;
402 
403  map->region.ew_res = ew_res;
404  map->region.ns_res = ns_res;
405  map->region.tb_res = tb_res;
406 
407  Rast3d_adjust_region(&(map->region));
408 
409  map->tileX = tileX;
410  map->tileY = tileY;
411  map->tileZ = tileZ;
412  map->tileXY = map->tileX * map->tileY;
413  map->tileSize = map->tileXY * map->tileZ;
414 
415  map->nx = (map->region.cols - 1) / tileX + 1;
416  map->ny = (map->region.rows - 1) / tileY + 1;
417  map->nz = (map->region.depths - 1) / tileZ + 1;
418  map->nxy = map->nx * map->ny;
419  map->nTiles = map->nxy * map->nz;
420 
421  if ((map->region.cols) % map->tileX != 0)
422  map->clipX = map->nx - 1;
423  else
424  map->clipX = -1;
425  if ((map->region.rows) % map->tileY != 0)
426  map->clipY = map->ny - 1;
427  else
428  map->clipY = -1;
429  if ((map->region.depths) % map->tileZ != 0)
430  map->clipZ = map->nz - 1;
431  else
432  map->clipZ = -1;
433 
434  if ((type != FCELL_TYPE) && (type != DCELL_TYPE))
435  Rast3d_fatal_error("Rast3d_fill_header: invalid type");
436  map->type = type;
437 
438  if ((typeIntern != FCELL_TYPE) && (typeIntern != DCELL_TYPE))
439  Rast3d_fatal_error("Rast3d_fill_header: invalid type");
440  map->typeIntern = typeIntern;
441 
442  if (!RASTER3D_VALID_XDR_OPTION(useXdr))
443  Rast3d_fatal_error("Rast3d_fill_header: invalid xdr option");
444  map->useXdr = useXdr; /* Only kept for backward compatibility */
445 
446  map->offset = nofHeaderBytes;
447 
448  if ((map->fileEndPtr = lseek(map->data_fd, (long)0, SEEK_END)) == -1) {
449  Rast3d_error("Rast3d_fill_header: can't position file");
450  return 0;
451  }
452 
453  map->useCache = (cache != RASTER3D_NO_CACHE);
454 
457 
458  map->compression = compression;
459  map->useRle = useRle; /* Only kept for backward compatibility */
460  map->useLzw = useLzw; /* Only kept for backward compatibility */
461  map->precision = precision;
462 
463 #define RLE_STATUS_BYTES 2
464 
465  if (map->compression != RASTER3D_NO_COMPRESSION) {
466  if (tmpCompress == NULL) {
468  map->tileSize *
472  if (tmpCompress == NULL) {
473  Rast3d_error("Rast3d_fill_header: error in Rast3d_malloc");
474  return 0;
475  }
476  }
477  else if (map->tileSize * RASTER3D_MAX(map->numLengthIntern,
478  map->numLengthExtern) +
482  map->tileSize *
486  if (tmpCompress == NULL) {
487  Rast3d_error("Rast3d_fill_header: error in Rast3d_realloc");
488  return 0;
489  }
490  }
491  }
492 
493 #define XDR_MISUSE_BYTES 10
494 
496  Rast3d_error("Rast3d_fill_header: error in Rast3d_init_fp_xdr");
497  return 0;
498  }
499 
500  if ((!map->useCache) ||
501  ((cache == RASTER3D_USE_CACHE_DEFAULT) && (g3d_cache_default == 0))) {
502  map->useCache = 0;
503  map->cache = NULL;
504  /* allocate one tile buffer */
505  map->data = Rast3d_malloc(map->tileSize * map->numLengthIntern);
506  if (map->data == NULL) {
507  Rast3d_error("Rast3d_fill_header: error in Rast3d_malloc");
508  return 0;
509  }
510  map->currentIndex = -1;
511  }
512  else {
513  if (!Rast3d_init_cache(
514  map, RASTER3D_MAX(
516  g3d_cache_max / map->tileSize /
517  map->numLengthIntern)))) {
518  Rast3d_error("Rast3d_fill_header: error in Rast3d_init_cache");
519  return 0;
520  }
521  }
522 
523  if (!Rast3d_init_index(map, hasIndex)) {
524  Rast3d_error("Rast3d_fill_header: error in Rast3d_init_index");
525  return 0;
526  }
527 
528  return 1;
529 }
#define NULL
Definition: ccmath.h:32
int g3d_cache_max
Definition: defaults.c:68
int g3d_cache_default
Definition: defaults.c:67
void G_warning(const char *,...) __attribute__((format(printf
void G_free_key_value(struct Key_Value *)
Free allocated Key_Value structure.
Definition: key_value1.c:104
struct Key_Value * G_read_key_value_file(const char *)
Read key/values pairs from file.
Definition: key_value3.c:55
void G_write_key_value_file(const char *, const struct Key_Value *)
Write key/value pairs to file.
Definition: key_value3.c:28
struct Key_Value * G_create_key_value(void)
Allocate and initialize Key_Value structure.
Definition: key_value1.c:23
char * G_store(const char *)
Copy string to allocated memory.
Definition: strings.c:87
void * Rast3d_realloc(void *, int)
Same as realloc (ptr, nBytes), except that in case of error Rast3d_error() is invoked.
void Rast3d_filename(char *, const char *, const char *, const char *)
Definition: filename.c:9
void Rast3d_make_mapset_map_directory(const char *)
int Rast3d_key_set_int(struct Key_Value *, const char *, const int *)
Definition: keys.c:93
int Rast3d_key_get_string(struct Key_Value *, const char *, char **)
Definition: keys.c:48
int Rast3d_init_index(RASTER3D_Map *, int)
int Rast3d_key_set_string(struct Key_Value *, const char *, char *const *)
Definition: keys.c:116
void Rast3d_adjust_region(RASTER3D_Region *)
Computes an adjusts the resolutions in the region structure from the region boundaries and number of ...
Definition: region.c:149
int Rast3d_init_fp_xdr(RASTER3D_Map *, int)
Definition: fpxdr.c:65
int Rast3d_key_get_int(struct Key_Value *, const char *, int *)
Definition: keys.c:7
int Rast3d_key_set_value(struct Key_Value *, const char *, const char *, const char *, int, int, const int *)
Definition: keys.c:125
int Rast3d_length(int)
Definition: raster3d/misc.c:75
int Rast3d_extern_length(int)
Definition: raster3d/misc.c:87
int Rast3d_key_get_double(struct Key_Value *, const char *, double *)
Definition: keys.c:27
void Rast3d_error(const char *,...) __attribute__((format(printf
int Rast3d_key_set_double(struct Key_Value *, const char *, const double *)
Definition: keys.c:104
int Rast3d_key_get_value(struct Key_Value *, const char *, char *, char *, int, int, int *)
Definition: keys.c:66
void Rast3d_fatal_error(const char *,...) __attribute__((format(printf
int Rast3d_init_cache(RASTER3D_Map *, int)
Definition: cache.c:221
void * Rast3d_malloc(int)
Same as malloc (nBytes), except that in case of error Rast3d_error() is invoked.
#define R_OK
Definition: dirent.c:25
#define GPATH_MAX
Definition: gis.h:194
#define _(str)
Definition: glocale.h:10
unsigned short compression
Definition: gsd_img_tif.c:42
#define RASTER3D_HEADER_PRECISION
int Rast3d_rewrite_header(RASTER3D_Map *map)
#define RASTER3D_HEADER_VERTICAL_UNIT
int Rast3d__compute_cache_size(RASTER3D_Map *map, int cacheCode)
#define RASTER3D_HEADER_USEXDR
#define RASTER3D_HEADER_VERSION
#define RASTER3D_HEADER_HASINDEX
#define RASTER3D_HEADER_TILEX
#define RASTER3D_HEADER_USELZW
#define RASTER3D_HEADER_UNIT
#define RASTER3D_HEADER_TYPE
void * xdr
int Rast3d_read_header(RASTER3D_Map *map, int *proj, int *zone, double *north, double *south, double *east, double *west, double *top, double *bottom, int *rows, int *cols, int *depths, double *ew_res, double *ns_res, double *tb_res, int *tileX, int *tileY, int *tileZ, int *type, int *compression, int *useRle, int *useLzw, int *precision, int *dataOffset, int *useXdr, int *hasIndex, char **unit, int *vertical_unit, int *version)
#define RASTER3D_HEADER_USERLE
int Rast3d_cache_size_encode(int cacheCode, int n)
Returns a number which encodes multiplicity n of cacheCode. This value can be used to specify the siz...
int xdrLength
#define RASTER3D_HEADER_COMPRESSION
#define RASTER3D_HEADER_DATA_OFFSET
void * tmpCompress
int Rast3d_fill_header(RASTER3D_Map *map, int operation, int compression, int useRle, int useLzw, int type, int precision, int cache, int hasIndex, int useXdr, int typeIntern, int nofHeaderBytes, int tileX, int tileY, int tileZ, int proj, int zone, double north, double south, double east, double west, double top, double bottom, int rows, int cols, int depths, double ew_res, double ns_res, double tb_res, char *unit, int vertical_unit, int version)
int Rast3d_write_header(RASTER3D_Map *map, int proj, int zone, double north, double south, double east, double west, double top, double bottom, int rows, int cols, int depths, double ew_res, double ns_res, double tb_res, int tileX, int tileY, int tileZ, int type, int compression, int useRle, int useLzw, int precision, int dataOffset, int useXdr, int hasIndex, char *unit, int vertical_unit, int version)
#define RASTER3D_HEADER_TILEY
int tmpCompressLength
#define XDR_MISUSE_BYTES
#define RLE_STATUS_BYTES
#define RASTER3D_HEADER_TILEZ
#define RASTER3D_HEADER_ELEMENT
Definition: raster3d.h:35
#define RASTER3D_USE_CACHE_X
Definition: raster3d.h:20
#define RASTER3D_USE_CACHE_XZ
Definition: raster3d.h:24
#define RASTER3D_USE_CACHE_YZ
Definition: raster3d.h:25
#define RASTER3D_NO_COMPRESSION
Definition: raster3d.h:13
#define RASTER3D_USE_CACHE_DEFAULT
Definition: raster3d.h:19
#define RASTER3D_NO_CACHE
Definition: raster3d.h:18
#define RASTER3D_USE_CACHE_XY
Definition: raster3d.h:23
#define RASTER3D_USE_CACHE_Z
Definition: raster3d.h:22
#define RASTER3D_USE_CACHE_Y
Definition: raster3d.h:21
#define RASTER3D_USE_CACHE_XYZ
Definition: raster3d.h:26
#define RASTER3D_REGION_COLS
#define RASTER3D_REGION_EAST
#define RASTER3D_REGION_PROJ
#define RASTER3D_REGION_NORTH
#define RASTER3D_VALID_XDR_OPTION(o)
#define RASTER3D_REGION_DEPTHS
#define RASTER3D_REGION_WEST
#define RASTER3D_REGION_NSRES
#define RASTER3D_VALID_OPERATION(o)
#define RASTER3D_REGION_ZONE
#define RASTER3D_MIN(a, b)
#define RASTER3D_REGION_ROWS
#define RASTER3D_REGION_BOTTOM
#define RASTER3D_REGION_TBRES
#define RASTER3D_REGION_SOUTH
#define RASTER3D_MAX(a, b)
#define RASTER3D_REGION_EWRES
#define RASTER3D_REGION_TOP
#define FCELL_TYPE
Definition: raster.h:12
#define DCELL_TYPE
Definition: raster.h:13
if(!(yy_init))
Definition: sqlp.yy.c:775
Definition: gis.h:528
int numLengthExtern
Definition: raster3d.h:173
int precision
Definition: raster3d.h:109
int compression
Definition: raster3d.h:111
char * fileName
Definition: raster3d.h:74
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
int version
Definition: raster3d.h:72
char * mapset
Definition: raster3d.h:76
char * unit
Definition: raster3d.h:91
int hasIndex
Definition: raster3d.h:136
int operation
Definition: raster3d.h:79
int tileSize
Definition: raster3d.h:180
int fileEndPtr
Definition: raster3d.h:133
int vertical_unit
Definition: raster3d.h:92
int numLengthIntern
Definition: raster3d.h:176
int useCache
Definition: raster3d.h:160
int typeIntern
Definition: raster3d.h:150
double tb_res
Definition: raster3d.h:56
double north
Definition: raster3d.h:49
double south
Definition: raster3d.h:49
double east
Definition: raster3d.h:50
double ns_res
Definition: raster3d.h:56
double ew_res
Definition: raster3d.h:56
double bottom
Definition: raster3d.h:51
double top
Definition: raster3d.h:51
double west
Definition: raster3d.h:50
Definition: path.h:15