[GRASS-SVN] r60106 - grass/trunk/display/d.legend

svn_grass at osgeo.org svn_grass at osgeo.org
Mon May 5 04:18:23 PDT 2014


Author: hamish
Date: 2014-05-05 04:18:23 -0700 (Mon, 05 May 2014)
New Revision: 60106

Modified:
   grass/trunk/display/d.legend/d.legend.html
   grass/trunk/display/d.legend/main.c
Log:
display map data units, if known

Modified: grass/trunk/display/d.legend/d.legend.html
===================================================================
--- grass/trunk/display/d.legend/d.legend.html	2014-05-05 10:10:23 UTC (rev 60105)
+++ grass/trunk/display/d.legend/d.legend.html	2014-05-05 11:18:23 UTC (rev 60106)
@@ -70,6 +70,9 @@
 on the <i>current computational region</i> settings set by <em>g.region</em>.
 The default <b>range</b> however covers the entire natural bounds of the input map.
 If the histogram appears empty, check your region settings.
+<p>
+If the raster map's <i>units</i> metadata has been set with the
+<em>r.support</em> module then it will be displayed along side the legend.
 
 
 <h2>SEE ALSO</h2>

Modified: grass/trunk/display/d.legend/main.c
===================================================================
--- grass/trunk/display/d.legend/main.c	2014-05-05 10:10:23 UTC (rev 60105)
+++ grass/trunk/display/d.legend/main.c	2014-05-05 11:18:23 UTC (rev 60106)
@@ -40,22 +40,18 @@
     char buff[512];
     char *map_name;
     int maptype;
-    int black;
+    int black, white, color;
     int cats_num;
-    int color;
     int cur_dot_row;
     int do_cats;
     int dots_per_line;
-    int thin;
     int i, j, k;
-    int lines, steps;
+    int thin, lines, steps;
     int fp;
     double t, b, l, r;
     int hide_catnum, hide_catstr, hide_nodata, do_smooth;
     char *cstr;
-    int white;
-    double x_box[5];
-    double y_box[5];
+    double x_box[5], y_box[5];
     struct Categories cats;
     struct Colors colors;
     struct GModule *module;
@@ -79,6 +75,7 @@
     double *catlist, maxCat;
     int catlistCount, use_catlist;
     double fontsize;
+    char *units;
 
 
     /* Initialize the GIS calls */
@@ -88,7 +85,7 @@
     G_add_keyword(_("display"));
     G_add_keyword(_("cartography"));
     module->description =
-	_("Displays a legend for a raster map in the active frame "
+	_("Displays a legend for a raster map (2 or 3D) in the active frame "
 	  "of the graphics monitor.");
 
     opt_rast2d = G_define_standard_option(G_OPT_R_MAP);
@@ -776,7 +773,7 @@
 	    if (color)
 		D_text(buff);
 
-	}			/*for */
+	}	/* for */
 
 	lleg = y1 - y0;
 	wleg = x1 - x0;
@@ -804,6 +801,31 @@
 	D_stroke();
 
 
+	/* print units label, if present */
+	if (maptype == MAP_TYPE_RASTER2D)
+	    units = Rast_read_units(map_name, "");
+	else
+	    units = "";
+/* FIXME: does the raster3d really need to be opened to read the units?
+	    units = Rast3d_get_unit(map_fid); */
+
+	if (!units)
+	    units = "";
+
+	if(strlen(units)) {
+	    D_use_color(color);
+	    /* D_text_size() should be already set */
+	    if (horiz)
+		D_pos_abs((x0 + x1)/2. - (strlen(units) * txsiz * 0.81)/2,
+			  y1 + (txsiz * 3));
+	    else
+		D_pos_abs(x1 - 4, y0 - (txsiz * 1.75));
+
+	    D_text(units);
+	}
+
+
+	/* display sidebar histogram, if requested */
 	if (histo->answer) {
 	    if (opt_range->answer != NULL)
 		G_warning(_("Histogram constrained by range not yet implemented"));
@@ -813,7 +835,7 @@
 	}
 
     }
-    else {			/* non FP, no smoothing */
+    else {	/* non FP, no smoothing */
 
 	int true_l, true_r;
 	double txsiz;



More information about the grass-commit mailing list