bh: thuban/test test_viewport.py,1.11,1.12

cvs@intevation.de cvs at intevation.de
Thu Jul 22 15:07:54 CEST 2004


Author: bh

Update of /thubanrepository/thuban/test
In directory doto:/tmp/cvs-serv30330/test

Modified Files:
	test_viewport.py 
Log Message:
* Thuban/UI/viewport.py (ViewPort.VisibleExtent): New.  Return the
visible extent of the map in projected coordinates

* test/test_viewport.py (SimpleViewPortTest.test_default_size)
(SimpleViewPortTest.test_init_with_size): Add some VisibleExtent()
tests.
(SimpleViewPortTest.test_visible_extent): New. The real test for
VisibleExtent()


Index: test_viewport.py
===================================================================
RCS file: /thubanrepository/thuban/test/test_viewport.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- test_viewport.py	22 Jul 2004 13:05:49 -0000	1.11
+++ test_viewport.py	22 Jul 2004 13:07:52 -0000	1.12
@@ -56,6 +56,7 @@
             self.assertEquals(port.GetPortSizeTuple(), (400, 300))
             self.assertEquals(port.scale, 1.0)
             self.assertEquals(port.offset, (0, 0))
+            self.assertEquals(port.VisibleExtent(), (0.0, -300.0, 400.0, 0.0))
         finally:
             port.Destroy()
 
@@ -64,6 +65,31 @@
         port = ViewPort((1001, 1001))
         try:
             self.assertEquals(port.GetPortSizeTuple(), (1001, 1001))
+            self.assertEquals(port.VisibleExtent(), (0.0, -1001.0, 1001.0, 0.0))
+        finally:
+            port.Destroy()
+
+    def test_visible_extent(self):
+        """Test ViewPort.VisibleExtent()"""
+        class MockMap:
+            def ProjectedBoundingBox(self):
+                return (500, 400, 600, 500)
+            # noops that the viewport expects but which aren't needed
+            # here:
+            Subscribe = Unsubscribe = lambda *args: None
+
+        map = MockMap()
+        port = ViewPort((1000, 1000))
+        try:
+            port.SetMap(map)
+            # The viewport adjusts automatically to the map.  Since both
+            # the map's bounding box and the viewport are square the map
+            # fits exactly.
+            self.assertEquals(port.VisibleExtent(), (500, 400, 600, 500))
+
+            # Zoom in a bit
+            port.ZoomFactor(2)
+            self.assertEquals(port.VisibleExtent(), (525, 425, 575, 475))
         finally:
             port.Destroy()
 





More information about the Thuban-devel mailing list

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