/[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 2551 by jonathan, Thu Jan 27 14:19:41 2005 UTC revision 2688 by frank, Fri Jun 30 12:27:20 2006 UTC
# Line 1  Line 1 
1  # Copyright (c) 2001-2004 by Intevation GmbH  # Copyright (c) 2001-2005 by Intevation GmbH
2  # Authors:  # Authors:
3  # Jan-Oliver Wagner <[email protected]> (2004)  # Jan-Oliver Wagner <[email protected]> (2004-2005)
4  # Bernhard Herzog <[email protected]> (2001-2004)  # Bernhard Herzog <[email protected]> (2001-2004)
5  # Jonathan Coles <[email protected]> (2003)  # Jonathan Coles <[email protected]> (2003)
6  # Frank Koormann <[email protected]> (2003)  # Frank Koormann <[email protected]> (2003)
# Line 23  import Thuban.Lib.fileutil Line 23  import Thuban.Lib.fileutil
23  from Thuban.Model.layer import Layer, RasterLayer  from Thuban.Model.layer import Layer, RasterLayer
24    
25  from Thuban.Model.classification import \  from Thuban.Model.classification import \
26      ClassGroupDefault, ClassGroupSingleton, ClassGroupRange, ClassGroupMap      ClassGroupDefault, ClassGroupSingleton, ClassGroupRange, \
27        ClassGroupPattern, ClassGroupMap
28  from Thuban.Model.transientdb import AutoTransientTable, TransientJoinedTable  from Thuban.Model.transientdb import AutoTransientTable, TransientJoinedTable
29  from Thuban.Model.table import DBFTable, FIELDTYPE_STRING  from Thuban.Model.table import DBFTable, FIELDTYPE_STRING
30  from Thuban.Model.data import DerivedShapeStore, ShapefileStore, \  from Thuban.Model.data import DerivedShapeStore, FileShapeStore, \
31                                SHAPETYPE_POINT                                SHAPETYPE_POINT
32    
33  from Thuban.Model.xmlwriter import XMLWriter  from Thuban.Model.xmlwriter import XMLWriter
# Line 201  class SessionSaver(XMLWriter): Line 202  class SessionSaver(XMLWriter):
202                  continue                  continue
203    
204              idvalue = self.define_id(container)              idvalue = self.define_id(container)
205              if isinstance(container, ShapefileStore):              if isinstance(container, FileShapeStore):
206                  self.define_id(container.Table(), idvalue)                  self.define_id(container.Table(), idvalue)
207                  filename = self.prepare_filename(container.FileName())                  filename = self.prepare_filename(container.FileName())
208                  self.write_element("fileshapesource",                  self.write_element("fileshapesource",
209                                     {"id": idvalue, "filename": filename,                                     {"id": idvalue, "filename": filename,
210                                      "filetype": "shapefile"})                                      "filetype": container.FileType()})
211              elif isinstance(container, DerivedShapeStore):              elif isinstance(container, DerivedShapeStore):
212                  shapesource, table = container.Dependencies()                  shapesource, table = container.Dependencies()
213                  self.write_element("derivedshapesource",                  self.write_element("derivedshapesource",
# Line 291  class SessionSaver(XMLWriter): Line 292  class SessionSaver(XMLWriter):
292    
293          if isinstance(layer, Layer):          if isinstance(layer, Layer):
294              attrs["shapestore"]   = self.get_id(layer.ShapeStore())              attrs["shapestore"]   = self.get_id(layer.ShapeStore())
   
             lc = layer.GetClassification()  
             attrs["stroke"] = lc.GetDefaultLineColor().hex()  
             attrs["stroke_width"] = str(lc.GetDefaultLineWidth())  
             attrs["fill"] = lc.GetDefaultFill().hex()  
   
295              self.open_element("layer", attrs)              self.open_element("layer", attrs)
296              self.write_projection(layer.GetProjection())              self.write_projection(layer.GetProjection())
297              self.write_classification(layer)              self.write_classification(layer)
298              self.close_element("layer")              self.close_element("layer")
299          elif isinstance(layer, RasterLayer):          elif isinstance(layer, RasterLayer):
300              attrs["filename"] = self.prepare_filename(layer.filename)              attrs["filename"] = self.prepare_filename(layer.filename)
301              if layer.UseMask():  
302                  attrs["use_mask"] = "true"              masknames = ["none", "bit", "alpha"]
303    
304                if layer.MaskType() != layer.MASK_BIT:
305                    attrs["masktype"] = masknames[layer.MaskType()]
306    
307                if layer.Opacity() != 1:
308                    attrs["opacity"] = str(layer.Opacity())
309    
310              self.open_element("rasterlayer", attrs)              self.open_element("rasterlayer", attrs)
311              self.write_projection(layer.GetProjection())              self.write_projection(layer.GetProjection())
# Line 320  class SessionSaver(XMLWriter): Line 321  class SessionSaver(XMLWriter):
321    
322          field = layer.GetClassificationColumn()          field = layer.GetClassificationColumn()
323    
324          #          if field is not None:
325          # there isn't a classification of anything so do nothing              attrs["field"] = field
326          #              attrs["field_type"] = str(layer.GetFieldType(field))
         if field is None: return  
327    
         attrs["field"] = field  
         attrs["field_type"] = str(layer.GetFieldType(field))  
328          self.open_element("classification", attrs)          self.open_element("classification", attrs)
329    
330          for g in lc:          for g in lc:
# Line 345  class SessionSaver(XMLWriter): Line 343  class SessionSaver(XMLWriter):
343                  open_el  = 'clrange label="%s" range="%s"' \                  open_el  = 'clrange label="%s" range="%s"' \
344                            % (self.encode(g.GetLabel()), str(g.GetRange()))                            % (self.encode(g.GetLabel()), str(g.GetRange()))
345                  close_el = 'clrange'                  close_el = 'clrange'
346                elif isinstance(g, ClassGroupPattern):
347                    open_el  = 'clpattern label="%s" pattern="%s"' \
348                              % (self.encode(g.GetLabel()), str(g.GetPattern()))
349                    close_el = 'clpattern'
350    
351              else:              else:
352                  assert False, _("Unsupported group type in classification")                  assert False, _("Unsupported group type in classification")
353                  continue                  continue

Legend:
Removed from v.2551  
changed lines
  Added in v.2688

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26