[GRASS-SVN] r47620 - in grass/trunk: include lib/ogsf

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Aug 14 05:57:03 EDT 2011


Author: martinl
Date: 2011-08-14 02:57:03 -0700 (Sun, 14 Aug 2011)
New Revision: 47620

Modified:
   grass/trunk/include/ogsf_proto.h
   grass/trunk/lib/ogsf/GP2.c
   grass/trunk/lib/ogsf/GV2.c
   grass/trunk/lib/ogsf/Gp3.c
   grass/trunk/lib/ogsf/Gv3.c
Log:
ogsflib: support for vector color tables


Modified: grass/trunk/include/ogsf_proto.h
===================================================================
--- grass/trunk/include/ogsf_proto.h	2011-08-14 09:12:16 UTC (rev 47619)
+++ grass/trunk/include/ogsf_proto.h	2011-08-14 09:57:03 UTC (rev 47620)
@@ -63,7 +63,8 @@
 int GP_get_sitename(int, char **);
 int GP_get_style(int, int *, int *, float *, int *);
 int GP_set_style(int, int, int, float, int);
-int GP_set_style_thematic(int, int, const char *, const char *, const char *, const char *);
+int GP_set_style_thematic(int, int, const char *, const char *, const char *,
+			  const char *, struct Colors *);
 int GP_unset_style_thematic(int);
 int GP_attmode_color(int, const char *);
 int GP_attmode_none(int);
@@ -244,7 +245,7 @@
 int GV_get_vectname(int, char **);
 int GV_set_style(int, int, int, int, int);
 int GV_get_style(int, int *, int *, int *, int *);
-int GV_set_style_thematic(int, int, const char*, const char*);
+int GV_set_style_thematic(int, int, const char *, const char *, struct Colors *);
 int GV_unset_style_thematic(int);
 void GV_set_trans(int, float, float, float);
 int GV_get_trans(int, float *, float *, float *);
@@ -317,7 +318,7 @@
 /* Gp3.c */
 int Gp_set_color(const char *, geopoint *);
 geopoint *Gp_load_sites(const char *, int *, int *);
-int Gp_load_sites_thematic(geosite *);
+int Gp_load_sites_thematic(geosite *, struct Colors *);
 
 /* Gs3.c */
 double Gs_distance(double *, double *);
@@ -343,7 +344,7 @@
 
 /* Gv3.c */
 geoline *Gv_load_vect(const char *, int *);
-int Gv_load_vect_thematic(geovect *);
+int Gv_load_vect_thematic(geovect *, struct Colors *);
 void sub_Vectmem(int);
 
 /* gk.c */

Modified: grass/trunk/lib/ogsf/GP2.c
===================================================================
--- grass/trunk/lib/ogsf/GP2.c	2011-08-14 09:12:16 UTC (rev 47619)
+++ grass/trunk/lib/ogsf/GP2.c	2011-08-14 09:57:03 UTC (rev 47620)
@@ -296,15 +296,17 @@
    
    \param id point set id
    \param layer layer number for thematic mapping
-   \param color icon color
-   \param width icon line width
-   \param size icon size
-   \param symbol icon symbol
+   \param color icon color column name
+   \param width icon line width column name
+   \param size icon size column name
+   \param symbol icon symbol column name
+   \param colors pointer to Colors structure or NULL
 
    \return 1 on success
    \return -1 on error (point set not found)
  */
-int GP_set_style_thematic(int id, int layer, const char* color, const char* width, const char* size, const char* symbol)
+int GP_set_style_thematic(int id, int layer, const char* color, const char* width,
+			  const char* size, const char* symbol, struct Colors *color_rules)
 {
     geosite *gp;
     
@@ -330,7 +332,7 @@
     if (width)
 	gp->tstyle->width_column = G_store(width);
 
-    Gp_load_sites_thematic(gp);
+    Gp_load_sites_thematic(gp, color_rules);
 
     return 1;
 }

Modified: grass/trunk/lib/ogsf/GV2.c
===================================================================
--- grass/trunk/lib/ogsf/GV2.c	2011-08-14 09:12:16 UTC (rev 47619)
+++ grass/trunk/lib/ogsf/GV2.c	2011-08-14 09:57:03 UTC (rev 47620)
@@ -1,19 +1,16 @@
 /*!
-   \file GV2.c
+   \file lib/ogsf/GV2.c
 
    \brief OGSF library - loading and manipulating vector sets (higher level functions)
 
-   GRASS OpenGL gsurf OGSF Library 
+   (C) 1999-2008, 2011 by the GRASS Development Team
 
-   (C) 1999-2008 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.
 
-   This program is free software under the 
-   GNU General Public License (>=v2). 
-   Read the file COPYING that comes with GRASS
-   for details.
-
    \author Bill Brown USACERL, GMSL/University of Illinois
-   \author Doxygenized by Martin Landa <landa.martin gmail.com>
+   \author Updated by Martin landa <landa.martin gmail.com>
+   (doxygenized in May 2008, thematic mapping in June 2011)
  */
 
 #include <stdlib.h>
