50 |
from Thuban.Model.table import DBFTable, MemoryTable, \ |
from Thuban.Model.table import DBFTable, MemoryTable, \ |
51 |
FIELDTYPE_DOUBLE, FIELDTYPE_INT, FIELDTYPE_STRING, \ |
FIELDTYPE_DOUBLE, FIELDTYPE_INT, FIELDTYPE_STRING, \ |
52 |
table_to_dbf |
table_to_dbf |
53 |
|
from Thuban.Model.label import ALIGN_CENTER, ALIGN_TOP, ALIGN_BOTTOM, \ |
54 |
|
ALIGN_LEFT, ALIGN_RIGHT, ALIGN_BASELINE |
55 |
|
|
56 |
|
|
57 |
def filenames_equal(name1, name2): |
def filenames_equal(name1, name2): |
689 |
self.check_format() |
self.check_format() |
690 |
|
|
691 |
|
|
692 |
|
class TestLabelLayer(LoadSessionTest): |
693 |
|
|
694 |
|
# Note that the labels deliberately contain non-ascii characters to |
695 |
|
# test whether they're supported correctly. |
696 |
|
|
697 |
|
file_contents = '''<?xml version="1.0" encoding="UTF-8"?> |
698 |
|
<!DOCTYPE session SYSTEM "thuban-1.0.dtd"> |
699 |
|
<session xmlns="http://thuban.intevation.org/dtds/thuban-1.0rc1.dtd" title="Thuban sample session"> |
700 |
|
<fileshapesource filetype="shapefile" id="D145265052" |
701 |
|
filename="../../Data/iceland/political.shp"/> |
702 |
|
<fileshapesource filetype="shapefile" id="D145412868" |
703 |
|
filename="../../Data/iceland/cultural_landmark-point.shp"/> |
704 |
|
<map title="Iceland map"> |
705 |
|
<projection name="Unknown"> |
706 |
|
<parameter value="zone=26"/> |
707 |
|
<parameter value="proj=utm"/> |
708 |
|
<parameter value="ellps=clrk66"/> |
709 |
|
</projection> |
710 |
|
<layer shapestore="D145265052" visible="true" stroke="#000000" |
711 |
|
title="political" stroke_width="1" fill="#c0c0c0"> |
712 |
|
<projection name="Geographic"> |
713 |
|
<parameter value="proj=latlong"/> |
714 |
|
<parameter value="to_meter=0.017453"/> |
715 |
|
<parameter value="ellps=clrk66"/> |
716 |
|
</projection> |
717 |
|
</layer> |
718 |
|
<layer shapestore="D145412868" visible="true" stroke="#000000" |
719 |
|
title="landmarks" stroke_width="1" fill="#ffff00"> |
720 |
|
<projection name="Geographic"> |
721 |
|
<parameter value="proj=latlong"/> |
722 |
|
<parameter value="to_meter=0.017453"/> |
723 |
|
<parameter value="ellps=clrk66"/> |
724 |
|
</projection> |
725 |
|
</layer> |
726 |
|
<labellayer> |
727 |
|
<label x="-21.5" y="64.25" text="RUINS" |
728 |
|
halign="left" valign="center"/> |
729 |
|
<label x="-15.125" y="64.75" text="H\xc3\xbctte" |
730 |
|
halign="right" valign="top"/> |
731 |
|
</labellayer> |
732 |
|
</map> |
733 |
|
</session> |
734 |
|
''' |
735 |
|
|
736 |
|
def test(self): |
737 |
|
"""Test loading a session with a label layer""" |
738 |
|
session = load_session(self.filename()) |
739 |
|
self.session = session |
740 |
|
|
741 |
|
label_layer = self.session.Maps()[0].LabelLayer() |
742 |
|
expected_labels = [(-21.5, 64.25, "RUINS", ALIGN_LEFT, ALIGN_CENTER), |
743 |
|
(-15.125, 64.75, "H\xfctte", ALIGN_RIGHT, ALIGN_TOP), |
744 |
|
] |
745 |
|
for label, values in zip(label_layer.Labels(), expected_labels): |
746 |
|
self.assertEquals((label.x, label.y, label.text, label.halign, |
747 |
|
label.valign), |
748 |
|
values) |
749 |
|
self.check_format() |
750 |
|
|
751 |
|
|
752 |
class TestPostGISLayer(LoadSessionTest): |
class TestPostGISLayer(LoadSessionTest): |
753 |
|
|