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 |
# |
# |
40 |
import dbflib |
import dbflib |
41 |
import shapelib |
import shapelib |
42 |
|
|
43 |
|
from Thuban import internal_from_unicode |
44 |
from Thuban.Model.save import save_session |
from Thuban.Model.save import save_session |
45 |
from Thuban.Model.load import load_session, parse_color, LoadError, \ |
from Thuban.Model.load import load_session, parse_color, LoadError, \ |
46 |
LoadCancelled |
LoadCancelled |
54 |
from Thuban.Model.label import ALIGN_CENTER, ALIGN_TOP, ALIGN_BOTTOM, \ |
from Thuban.Model.label import ALIGN_CENTER, ALIGN_TOP, ALIGN_BOTTOM, \ |
55 |
ALIGN_LEFT, ALIGN_RIGHT, ALIGN_BASELINE |
ALIGN_LEFT, ALIGN_RIGHT, ALIGN_BASELINE |
56 |
|
|
|
|
|
57 |
def filenames_equal(name1, name2): |
def filenames_equal(name1, name2): |
58 |
"""Return true if the filenames name1 and name2 are equal. |
"""Return true if the filenames name1 and name2 are equal. |
59 |
|
|
124 |
print a != b and "***************" or "" |
print a != b and "***************" or "" |
125 |
print a |
print a |
126 |
print b |
print b |
127 |
|
|
128 |
self.assertEquals(el1, el2, |
self.assertEquals(el1, el2, |
129 |
"loaded file not equivalent to the saved file") |
"loaded file not equivalent to the saved file") |
130 |
|
|
215 |
self.session = session |
self.session = session |
216 |
|
|
217 |
# Check the title |
# Check the title |
218 |
eq(session.Title(), "Stra\xdfen & Landmarken") |
eq(session.Title(), internal_from_unicode(u"Stra\xdfen & Landmarken")) |
219 |
|
|
220 |
# the session has one map. |
# the session has one map. |
221 |
maps = session.Maps() |
maps = session.Maps() |
223 |
|
|
224 |
# Check the map's attributes |
# Check the map's attributes |
225 |
map = maps[0] |
map = maps[0] |
226 |
eq(map.Title(), "\xdcbersicht") |
eq(map.Title(), internal_from_unicode(u"\xdcbersicht")) |
227 |
proj = map.GetProjection() |
proj = map.GetProjection() |
228 |
eq(proj.GetName(), "WGS 84 / UTM zone 27N") |
eq(proj.GetName(), "WGS 84 / UTM zone 27N") |
229 |
eq(proj.EPSGCode(), "32627") |
eq(proj.EPSGCode(), "32627") |
238 |
|
|
239 |
# Check the layer attributes |
# Check the layer attributes |
240 |
layer = layers[0] |
layer = layers[0] |
241 |
eq(layer.Title(), "K\xfcste") |
eq(layer.Title(), internal_from_unicode(u"K\xfcste")) |
242 |
self.failUnless(filenames_equal(layer.ShapeStore().FileName(), |
self.failUnless(filenames_equal(layer.ShapeStore().FileName(), |
243 |
os.path.join(self.temp_dir(), |
os.path.join(self.temp_dir(), |
244 |
os.pardir, os.pardir, |
os.pardir, os.pardir, |
511 |
("#000000", 2, "None")), |
("#000000", 2, "None")), |
512 |
("single", "1", "", |
("single", "1", "", |
513 |
("#000000", 10, "None")), |
("#000000", 10, "None")), |
514 |
("single", "\xe4\xf6\xfc", "\xdcml\xe4uts", |
("single", internal_from_unicode(u"\xe4\xf6\xfc"), |
515 |
|
internal_from_unicode(u"\xdcml\xe4uts"), |
516 |
("#000000", 1, "None"))]), |
("#000000", 1, "None"))]), |
517 |
("My Layer 2", 4, |
("My Layer 2", 4, |
518 |
[("default", (), "", |
[("default", (), "", |
666 |
title="single map&layer"> |
title="single map&layer"> |
667 |
<map title="Test Map"> |
<map title="Test Map"> |
668 |
<rasterlayer visible="false" filename="../../Data/iceland/island.tif" |
<rasterlayer visible="false" filename="../../Data/iceland/island.tif" |
669 |
title="My RasterLayer"/> |
title="My RasterLayer" opacity="0.4" masktype="alpha"/> |
670 |
</map> |
</map> |
671 |
</session> |
</session> |
672 |
''' |
''' |
683 |
layer = map.Layers()[0] # one layer in the sample |
layer = map.Layers()[0] # one layer in the sample |
684 |
|
|
685 |
eq(layer.Title(), "My RasterLayer") |
eq(layer.Title(), "My RasterLayer") |
686 |
|
eq(layer.Opacity(), 0.4) |
687 |
|
eq(layer.MaskType(), layer.MASK_ALPHA) |
688 |
|
|
689 |
self.failIf(layer.Visible()) |
self.failIf(layer.Visible()) |
690 |
self.failUnless(filenames_equal(layer.GetImageFilename(), |
self.failUnless(filenames_equal(layer.GetImageFilename(), |
691 |
os.path.join(self.temp_dir(), |
os.path.join(self.temp_dir(), |
794 |
|
|
795 |
label_layer = self.session.Maps()[0].LabelLayer() |
label_layer = self.session.Maps()[0].LabelLayer() |
796 |
expected_labels = [(-21.5, 64.25, "RUINS", ALIGN_LEFT, ALIGN_CENTER), |
expected_labels = [(-21.5, 64.25, "RUINS", ALIGN_LEFT, ALIGN_CENTER), |
797 |
(-15.125, 64.75, "H\xfctte", ALIGN_RIGHT, ALIGN_TOP), |
(-15.125, 64.75, internal_from_unicode(u"H\xfctte"), |
798 |
|
ALIGN_RIGHT, ALIGN_TOP), |
799 |
] |
] |
800 |
for label, values in zip(label_layer.Labels(), expected_labels): |
for label, values in zip(label_layer.Labels(), expected_labels): |
801 |
self.assertEquals((label.x, label.y, label.text, label.halign, |
self.assertEquals((label.x, label.y, label.text, label.halign, |
1051 |
|
|
1052 |
def test_01_single_path_error_fix(self): |
def test_01_single_path_error_fix(self): |
1053 |
"""Test single file path error fix.""" |
"""Test single file path error fix.""" |
|
|
|
|
eq = self.assertEquals |
|
|
|
|
1054 |
# The usual initial case |
# The usual initial case |
1055 |
s_cb = Shapefile_CallBack({ |
s_cb = Shapefile_CallBack({ |
1056 |
"search": [("../Data/iceland/roads-line.shp",0)], |
"search": [("../Data/iceland/roads-line.shp",0)], |