4
#include <grass/glocale.h>
6
int WindowRange(char *name, char *mapset, long *min, long *max)
8
char inbuf[512]; /* input buffer for reading stats */
10
char stats_cmd[GPATH_MAX]; /* string for r.stats command */
11
char *temp_fname; /* temp file name */
12
FILE *temp_file; /* temp file pointer */
13
long int cat; /* a category value */
14
long int stat; /* a category stat value */
17
/* write stats to a temp file */
18
temp_fname = G_tempfile();
19
sprintf(stats_cmd, "r.stats -ci \"%s\" > \"%s\"", name, temp_fname);
20
G_debug(3, "r.stats command=[%s]", stats_cmd);
23
/* open temp file and read the stats into a linked list */
24
temp_file = fopen(temp_fname, "r");
28
if (fgets(inbuf, sizeof(inbuf), temp_file) != NULL) {
29
if (sscanf(inbuf, "%ld %ld", &cat, &stat) == 2) {
53
int quick_range(char *name, char *mapset, long *min, long *max)
56
struct FPRange fprange;
60
switch (G_raster_map_type(name, mapset)) {
62
if (G_read_range(name, mapset, &range) <= 0)
64
G_get_range_min_max(&range, &xmin, &xmax);
69
if (G_read_fp_range(name, mapset, &fprange) <= 0)
71
G_get_fp_range_min_max(&fprange, &fpxmin, &fpxmax);
79
int slow_range(char *name, char *mapset, long *min, long *max)
89
G_message(_("one moment ..."));
90
sprintf(buf, "Gdescribe -r -1 '%s in %s'", name, mapset);
96
while (ok && fgets(buf, sizeof(buf), fd)) {
97
ok = (sscanf(buf, "%ld", &n) == 1);