GRASS GIS 8 Programmer's Manual  8.4.0dev(2024)-55b2a2bccc
quant_io.c File Reference

Raster Library - Quantization rules (input / output) More...

#include <string.h>
#include <grass/gis.h>
#include <grass/raster.h>
#include <grass/glocale.h>
Include dependency graph for quant_io.c:

Go to the source code of this file.


#define QUANT_FILE_NAME   "f_quant"


int Rast__quant_import (const char *name, const char *mapset, struct Quant *quant)
 Reads quantization rules (internal use only) More...
int Rast__quant_export (const char *name, const char *mapset, const struct Quant *quant)
 Writes the quantization rules (internal use only) More...

Detailed Description

Raster Library - Quantization rules (input / output)

(C) 1999-2010 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

USACERL and many others

Definition in file quant_io.c.

Macro Definition Documentation


#define QUANT_FILE_NAME   "f_quant"

Definition at line 24 of file quant_io.c.

Function Documentation

◆ Rast__quant_export()

int Rast__quant_export ( const char *  name,
const char *  mapset,
const struct Quant quant 

Writes the quantization rules (internal use only)

Writes the quantization rules stored in quant for name . If the mapset is the same as the current mapset, the quant file is created in 'cell_misc/name' directory, otherwise it is created in 'quant2/mapset' directory, much like writing colors for map in another mapset. The rules are written in decreasing order of priority (i.e. rules added earlier are written later).

Note: if no rules are defined an empty file is created.

namemap name
mapsetmapset name
quantpointer to Quant structure
-1 if map name is not fully qualified or file could not be opened.
1 otherwise.

Definition at line 270 of file quant_io.c.

References G__make_mapset_element_misc(), G_fopen_new(), G_fopen_new_misc(), G_make_mapset_object_group(), G_mapset(), G_name_is_fully_qualified(), G_remove(), G_remove_misc(), GMAPSET_MAX, GNAME_MAX, name, and QUANT_FILE_NAME.

Referenced by Rast_write_quant().

◆ Rast__quant_import()

int Rast__quant_import ( const char *  name,
const char *  mapset,
struct Quant quant 

Reads quantization rules (internal use only)

Reads quantization rules for raster map name in mapset and stores them in the quantization structure "quant". If the map is in another mapset, first checks for quant2 table for this map in current mapset.

Note: in the case of negative return value, the result of using the quantization structure is not defined. in case of return value 0, calls to Rast_quant_perform_d() and Rast_quant_perform_f() return NO_DATA (see description of Rast_quant_perform_d() for more details). in case of return values 2 and 3, the explicit rule for quant is set: floating range is mapped to integer range.

Note: use Rast_quant_init() to allocate and initialize the quantization staructure quant before the first usage of G_quant_import().

Note: this function uses Rast_quant_free () to clear all previously stored rules in quant.

namemap name
mapsetmapset name
[out]quantpointer to Quant structure
-2 if raster map is of type integer.
-1 if map name is fully qualified and mapset is not the current one
0 if quantization file does not exist, or the file is empty,
1 if non-empty quantization file exists.

Definition at line 95 of file quant_io.c.

References _, CELL_TYPE, G_fopen_old(), G_fully_qualified_name(), G_mapset(), G_name_is_fully_qualified(), G_warning(), GMAPSET_MAX, GNAME_MAX, name, Rast_map_type(), and Rast_quant_free().

Referenced by Rast_read_quant().