bh: thuban/Thuban/Model layer.py,1.65,1.66

cvs@intevation.de cvs at intevation.de
Tue Jul 5 18:30:53 CEST 2005


Author: bh

Update of /thubanrepository/thuban/Thuban/Model
In directory doto:/tmp/cvs-serv22993/Thuban/Model

Modified Files:
	layer.py 
Log Message:
* Thuban/Model/layer.py (Layer.__mangle_bounding_box)
(Layer.ClipBoundingBox): Rename ClipBoundingBox to
__mangle_bounding_box.  See the comments in the code and RT #2845

* test/test_layer.py (TestLayer.test_arc_layer_with_projection):
Remove the explicit test of ClipBoundingBox.  The method isn't
public anymore and the direct call in the test wasn't necessary in
the first place.  If ClipBoundingBox (now __mangle_bounding_box)
isn't called, the return value of ShapesInRegion will be
different.


Index: layer.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/Model/layer.py,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- layer.py	6 May 2005 14:16:38 -0000	1.65
+++ layer.py	5 Jul 2005 16:30:51 -0000	1.66
@@ -1,4 +1,4 @@
-# Copyright (c) 2001, 2002, 2003, 2004 by Intevation GmbH
+# Copyright (c) 2001, 2002, 2003, 2004, 2005 by Intevation GmbH
 # Authors:
 # Bernhard Herzog <bh at intevation.de>
 # Jonathan Coles <jonathan at intevation.de>
@@ -237,7 +237,7 @@
             # Ensure that region lies within the layer's bounding box
             # Otherwise projection of the region would lead to incorrect
             # values.
-            clipbbox = self.ClipBoundingBox(bbox)
+            clipbbox = self.__mangle_bounding_box(bbox)
             bbox = self.projection.ForwardBBox(clipbbox)
         return self.store.ShapesInRegion(bbox)
 
@@ -314,14 +314,20 @@
 
         return (_("Layer '%s'") % self.Title(), items)
 
-    def ClipBoundingBox(self, bbox):
-        """ Clip bbox to layer's bounding box.
-
-        Returns that part of bbox that lies within the layers bounding box.
-        If bbox is completely outside of the layers bounding box, bbox is
-        returned.  It is assumed that bbox has sensible values, i.e. bminx
-        < bmaxx and bminy < bmaxy.
-        """
+    def __mangle_bounding_box(self, bbox):
+        # FIXME: This method doesn't make much sense.
+        # See RT #2845 which effectively says:
+        #
+        # If this method, which was originally called ClipBoundingBox,
+        # is supposed to do clipping it shouldn't return the parameter
+        # unchanged when it lies completely outside of the bounding box.
+        # It would be better to return None and return an empty list in
+        # ShapesInRegion (the only caller) in that case.
+        #
+        # This method was introduced to fix a bug that IIRC had
+        # something todo with projections and bounding boxes containing
+        # NaN or INF when the parameter to ShapesInRegion covered the
+        # entire earth or something similarly large).
         bminx, bminy, bmaxx, bmaxy = bbox
         lminx, lminy, lmaxx, lmaxy = self.LatLongBoundingBox()
         if bminx > lmaxx or bmaxx < lminx:
@@ -334,7 +340,7 @@
         else:
             bottom = max(lminy, bminy)
             top = min(lmaxy, bmaxy)
-        
+
         return (left, bottom, right, top)
 
 





More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)