/[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 2104 by bh, Fri Mar 12 12:19:15 2004 UTC revision 2606 by jan, Wed Apr 27 11:05:19 2005 UTC
# Line 1  Line 1 
1  # Copyright (c) 2001, 2002, 2003, 2004 by Intevation GmbH  # Copyright (c) 2001-2005 by Intevation GmbH
2  # Authors:  # Authors:
3  # Jan-Oliver Wagner <[email protected]>  # Jan-Oliver Wagner <[email protected]> (2004)
4  # Bernhard Herzog <[email protected]>  # Bernhard Herzog <[email protected]> (2001-2004)
5  # Jonathan Coles <[email protected]>  # Jonathan Coles <[email protected]> (2003)
6    # Frank Koormann <[email protected]> (2003)
7  #  #
8  # This program is free software under the GPL (>=v2)  # This program is free software under the GPL (>=v2)
9  # Read the file COPYING coming with Thuban for details.  # Read the file COPYING coming with Thuban for details.
# Line 12  Functions to save a session to a file Line 13  Functions to save a session to a file
13  """  """
14    
15  __version__ = "$Revision$"  __version__ = "$Revision$"
16    # $Source$
17    # $Id$
18    
19  import os  import os
20    
# Line 23  from Thuban.Model.classification import Line 26  from Thuban.Model.classification import
26      ClassGroupDefault, ClassGroupSingleton, ClassGroupRange, ClassGroupMap      ClassGroupDefault, ClassGroupSingleton, ClassGroupRange, ClassGroupMap
27  from Thuban.Model.transientdb import AutoTransientTable, TransientJoinedTable  from Thuban.Model.transientdb import AutoTransientTable, TransientJoinedTable
28  from Thuban.Model.table import DBFTable, FIELDTYPE_STRING  from Thuban.Model.table import DBFTable, FIELDTYPE_STRING
29  from Thuban.Model.data import DerivedShapeStore, ShapefileStore  from Thuban.Model.data import DerivedShapeStore, FileShapeStore, \
30                                  SHAPETYPE_POINT
31    
32  from Thuban.Model.xmlwriter import XMLWriter  from Thuban.Model.xmlwriter import XMLWriter
33  from postgisdb import PostGISConnection, PostGISShapeStore  from postgisdb import PostGISConnection, PostGISShapeStore
# Line 86  def sort_data_stores(stores): Line 90  def sort_data_stores(stores):
90              processed[id(container)] = 1              processed[id(container)] = 1
91      return result      return result
92    
93    def bool2str(b):
94        if b: return "true"
95        else: return "false"
96    
97  class SessionSaver(XMLWriter):  class SessionSaver(XMLWriter):
98    
# Line 194  class SessionSaver(XMLWriter): Line 201  class SessionSaver(XMLWriter):
201                  continue                  continue
202    
203              idvalue = self.define_id(container)              idvalue = self.define_id(container)
204              if isinstance(container, ShapefileStore):              if isinstance(container, FileShapeStore):
205                  self.define_id(container.Table(), idvalue)                  self.define_id(container.Table(), idvalue)
206                  filename = self.prepare_filename(container.FileName())                  filename = self.prepare_filename(container.FileName())
207                  self.write_element("fileshapesource",                  self.write_element("fileshapesource",
208                                     {"id": idvalue, "filename": filename,                                     {"id": idvalue, "filename": filename,
209                                      "filetype": "shapefile"})                                      "filetype": container.FileType()})
210              elif isinstance(container, DerivedShapeStore):              elif isinstance(container, DerivedShapeStore):
211                  shapesource, table = container.Dependencies()                  shapesource, table = container.Dependencies()
212                  self.write_element("derivedshapesource",                  self.write_element("derivedshapesource",
# Line 280  class SessionSaver(XMLWriter): Line 287  class SessionSaver(XMLWriter):
287              attrs = {}              attrs = {}
288    
289          attrs["title"]   = layer.title          attrs["title"]   = layer.title
290          attrs["visible"] = ("false", "true")[int(layer.Visible())]          attrs["visible"] = bool2str(layer.Visible())
291    
292          if isinstance(layer, Layer):          if isinstance(layer, Layer):
293              attrs["shapestore"]   = self.get_id(layer.ShapeStore())              attrs["shapestore"]   = self.get_id(layer.ShapeStore())
# Line 344  class SessionSaver(XMLWriter): Line 351  class SessionSaver(XMLWriter):
351                      'stroke_width': str(data.GetLineWidth()),                      'stroke_width': str(data.GetLineWidth()),
352                      'fill'        : data.GetFill().hex()}                      'fill'        : data.GetFill().hex()}
353    
354                # only for point layers write the size attribute
355                if layer.ShapeType() == SHAPETYPE_POINT:
356                    dict['size'] =  str(data.GetSize())
357    
358              self.open_element(open_el)              self.open_element(open_el)
359              self.write_element("cldata", dict)              self.write_element("cldata", dict)
360              self.close_element(close_el)              self.close_element(close_el)

Legend:
Removed from v.2104  
changed lines
  Added in v.2606

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26