jonathan: thuban/test test_load_1_0_1.py, NONE, 1.1 test_baserenderer.py, 1.8, 1.9 test_layer.py, 1.32, 1.33 test_load.py, 1.43, 1.44 test_save.py, 1.33, 1.34

cvs@intevation.de cvs at intevation.de
Thu Jan 27 15:19:43 CET 2005


Author: jonathan

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

Modified Files:
	test_baserenderer.py test_layer.py test_load.py test_save.py 
Added Files:
	test_load_1_0_1.py 
Log Message:
Add a new dialog box for raster layers. The dialog box allows
the user to toggle a mask that is generated by ProjectRasterFile
and is used to only draw the real parts of the projected image.


--- NEW FILE: test_load_1_0_1.py ---
# Copyright (c) 2002, 2003, 2004 by Intevation GmbH
# Authors:
# Bernhard Herzog <bh at intevation.de>
#
# This program is free software under the GPL (>=v2)
# Read the file COPYING coming with Thuban for details.

"""
Test loading a thuban session from a file

The tests in this file (test_load.py) are always be the tests for the
current version of the thuban file format. Tests for older versions can
be found in the version specific test modules, e.g. test_load_0_2 for
files created by Thuban 0.2.

Maintenance of the test cases:

When during a development period the file format is changed with respect
to the last released version for the first time, the tests here should
[...1070 lines suppressed...]
        self.session = load_session(self.filename(), 
                                    shapefile_callback =s_cb.s_cb)
        self.checkSession(self.session)

    def test_06_path_error_fix_from_list_fails(self):
        """Test alternative path recovery from list."""
        s_cb = Shapefile_CallBack({
                "search": [("../wrong/iceland/roads-line.shp",1),
                            ("../Data/iceland/roads-line.shp",0)], 
                "check": [(None,None)]
               })
        self.session = load_session(self.filename(), 
                                    shapefile_callback =s_cb.s_cb)
        self.assertRaises(IndexError, 
                            s_cb.s_cb, None, "search")
        


if __name__ == "__main__":
    support.run_tests()

Index: test_baserenderer.py
===================================================================
RCS file: /thubanrepository/thuban/test/test_baserenderer.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- test_baserenderer.py	21 Jan 2005 14:01:25 -0000	1.8
+++ test_baserenderer.py	27 Jan 2005 14:19:41 -0000	1.9
@@ -89,7 +89,7 @@
     def label_font(self):
         return "label font"
 
-    def draw_raster_data(self, x, y, data, format='BMP', mask = None):
+    def draw_raster_data(self, x, y, data, format='BMP'):
         self.raster_data = data
         self.raster_format = format
 
@@ -319,7 +319,7 @@
             'bmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmb'
             'mUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbm'
             'UmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbm\n')
-        self.assertEquals(renderer.raster_data, [20,20,raw_data])
+        self.assertEquals(renderer.raster_data, (20,20,(raw_data, None)))
         self.assertEquals(renderer.raster_format, "RAW")
 
         self.assertEquals(dc.calls,

Index: test_layer.py
===================================================================
RCS file: /thubanrepository/thuban/test/test_layer.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- test_layer.py	25 Sep 2004 18:49:20 -0000	1.32
+++ test_layer.py	27 Jan 2005 14:19:41 -0000	1.33
@@ -33,6 +33,7 @@
 from Thuban.Model.data import DerivedShapeStore
 from Thuban.Model.classification import Classification, ClassGroupSingleton, \
      ClassGroupRange
+from Thuban.Model.color import Color
 
 import Thuban.Model.resource
 
@@ -230,6 +231,7 @@
         layer = RasterLayer("Test RasterLayer", filename)
         self.failIf(layer.HasClassification())
         self.failIf(layer.HasShapes())
+        self.failIf(layer.UseMask())
         self.assertEquals(layer.GetImageFilename(), os.path.abspath(filename))
         self.assertFloatSeqEqual(layer.BoundingBox(),
                                  [-24.5500000, 63.2833330,
@@ -238,6 +240,18 @@
                                  [-24.5500000, 63.2833330,
                                   -13.4916670, 66.5666670])
 
+        info = layer.ImageInfo()
+        self.failIf(info is None)
+        self.failUnless(info.has_key("nBands"))
+        self.failUnless(info.has_key("Size"))
+        self.failUnless(info.has_key("Driver"))
+        self.failUnless(info.has_key("BandData"))
+
+        self.assertEquals(info["nBands"], 1)
+        self.assertEquals(info["Size"], (5002, 394))
+        self.assertEquals(info["Driver"], "GTiff")
+        self.assertEquals(info["BandData"], [(0.0, 140.0)])
+
     def test_derived_store(self):
         """Test layer with derived store"""
         layer = self.layer = Layer("Test Layer",
@@ -380,6 +394,9 @@
         self.session = None
         self.clear_messages()
 
+    def build_path(self, filename):
+        return os.path.join("..", "Data", "iceland", filename)
+
     def test_sanity(self):
         """TestLayerModification Sanity Checks"""
         # test default settings
@@ -432,6 +449,38 @@
                             'Shapetype: Polygon',
                             self.layer.GetClassification()]))
 
+    def test_raster_layer(self):
+        if not Thuban.Model.resource.has_gdal_support():
+            raise support.SkipTest("No gdal support")
+
+
+        filename = self.build_path("island.tif")
+        layer = RasterLayer("Test RasterLayer", filename)
+
+        layer.Subscribe(LAYER_CHANGED, self.subscribe_with_params,
+                        LAYER_CHANGED)
+
+        self.failIf(layer.UseMask())
+
+        layer.SetUseMask(True)
+        self.failUnless(layer.UseMask())
+        self.check_messages([(layer, LAYER_CHANGED)])
+        self.clear_messages()
+
+        layer.SetUseMask(True)
+        self.failUnless(layer.UseMask())
+        self.check_messages([])
+        self.clear_messages()
+
+        layer.SetUseMask(False)
+        self.failIf(layer.UseMask())
+        self.check_messages([(layer, LAYER_CHANGED)])
+        self.clear_messages()
+
+        layer.SetUseMask(False)
+        self.failIf(layer.UseMask())
+        self.check_messages([])
+        self.clear_messages()
 
 if __name__ == "__main__":
     support.run_tests()

Index: test_load.py
===================================================================
RCS file: /thubanrepository/thuban/test/test_load.py,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- test_load.py	15 Dec 2004 09:58:30 -0000	1.43
+++ test_load.py	27 Jan 2005 14:19:41 -0000	1.44
@@ -53,7 +53,6 @@
 from Thuban.Model.label import ALIGN_CENTER, ALIGN_TOP, ALIGN_BOTTOM, \
      ALIGN_LEFT, ALIGN_RIGHT, ALIGN_BASELINE
 
-
 def filenames_equal(name1, name2):
     """Return true if the filenames name1 and name2 are equal.
 
