14 |
# $Id$ |
# $Id$ |
15 |
|
|
16 |
import unittest |
import unittest |
17 |
|
import locale |
18 |
import os |
import os |
19 |
|
|
20 |
|
import localessupport |
21 |
import xmlsupport |
import xmlsupport |
22 |
import support |
import support |
23 |
support.initthuban() |
support.initthuban() |
98 |
"ellps=clrk66"]) |
"ellps=clrk66"]) |
99 |
self.assertEquals(proj.GetProjectedUnits(), PROJ_UNITS_DEGREES) |
self.assertEquals(proj.GetProjectedUnits(), PROJ_UNITS_DEGREES) |
100 |
|
|
101 |
|
def test_lc_numeric_robustness(self): |
102 |
|
"""Test if an LC_NUMERIC local with comma as decimal_point will work. |
103 |
|
|
104 |
|
Some versions of proj are not robust against this. |
105 |
|
Starting with Python 2.4 there is a different behaviour when |
106 |
|
calling C extensions and now they will see changes locales settings |
107 |
|
which might tickle the bug in proj. |
108 |
|
""" |
109 |
|
params = ["proj=latlong", "to_meter=0.01745", "ellps=clrk66"] |
110 |
|
|
111 |
|
oldlocale = localessupport.setdecimalcommalocale() |
112 |
|
if oldlocale == None: |
113 |
|
raise support.SkipTest( |
114 |
|
"No locale with comma as decimal_point found.") |
115 |
|
|
116 |
|
proj = Projection(params) |
117 |
|
result1 = proj.Forward(1,1) |
118 |
|
|
119 |
|
locale.setlocale(locale.LC_NUMERIC, "C") |
120 |
|
proj = Projection(params) |
121 |
|
result2= proj.Forward(1,1) |
122 |
|
|
123 |
|
locale.setlocale(locale.LC_NUMERIC, oldlocale) |
124 |
|
self.assertFloatSeqEqual(result1, result2, epsilon = 1e-5 ) |
125 |
|
|
126 |
def test_get_projection_units_normal(self): |
def test_get_projection_units_normal(self): |
127 |
"""Test Projection.GetProjectedUnits() for normal projection""" |
"""Test Projection.GetProjectedUnits() for normal projection""" |
128 |
proj = Projection(["zone=26", "proj=utm", "ellps=clrk66"]) |
proj = Projection(["zone=26", "proj=utm", "ellps=clrk66"]) |