jonathan: thuban/test test_baserenderer.py,1.11,1.12
cvs@intevation.de
cvs at intevation.de
Fri Feb 18 15:54:19 CET 2005
Author: jonathan
Update of /thubanrepository/thuban/test
In directory doto:/tmp/cvs-serv11859/test
Modified Files:
test_baserenderer.py
Log Message:
Refactored baserenderer.py and renderer.py to remove baserenderer.py's
dependencies on wxPython. Added a new method projected_raster_layer()
that returns a raster layer image in projected space. This must be
implemented in classes derived from BaseRenderer. This also eliminates
the dependency on gdal in baserenderer.py.
Index: test_baserenderer.py
===================================================================
RCS file: /thubanrepository/thuban/test/test_baserenderer.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- test_baserenderer.py 16 Feb 2005 21:14:47 -0000 1.11
+++ test_baserenderer.py 18 Feb 2005 14:54:17 -0000 1.12
@@ -32,7 +32,8 @@
from Thuban.UI.baserenderer import BaseRenderer, \
add_renderer_extension, init_renderer_extensions
-from Thuban.version import versions
+if Thuban.Model.resource.has_gdal_support():
+ from gdalwarp import ProjectRasterFile
class MockDC:
@@ -94,7 +95,19 @@
self.raster_data = data
self.raster_format = format
+ def projected_raster_layer(self, layer, srcProj, dstProj, extents,
+ resolution, dimensions, options):
+
+ if not Thuban.Model.resource.has_gdal_support():
+ raise support.SkipTest("No gdal support")
+
+ #print srcProj, dstProj,extents, resolution, dimensions, options
+ return ProjectRasterFile(layer.GetImageFilename(),
+ srcProj, dstProj,
+ extents, resolution, dimensions,
+ options)
+
class MockProjection:
"""Objects that look like projections but simply apply non-uniform scalings
@@ -263,6 +276,72 @@
('SetFont', "label font"),
('EndDrawing',)])
+ def test_projected_raster_layer(self):
+ if not Thuban.Model.resource.has_gdal_support():
+ raise support.SkipTest("No gdal support")
+
+ layer = RasterLayer("raster layer",
+ os.path.join("..", "Data", "iceland",
+ "island.tif"))
+
+ dc = MockDC(size = (20, 20))
+ renderer = SimpleRenderer(dc, map, 34, (800, 2250))
+
+ # The reference data as a base64 coded RAW image
+ raw_data = binascii.a2b_base64(
+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mUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbm'
+ 'UmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmU'
+ 'mbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUm'
+ 'bmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmb'
+ 'mUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbm'
+ 'UmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmU'
+ 'mbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUm'
+ 'bmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmb'
+ 'mUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbm'
+ 'UmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbm\n')
+
+ raw_mask = binascii.a2b_base64(
+ '//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P/'
+ '/8P//8P//8P//8P//8P\n')
+
+ raw_mask_inverted = binascii.a2b_base64(
+ 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
+ 'AAAAAAAAAAAAAAAAAAA\n')
+
+ raw_alpha = binascii.a2b_base64(
+ '/////////////////////////////////////////////////////////////'
+ '/////////////////////////////////////////////////////////////'
+ '/////////////////////////////////////////////////////////////'
+ '/////////////////////////////////////////////////////////////'
+ '/////////////////////////////////////////////////////////////'
+ '/////////////////////////////////////////////////////////////'
+ '/////////////////////////////////////////////////////////////'
+ '/////////////////////////////////////////////////////////////'
+ '/////////////////////////////////////////////w==\n')
+
+ for opts, data in [[1, (raw_data, raw_mask, None)],
+ [1|4, (raw_data, raw_mask_inverted, None)],
+ [2, (raw_data, None, raw_alpha)]]:
+
+ img_data = renderer.projected_raster_layer(layer, "", "",
+ (-24, 65, -23, 66), [0, 0], (20, 20), opts)
+ self.assertEquals(img_data, data)
+
def test_raster_no_projection(self):
"""Test BaseRenderer with raster layer and no projections
@@ -278,6 +357,8 @@
layer = RasterLayer("raster layer",
os.path.join("..", "Data", "iceland",
"island.tif"))
+ layer.SetMaskType(layer.MASK_NONE)
+
map.AddLayer(layer)
self.to_destroy.append(map)
@@ -321,24 +402,8 @@
'mUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbm'
'UmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbm\n')
- #print
- #hexed = binascii.b2a_base64(renderer.raster_data[2][1])
- #while hexed:
- #print repr(hexed[:61])
- #hexed = hexed[61:]
-
-
- if versions['wxPython-tuple'] < (2,5,3):
- raw_mask = binascii.a2b_base64(
- 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
- 'AAAAAAAAAAAAAAAAAAA\n')
- else:
- raw_mask = binascii.a2b_base64(
- '//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P/'
- '/8P//8P//8P//8P//8P\n')
-
self.assertEquals(renderer.raster_data,
- (20,20,(raw_data, raw_mask, None)))
+ (20,20,(raw_data, None, None)))
self.assertEquals(renderer.raster_format, "RAW")
@@ -346,33 +411,6 @@
[('BeginDrawing',),
('SetFont', "label font"),
('EndDrawing',)])
-
- if versions['wxPython-tuple'] >= (2,5,3):
- layer.SetMaskType(layer.MASK_ALPHA)
- renderer.render_map()
-
- #print
- #hexed = binascii.b2a_base64(renderer.raster_data[2][2])
- #while hexed:
- #print repr(hexed[:61])
- #hexed = hexed[61:]
- raw_alpha = binascii.a2b_base64(
- '/////////////////////////////////////////////////////////////'
- '/////////////////////////////////////////////////////////////'
- '/////////////////////////////////////////////////////////////'
- '/////////////////////////////////////////////////////////////'
- '/////////////////////////////////////////////////////////////'
- '/////////////////////////////////////////////////////////////'
- '/////////////////////////////////////////////////////////////'
- '/////////////////////////////////////////////////////////////'
- '/////////////////////////////////////////////w==\n')
- self.assertEquals(renderer.raster_data,
- (20,20,(raw_data, None, raw_alpha)))
-
-
- layer.SetMaskType(layer.MASK_NONE)
- renderer.render_map()
- self.assertEquals(renderer.raster_data, (20,20,(raw_data, None, None)))
def test_point_map_projection(self):
"""Test BaseRenderer with point layer and map projection"""
More information about the Thuban-devel
mailing list
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)