GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
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.

Macros

#define QUANT_FILE_NAME   "f_quant"
 

Functions

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.

Author
USACERL and many others

Definition in file quant_io.c.

Macro Definition Documentation

◆ QUANT_FILE_NAME

#define QUANT_FILE_NAME   "f_quant"

Definition at line 24 of file quant_io.c.

Referenced by Rast__quant_export().

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.

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

Definition at line 268 of file quant_io.c.

References G__make_mapset_element_misc(), G_fopen_new(), G_fopen_new_misc(), G_make_mapset_element(), G_mapset(), G_name_is_fully_qualified(), G_remove(), G_remove_misc(), GMAPSET_MAX, GNAME_MAX, 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.

Parameters
namemap name
mapsetmapset name
[out]quantpointer to Quant structure
Returns
-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 94 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, Rast_map_type(), and Rast_quant_free().

Referenced by Rast_read_quant().