/[thuban]/branches/WIP-pyshapelib-bramz/test/test_baserenderer.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/test/test_baserenderer.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1557 by bh, Thu Aug 7 17:29:46 2003 UTC revision 1591 by bh, Fri Aug 15 14:00:53 2003 UTC
# Line 15  import os Line 15  import os
15  import binascii  import binascii
16  import unittest  import unittest
17    
18    from mockgeo import SimpleShapeStore
19  import support  import support
20  support.initthuban()  support.initthuban()
21    
# Line 24  from Thuban.Model.map import Map Line 25  from Thuban.Model.map import Map
25  from Thuban.Model.layer import Layer, RasterLayer  from Thuban.Model.layer import Layer, RasterLayer
26  from Thuban.Model.table import MemoryTable, \  from Thuban.Model.table import MemoryTable, \
27       FIELDTYPE_DOUBLE, FIELDTYPE_INT, FIELDTYPE_STRING       FIELDTYPE_DOUBLE, FIELDTYPE_INT, FIELDTYPE_STRING
28    from Thuban.Model.classification import ClassGroupSingleton
29  import Thuban.Model.resource  import Thuban.Model.resource
30    
31    
32  from Thuban.UI.baserenderer import BaseRenderer  from Thuban.UI.baserenderer import BaseRenderer
33    
34    
# Line 89  class SimpleRenderer(BaseRenderer): Line 92  class SimpleRenderer(BaseRenderer):
92          self.raster_data = data          self.raster_data = data
93    
94    
 class SimpleShape:  
   
     def __init__(self, points):  
         self.points = points  
   
     def Points(self):  
         return self.points  
   
 class SimpleShapeStore:  
   
     def __init__(self, shapetype, shapes, table):  
         self.shapetype = shapetype  
         self.shapes = shapes  
         self.table = table  
         assert table.NumRows() == len(shapes)  
   
     def ShapeType(self):  
         return self.shapetype  
   
     def Table(self):  
         return self.table  
   
     def NumShapes(self):  
         return len(self.shapes)  
   
     def Shape(self, index):  
         return SimpleShape(self.shapes[index])  
   
   
95  class MockProjection:  class MockProjection:
96    
97      """Objects that look like projections but simply apply non-uniform scalings      """Objects that look like projections but simply apply non-uniform scalings
# Line 442  class TestBaseRenderer(unittest.TestCase Line 416  class TestBaseRenderer(unittest.TestCase
416                             ('EndDrawing',)])                             ('EndDrawing',)])
417    
418    
419        def test_point_with_classification(self):
420            """Test BaseRenderer with point layer and classification"""
421            table = MemoryTable([("type", FIELDTYPE_STRING),
422                                 ("value", FIELDTYPE_DOUBLE),
423                                 ("code", FIELDTYPE_INT)],
424                                [("UNKNOWN", 0.0, 0),
425                                 ("UNKNOWN", 0.0, 1)])
426            shapes = [[[(0, 0)]], [[(10, 10)]]]
427            store = SimpleShapeStore(SHAPETYPE_POINT, shapes, table)
428    
429            map = Map("TestBaseRenderer")
430            layer = Layer("point layer", store)
431            group = ClassGroupSingleton(1)
432            group.GetProperties().SetFill(Color(0, 0, 1))
433            layer.GetClassification().AppendGroup(group)
434            layer.SetClassificationColumn("code")
435    
436            map.AddLayer(layer)
437            self.to_destroy.append(map)
438    
439            dc = MockDC()
440            renderer = SimpleRenderer(dc, 2, (10, 10))
441    
442            renderer.render_map(map)
443    
444            self.assertEquals(dc.calls,
445                              [('BeginDrawing',),
446                               ('SetBrush', ('brush', Transparent)),
447                               ('SetPen', ('pen', Color(0, 0, 0), 1)),
448                               ('DrawEllipse', 5, 5, 10, 10),
449                               ('SetBrush', ('brush', Color(0, 0, 1))),
450                               ('SetPen', ('pen', Color(0, 0, 0), 1)),
451                               ('DrawEllipse', 25, -15, 10, 10),
452                               ('SetFont', "label font"),
453                               ('EndDrawing',)])
454    
455    
456  if __name__ == "__main__":  if __name__ == "__main__":
457      support.run_tests()      support.run_tests()

Legend:
Removed from v.1557  
changed lines
  Added in v.1591

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26