GRASS GIS 7 Programmer's Manual  7.7.svn(2018)-r73600
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
raster/color_read.c File Reference

Raster Library - Read color table of raster map. More...

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

Go to the source code of this file.

Functions

int Rast_read_colors (const char *name, const char *mapset, struct Colors *colors)
 Read color table of raster map. More...
 
int Rast__read_colors (const char *element, const char *name, const char *mapset, struct Colors *colors)
 
void Rast_mark_colors_as_fp (struct Colors *colors)
 Mark colors as floating-point. More...
 

Detailed Description

Raster Library - Read color table of raster map.

(C) 1999-2009, 2011 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 raster/color_read.c.

Function Documentation

int Rast__read_colors ( const char *  element,
const char *  name,
const char *  mapset,
struct Colors colors 
)

Definition at line 116 of file raster/color_read.c.

References fclose(), fd, G_fopen_old(), G_fseek(), G_strip(), NULL, and Colors::version.

Referenced by Rast_read_colors(), and Vect_read_colors().

void Rast_mark_colors_as_fp ( struct Colors colors)

Mark colors as floating-point.

Sets a flag in the colors structure that indicates that these colors should only be looked up using floating-point raster data (not integer data). In particular if this flag is set, the routine Rast_get_c_colors_min_max() should return min=-255$^3$ and max=255$^3$.

Parameters
colorspointer to Colors structure

Definition at line 394 of file raster/color_read.c.

References Colors::is_float.

Referenced by Rast3d_read_colors(), and Rast_read_colors().

int Rast_read_colors ( const char *  name,
const char *  mapset,
struct Colors colors 
)

Read color table of raster map.

The color table for the raster map name in the specified mapset is read into the colors structure. If the data layer has no color table, a default color table is generated and 0 is returned. If there is an error reading the color table, a diagnostic message is printed and -1 is returned. If the color table is read ok, 1 is returned.

This routine reads the rules from the color file. If the input raster map is is a floating-point map it calls Rast_mark_colors_as_fp().

Note: If a secondary color file for map name name exists in the current project, that color file is read. This allows the user to define their own color lookup tables for cell maps found in other mapsets.

Warning message is printed if the color file is missing or invalid.

Parameters
namemap name
mapsetmapset name
[out]colorspointer to Colors structure
Returns
-1 on error
0 if missing, but default colors generated
1 on success

Definition at line 55 of file raster/color_read.c.

References _, DEFAULT_COLOR_TABLE, err(), G_find_raster(), G_mapset(), G_warning(), GNAME_MAX, max, min, Rast__read_colors(), Rast_get_fp_range_min_max(), Rast_get_range_min_max(), Rast_init_colors(), Rast_is_c_null_value(), Rast_is_d_null_value(), Rast_make_colors(), Rast_make_fp_colors(), Rast_map_is_fp(), Rast_mark_colors_as_fp(), Rast_read_fp_range(), and Rast_read_range().

Referenced by Gs_build_256lookup(), Gs_pack_colors(), Gs_pack_colors_float(), gsd_put_legend(), IL_resample_output_2d(), and Rast_map_to_img_str().