13 |
# $Source$ |
# $Source$ |
14 |
# $Id$ |
# $Id$ |
15 |
|
|
16 |
|
from Thuban import _ |
17 |
|
|
18 |
import unittest |
import unittest |
19 |
import os |
import os |
20 |
|
|
37 |
|
|
38 |
def test(self): |
def test(self): |
39 |
"""Test Projection""" |
"""Test Projection""" |
40 |
proj = Projection(["zone=26", "proj=utm", "ellps=clrk66"]) |
params = ["zone=26", "proj=utm", "ellps=clrk66"] |
41 |
self.assertEquals(proj.params, ["zone=26", "proj=utm", "ellps=clrk66"]) |
proj = Projection(params) |
42 |
|
self.assertEquals(proj.params, params) |
43 |
|
|
44 |
# It's not clear whether this value is really the correct one |
# It's not clear whether this value is really the correct one |
45 |
# but a test failure here probably still means a bug somewhere |
# but a test failure here probably still means a bug somewhere |
54 |
3875381.8535437919, 252962.10480170773), |
3875381.8535437919, 252962.10480170773), |
55 |
epsilon = 1e-5) |
epsilon = 1e-5) |
56 |
|
|
57 |
|
# GetName() |
58 |
|
self.assertEquals(proj.GetName(), _("Unknown")) |
59 |
|
|
60 |
|
# GetParameter() |
61 |
self.assertEquals(proj.GetParameter("zone"), "26") |
self.assertEquals(proj.GetParameter("zone"), "26") |
62 |
self.assertEquals(proj.GetParameter("proj"), "utm") |
self.assertEquals(proj.GetParameter("proj"), "utm") |
63 |
self.assertEquals(proj.GetParameter("ellps"), "clrk66") |
self.assertEquals(proj.GetParameter("ellps"), "clrk66") |
64 |
self.assertEquals(proj.GetParameter("hallo"), "") |
self.assertEquals(proj.GetParameter("hallo"), "") |
65 |
|
|
66 |
|
# GetAllParameters() |
67 |
|
self.assertEquals(proj.GetAllParameters(), params) |
68 |
|
|
69 |
|
# GetName() |
70 |
|
proj = Projection(params, "MyName") |
71 |
|
self.assertEquals(proj.GetName(), "MyName") |
72 |
|
|
73 |
|
|
74 |
sample_projfile = '''\ |
sample_projfile = '''\ |
75 |
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
137 |
|
|
138 |
eq = self.assertEquals |
eq = self.assertEquals |
139 |
|
|
140 |
|
|
141 |
# |
# |
142 |
# __init__() |
# __init__() |
143 |
# GetFilename() |
# GetFilename() |
164 |
eq(len(projFile.GetProjections()), 0) |
eq(len(projFile.GetProjections()), 0) |
165 |
|
|
166 |
# try to remove something that doesn't exist |
# try to remove something that doesn't exist |
167 |
|
self.assertRaises(ValueError, projFile.Remove, None) |
168 |
self.assertRaises(ValueError, projFile.Remove, proj0) |
self.assertRaises(ValueError, projFile.Remove, proj0) |
169 |
|
|
170 |
projFile.Add(proj0) |
projFile.Add(proj0) |
178 |
eq(projs[1], proj1) |
eq(projs[1], proj1) |
179 |
eq(projs[2], proj2) |
eq(projs[2], proj2) |
180 |
|
|
181 |
# |
projFile.Remove(proj2) |
182 |
# SetAllParameters() |
projFile.Remove(proj1) |
183 |
# SetName() |
|
184 |
# SetProjection() |
# Replace() |
185 |
# |
projFile.Replace(proj0, proj1) |
186 |
params = ["proj=utm", "ellps=clrk66", "zone=13"] |
projs = projFile.GetProjections() |
187 |
proj0.SetAllParameters(params) |
eq(projs[0], proj1) |
188 |
eq(proj0.GetAllParameters(), params) |
|
189 |
|
# replace a non-existent projection |
190 |
proj2.SetName("something") |
self.assertRaises(ValueError, projFile.Replace, None, proj2) |
191 |
proj0.SetProjection(proj2) |
self.assertRaises(ValueError, projFile.Replace, proj0, proj2) |
|
eq(proj0.GetName(), "something") |
|
|
eq(proj0.GetAllParameters(), proj2.GetAllParameters()) |
|
192 |
|
|
193 |
def testRead(self): |
def testRead(self): |
194 |
"""Test ReadProjFile""" |
"""Test ReadProjFile""" |