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"
36 Rast3d_readWriteHeader(
struct Key_Value *headerKeys,
int doRead,
int *proj,
37 int *zone,
double *north,
double *south,
double *east,
38 double *west,
double *top,
double *bottom,
int *rows,
39 int *cols,
int *depths,
double *ew_res,
double *ns_res,
40 double *tb_res,
int *tileX,
int *tileY,
int *tileZ,
41 int *type,
int *
compression,
int *useRle,
int *useLzw,
42 int *precision,
int *dataOffset,
int *useXdr,
43 int *hasIndex,
char **unit,
int *vertical_unit,
int *version)
46 int (*headerInt) (), (*headerDouble) (), (*headerValue) ();
47 int (*headerString) ();
90 "0",
"1", 0, 1, useRle);
92 "0",
"1", 0, 1, useLzw);
98 "0",
"1", 0, 1, useXdr);
100 "0",
"1", 0, 1, hasIndex);
104 G_warning(
"You are using an old raster3d data format, the vertical unit is undefined. "
105 "Please use r3.support to define the vertical unit to avoid this warning.");
108 G_warning(
"You are using an old raster3d data format, the version is undefined.");
115 Rast3d_error(
"Rast3d_readWriteHeader: error reading/writing header");
123 double *south,
double *east,
double *west,
double *top,
124 double *bottom,
int *rows,
int *cols,
int *depths,
125 double *ew_res,
double *ns_res,
double *tb_res,
int *tileX,
126 int *tileY,
int *tileZ,
int *type,
int *
compression,
127 int *useRle,
int *useLzw,
int *precision,
int *dataOffset,
128 int *useXdr,
int *hasIndex,
char **unit,
int *vertical_unit,
142 if (!Rast3d_readWriteHeader(headerKeys, 1,
144 north, south, east, west, top, bottom,
146 ew_res, ns_res, tb_res,
149 dataOffset, useXdr, hasIndex, unit, vertical_unit, version)) {
150 Rast3d_error(
"Rast3d_read_header: error extracting header key(s) of file %s",
163 double east,
double west,
double top,
double bottom,
int rows,
164 int cols,
int depths,
double ew_res,
double ns_res,
165 double tb_res,
int tileX,
int tileY,
int tileZ,
int type,
166 int compression,
int useRle,
int useLzw,
int precision,
167 int dataOffset,
int useXdr,
int hasIndex,
char *unit,
int vertical_unit,
175 if (!Rast3d_readWriteHeader(headerKeys, 0,
177 &north, &south, &east, &west, &top, &bottom,
178 &rows, &cols, &depths,
179 &ew_res, &ns_res, &tb_res,
180 &tileX, &tileY, &tileZ,
182 &precision, &dataOffset, &useXdr, &hasIndex,
183 &unit, &vertical_unit, &version)) {
184 Rast3d_error(
"Rast3d_write_header: error adding header key(s) for file %s",
254 return cacheCode * n;
261 return n * (-10) + cacheCode;
275 n = -(cacheCode / 10);
277 cacheCode = -((-cacheCode) % 10);
288 size = map->
nx * map->
nz * n;
290 size = map->
ny * map->
nz * n;
307 int useLzw,
int type,
int precision,
int cache,
int hasIndex,
308 int useXdr,
int typeIntern,
int nofHeaderBytes,
int tileX,
309 int tileY,
int tileZ,
int proj,
int zone,
double north,
310 double south,
double east,
double west,
double top,
311 double bottom,
int rows,
int cols,
int depths,
double ew_res,
312 double ns_res,
double tb_res,
char *unit,
int vertical_unit,
382 map->
offset = nofHeaderBytes;
385 Rast3d_error(
"Rast3d_fill_header: can't position file");
399 #define RLE_STATUS_BYTES 2
408 Rast3d_error(
"Rast3d_fill_header: error in Rast3d_malloc");
420 Rast3d_error(
"Rast3d_fill_header: error in Rast3d_realloc");
426 #define XDR_MISUSE_BYTES 10
429 Rast3d_error(
"Rast3d_fill_header: error in Rast3d_init_fp_xdr");
440 Rast3d_error(
"Rast3d_fill_header: error in Rast3d_malloc");
452 Rast3d_error(
"Rast3d_fill_header: error in Rast3d_init_cache");
458 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