22 |
from Thuban.Model.classification import \ |
from Thuban.Model.classification import \ |
23 |
ClassGroupDefault, ClassGroupSingleton, ClassGroupRange, ClassGroupMap |
ClassGroupDefault, ClassGroupSingleton, ClassGroupRange, ClassGroupMap |
24 |
from Thuban.Model.transientdb import AutoTransientTable, TransientJoinedTable |
from Thuban.Model.transientdb import AutoTransientTable, TransientJoinedTable |
25 |
from Thuban.Model.table import DBFTable |
from Thuban.Model.table import DBFTable, FIELDTYPE_STRING |
26 |
from Thuban.Model.data import DerivedShapeStore, ShapefileStore |
from Thuban.Model.data import DerivedShapeStore, ShapefileStore |
27 |
|
|
28 |
from Thuban.Model.xmlwriter import XMLWriter |
from Thuban.Model.xmlwriter import XMLWriter |
254 |
|
|
255 |
lc = layer.GetClassification() |
lc = layer.GetClassification() |
256 |
|
|
257 |
field = lc.GetField() |
field = layer.GetClassificationColumn() |
258 |
|
|
259 |
# |
# |
260 |
# there isn't a classification of anything so do nothing |
# there isn't a classification of anything so do nothing |
261 |
# |
# |
262 |
if field is None: return |
if field is None: return |
263 |
|
|
264 |
attrs["field"] = field |
attrs["field"] = field |
265 |
attrs["field_type"] = str(lc.GetFieldType()) |
attrs["field_type"] = str(layer.GetFieldType(field)) |
266 |
self.open_element("classification", attrs) |
self.open_element("classification", attrs) |
267 |
|
|
268 |
for g in lc: |
for g in lc: |
269 |
if isinstance(g, ClassGroupDefault): |
if isinstance(g, ClassGroupDefault): |
270 |
open_el = 'clnull label="%s"' % self.encode(g.GetLabel()) |
open_el = 'clnull label="%s"' % self.encode(g.GetLabel()) |
271 |
close_el = 'clnull' |
close_el = 'clnull' |
272 |
elif isinstance(g, ClassGroupSingleton): |
elif isinstance(g, ClassGroupSingleton): |
273 |
|
if layer.GetFieldType(field) == FIELDTYPE_STRING: |
274 |
|
value = self.encode(g.GetValue()) |
275 |
|
else: |
276 |
|
value = str(g.GetValue()) |
277 |
open_el = 'clpoint label="%s" value="%s"' \ |
open_el = 'clpoint label="%s" value="%s"' \ |
278 |
% (self.encode(g.GetLabel()), str(g.GetValue())) |
% (self.encode(g.GetLabel()), value) |
279 |
close_el = 'clpoint' |
close_el = 'clpoint' |
280 |
elif isinstance(g, ClassGroupRange): |
elif isinstance(g, ClassGroupRange): |
281 |
open_el = 'clrange label="%s" range="%s"' \ |
open_el = 'clrange label="%s" range="%s"' \ |