[GRASS-SVN] r47525 - in grass/trunk: include include/Make
lib/vector/Vlib
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Aug 10 06:12:18 EDT 2011
Author: martinl
Date: 2011-08-10 03:12:18 -0700 (Wed, 10 Aug 2011)
New Revision: 47525
Added:
grass/trunk/lib/vector/Vlib/color_read.c
Modified:
grass/trunk/include/Make/Grass.make
grass/trunk/include/vector.h
grass/trunk/lib/vector/Vlib/Makefile
Log:
vlib: Vect_read_colors() added
dependency to rasterlib introduced
Modified: grass/trunk/include/Make/Grass.make
===================================================================
--- grass/trunk/include/Make/Grass.make 2011-08-10 10:09:37 UTC (rev 47524)
+++ grass/trunk/include/Make/Grass.make 2011-08-10 10:12:18 UTC (rev 47525)
@@ -221,7 +221,7 @@
STATSDEPS = $(RASTERLIB) $(GISLIB) $(MATHLIB) # NB: doesn't use libgis directly
SYMBDEPS = $(GISLIB) $(MATHLIB)
TRANSDEPS = $(MATHLIB)
-VECTORDEPS = $(DBMILIB) $(GRAPHLIB) $(DIG2LIB) $(LINKMLIB) $(RTREELIB) $(GISLIB) $(GEOSLIBS) $(GDALLIBS) $(MATHLIB) $(BTREE2LIB) $(GPROJLIB)
+VECTORDEPS = $(DBMILIB) $(GRAPHLIB) $(DIG2LIB) $(LINKMLIB) $(RTREELIB) $(GISLIB) $(GEOSLIBS) $(GDALLIBS) $(MATHLIB) $(BTREE2LIB) $(GPROJLIB) $(RASTERDEP)
VEDITDEPS = $(VECTORLIB) $(DBMILIB) $(GISLIB) $(MATHLIB)
NETADEPS = $(VECTORLIB) $(DBMILIB) $(GISLIB)
Modified: grass/trunk/include/vector.h
===================================================================
--- grass/trunk/include/vector.h 2011-08-10 10:09:37 UTC (rev 47524)
+++ grass/trunk/include/vector.h 2011-08-10 10:12:18 UTC (rev 47525)
@@ -540,4 +540,7 @@
GEOSCoordSequence *Vect_get_isle_points_geos(struct Map_info *, int);
#endif
+ /* Raster color tables */
+int Vect_read_colors(const char *, const char *, struct Colors *);
+
#endif /* GRASS_VECT_H */
Modified: grass/trunk/lib/vector/Vlib/Makefile
===================================================================
--- grass/trunk/lib/vector/Vlib/Makefile 2011-08-10 10:09:37 UTC (rev 47524)
+++ grass/trunk/lib/vector/Vlib/Makefile 2011-08-10 10:12:18 UTC (rev 47525)
@@ -7,7 +7,8 @@
DEPENDENCIES = $(ARCH_INCDIR)/Vect.h $(ARCH_INCDIR)/V_.h \
$(ARCH_INCDIR)/vect/dig_defines.h \
$(ARCH_INCDIR)/vect/dig_macros.h $(ARCH_INCDIR)/vect/dig_structs.h \
- $(ARCH_INCDIR)/vect/dig_externs.h $(ARCH_INCDIR)/vect/dig_globs.h $(GISDEP)
+ $(ARCH_INCDIR)/vect/dig_externs.h $(ARCH_INCDIR)/vect/dig_globs.h \
+ $(GISDEP) $(RASTERDEP)
include $(MODULE_TOPDIR)/include/Make/Lib.make
Added: grass/trunk/lib/vector/Vlib/color_read.c
===================================================================
--- grass/trunk/lib/vector/Vlib/color_read.c (rev 0)
+++ grass/trunk/lib/vector/Vlib/color_read.c 2011-08-10 10:12:18 UTC (rev 47525)
@@ -0,0 +1,65 @@
+/*!
+ \file lib/vector/Vlib/color_read.c
+
+ \brief Vector Library - read color table of vector map
+
+ (C) 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 Martin Landa <landa.martin gmail.com>
+*/
+
+#include <grass/gis.h>
+#include <grass/raster.h>
+#include <grass/vector.h>
+
+/*!
+ \brief Read color table of vector map
+
+ The color table for the vector map <i>name</i> in the specified
+ <i>mapset</i> is read into the <i>colors</i> structure.
+
+ Note: If a secondary color file for map name <i>name</i> exists in
+ the current mapset, that color file is read. This allows the user to
+ define their own color lookup tables for vector maps found in other
+ mapsets.
+
+ Warning message is printed if the color file is missing or invalid.
+
+ \param name vector map name
+ \param mapset mapset name ("" for search path)
+ \param[out] colors pointer to Colors structure
+
+ \return -1 on error
+ \return 0 if color table missing
+ \return 1 on success (color table found)
+*/
+int Vect_read_colors(const char *name, const char *mapset,
+ struct Colors *colors)
+{
+ char buf[GPATH_MAX];
+ char xname[GNAME_MAX];
+
+ Rast_init_colors(colors);
+
+ strcpy(xname, name);
+ mapset = G_find_vector(xname, mapset);
+ if (!mapset)
+ return -1;
+
+ name = xname;
+
+ if (strcmp(mapset, G_mapset()) == 0)
+ /* look for the regular color table */
+ sprintf(buf, "vector/%s/colr", name);
+ else
+ /* look for secondary color table in current mapset */
+ sprintf(buf, "vector/%s/colr2", name);
+
+ if (Rast__read_colors(buf, "", mapset, colors) >= 0)
+ return 1;
+
+ return 0;
+}
Property changes on: grass/trunk/lib/vector/Vlib/color_read.c
___________________________________________________________________
Added: svn:mime-type
+ text/x-csrc
Added: svn:eol-style
+ native
More information about the grass-commit
mailing list