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"
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)
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,
48 int (*headerString)(
struct Key_Value *,
const char *,
char **);
97 G_warning(
"You are using an old raster3d data format, the vertical "
99 "Please use r3.support to define the vertical unit to avoid "
103 G_warning(
"You are using an old raster3d data format, the version is "
111 Rast3d_error(
"Rast3d_readWriteHeader: error reading/writing header");
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)
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 *);
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 "
183 G_warning(
"You are using an old raster3d data format, the version is "
191 Rast3d_error(
"Rast3d_readWriteHeader: error reading/writing header");
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,
203 int *precision,
int *dataOffset,
int *useXdr,
204 int *hasIndex,
char **unit,
int *vertical_unit,
218 if (!Rast3d__readHeader(headerKeys, proj, zone, north, south, east, west,
219 top, bottom, rows, cols, depths, ew_res, ns_res,
221 useRle, useLzw, precision, dataOffset, useXdr,
222 hasIndex, unit, vertical_unit, version)) {
224 "Rast3d_read_header: error extracting header key(s) of file %s",
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,
240 int useRle,
int useLzw,
int precision,
int dataOffset,
241 int useXdr,
int hasIndex,
char *unit,
int vertical_unit,
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)) {
255 "Rast3d_write_header: error adding header key(s) for file %s",
282 G_warning(
_(
"Unable to write header for 3D raster map <%s>"),
318 return cacheCode * n;
325 return n * (-10) + cacheCode;
339 n = -(cacheCode / 10);
341 cacheCode = -((-cacheCode) % 10);
352 size = map->
nx * map->
nz * n;
354 size = map->
ny * map->
nz * n;
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)
446 map->
offset = nofHeaderBytes;
449 Rast3d_error(
"Rast3d_fill_header: can't position file");
463 #define RLE_STATUS_BYTES 2
473 Rast3d_error(
"Rast3d_fill_header: error in Rast3d_malloc");
487 Rast3d_error(
"Rast3d_fill_header: error in Rast3d_realloc");
493 #define XDR_MISUSE_BYTES 10
496 Rast3d_error(
"Rast3d_fill_header: error in Rast3d_init_fp_xdr");
507 Rast3d_error(
"Rast3d_fill_header: error in Rast3d_malloc");
518 Rast3d_error(
"Rast3d_fill_header: error in Rast3d_init_cache");
524 Rast3d_error(
"Rast3d_fill_header: error in Rast3d_init_index");
void G_warning(const char *,...) __attribute__((format(printf
void G_free_key_value(struct Key_Value *)
Free allocated Key_Value structure.
struct Key_Value * G_read_key_value_file(const char *)
Read key/values pairs from file.
void G_write_key_value_file(const char *, const struct Key_Value *)
Write key/value pairs to file.
struct Key_Value * G_create_key_value(void)
Allocate and initialize Key_Value structure.
char * G_store(const char *)
Copy string to allocated memory.
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 *)
void Rast3d_make_mapset_map_directory(const char *)
int Rast3d_key_set_int(struct Key_Value *, const char *, const int *)
int Rast3d_key_get_string(struct Key_Value *, const char *, char **)
int Rast3d_init_index(RASTER3D_Map *, int)
int Rast3d_key_set_string(struct Key_Value *, const char *, char *const *)
void Rast3d_adjust_region(RASTER3D_Region *)
Computes an adjusts the resolutions in the region structure from the region boundaries and number of ...
int Rast3d_init_fp_xdr(RASTER3D_Map *, int)
int Rast3d_key_get_int(struct Key_Value *, const char *, int *)
int Rast3d_key_set_value(struct Key_Value *, const char *, const char *, const char *, int, int, const int *)
int Rast3d_extern_length(int)
int Rast3d_key_get_double(struct Key_Value *, const char *, double *)
void Rast3d_error(const char *,...) __attribute__((format(printf
int Rast3d_key_set_double(struct Key_Value *, const char *, const double *)
int Rast3d_key_get_value(struct Key_Value *, const char *, char *, char *, int, int, int *)
void Rast3d_fatal_error(const char *,...) __attribute__((format(printf
int Rast3d_init_cache(RASTER3D_Map *, int)
void * Rast3d_malloc(int)
Same as malloc (nBytes), except that in case of error Rast3d_error() is invoked.
unsigned short compression
#define RASTER3D_HEADER_ELEMENT
#define RASTER3D_USE_CACHE_X
#define RASTER3D_USE_CACHE_XZ
#define RASTER3D_USE_CACHE_YZ
#define RASTER3D_NO_COMPRESSION
#define RASTER3D_USE_CACHE_DEFAULT
#define RASTER3D_NO_CACHE
#define RASTER3D_USE_CACHE_XY
#define RASTER3D_USE_CACHE_Z
#define RASTER3D_USE_CACHE_Y
#define RASTER3D_USE_CACHE_XYZ
#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