1 |
# Copyright (c) 2001, 2002 by Intevation GmbH |
# Copyright (c) 2001, 2002, 2003 by Intevation GmbH |
2 |
# Authors: |
# Authors: |
3 |
# Jan-Oliver Wagner <[email protected]> |
# Jan-Oliver Wagner <[email protected]> |
4 |
# Bernhard Herzog <[email protected]> |
# Bernhard Herzog <[email protected]> |
57 |
"""Class to serialize a session into an XML file. |
"""Class to serialize a session into an XML file. |
58 |
|
|
59 |
Applications built on top of Thuban may derive from this class and |
Applications built on top of Thuban may derive from this class and |
60 |
override or extend the methods to save additinal information. This |
override or extend the methods to save additional information. This |
61 |
additional information should take the form of additional attributes |
additional information should take the form of additional attributes |
62 |
or elements whose names are prefixed with a namespace. To define a |
or elements whose names are prefixed with a namespace. To define a |
63 |
namespace derived classes should extend the write_session method to |
namespace derived classes should extend the write_session method to |
180 |
element, call write_layer for each layer contained in the map |
element, call write_layer for each layer contained in the map |
181 |
and finally call write_label_layer to write the label layer. |
and finally call write_label_layer to write the label layer. |
182 |
""" |
""" |
183 |
write = self.file.write |
#write = self.file.write |
184 |
self.open_element('map title="%s"' % escape(map.title)) |
self.open_element('map title="%s"' % escape(map.title)) |
185 |
self.write_projection(map.projection) |
self.write_projection(map.projection) |
186 |
for layer in map.Layers(): |
for layer in map.Layers(): |
211 |
|
|
212 |
attrs["title"] = layer.title |
attrs["title"] = layer.title |
213 |
attrs["filename"] = relative_filename(self.dir, layer.filename) |
attrs["filename"] = relative_filename(self.dir, layer.filename) |
214 |
attrs["stroke"] = lc.GetDefaultStroke().hex() |
attrs["stroke"] = lc.GetDefaultLineColor().hex() |
215 |
attrs["stroke_width"] = str(lc.GetDefaultStrokeWidth()) |
attrs["stroke_width"] = str(lc.GetDefaultLineWidth()) |
216 |
attrs["fill"] = lc.GetDefaultFill().hex() |
attrs["fill"] = lc.GetDefaultFill().hex() |
217 |
|
|
218 |
self.open_element("layer", attrs) |
self.open_element("layer", attrs) |
234 |
if field is None: return |
if field is None: return |
235 |
|
|
236 |
attrs["field"] = field |
attrs["field"] = field |
237 |
|
attrs["field_type"] = str(lc.GetFieldType()) |
238 |
self.open_element("classification", attrs) |
self.open_element("classification", attrs) |
239 |
|
|
240 |
|
|
264 |
|
|
265 |
if type <= 2: |
if type <= 2: |
266 |
data = group.GetProperties() |
data = group.GetProperties() |
267 |
dict = {'stroke' : data.GetStroke().hex(), |
dict = {'stroke' : data.GetLineColor().hex(), |
268 |
'stroke_width': str(data.GetStrokeWidth()), |
'stroke_width': str(data.GetLineWidth()), |
269 |
'fill' : data.GetFill().hex()} |
'fill' : data.GetFill().hex()} |
270 |
|
|
271 |
self.open_element(types[type][0](group)) |
self.open_element(types[type][0](group)) |