[GRASS-SVN] r41282 - grass/trunk/ps/ps.map

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Mar 4 02:06:21 EST 2010


Author: hamish
Date: 2010-03-04 02:06:20 -0500 (Thu, 04 Mar 2010)
New Revision: 41282

Modified:
   grass/trunk/ps/ps.map/ps_clrtbl.c
Log:
bugfix: query color using correct datatype (merge from devbr6)

Modified: grass/trunk/ps/ps.map/ps_clrtbl.c
===================================================================
--- grass/trunk/ps/ps.map/ps_clrtbl.c	2010-03-04 06:52:10 UTC (rev 41281)
+++ grass/trunk/ps/ps.map/ps_clrtbl.c	2010-03-04 07:06:20 UTC (rev 41282)
@@ -26,6 +26,7 @@
     double col_width;
     int do_color;
     double grey_color_val;
+    RASTER_MAP_TYPE rast_type;
 
     /* let user know what's happenning */
     G_message(_("Creating color table for <%s in %s>..."),
@@ -39,6 +40,8 @@
     if (Rast_read_colors(ct.name, ct.mapset, &colors) == -1)
 	G_warning(_("Unable to read colors for colorbar"));
 
+    rast_type = Rast_map_type(ct.name, ct.mapset);
+
     do_color = (PS.grey == 0 && PS.level == 2);
 
     /* How many categories to show */
@@ -87,9 +90,12 @@
 	    i++;		/* step over 'no data' */
 	if (!i)
 	    fprintf(PS.fp, "(%s)\n", "no data");
-	else
+	else {
 	    fprintf(PS.fp, "(%s)\n",
 		    Rast_get_ith_d_cat(&PS.cats, i - 1, &dmin, &dmax));
+	    G_debug(5, "i=%d  dmin=%f  dmax=%f  catlabel=[%s]", i, dmin, dmax,
+		    Rast_get_ith_d_cat(&PS.cats, i - 1, &dmin, &dmax));
+	}
     }
     fprintf(PS.fp, "] def\n");
 
@@ -135,8 +141,10 @@
 	    /* get the data range */
 
 	    /* fill box and outline in black */
-	    if (i)
+	    if (i) {
 		label = Rast_get_ith_d_cat(&PS.cats, i - 1, &dmin, &dmax);
+		G_debug(5, "j=%d i=%d label=[%s]", j, i, label);
+	    }
 
 	    x1 = l + (double)j *72.0 * col_width;
 
@@ -148,9 +156,22 @@
 		/* set box fill color */
 		if (!i)
 		    Rast_get_null_value_color(&R, &G, &B, &colors);
-		else
-		    Rast_get_d_color(&dmin, &R, &G, &B, &colors);
+		else {
+		    if (rast_type == CELL_TYPE) {
+			CELL cmin = (CELL)dmin;
+			Rast_get_c_color(&cmin, &R, &G, &B, &colors);
+		    }
+		    else if (rast_type == FCELL_TYPE) {
+			FCELL fmin = (FCELL)dmin;
+			Rast_get_f_color(&fmin, &R, &G, &B, &colors);
+		    }
+		    else if (rast_type == DCELL_TYPE)
+			Rast_get_color(&dmin, &R, &G, &B, &colors, rast_type);
+		    else G_fatal_error("Please contact development team");
 
+		    G_debug(5, "    dmin=%f  RGB=%d:%d:%d", dmin, R, G, B);
+		}
+
 		if (do_color)
 		    fprintf(PS.fp, "%.3f %.3f %.3f C\n",
 			    (double)R / 255., (double)G / 255.,



More information about the grass-commit mailing list