[GRASS-SVN] r45891 -
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Apr 10 14:43:14 EDT 2011
Author: martinl
Date: 2011-04-10 11:43:14 -0700 (Sun, 10 Apr 2011)
New Revision: 45891
Modified:
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp_window.py
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/render.py
Log:
attempt to fix #1300 (WxGUI measure tool gives wrong results)
wxGUI: fix formatting distance, multi-line output
(merge r45883 & r45884 from devbr6)
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py 2011-04-10 06:05:36 UTC (rev 45890)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py 2011-04-10 18:43:14 UTC (rev 45891)
@@ -1621,32 +1621,37 @@
"""
if self._layerManager.notebook.GetSelection() != 1:
self._layerManager.notebook.SetSelection(1)
-
+
dist, (north, east) = self.MapWindow.Distance(beginpt, endpt)
-
+
dist = round(dist, 3)
d, dunits = self.FormatDist(dist)
-
+
self.totaldist += dist
td, tdunits = self.FormatDist(self.totaldist)
-
+
strdist = str(d)
strtotdist = str(td)
-
+
if self.Map.projinfo['proj'] == 'xy' or 'degree' not in self.Map.projinfo['unit']:
angle = int(math.degrees(math.atan2(north,east)) + 0.5)
angle = 180 - angle
if angle < 0:
angle = 360+angle
-
- mstring = 'segment = %s %s\ttotal distance = %s %s\tbearing = %d deg' \
- % (strdist,dunits,strtotdist,tdunits,angle)
+
+ mstring = '%s = %s %s\n%s = %s %s\n%s = %d %s\n%s' \
+ % (_('segment'), strdist, dunits,
+ _('total distance'), strtotdist, tdunits,
+ _('bearing'), angle, _('deg'),
+ '-' * 60)
else:
- mstring = 'segment = %s %s\ttotal distance = %s %s' \
- % (strdist,dunits,strtotdist,tdunits)
-
+ mstring = '%s = %s %s\n%s = %s %s\n%s' \
+ % (_('segment'), strdist, dunits,
+ _('total distance'), strtotdist, tdunits,
+ '-' * 60)
+
self._layerManager.goutput.WriteLog(mstring)
-
+
return dist
def Profile(self, event):
@@ -1669,13 +1674,14 @@
"""!Format length numbers and units in a nice way,
as a function of length. From code by Hamish Bowman
Grass Development Team 2006"""
-
+
mapunits = self.Map.projinfo['units']
- if mapunits == 'metres': mapunits = 'meters'
+ if mapunits == 'metres':
+ mapunits = 'meters'
outunits = mapunits
dist = float(dist)
divisor = 1.0
-
+
# figure out which units to use
if mapunits == 'meters':
if dist > 2500.0:
@@ -1698,7 +1704,7 @@
divisor = (1/60.0)
else:
outunits = 'deg'
-
+
# format numbers in a nice way
if (dist/divisor) >= 2500.0:
outdist = round(dist/divisor)
@@ -1708,10 +1714,9 @@
outdist = round(dist/divisor,int(math.ceil(3-math.log10(dist/divisor))))
else:
outdist = float(dist/divisor)
-
+
return (outdist, outunits)
-
-
+
def Histogram(self, event):
"""!Init histogram display canvas and tools
"""
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp_window.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp_window.py 2011-04-10 06:05:36 UTC (rev 45890)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp_window.py 2011-04-10 18:43:14 UTC (rev 45891)
@@ -2906,7 +2906,7 @@
if tmpreg:
os.environ["GRASS_REGION"] = tmpreg
- def Distance(self, beginpt, endpt, screen=True):
+ def Distance(self, beginpt, endpt, screen = True):
"""!Calculete distance
LL-locations not supported
@@ -2917,13 +2917,14 @@
@param endpt second point
@param screen True for screen coordinates otherwise EN
"""
- x1, y1 = beginpt
- x2, y2 = endpt
if screen:
- dEast = (x2 - x1) * self.Map.region["ewres"]
- dNorth = (y2 - y1) * self.Map.region["nsres"]
+ e1, n1 = self.Pixel2Cell(beginpt)
+ e2, n2 = self.Pixel2Cell(endpt)
else:
- dEast = (x2 - x1)
- dNorth = (y2 - y1)
+ e1, n1 = beginpt
+ e2, n2 = endpt
+
+ dEast = (e2 - e1)
+ dNorth = (n2 - n1)
- return (math.sqrt(math.pow((dEast),2) + math.pow((dNorth),2)), (dEast, dNorth))
+ return (math.sqrt(math.pow((dEast), 2) + math.pow((dNorth), 2)), (dEast, dNorth))
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/render.py 2011-04-10 06:05:36 UTC (rev 45890)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/render.py 2011-04-10 18:43:14 UTC (rev 45891)
@@ -449,8 +449,10 @@
for line in ret.splitlines():
if ':' in line:
- key, val = line.split(':')
- projinfo[key.strip()] = val.strip()
+ key, val = map(lambda x: x.strip(), line.split(':'))
+ if key in ['units']:
+ val = val.lower()
+ projinfo[key] = val
elif "XY location (unprojected)" in line:
projinfo['proj'] = 'xy'
projinfo['units'] = ''
More information about the grass-commit
mailing list