[GRASS-SVN] r47524 - in grass/trunk: include lib/raster
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Aug 10 06:09:37 EDT 2011
Author: martinl
Date: 2011-08-10 03:09:37 -0700 (Wed, 10 Aug 2011)
New Revision: 47524
Modified:
grass/trunk/include/gis.h
grass/trunk/include/raster.h
grass/trunk/include/rasterdefs.h
grass/trunk/lib/raster/color_read.c
Log:
gislib/rasterlib: struct Colors moved to gislib
Rast__read_colors() added
Modified: grass/trunk/include/gis.h
===================================================================
--- grass/trunk/include/gis.h 2011-08-10 10:09:01 UTC (rev 47523)
+++ grass/trunk/include/gis.h 2011-08-10 10:09:37 UTC (rev 47524)
@@ -397,6 +397,73 @@
int pid;
};
+typedef int CELL;
+typedef double DCELL;
+typedef float FCELL;
+
+struct _Color_Value_
+{
+ DCELL value;
+ unsigned char red;
+ unsigned char grn;
+ unsigned char blu;
+};
+
+struct _Color_Rule_
+{
+ struct _Color_Value_ low, high;
+ struct _Color_Rule_ *next;
+ struct _Color_Rule_ *prev;
+};
+
+struct _Color_Info_
+{
+ struct _Color_Rule_ *rules;
+ int n_rules;
+
+ struct
+ {
+ unsigned char *red;
+ unsigned char *grn;
+ unsigned char *blu;
+ unsigned char *set;
+ int nalloc;
+ int active;
+ } lookup;
+
+ struct
+ {
+ DCELL *vals;
+ /* pointers to color rules corresponding to the intervals btwn vals */
+ struct _Color_Rule_ **rules;
+ int nalloc;
+ int active;
+ } fp_lookup;
+
+ DCELL min, max;
+};
+
+struct Colors
+{
+ int version; /* set by read_colors: -1=old,1=new */
+ DCELL shift;
+ int invert;
+ int is_float; /* defined on floating point raster data? */
+ int null_set; /* the colors for null are set? */
+ unsigned char null_red;
+ unsigned char null_grn;
+ unsigned char null_blu;
+ int undef_set; /* the colors for cells not in range are set? */
+ unsigned char undef_red;
+ unsigned char undef_grn;
+ unsigned char undef_blu;
+ struct _Color_Info_ fixed;
+ struct _Color_Info_ modular;
+ DCELL cmin;
+ DCELL cmax;
+ int organizing;
+};
+
/*============================== Prototypes ================================*/
/* Since there are so many prototypes for the gis library they are stored */
Modified: grass/trunk/include/raster.h
===================================================================
--- grass/trunk/include/raster.h 2011-08-10 10:09:01 UTC (rev 47523)
+++ grass/trunk/include/raster.h 2011-08-10 10:09:37 UTC (rev 47524)
@@ -17,10 +17,6 @@
#define CUBIC 3 /* cubic interpolation */
/*** typedefs ***/
-typedef int CELL;
-typedef double DCELL;
-typedef float FCELL;
-
typedef int RASTER_MAP_TYPE;
/* for G_get_raster_sample() */
@@ -224,70 +220,6 @@
struct GDAL_link;
-struct _Color_Value_
-{
- DCELL value;
- unsigned char red;
- unsigned char grn;
- unsigned char blu;
-};
-
-struct _Color_Rule_
-{
- struct _Color_Value_ low, high;
- struct _Color_Rule_ *next;
- struct _Color_Rule_ *prev;
-};
-
-struct _Color_Info_
-{
- struct _Color_Rule_ *rules;
- int n_rules;
-
- struct
- {
- unsigned char *red;
- unsigned char *grn;
- unsigned char *blu;
- unsigned char *set;
- int nalloc;
- int active;
- } lookup;
-
- struct
- {
- DCELL *vals;
- /* pointers to color rules corresponding to the intervals btwn vals */
- struct _Color_Rule_ **rules;
- int nalloc;
- int active;
- } fp_lookup;
-
- DCELL min, max;
-};
-
-struct Colors
-{
- int version; /* set by read_colors: -1=old,1=new */
- DCELL shift;
- int invert;
- int is_float; /* defined on floating point raster data? */
- int null_set; /* the colors for null are set? */
- unsigned char null_red;
- unsigned char null_grn;
- unsigned char null_blu;
- int undef_set; /* the colors for cells not in range are set? */
- unsigned char undef_red;
- unsigned char undef_grn;
- unsigned char undef_blu;
- struct _Color_Info_ fixed;
- struct _Color_Info_ modular;
- DCELL cmin;
- DCELL cmax;
- int organizing;
-};
-
-
typedef struct
{
unsigned char r, g, b, a; /* red, green, blue, and alpha */
Modified: grass/trunk/include/rasterdefs.h
===================================================================
--- grass/trunk/include/rasterdefs.h 2011-08-10 10:09:01 UTC (rev 47523)
+++ grass/trunk/include/rasterdefs.h 2011-08-10 10:09:37 UTC (rev 47524)
@@ -185,6 +185,7 @@
/* color_read.c */
int Rast_read_colors(const char *, const char *, struct Colors *);
+int Rast__read_colors(const char *, const char *, const char *, struct Colors *);
void Rast_mark_colors_as_fp(struct Colors *);
/* color_remove.c */
Modified: grass/trunk/lib/raster/color_read.c
===================================================================
--- grass/trunk/lib/raster/color_read.c 2011-08-10 10:09:01 UTC (rev 47523)
+++ grass/trunk/lib/raster/color_read.c 2011-08-10 10:09:37 UTC (rev 47524)
@@ -1,16 +1,16 @@
/*!
- * \file raster/color_read.c
- *
- * \brief Raster Library - Read color table of raster map
- *
- * (C) 1999-2009 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
- */
+ \file lib/raster/color_read.c
+
+ \brief 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
+*/
#include <string.h>
@@ -18,42 +18,40 @@
#include <grass/raster.h>
#include <grass/glocale.h>
-static int read_colors(const char *, const char *, const char *,
- struct Colors *);
static int read_new_colors(FILE *, struct Colors *);
static int read_old_colors(FILE *, struct Colors *);
/*!
- * \brief Read raster map layer color table
- *
- * The color table for the raster map <i>name</i> in the specified
- * <i>mapset</i> is read into the <i>colors</i> 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 <i>name</i> 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.
- *
- * \param name map name
- * \param mapset mapset name
- * \param[out] colors pointer to Colors structure
- *
- * \return -1 on error
- * \return 0 if missing, but default colors generated
- * \return 1 on success
- */
+ \brief Read color table of raster map
+
+ The color table for the raster map <i>name</i> in the specified
+ <i>mapset</i> is read into the <i>colors</i> 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 <i>name</i> 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.
+
+ \param name map name
+ \param mapset mapset name
+ \param[out] colors pointer to Colors structure
+
+ \return -1 on error
+ \return 0 if missing, but default colors generated
+ \return 1 on success
+*/
int Rast_read_colors(const char *name, const char *mapset,
struct Colors *colors)
{
@@ -78,11 +76,11 @@
/* first look for secondary color table in current mapset */
sprintf(buf, "colr2/%s", mapset);
- if (read_colors(buf, name, G_mapset(), colors) >= 0)
+ if (Rast__read_colors(buf, name, G_mapset(), colors) >= 0)
return 1;
/* now look for the regular color table */
- switch (read_colors("colr", name, mapset, colors)) {
+ switch (Rast__read_colors("colr", name, mapset, colors)) {
case -2:
if (!fp) {
if (Rast_read_range(name, mapset, &range) >= 0) {
@@ -115,8 +113,8 @@
return -1;
}
-static int read_colors(const char *element, const char *name,
- const char *mapset, struct Colors *colors)
+int Rast__read_colors(const char *element, const char *name,
+ const char *mapset, struct Colors *colors)
{
FILE *fd;
int stat;
More information about the grass-commit
mailing list