17 #include <sys/types.h>
28 #define FORMAT_FILE "f_format"
29 #define NULL_FILE "null"
31 #define NULLC_FILE "nullcmpr"
33 static int new_fileinfo(
void)
36 int newsize = oldsize;
39 for (i = 0; i < oldsize; i++)
54 for (i = oldsize; i < newsize; i++) {
84 static int open_raster_new(
const char *
name,
int open_mode,
158 const char *r_mapset;
182 switch (reclass_flag) {
188 r_name = reclass.
name;
189 r_mapset = reclass.
mapset;
192 _(
"Unable to open raster map <%s@%s> since it is a reclass "
193 "of raster map <%s@%s> which does not exist"),
194 name, mapset, r_name, r_mapset);
197 G_fatal_error(
_(
"Error reading reclass file for raster map <%s>"),
214 CELL_nbytes = cellhd.
format + 1;
217 _(
"Raster map <%s@%s>: format field in header file invalid"),
236 G_fatal_error(
_(
"Compression with %s is not supported in this GRASS "
243 _(
"Raster map <%s> is in different projection than current region. "
244 "Found <%s>, should be <%s>."),
251 "current region (%d)"),
256 if (MAP_TYPE ==
CELL_TYPE && (
unsigned int)CELL_nbytes >
sizeof(
CELL))
257 G_fatal_error(
_(
"Raster map <%s>: bytes per cell (%d) too large"),
271 MAP_NBYTES = CELL_nbytes;
282 "compiled without GDAL support"),
291 cell_fd =
G_open_old(cell_dir, r_name, r_mapset);
294 cell_dir, r_name, r_mapset);
485 for (i = 0; i <
sizeof(
CELL); i++)
488 return sizeof(
CELL) - 1;
527 static int open_raster_new_gdal(
char *map,
char *mapset,
596 const char *cell_dir;
620 G_fatal_error(
_(
"Raster map <%s> is not in the current mapset (%s)"),
636 cell_fd = creat(tempname, 0666);
717 fcb->
null_fd = creat(tempname, 0666);
776 _(
"Raster map <%s> does not exist in the current mapset (%s)"),
780 G_fatal_error(
_(
"Raster map <%s> is not in the current mapset (%s)"),
788 G_zero(fcb,
sizeof(*fcb));
797 fcb->
null_fd = creat(tempname, 0666);
844 "FCELL_TYPE or DCELL_TYPE"));
872 if (access(
path, 0) == 0)
876 if (access(
path, 0) == 0)
910 if (access(
path, 0) == 0)
915 if (access(
path, 0) == 0)
952 const char *str, *str1;
963 if (access(
path, 0) != 0)
969 if (strcmp(str,
"double") == 0)
971 else if (strcmp(str,
"float") == 0)
985 if (strcmp(str1,
"xdr") != 0)
1056 "raster maps opened for reading"));
#define OPEN_NEW_COMPRESSED
#define OPEN_NEW_UNCOMPRESSED
#define XDR_DOUBLE_NBYTES
char * G_file_name_misc(char *, const char *, const char *, const char *, const char *)
Builds full path names to GIS misc data files.
void G_zero(void *, int)
Zero out a buffer, buf, of length i.
void G_free(void *)
Free allocated memory.
int G_unqualified_name(const char *, const char *, char *, char *)
Returns unqualified map name (without @ mapset)
const char * G_find_file2(const char *, const char *, const char *)
Searches for a file from the mapset search list or in a specified mapset. (look but don't touch)
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void G_warning(const char *,...) __attribute__((format(printf
char * G_file_name(char *, const char *, const char *, const char *)
Builds full path names to GIS data files.
int G_legal_filename(const char *)
Check for legal database file name.
const char * G_find_key_value(const char *, const struct Key_Value *)
Find given key (case sensitive)
int G_open_old_misc(const char *, const char *, const char *, const char *)
open a database misc file for reading
int G_make_mapset_object_group(const char *)
Create directory for group of elements of a given type.
const char * G_find_raster2(const char *, const char *)
Find a raster map (look but don't touch)
char * G_tempfile(void)
Returns a temporary file name.
int G_open_old(const char *, const char *, const char *)
Open a database file for reading.
void G_free_key_value(struct Key_Value *)
Free allocated Key_Value structure.
char * G_compressor_name(int)
const char * G_mapset(void)
Get current mapset name.
const char * G_projection_name(int)
Get projection name.
int G_check_compressor(int)
struct Key_Value * G_read_key_value_file(const char *)
Read key/values pairs from file.
char * G_fully_qualified_name(const char *, const char *)
Get fully qualified element name.
char * G_store(const char *)
Copy string to allocated memory.
int Rast__read_null_row_ptrs(int, int)
int Rast_quant_get_neg_infinite_rule(const struct Quant *, DCELL *, CELL *)
Returns in "dLeft" and "c" the rule values.
int Rast__check_for_auto_masking(void)
Checks for auto masking.
int Rast_get_reclass(const char *, const char *, struct Reclass *)
Get reclass.
struct R_vrt * Rast_get_vrt(const char *, const char *)
int Rast__check_format(int)
void Rast_quant_set_pos_infinite_rule(struct Quant *, DCELL, CELL)
Defines a rule for values "dRight" and larger.
int Rast_read_quant(const char *, const char *, struct Quant *)
Reads quantization rules for name in mapset and stores them in the quantization structure....
void Rast_quant_set_neg_infinite_rule(struct Quant *, DCELL, CELL)
Defines a rule for values "dLeft" and smaller.
int Rast__write_row_ptrs(int)
struct GDAL_link * Rast_create_gdal_link(const char *, RASTER_MAP_TYPE)
Create GDAL settings for given raster map.
unsigned char * Rast__allocate_null_bits(int)
Allocates memory for null bits.
int Rast__write_null_row_ptrs(int, int)
void Rast_quant_add_rule(struct Quant *, DCELL, DCELL, CELL, CELL)
Adds a new rule to the set of quantization rules.
size_t Rast_cell_size(RASTER_MAP_TYPE)
Returns size of a raster cell in bytes.
void Rast_init_range(struct Range *)
Initialize range structure.
int Rast_quant_get_pos_infinite_rule(const struct Quant *, DCELL *, CELL *)
Returns in "dRight" and "c" the rule values.
void Rast_get_cellhd(const char *, const char *, struct Cell_head *)
Read the raster header.
void Rast_quant_init(struct Quant *)
Initialize the structure.
struct GDAL_link * Rast_get_gdal_link(const char *, const char *)
Get GDAL link settings for given raster map.
void Rast_init_fp_range(struct FPRange *)
Initialize fp range.
void Rast_quant_truncate(struct Quant *)
Sets the quant rules to perform simple truncation on floats.
void Rast_init_cell_stats(struct Cell_stats *)
Initialize cell stats.
void Rast__create_window_mapping(int)
Create window mapping.
int Rast__open_old(const char *name, const char *mapset)
Lower level function, open cell files, supercell files, and the MASK file.
void Rast_set_fp_type(RASTER_MAP_TYPE map_type)
Set raster map floating-point data format.
int Rast__open_null_write(const char *name)
int Rast_get_cell_format(CELL v)
Get cell value format.
int Rast_open_new(const char *name, RASTER_MAP_TYPE wr_type)
Opens a new raster map.
void Rast_set_quant_rules(int fd, struct Quant *q)
Sets quant translation rules for raster map opened for reading.
void Rast_want_histogram(int flag)
Save histogram for newly create raster map (cell)
RASTER_MAP_TYPE Rast_get_map_type(int fd)
Determine raster type from descriptor.
void Rast_set_cell_format(int n)
Sets the format for subsequent opens on new integer cell files (uncompressed and random only).
int Rast_open_c_new_uncompressed(const char *name)
Opens a new cell file in a database (uncompressed)
int Rast_open_fp_new_uncompressed(const char *name)
Opens new fcell file in a database (uncompressed)
int Rast_open_old(const char *name, const char *mapset)
Open an existing integer raster map (cell)
RASTER_MAP_TYPE Rast__check_fp_type(const char *name, const char *mapset)
Determines whether the floating points cell file has double or float type.
int Rast_open_fp_new(const char *name)
Opens new fcell file in a database.
int Rast_open_c_new(const char *name)
Opens a new cell file in a database (compressed)
int Rast_open_new_uncompressed(const char *name, RASTER_MAP_TYPE wr_type)
Opens a new raster map (uncompressed)
int Rast_map_is_fp(const char *name, const char *mapset)
Check if raster map is floating-point.
RASTER_MAP_TYPE Rast_map_type(const char *name, const char *mapset)
Determine raster data type.
2D/3D raster map header (used also for region)
int compressed
Compression mode (raster header only)
int format
Max number of bytes per raster data value minus 1 (raster header only)
int zone
Projection zone (UTM)
int rows
Number of rows for 2D data.
int cols
Number of columns for 2D data.
struct Quant_table * table
struct fileinfo * fileinfo
struct Cell_head wr_window
struct Cell_head rd_window
unsigned char * null_bits
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)