/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/Model/save.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/Model/save.py

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

revision 1219 by bh, Mon Jun 16 17:42:54 2003 UTC revision 1251 by jonathan, Fri Jun 20 09:27:55 2003 UTC
# Line 123  class SessionSaver(XMLWriter): Line 123  class SessionSaver(XMLWriter):
123          if attrs is None:          if attrs is None:
124              attrs = {}              attrs = {}
125    
126          attrs["title"]        = layer.title          attrs["title"]   = layer.title
127          attrs["visible"]      = ("false", "true")[int(layer.Visible())]          attrs["visible"] = ("false", "true")[int(layer.Visible())]
128    
129          if isinstance(layer, Layer):          if isinstance(layer, Layer):
130              attrs["filename"] = relative_filename(self.dir,              attrs["filename"] = relative_filename(self.dir,
# Line 147  class SessionSaver(XMLWriter): Line 147  class SessionSaver(XMLWriter):
147              self.close_element("rasterlayer")              self.close_element("rasterlayer")
148    
149      def write_classification(self, layer, attrs = None):      def write_classification(self, layer, attrs = None):
150            """Write Classification information."""
151    
152          if attrs is None:          if attrs is None:
153              attrs = {}              attrs = {}
154    
# Line 155  class SessionSaver(XMLWriter): Line 157  class SessionSaver(XMLWriter):
157          field = lc.GetField()          field = lc.GetField()
158    
159          #          #
160          # there isn't a classification of anything          # there isn't a classification of anything so do nothing
         # so don't do anything  
161          #          #
162          if field is None: return          if field is None: return
163    
# Line 164  class SessionSaver(XMLWriter): Line 165  class SessionSaver(XMLWriter):
165          attrs["field_type"] = str(lc.GetFieldType())          attrs["field_type"] = str(lc.GetFieldType())
166          self.open_element("classification", attrs)          self.open_element("classification", attrs)
167    
168            for g in lc:
169          types = [[lambda p: 'clnull label="%s"' % self.encode(p.GetLabel()),              if isinstance(g, ClassGroupDefault):
170                    lambda p: 'clnull'],                  open_el  = 'clnull label="%s"' % self.encode(g.GetLabel())
171                   [lambda p: 'clpoint label="%s" value="%s"' %                  close_el = 'clnull'
172                               (self.encode(p.GetLabel()), str(p.GetValue())),              elif isinstance(g, ClassGroupSingleton):
173                    lambda p: 'clpoint'],                  open_el  = 'clpoint label="%s" value="%s"' \
174                   [lambda p: 'clrange label="%s" range="%s"' %                             % (self.encode(g.GetLabel()), str(g.GetValue()))
175                               (self.encode(p.GetLabel()),                  close_el = 'clpoint'
176                                str(p.GetRange())),              elif isinstance(g, ClassGroupRange):
177                    lambda p: 'clrange']]                  open_el  = 'clrange label="%s" range="%s"' \
178                              % (self.encode(g.GetLabel()), str(g.GetRange()))
179          def write_class_group(group):                  close_el = 'clrange'
180              type = -1              else:
181              if isinstance(group, ClassGroupDefault): type = 0                  assert False, _("Unsupported group type in classification")
182              elif isinstance(group, ClassGroupSingleton): type = 1                  continue
183              elif isinstance(group, ClassGroupRange): type = 2  
184              elif isinstance(group, ClassGroupMap):   type = 3              data = g.GetProperties()
185              assert type >= 0              dict = {'stroke'      : data.GetLineColor().hex(),
186                        'stroke_width': str(data.GetLineWidth()),
187              if type <= 2:                      'fill'        : data.GetFill().hex()}
188                  data = group.GetProperties()  
189                  dict = {'stroke'      : data.GetLineColor().hex(),              self.open_element(open_el)
190                          'stroke_width': str(data.GetLineWidth()),              self.write_element("cldata", dict)
191                          'fill'        : data.GetFill().hex()}              self.close_element(close_el)
   
                 self.open_element(types[type][0](group))  
                 self.write_element("cldata", dict)  
                 self.close_element(types[type][1](group))  
             else: pass # XXX: we need to handle maps  
   
         for i in lc:  
             write_class_group(i)  
192    
193          self.close_element("classification")          self.close_element("classification")
194    

Legend:
Removed from v.1219  
changed lines
  Added in v.1251

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26