32     char str1[100], str2[100];
 
   39     fprintf(fd, 
"# %ld categories\n", (
long)cats->
num);
 
   45     fprintf(fd, 
"%s\n", cats->
fmt != 
NULL ? cats->
fmt : 
"");
 
   46     fprintf(fd, 
"%.2f %.2f %.2f %.2f\n", cats->
m1, cats->
a1, cats->
m2,
 
   52         if ((cats->
fmt && cats->
fmt[0]) || (descr && descr[0])) {
 
   54                 snprintf(str1, 
sizeof(str1), 
"%.10f", val1);
 
   56                 fprintf(fd, 
"%s:%s\n", str1, descr != 
NULL ? descr : 
"");
 
   59                 snprintf(str1, 
sizeof(str1), 
"%.10f", val1);
 
   61                 snprintf(str2, 
sizeof(str2), 
"%.10f", val2);
 
   63                 fprintf(fd, 
"%s:%s:%s\n", str1, str2,
 
   64                         descr != 
NULL ? descr : 
"");
 
   74 static int read_cats(
const char *
name, 
const char *mapset,
 
   91     if (
G_getl(buff, 
sizeof(buff), fd) == 0)
 
   94     if (sscanf(buff, 
"# %ld", &num) == 1)
 
   96     else if (sscanf(buff, 
"%ld", &num) == 1)
 
  100     if (
G_getl(buff, 
sizeof(buff), fd) == 0)
 
  110         float m1, a1, m2, a2;
 
  112         if (
G_getl(fmt, 
sizeof(fmt), fd) == 0)
 
  115         if (
G_getl(buff, 
sizeof(buff), fd) == 0)
 
  117         if (sscanf(buff, 
"%f %f %f %f", &m1, &a1, &m2, &a2) != 4)
 
  123     for (cat = 0;; cat++) {
 
  126         if (
G_getl(buff, 
sizeof(buff), fd) == 0)
 
  133             if (sscanf(buff, 
"%1s", label) != 1)
 
  140             if (sscanf(buff, 
"%lf:%lf:%[^\n]", &val1, &val2, label) == 3)
 
  142             else if (sscanf(buff, 
"%d:%[^\n]", &cat, label) >= 1)
 
  144             else if (sscanf(buff, 
"%lf:%[^\n]", &val1, label) >= 1)
 
  179     switch (read_cats(
name, mapset, pcats)) {
 
  190     G_warning(
"category support for [%s] in mapset [%s] %s", 
name, mapset,
 
FILE * G_fopen_old_misc(const char *, const char *, const char *, const char *)
open a database misc file for reading
void G_warning(const char *,...) __attribute__((format(printf
FILE * G_fopen_new_misc(const char *, const char *, const char *)
open a new database misc file
void G_trim_decimal(char *)
Removes trailing zeros from decimal number.
void G_strip(char *)
Removes all leading and trailing white space from string.
int G_getl(char *, int, FILE *)
Gets a line of text from a file.
char * Rast_get_ith_d_cat(const struct Categories *, int, DCELL *, DCELL *)
Get category description (DCELL)
void Rast_set_cats_fmt(const char *, double, double, double, double, struct Categories *)
Set category fmt (?)
void Rast_init_cats(const char *, struct Categories *)
Initialize category structure.
int Rast_set_cat(const void *, const void *, const char *, struct Categories *, RASTER_MAP_TYPE)
Set a raster category label.
int Rast_set_c_cat(const CELL *, const CELL *, const char *, struct Categories *)
Set a raster category label (CELL)
int Rast_quant_nof_rules(const struct Quant *)
Returns the number of quantization rules defined.
int Rast3d_write_cats(const char *name, struct Categories *cats)
Writes the categories stored in the cats structure into the categories file for map name in the curre...
int Rast3d_read_cats(const char *name, const char *mapset, struct Categories *pcats)
Reads the categories file for map name in mapset and stores the categories in the pcats structure....
#define RASTER3D_DIRECTORY
#define RASTER3D_CATS_ELEMENT