bh: thuban/Thuban/UI viewport.py,1.20,1.21
cvs@intevation.de
cvs at intevation.de
Tue Jul 5 18:00:50 CEST 2005
Author: bh
Update of /thubanrepository/thuban/Thuban/UI
In directory doto:/tmp/cvs-serv22461/Thuban/UI
Modified Files:
viewport.py
Log Message:
(ViewPort.set_view_transform): Handle
ZeroDivisionError exceptions. I don't know when they happen
exactly. It probably happens when the projections aren't set
properly.
Index: viewport.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/UI/viewport.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- viewport.py 24 Jan 2005 11:19:53 -0000 1.20
+++ viewport.py 5 Jul 2005 16:00:47 -0000 1.21
@@ -15,6 +15,7 @@
# $Source$
# $Id$
+import sys
from math import hypot
from wxproj import point_in_polygon_shape, shape_centroid
@@ -410,8 +411,17 @@
# The window's center in projected coordinates assuming the new
# scale/offset
- pcenterx = (wwidth/2 - offset[0]) / scale
- pcentery = (offset[1] - wheight/2) / scale
+ try:
+ pcenterx = (wwidth/2 - offset[0]) / scale
+ pcentery = (offset[1] - wheight/2) / scale
+ except ZeroDivisionError:
+ # scale was zero. Probably a problem with the projections.
+ # printing an error message and return immediately. The user
+ # will hopefully be informed by the UI which displays a
+ # message for at least some of the projection problems.
+ print >>sys.stderr, "ViewPort.set_view_transform:", \
+ "ZeroDivisionError, scale =", repr(scale)
+ return
min_scale, max_scale = self.calc_min_max_scales(scale)
More information about the Thuban-devel
mailing list
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)