[GRASS-SVN] r45883 -
grass/branches/develbranch_6/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Apr 9 15:24:09 EDT 2011
Author: martinl
Date: 2011-04-09 12:24:09 -0700 (Sat, 09 Apr 2011)
New Revision: 45883
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py
Log:
attempt to fix #1300 (WxGUI measure tool gives wrong results)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py 2011-04-09 18:59:47 UTC (rev 45882)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py 2011-04-09 19:24:09 UTC (rev 45883)
@@ -1647,32 +1647,33 @@
"""
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\t%s = %s %s\tbearing = %d %s' \
+ % (_('segment'), strdist, dunits, _('total distance'), strtotdist, tdunits,
+ angle, _('deg'))
else:
- mstring = 'segment = %s %s\ttotal distance = %s %s' \
- % (strdist,dunits,strtotdist,tdunits)
-
+ mstring = '%s = %s %s\t%s = %s %s' \
+ % (_('segment'), strdist, dunits, _('total distance'), strtotdist, tdunits)
+
self._layerManager.goutput.WriteLog(mstring)
-
+
return dist
def Profile(self, event):
@@ -1695,13 +1696,13 @@
"""!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'
outunits = mapunits
dist = float(dist)
divisor = 1.0
-
+
# figure out which units to use
if mapunits == 'meters':
if dist > 2500.0:
@@ -1724,7 +1725,7 @@
divisor = (1/60.0)
else:
outunits = 'deg'
-
+
# format numbers in a nice way
if (dist/divisor) >= 2500.0:
outdist = round(dist/divisor)
@@ -1734,10 +1735,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/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py 2011-04-09 18:59:47 UTC (rev 45882)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py 2011-04-09 19:24:09 UTC (rev 45883)
@@ -1743,7 +1743,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
@@ -1754,13 +1754,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))
More information about the grass-commit
mailing list