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

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

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

revision 692 by jonathan, Wed Apr 16 14:10:10 2003 UTC revision 746 by jonathan, Fri Apr 25 10:27:05 2003 UTC
# Line 136  contents_test_labels = '''\ Line 136  contents_test_labels = '''\
136  </session>  </session>
137  '''  '''
138    
139    contents_test_layer_projection = '''\
140    <?xml version="1.0" encoding="UTF-8"?>
141    <!DOCTYPE session SYSTEM "thuban.dtd">
142    <session title="single map&amp;layer">
143            <map title="Test Map">
144                    <projection>
145                            <parameter value="zone=26"/>
146                            <parameter value="proj=utm"/>
147                            <parameter value="ellps=clrk66"/>
148                    </projection>
149                    <layer title="My Layer" stroke_width="1" fill="None"
150                        filename="../../Data/iceland/political.shp"
151                        stroke="#000000">
152                        <projection name="hello">
153                            <parameter value="zone=13"/>
154                            <parameter value="proj=tmerc"/>
155                            <parameter value="ellps=clrk66"/>
156                        </projection>
157                <classification field="POPYREG" field_type="string">
158                    <clnull label="hallo">
159                        <cldata stroke="#000000" stroke_width="1" fill="None"/>
160                    </clnull>
161                    <clpoint label="welt" value="1">
162                        <cldata stroke="#000000" stroke_width="2" fill="None"/>
163                    </clpoint>
164                </classification>
165            </layer>
166                    <layer title="My Layer" stroke_width="1" fill="None"
167                        filename="../../Data/iceland/political.shp"
168                        stroke="#000000">
169                        <projection>
170                            <parameter value="proj=lcc"/>
171                            <parameter value="ellps=clrk66"/>
172                        </projection>
173            </layer>
174        </map>
175    </session>
176    '''
177    
178  class LoadSessionTest(unittest.TestCase, support.FileTestMixin):  class LoadSessionTest(unittest.TestCase, support.FileTestMixin):
179    
180      def setUp(self):      def setUp(self):
# Line 151  class LoadSessionTest(unittest.TestCase, Line 190  class LoadSessionTest(unittest.TestCase,
190          file = open(self.temp_file_name("load_labels.thuban"), "w")          file = open(self.temp_file_name("load_labels.thuban"), "w")
191          file.write(contents_test_labels)          file.write(contents_test_labels)
192          file.close()          file.close()
193    
194            file = open(self.temp_file_name("load_layerproj.thuban"), "w")
195            file.write(contents_test_layer_projection)
196            file.close()
197    
198          self.session = None          self.session = None
199    
200      def tearDown(self):      def tearDown(self):
# Line 283  class LoadSessionTest(unittest.TestCase, Line 327  class LoadSessionTest(unittest.TestCase,
327    
328          self.TestLayers(map.Layers(), expected)          self.TestLayers(map.Layers(), expected)
329    
330        def testLayerProjection(self):
331            eq = self.assertEquals
332            neq = self.assertNotEqual
333    
334            session = load_session(self.temp_file_name("load_layerproj.thuban"))
335            self.session = session
336    
337            map = self.session.Maps()[0] # only one map in the sample
338    
339            layers = map.Layers() # two layers in the sample
340    
341            # test layer with a named projection
342            proj = layers[0].GetProjection()
343            neq(proj, None)
344            eq(proj.GetName(), "hello")
345            eq(proj.GetParameter("proj"), "tmerc")
346            eq(proj.GetParameter("zone"), "13")
347            eq(proj.GetParameter("ellps"), "clrk66")
348    
349            # test layer with an unnamed projection
350            proj = layers[1].GetProjection()
351            neq(proj, None)
352            eq(proj.GetName(), "Unknown")
353            eq(proj.GetParameter("proj"), "lcc")
354            eq(proj.GetParameter("ellps"), "clrk66")
355    
356  if __name__ == "__main__":  if __name__ == "__main__":
357      unittest.main()      unittest.main()
358    

Legend:
Removed from v.692  
changed lines
  Added in v.746

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26