1 |
# Copyright (c) 2002, 2003 by Intevation GmbH |
# Copyright (c) 2002, 2003, 2006 by Intevation GmbH |
2 |
# Authors: |
# Authors: |
3 |
# Bernhard Herzog <[email protected]> |
# Bernhard Herzog <[email protected]> |
4 |
|
# Bernhard Reiter <[email protected]> |
5 |
# |
# |
6 |
# This program is free software under the GPL (>=v2) |
# This program is free software under the GPL (>=v2) |
7 |
# Read the file COPYING coming with Thuban for details. |
# Read the file COPYING coming with Thuban for details. |
15 |
# $Id$ |
# $Id$ |
16 |
|
|
17 |
import unittest |
import unittest |
18 |
|
import locale |
19 |
import os |
import os |
20 |
|
|
21 |
|
import localessupport |
22 |
import xmlsupport |
import xmlsupport |
23 |
import support |
import support |
24 |
support.initthuban() |
support.initthuban() |
99 |
"ellps=clrk66"]) |
"ellps=clrk66"]) |
100 |
self.assertEquals(proj.GetProjectedUnits(), PROJ_UNITS_DEGREES) |
self.assertEquals(proj.GetProjectedUnits(), PROJ_UNITS_DEGREES) |
101 |
|
|
102 |
|
def test_lc_numeric_robustness(self): |
103 |
|
"""Test if an LC_NUMERIC local with comma as decimal_point will work. |
104 |
|
|
105 |
|
Some versions of proj are not robust against this. |
106 |
|
Starting with Python 2.4 there is a different behaviour when |
107 |
|
calling C extensions and now they will see changes locales settings |
108 |
|
which might tickle the bug in proj. |
109 |
|
""" |
110 |
|
params = ["proj=latlong", "to_meter=0.01745", "ellps=clrk66"] |
111 |
|
|
112 |
|
oldlocale = localessupport.setdecimalcommalocale() |
113 |
|
if oldlocale == None: |
114 |
|
raise support.SkipTest( |
115 |
|
"No locale with comma as decimal_point found.") |
116 |
|
|
117 |
|
proj = Projection(params) |
118 |
|
#print proj.work_around_broken_proj |
119 |
|
result1 = proj.Forward(1.2,3.2) |
120 |
|
|
121 |
|
locale.setlocale(locale.LC_NUMERIC, "C") |
122 |
|
proj = Projection(params) |
123 |
|
result2= proj.Forward(1.2,3.2) |
124 |
|
|
125 |
|
locale.setlocale(locale.LC_NUMERIC, oldlocale) |
126 |
|
self.assertFloatSeqEqual(result1, result2, epsilon = 1e-5 ) |
127 |
|
|
128 |
def test_get_projection_units_normal(self): |
def test_get_projection_units_normal(self): |
129 |
"""Test Projection.GetProjectedUnits() for normal projection""" |
"""Test Projection.GetProjectedUnits() for normal projection""" |
130 |
proj = Projection(["zone=26", "proj=utm", "ellps=clrk66"]) |
proj = Projection(["zone=26", "proj=utm", "ellps=clrk66"]) |