81 #include <rpc/types.h>
84 #include <grass/glocale.h>
85 #define DEFAULT_CELL_MIN 1
86 #define DEFAULT_CELL_MAX 255
140 struct FPRange *drange)
144 char buf[200], xdr_buf[100];
145 DCELL dcell1, dcell2;
156 if (range.first_time)
180 if (!xdr_double(&xdr_str, &dcell1) || !xdr_double(&xdr_str, &dcell2))
192 sprintf(buf, _(
"can't read f_range file for [%s in %s]"), name, mapset);
233 struct FPRange drange;
244 "G_read_range(): can't read quant rules for fp map %s@%s",
259 x[0] = (CELL) (dmin + .5);
261 x[0] = (CELL) (dmin - .5);
263 x[1] = (CELL) (dmax + .5);
265 x[1] = (CELL) (dmax - .5);
285 if (!fgets(buf,
sizeof buf, fd))
288 x[0] = x[1] = x[2] = x[3] = 0;
289 count = sscanf(buf,
"%d%d%d%d", &x[0], &x[1], &x[2], &x[3]);
295 for (n = 0; n < count; n++) {
298 if (count < 4 || x[n])
308 sprintf(buf, _(
"can't read range file for [%s in %s]"), name, mapset);
340 sprintf(buf,
"G_write_range(): the map is floating point!");
347 if (range->first_time)
353 fprintf(fd,
"%ld %ld\n", (
long)range->min, (
long)range->max);
359 sprintf(buf, _(
"can't write range file for [%s in %s]"),
383 char buf[200], xdr_buf[100];
386 sprintf(buf,
"cell_misc/%s", name);
391 if (range->first_time)
401 if (!xdr_double(&xdr_str, (
double *)&(range->min)))
403 if (!xdr_double(&xdr_str, (
double *)&(range->max)))
406 write(fd, xdr_buf, XDR_DOUBLE_NBYTES * 2);
412 sprintf(buf, _(
"can't write range file for [%s in %s]"),
439 if (range->first_time) {
440 range->first_time = 0;
445 if (cat < range->
min)
447 if (cat > range->max)
459 if (range->first_time) {
460 range->first_time = 0;
465 if (val < range->
min)
467 if (val > range->max)
499 struct Range *
range,
int ignore_zeros)
507 if (range->first_time) {
508 range->first_time = 0;
513 if (cat < range->
min)
515 if (cat > range->max)
525 struct FPRange *
range, RASTER_MAP_TYPE data_type)
532 val = (DCELL) * ((CELL *) rast);
535 val = (DCELL) * ((FCELL *) rast);
538 val = *((DCELL *) rast);
546 if (range->first_time) {
547 range->first_time = 0;
552 if (val < range->
min)
554 if (val > range->max)
583 range->first_time = 1;
610 if (range->first_time) {
646 range->first_time = 1;
670 if (range->first_time) {