2 |
# Authors: |
# Authors: |
3 |
# Jan-Oliver Wagner <[email protected]> |
# Jan-Oliver Wagner <[email protected]> |
4 |
# Bernhard Herzog <[email protected]> |
# Bernhard Herzog <[email protected]> |
5 |
|
# Jonathan Coles <[email protected]> |
6 |
# |
# |
7 |
# This program is free software under the GPL (>=v2) |
# This program is free software under the GPL (>=v2) |
8 |
# Read the file COPYING coming with Thuban for details. |
# Read the file COPYING coming with Thuban for details. |
205 |
given, should be a mapping from attribute names to attribute |
given, should be a mapping from attribute names to attribute |
206 |
values. The values should not be XML-escaped yet. |
values. The values should not be XML-escaped yet. |
207 |
""" |
""" |
208 |
lc = layer.classification |
lc = layer.GetClassification() |
209 |
|
|
210 |
if attrs is None: |
if attrs is None: |
211 |
attrs = {} |
attrs = {} |
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() |
215 |
attrs["stroke_width"] = str(lc.GetDefaultStrokeWidth()) |
attrs["stroke_width"] = str(lc.GetDefaultStrokeWidth()) |
216 |
fill = lc.GetDefaultFill() |
attrs["fill"] = lc.GetDefaultFill().hex() |
217 |
if fill is None: |
|
218 |
attrs["fill"] = "None" |
#fill = lc.GetDefaultFill() |
219 |
else: |
#if fill is None: |
220 |
attrs["fill"] = fill.hex() |
#attrs["fill"] = "None" |
221 |
stroke = lc.GetDefaultStroke() |
#else: |
222 |
if stroke is None: |
#attrs["fill"] = fill.hex() |
223 |
attrs["stroke"] = "None" |
|
224 |
else: |
|
225 |
attrs["stroke"] = stroke.hex() |
#stroke = lc.GetDefaultStroke() |
226 |
|
#if stroke is None: |
227 |
|
#attrs["stroke"] = "None" |
228 |
|
#else: |
229 |
|
#attrs["stroke"] = stroke.hex() |
230 |
|
|
231 |
self.open_element("layer", attrs) |
self.open_element("layer", attrs) |
232 |
self.write_classification(layer) |
self.write_classification(layer) |
236 |
if attrs is None: |
if attrs is None: |
237 |
attrs = {} |
attrs = {} |
238 |
|
|
239 |
lc = layer.classification |
lc = layer.GetClassification() |
240 |
|
|
241 |
field = lc.field |
field = lc.field |
242 |
|
|
250 |
self.open_element("classification", attrs) |
self.open_element("classification", attrs) |
251 |
|
|
252 |
def write_class_data(data): |
def write_class_data(data): |
253 |
dict = {'stroke' : data.GetStroke(), |
dict = {'stroke' : data.GetStroke().hex(), |
254 |
'stroke_width': data.GetStrokeWidth(), |
'stroke_width': str(data.GetStrokeWidth()), |
255 |
'fill' : data.GetFill()} |
'fill' : data.GetFill().hex()} |
256 |
self.write_element("cldata", dict) |
self.write_element("cldata", dict) |
257 |
|
|
258 |
self.open_element("clnull") |
self.open_element("clnull") |
260 |
self.close_element("clnull") |
self.close_element("clnull") |
261 |
|
|
262 |
if lc.points != {}: |
if lc.points != {}: |
263 |
for value, data in lc.points.items(): |
for p in lc.points.values(): |
264 |
self.open_element('clpoint value="%s"' % (escape(str(value)))) |
self.open_element('clpoint value="%s"' % |
265 |
write_class_data(data) |
(escape(str(p.GetValue())))) |
266 |
|
write_class_data(p) |
267 |
self.close_element('clpoint') |
self.close_element('clpoint') |
268 |
|
|
269 |
if lc.ranges != []: |
if lc.ranges != []: |
270 |
for p in lc.ranges: |
for p in lc.ranges: |
271 |
self.open_element('clrange min="%s" max="%s"' |
self.open_element('clrange min="%s" max="%s"' |
272 |
% (escape(str(p[0])), escape(str(p[1])))) |
% (escape(str(p.GetMin())), escape(str(p.GetMax())))) |
273 |
write_class_data(p[2]) |
write_class_data(p) |
274 |
self.close_element('clrange') |
self.close_element('clrange') |
275 |
|
|
276 |
self.close_element("classification") |
self.close_element("classification") |