@@ -280,13 +277,15 @@
    
    \param id vector set id
    \param layer layer number for thematic mapping
-   \param color color column
-   \param width width column
-   
+   \param color color column name
+   \param width width column name
+   \param colors pointer to Colors structure or NULL
+
    \return 1 on success
    \return -1 on error (point set not found)
  */
-int GV_set_style_thematic(int id, int layer, const char* color, const char* width)
+int GV_set_style_thematic(int id, int layer, const char* color, const char* width,
+			  struct Colors *color_rules)
 {
     geovect *gv;
 
@@ -305,7 +304,7 @@
     if (width)
 	gv->tstyle->width_column = G_store(width);
 
-    Gv_load_vect_thematic(gv);
+    Gv_load_vect_thematic(gv, color_rules);
 
     return 1;
 }

Modified: grass/trunk/lib/ogsf/Gp3.c
===================================================================
--- grass/trunk/lib/ogsf/Gp3.c	2011-08-14 09:12:16 UTC (rev 47619)
+++ grass/trunk/lib/ogsf/Gp3.c	2011-08-14 09:57:03 UTC (rev 47620)
@@ -159,11 +159,12 @@
   \brief Load styles for geopoints based on thematic mapping
 
   \param gp pointer to geosite structure
-
+  \param colors pointer to Colors structure or NULL
+  
   \return number of points defined by thematic mapping
   \return -1 on error
 */
-int Gp_load_sites_thematic(geosite *gp)
+int Gp_load_sites_thematic(geosite *gp, struct Colors *colors)
 {
     geopoint *gpt;
 
@@ -220,6 +221,14 @@
 	    continue;
 
 	/* color */
+	if (colors) {
+	    if (!Rast_get_c_color((const CELL *) &cat, &red, &grn, &blu, colors)) {
+		G_warning(_("No color rule defined for category %d"), cat);
+		gpt->style->color = gp->style->color;
+	    }
+	    gpt->style->color = (red & RED_MASK) + ((int)((grn) << 8) & GRN_MASK) +
+		((int)((blu) << 16) & BLU_MASK);
+	}
 	if (gp->tstyle->color_column) {
 	    nvals = db_select_value(driver, Fi->table, Fi->key, cat, gp->tstyle->color_column, &value);
 	    if (nvals < 1)
@@ -235,7 +244,7 @@
 		    ((int)((blu) << 16) & BLU_MASK);
 	    }
 	}
-
+	
 	/* size */
 	if (gp->tstyle->size_column) {
 	    nvals = db_select_value(driver, Fi->table, Fi->key, cat, gp->tstyle->size_column, &value);

Modified: grass/trunk/lib/ogsf/Gv3.c
===================================================================
--- grass/trunk/lib/ogsf/Gv3.c	2011-08-14 09:12:16 UTC (rev 47619)
+++ grass/trunk/lib/ogsf/Gv3.c	2011-08-14 09:57:03 UTC (rev 47620)
@@ -19,6 +19,7 @@
 
 #include <grass/gis.h>
 #include <grass/colors.h>
+#include <grass/raster.h>
 #include <grass/vector.h>
 #include <grass/dbmi.h>
 #include <grass/glocale.h>
@@ -296,11 +297,12 @@
   \brief Load styles for geolines based on thematic mapping
 
   \param gv pointer to geovect structure
+  \param colors pointer to Colors structure or NULL
 
   \return number of features defined by thematic mapping
   \return -1 on error
 */
-int Gv_load_vect_thematic(geovect *gv)
+int Gv_load_vect_thematic(geovect *gv, struct Colors *colors)
 {
     geoline *gvt;
 
@@ -357,6 +359,15 @@
 	    continue;
 
 	/* color */
+	if (colors) {
+	    if (!Rast_get_c_color((const CELL *) &cat, &red, &grn, &blu, colors)) {
+		G_warning(_("No color rule defined for category %d"), cat);
+		gvt->style->color = gv->style->color;
+	    }
+	    gvt->style->color = (red & RED_MASK) + ((int)((grn) << 8) & GRN_MASK) +
+		((int)((blu) << 16) & BLU_MASK);
+	}
+	
 	if (gv->tstyle->color_column) {
 	    nvals = db_select_value(driver, Fi->table, Fi->key, cat, gv->tstyle->color_column, &value);
 	    if (nvals < 1)



More information about the grass-commit mailing list