@@ -124,6 +123,7 @@
                 print a != b and "***************" or ""
                 print a
                 print b
+
         self.assertEquals(el1, el2,
                           "loaded file not equivalent to the saved file")
 
@@ -663,7 +663,7 @@
 <session xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd"
         title="single map&amp;layer">
     <map title="Test Map">
-        <rasterlayer visible="false" filename="../../Data/iceland/island.tif"
+        <rasterlayer visible="false" use_mask="true" filename="../../Data/iceland/island.tif"
                 title="My RasterLayer"/>
     </map>
 </session>
@@ -679,6 +679,8 @@
         map = self.session.Maps()[0] # only one map in the sample
 
         layer = map.Layers()[0] # one layer in the sample
+
+        layer.SetUseMask(True)
 
         eq(layer.Title(), "My RasterLayer")
         self.failIf(layer.Visible())

Index: test_save.py
===================================================================
RCS file: /thubanrepository/thuban/test/test_save.py,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- test_save.py	12 Mar 2004 12:19:15 -0000	1.33
+++ test_save.py	27 Jan 2005 14:19:41 -0000	1.34
@@ -242,6 +242,7 @@
         imgfile = os.path.join(os.path.dirname(__file__),
                                os.pardir, "Data", "iceland", "island.tif")
         layer = RasterLayer("My RasterLayer", imgfile)
+        layer.SetUseMask(True)
         map.AddLayer(layer)
 
         filename = self.temp_file_name("%s.thuban" % self.id())
@@ -258,7 +259,7 @@
             <map title="Test Map">
                 <rasterlayer title="My RasterLayer"
                         filename="../../Data/iceland/island.tif"
-                        visible="true">
+                        visible="true" use_mask="true">
                 </rasterlayer>
             </map>
         </session>'''





More information about the Thuban-devel mailing list

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