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

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

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

revision 1555 by bh, Thu Aug 7 15:41:05 2003 UTC revision 1587 by bh, Fri Aug 15 10:31:07 2003 UTC
# Line 16  __version__ = "$Revision$" Line 16  __version__ = "$Revision$"
16  import os  import os
17  import unittest  import unittest
18    
19    import mockgeo
20  import support  import support
21  support.initthuban()  support.initthuban()
22    
# Line 40  class TestLayer(unittest.TestCase, suppo Line 41  class TestLayer(unittest.TestCase, suppo
41    
42      """Test cases for different layer (shape) types"""      """Test cases for different layer (shape) types"""
43    
     def assertPointListEquals(self, test, value):  
         """Assert equality of two lists of lists of tuples of float"""  
         for i in range(len(test)):  
             self.assertEquals(len(test[i]), len(value[i]))  
             for j in range(len(test[i])):  
                 self.assertFloatSeqEqual(test[i][j], value[i][j])  
   
44      def setUp(self):      def setUp(self):
45          """Create a session self.session and initialize self.layer to None"""          """Create a session self.session and initialize self.layer to None"""
46          self.session = Session("Test session for %s" % self.__class__)          self.session = Session("Test session for %s" % self.__class__)
# Line 167  class TestLayer(unittest.TestCase, suppo Line 161  class TestLayer(unittest.TestCase, suppo
161          self.assertEquals(layer.ShapesInRegion((-24.0, 64.0, -23.80, 64.1)),          self.assertEquals(layer.ShapesInRegion((-24.0, 64.0, -23.80, 64.1)),
162                            [0, 1, 2, 3, 4, 5, 27, 28, 29, 30, 31])                            [0, 1, 2, 3, 4, 5, 27, 28, 29, 30, 31])
163    
164        def test_point_layer_with_projection(self):
165            """Test Layer with point shapes and a projection"""
166            # We use mock data here so that we have precise control over the
167            # values
168            table = MemoryTable([("FOO", FIELDTYPE_STRING)], [("bla",)])
169            store = mockgeo.SimpleShapeStore(SHAPETYPE_POINT, [[[(10,10)]]], table)
170            layer = self.layer = Layer("Test Layer", store)
171    
172            # Rotation by 45 degrees counter clockwise. This detects a bug
173            # in the ShapesInRegion method which transforms the bounding box
174            # by only transforming two opposite corners because they have
175            # the same x or y coordinates after application of the
176            # projection or its inverse.
177            proj = mockgeo.AffineProjection((1, 1, -1, 1, 0, 0))
178            layer.SetProjection(proj)
179    
180            self.assertEquals(layer.BoundingBox(), (10, 10, 10, 10))
181            self.assertEquals(layer.LatLongBoundingBox(), (10.0, 0.0, 10.0, 0.0))
182            self.assertEquals(layer.ShapesInRegion((0, 0, 20, 20)), [0])
183    
184      def test_empty_layer(self):      def test_empty_layer(self):
185          """Test Layer with empty shape file"""          """Test Layer with empty shape file"""
186          # create an empty shape file          # create an empty shape file

Legend:
Removed from v.1555  
changed lines
  Added in v.1587

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26