[GRASS-SVN] r67343 - grass-addons/grass7/raster/r.out.legend
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Dec 23 08:25:56 PST 2015
Author: pvanbosgeo
Date: 2015-12-23 08:25:56 -0800 (Wed, 23 Dec 2015)
New Revision: 67343
Modified:
grass-addons/grass7/raster/r.out.legend/r.out.legend.py
Log:
Improving computation margins
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:25:51 UTC (rev 67342)
+++ grass-addons/grass7/raster/r.out.legend/r.out.legend.py 2015-12-23 16:25:56 UTC (rev 67343)
@@ -197,26 +197,30 @@
# Compute output size of legend bar in pixels
if unit=='cm':
- w = math.ceil(float(width)/2.54*float(resol))
- h = math.ceil(float(height)/2.54*float(resol))
+ w = math.ceil(float(width)/2.54*float(resol)) + 6
+ h = math.ceil(float(height)/2.54*float(resol)) + 6
elif unit=='mm':
- w = math.ceil(float(width)/25.4*float(resol))
- h = math.ceil(float(height)/25.4*float(resol))
+ w = math.ceil(float(width)/25.4*float(resol)) + 6
+ h = math.ceil(float(height)/25.4*float(resol)) + 6
elif unit=='inch':
- w = math.ceil(width*resol)
- h = math.ceil(height*resol)
+ w = math.ceil(width*resol) + 6
+ h = math.ceil(height*resol) + 6
elif unit=="px":
- w=float(width)
- h=float(height)
+ w=float(width) + 6
+ h=float(height) + 6
else:
grass.error('Unit must be inch, cm, mm or px')
+ # Margins
+ mw = 3 / w * 100
+ mh = 3 / h * 100
+
# Check if fontsize = 0 ( = no raster values)
if fontsize==0:
iw = w
ih = h
fz = 1
- at = "1,99,2,98"
+ at = mw + "," + 100-mw + "," + mh + "," + 100-mh
else:
fz = round(float(fontsize) * (float(resol)/72.272))
@@ -231,14 +235,14 @@
if float(height)>float(width):
iw = w + fz * maxl
ih = h
- at = "1,99,3," + str((100*w/iw)-1)
+ at = mh + "," + 100-mh + "," + 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)) + ",96," + \
+ at = str(100 - (100*h/ih)) + 100-mh + \
str((100 * fz * margin_left / iw)) + "," + \
str(100 - (100 * fz * margin_right / iw))
More information about the grass-commit
mailing list