1 |
# Copyright (c) 2002, 2003, 2004 by Intevation GmbH |
# Copyright (c) 2002, 2003, 2004, 2005 by Intevation GmbH |
2 |
# Authors: |
# Authors: |
3 |
# Bernhard Herzog <[email protected]> |
# Bernhard Herzog <[email protected]> |
4 |
# |
# |
25 |
|
|
26 |
import dbflib |
import dbflib |
27 |
|
|
28 |
|
from Thuban import internal_from_unicode |
29 |
from Thuban.Lib.fileutil import relative_filename |
from Thuban.Lib.fileutil import relative_filename |
30 |
from Thuban.Model.save import XMLWriter, save_session, sort_data_stores |
from Thuban.Model.save import XMLWriter, save_session, sort_data_stores |
31 |
from Thuban.Model.session import Session |
from Thuban.Model.session import Session |
34 |
from Thuban.Model.proj import Projection |
from Thuban.Model.proj import Projection |
35 |
from Thuban.Model.table import DBFTable |
from Thuban.Model.table import DBFTable |
36 |
from Thuban.Model.transientdb import TransientJoinedTable |
from Thuban.Model.transientdb import TransientJoinedTable |
37 |
from Thuban.Model.data import DerivedShapeStore |
from Thuban.Model.data import DerivedShapeStore, SHAPETYPE_ARC |
38 |
|
|
39 |
from Thuban.Model.classification import ClassGroupSingleton, ClassGroupRange, \ |
from Thuban.Model.classification import ClassGroupSingleton, ClassGroupRange, \ |
40 |
ClassGroupProperties |
ClassGroupProperties |
54 |
eq(writer.encode("hello world"), "hello world") |
eq(writer.encode("hello world"), "hello world") |
55 |
eq(writer.encode(unicode("hello world")), unicode("hello world")) |
eq(writer.encode(unicode("hello world")), unicode("hello world")) |
56 |
|
|
57 |
eq(writer.encode("\x80\x90\xc2\x100"), |
eq(writer.encode(internal_from_unicode(u"\x80\x90\xc2\x100")), |
58 |
"\xc2\x80\xc2\x90\xc3\x82\x100") |
"\xc2\x80\xc2\x90\xc3\x82\x100") |
59 |
eq(writer.encode(u"\x80\x90\xc2\x100"), |
eq(writer.encode(u"\x80\x90\xc2\x100"), |
60 |
"\xc2\x80\xc2\x90\xc3\x82\x100") |
"\xc2\x80\xc2\x90\xc3\x82\x100") |
61 |
eq(writer.encode(u"\xFF5E"), "\xc3\xbf5E") |
eq(writer.encode(u"\xFF5E"), "\xc3\xbf5E") |
62 |
|
|
156 |
<parameter value="datum=WGS84"/> |
<parameter value="datum=WGS84"/> |
157 |
<parameter value="units=m"/> |
<parameter value="units=m"/> |
158 |
</projection> |
</projection> |
159 |
<layer title="My Layer" shapestore="D1" |
<layer title="My Layer" shapestore="D1" visible="%s"> |
160 |
fill="None" stroke="#000000" stroke_width="1" visible="%s"/> |
<classification> |
161 |
|
<clnull label=""> |
162 |
|
<cldata fill="None" stroke="#000000" |
163 |
|
stroke_width="1"/> |
164 |
|
</clnull> |
165 |
|
</classification> |
166 |
|
</layer> |
167 |
</map> |
</map> |
168 |
</session>''' |
</session>''' |
169 |
|
|
222 |
<parameter value="proj=utm"/> |
<parameter value="proj=utm"/> |
223 |
<parameter value="ellps=clrk66"/> |
<parameter value="ellps=clrk66"/> |
224 |
</projection> |
</projection> |
225 |
<layer title="My Layer" shapestore="D1" |
<layer title="My Layer" shapestore="D1" visible="true"> |
|
fill="None" stroke="#000000" stroke_width="1" visible="true"> |
|
226 |
<projection name="Layer Projection"> |
<projection name="Layer Projection"> |
227 |
<parameter value="proj=lcc"/> |
<parameter value="proj=lcc"/> |
228 |
<parameter value="ellps=clrk66"/> |
<parameter value="ellps=clrk66"/> |
229 |
<parameter value="lat_1=0"/> |
<parameter value="lat_1=0"/> |
230 |
<parameter value="lat_2=20"/> |
<parameter value="lat_2=20"/> |
231 |
</projection> |
</projection> |
232 |
|
<classification> |
233 |
|
<clnull label=""> |
234 |
|
<cldata fill="None" stroke="#000000" |
235 |
|
stroke_width="1"/> |
236 |
|
</clnull> |
237 |
|
</classification> |
238 |
</layer> |
</layer> |
239 |
</map> |
</map> |
240 |
</session>''' |
</session>''' |
337 |
layer2.SetClassificationColumn("POPYCOUN") |
layer2.SetClassificationColumn("POPYCOUN") |
338 |
|
|
339 |
# Classification with Latin 1 text |
# Classification with Latin 1 text |
340 |
clazz.AppendGroup(ClassGroupSingleton('\xe4\xf6\xfc', # ae, oe, ue |
clazz.AppendGroup(ClassGroupSingleton( |
341 |
ClassGroupProperties(), |
internal_from_unicode(u'\xe4\xf6\xfc'), # ae, oe, ue |
342 |
'\xdcml\xe4uts')) # Uemlaeuts |
ClassGroupProperties(), |
343 |
|
internal_from_unicode(u'\xdcml\xe4uts'))) # Uemlaeuts |
344 |
|
|
345 |
|
|
346 |
filename = self.temp_file_name("%s.thuban" % self.id()) |
filename = self.temp_file_name("%s.thuban" % self.id()) |
362 |
<parameter value="proj=utm"/> |
<parameter value="proj=utm"/> |
363 |
<parameter value="ellps=clrk66"/> |
<parameter value="ellps=clrk66"/> |
364 |
</projection> |
</projection> |
365 |
<layer title="My Layer" shapestore="D1" |
<layer title="My Layer" shapestore="D1" visible="true"> |
|
fill="None" stroke="#000000" stroke_width="1" visible="true"> |
|
366 |
<classification field="AREA" field_type="double"> |
<classification field="AREA" field_type="double"> |
367 |
<clnull label=""> |
<clnull label=""> |
368 |
<cldata fill="None" stroke="#000000" stroke_width="1"/> |
<cldata fill="None" stroke="#000000" stroke_width="1"/> |
381 |
</clrange> |
</clrange> |
382 |
</classification> |
</classification> |
383 |
</layer> |
</layer> |
384 |
<layer title="My Layer" shapestore="D1" |
<layer title="My Layer" shapestore="D1" visible="true"> |
|
fill="None" stroke="#000000" stroke_width="1" visible="true"> |
|
385 |
<classification field="POPYCOUN" field_type="string"> |
<classification field="POPYCOUN" field_type="string"> |
386 |
<clnull label=""> |
<clnull label=""> |
387 |
<cldata fill="None" stroke="#000000" stroke_width="1"/> |
<cldata fill="None" stroke="#000000" stroke_width="1"/> |
495 |
shapesource="D142197204"/> |
shapesource="D142197204"/> |
496 |
<map title="Test Map"> |
<map title="Test Map"> |
497 |
<layer title="My Layer" |
<layer title="My Layer" |
498 |
shapestore="D141915644" visible="true" |
shapestore="D141915644" visible="true"> |
499 |
stroke="#000000" stroke_width="1" fill="None"/> |
<classification> |
500 |
|
<clnull label=""> |
501 |
|
<cldata fill="None" stroke="#000000" |
502 |
|
stroke_width="1"/> |
503 |
|
</clnull> |
504 |
|
</classification> |
505 |
|
</layer> |
506 |
</map> |
</map> |
507 |
</session>''' |
</session>''' |
508 |
|
|
526 |
def _fetch_table_information(self): |
def _fetch_table_information(self): |
527 |
# pretend that we've found a geometry column |
# pretend that we've found a geometry column |
528 |
self.geometry_column = "the_geom" |
self.geometry_column = "the_geom" |
529 |
|
# pretend this is a ARC shape type. |
530 |
|
self.shape_type = SHAPETYPE_ARC |
531 |
def IDColumn(self): |
def IDColumn(self): |
532 |
"""Return an object with a name attribute with value 'gid'""" |
"""Return an object with a name attribute with value 'gid'""" |
533 |
class dummycol: |
class dummycol: |
566 |
id_column="gid" geometry_column="the_geom"/> |
id_column="gid" geometry_column="the_geom"/> |
567 |
<map title="Test Map"> |
<map title="Test Map"> |
568 |
<layer title="Roads to Nowhere" |
<layer title="Roads to Nowhere" |
569 |
shapestore="roads" visible="true" |
shapestore="roads" visible="true"> |
570 |
stroke="#000000" stroke_width="1" fill="None"/> |
<classification> |
571 |
|
<clnull label=""> |
572 |
|
<cldata fill="None" stroke="#000000" |
573 |
|
stroke_width="1"/> |
574 |
|
</clnull> |
575 |
|
</classification> |
576 |
|
</layer> |
577 |
</map> |
</map> |
578 |
</session>''' |
</session>''' |
579 |
self.compare_xml(written, expected) |
self.compare_xml(written, expected) |