21 #define DEFAULT_CELL_MIN 1
22 #define DEFAULT_CELL_MAX 255
24 static void init_rstats(
struct R_stats *);
103 G_warning(
_(
"Unable to read fp range file for <%s>"),
108 if (read(fd, xdr_buf,
sizeof(xdr_buf)) !=
sizeof(xdr_buf)) {
111 G_debug(1,
"Empty fp range file meaning Nulls for <%s>",
125 G_warning(
_(
"Missing fp range file for <%s> (run r.support -s)"),
177 G_warning(
_(
"Unable to read quant rules for raster map <%s>"),
191 x[0] = (
CELL)(dmin + .5);
193 x[0] = (
CELL)(dmin - .5);
195 x[1] = (
CELL)(dmax + .5);
197 x[1] = (
CELL)(dmax - .5);
214 G_warning(
_(
"Unable to read range file for <%s>"),
220 if (!fgets(buf,
sizeof buf, fd)) {
226 x[0] =
x[1] =
x[2] =
x[3] = 0;
227 count = sscanf(buf,
"%d%d%d%d", &
x[0], &
x[1], &
x[2], &
x[3]);
234 G_warning(
_(
"Unable to read range file for <%s>"),
239 for (n = 0; n <
count; n++) {
249 G_warning(
_(
"Missing range file for <%s> (run r.support -s)"),
281 DCELL dcell1, dcell2;
293 G_debug(1,
"Stats file does not exist");
299 G_warning(
_(
"Unable to read stats file for <%s>"),
304 if (read(fd, xdr_buf,
sizeof(xdr_buf)) !=
sizeof(xdr_buf)) {
307 G_debug(1,
"Empty stats file meaning Nulls for <%s>",
320 if (read(fd, &nbytes, 1) != 1) {
323 G_debug(1,
"Unable to read byte count in stats file for <%s>",
332 if (nbytes < 1 || (
unsigned char)nbytes >
sizeof(
grass_int64)) {
334 G_debug(1,
"Invalid byte count in stats file for <%s>",
338 if (read(fd, cc, nbytes) != nbytes) {
341 G_debug(1,
"Unable to read count in stats file for <%s>",
347 for (i = nbytes - 1; i >= 0; i--) {
394 fprintf(fp,
"%ld %ld\n", (
long)range->
min, (
long)range->
max);
433 if (write(fd, xdr_buf,
sizeof(xdr_buf)) !=
sizeof(xdr_buf)) {
477 if (write(fd, xdr_buf,
sizeof(xdr_buf)) !=
sizeof(xdr_buf)) {
487 cc[i] =
count & 0xff;
495 if (write(fd, &nbytes, 1) != 1) {
500 if (nbytes > 0 && write(fd, cc, nbytes) != nbytes) {
529 if (cat < range->
min)
531 if (cat > range->
max)
557 if (val < range->
min)
559 if (val > range->
max)
611 if (cat < range->
min)
613 if (cat > range->
max)
650 val = *((
DCELL *)rast);
668 if (val < range->
min)
670 if (val > range->
max)
699 init_rstats(&range->
rstats);
751 init_rstats(&range->
rstats);
#define XDR_DOUBLE_NBYTES
FILE * G_fopen_old_misc(const char *, const char *, const char *, const char *)
open a database misc file for reading
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void G_warning(const char *,...) __attribute__((format(printf
int G_open_old_misc(const char *, const char *, const char *, const char *)
open a database misc file for reading
FILE * G_fopen_new_misc(const char *, const char *, const char *)
open a new database misc file
const char * G_mapset(void)
Get current mapset name.
const char * G_find_file2_misc(const char *, const char *, const char *, const char *)
Searches for a misc file from the mapset search list or in a specified mapset. (look but don't touch)
int G_remove_misc(const char *, const char *, const char *)
Remove a database misc file.
void G_xdr_put_double(void *, const double *)
char * G_fully_qualified_name(const char *, const char *)
Get fully qualified element name.
void G_xdr_get_double(double *, const void *)
#define G_incr_void_ptr(ptr, size)
int G_open_new_misc(const char *, const char *, const char *)
open a new database misc file
int G_debug(int, const char *,...) __attribute__((format(printf
int Rast_is_null_value(const void *, RASTER_MAP_TYPE)
To check if a raster value is set to NULL.
void Rast_init(void)
Initialize GRASS GIS engine.
int Rast_quant_get_limits(const struct Quant *, DCELL *, DCELL *, CELL *, CELL *)
Returns the minimum and maximum cell and dcell values of all the ranges defined.
void Rast_set_d_null_value(DCELL *, int)
To set a number of DCELL raster values to NULL.
int Rast_read_quant(const char *, const char *, struct Quant *)
Reads quantization rules for name in mapset and stores them in the quantization structure....
int Rast_quant_is_round(const struct Quant *)
Returns whether or not quant rules are set to round map.
void Rast_set_c_null_value(CELL *, int)
To set a number of CELL raster values to NULL.
RASTER_MAP_TYPE Rast_map_type(const char *, const char *)
Determine raster data type.
size_t Rast_cell_size(RASTER_MAP_TYPE)
Returns size of a raster cell in bytes.
#define Rast_is_d_null_value(dcellVal)
#define Rast_is_c_null_value(cellVal)
int Rast_quant_is_truncate(const struct Quant *)
Returns whether or not quant rules are set to truncate map.
void Rast_write_fp_range(const char *name, const struct FPRange *range)
Write raster range file (floating-point)
void Rast__row_update_range(const CELL *cell, int n, struct Range *range, int ignore_zeros)
Update range structure based on raster row.
int Rast_read_range(const char *name, const char *mapset, struct Range *range)
Read raster range (CELL)
void Rast__remove_fp_range(const char *name)
Remove floating-point range.
void Rast_construct_default_range(struct Range *range)
Construct default range.
void Rast_update_fp_range(DCELL val, struct FPRange *range)
Update range structure (floating-point)
void Rast_write_rstats(const char *name, const struct R_stats *rstats)
Write raster stats file.
int Rast_read_rstats(const char *name, const char *mapset, struct R_stats *rstats)
Read raster stats.
void Rast_row_update_fp_range(const void *rast, int n, struct FPRange *range, RASTER_MAP_TYPE data_type)
Update range structure based on raster row (floating-point)
void Rast_write_range(const char *name, const struct Range *range)
Write raster range file.
void Rast_init_range(struct Range *range)
Initialize range structure.
int Rast_read_fp_range(const char *name, const char *mapset, struct FPRange *drange)
Read floating-point range.
void Rast_update_range(CELL cat, struct Range *range)
Update range structure (CELL)
void Rast_init_fp_range(struct FPRange *range)
Initialize fp range.
void Rast_get_range_min_max(const struct Range *range, CELL *min, CELL *max)
Get range min and max.
void Rast_row_update_range(const CELL *cell, int n, struct Range *range)
Update range structure based on raster row (CELL)
void Rast_get_fp_range_min_max(const struct FPRange *range, DCELL *min, DCELL *max)
Get minimum and maximum value from fp range.