[GRASS-SVN] r67345 - grass-addons/grass7/raster/r.out.legend

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Dec 23 08:26:08 PST 2015


Author: pvanbosgeo
Date: 2015-12-23 08:26:08 -0800 (Wed, 23 Dec 2015)
New Revision: 67345

Modified:
   grass-addons/grass7/raster/r.out.legend/r.out.legend.html
   grass-addons/grass7/raster/r.out.legend/r.out.legend.py
Log:
Some improvements how margins are determined

Modified: grass-addons/grass7/raster/r.out.legend/r.out.legend.html
===================================================================
--- grass-addons/grass7/raster/r.out.legend/r.out.legend.html	2015-12-23 16:26:02 UTC (rev 67344)
+++ grass-addons/grass7/raster/r.out.legend/r.out.legend.html	2015-12-23 16:26:08 UTC (rev 67345)
@@ -2,7 +2,7 @@
 
 The <em>r.out.legend</em> script provides a convenient way 
 to quickly create a smoothed legend image for floating point raster maps 
-(continous values as opposed to categories), with the dimensions and 
+(continuous values as opposed to categories), with the dimensions and 
 resolution required. It is furthermore possible to set the font (default 
 is 'Arial') and font size (default=10). The legend can be saved as 
 <a href="https://grass.osgeo.org/grass64/manuals/pngdriver.html">PNG</a>, 
@@ -99,9 +99,9 @@
 ----------------------------
 File saved as r_out_legend_1.png
 The image dimensions are:
-282px wide and 46px heigh
+285px wide and 49px heigh
 at a resolution of 150 ppi this is:
-4.7752 cm x 0.7874 cm
+4.826 cm x 0.8382 cm
 ----------------------------
 </pre></div>
 

Modified: grass-addons/grass7/raster/r.out.legend/r.out.legend.py
===================================================================
--- grass-addons/grass7/raster/r.out.legend/r.out.legend.py	2015-12-23 16:26:02 UTC (rev 67344)
+++ grass-addons/grass7/raster/r.out.legend/r.out.legend.py	2015-12-23 16:26:08 UTC (rev 67345)
@@ -197,11 +197,11 @@
 
     # Compute output size of legend bar in pixels
     if unit=='cm':
-        w = math.ceil(float(width)/2.54*float(resol)) + 6
-        h = math.ceil(float(height)/2.54*float(resol)) + 6
+        w = math.ceil(float(width)/2.54*float(resol)) + 3
+        h = math.ceil(float(height)/2.54*float(resol)) + 3
     elif unit=='mm':
-        w = math.ceil(float(width)/25.4*float(resol)) + 6
-        h = math.ceil(float(height)/25.4*float(resol)) + 6
+        w = math.ceil(float(width)/25.4*float(resol)) + 3
+        h = math.ceil(float(height)/25.4*float(resol)) + 3
     elif unit=='inch':
         w = math.ceil(width*resol) + 6
         h = math.ceil(height*resol) + 6
@@ -212,15 +212,15 @@
         grass.error('Unit must be inch, cm, mm or px')
 
     # Margins
-    mw = 3 / w * 100
-    mh = 3 / h * 100
+    mw = 2 / w * 100
+    mh = 2 / h * 100
 
     # Check if fontsize = 0 ( = no raster values)
     if fontsize==0:
         iw = w
         ih = h
         fz = 1
-        at = mw + "," + 100-mw + "," + mh + "," + 100-mh
+        at = str(mw) + "," + str(100-mw) + "," + str(mh) + "," + str(100-mh)
     else:
         fz = round(float(fontsize) * (float(resol)/72.272))
 
@@ -235,14 +235,14 @@
         if float(height)>float(width):
             iw = w + fz * maxl
             ih = h
-            at = mh + "," + 100-mh + "," + mw + "," + str((100*w/iw)-1)
+            at = str(mh) + "," + str(100-mh) + "," + str(mw) + "," + str((100*w/iw)-1)
         else:
             minval = round(maprange['min'],digits)
             margin_left = 0.5 * (len(str(minval)) - 1)
             margin_right = 0.5 * maxl
             iw = w + fz * (margin_left + margin_right)
             ih = h + fz * 1.5
-            at = str(100 - (100*h/ih)) + 100-mh + \
+            at = str(100 - (100*h/ih)) + "," + str(100-mh) + "," + \
             str((100 * fz * margin_left / iw)) + "," + \
             str(100 - (100 * fz * margin_right / iw))
 



More information about the grass-commit mailing list