1 |
# Copyright (C) 2003 by Intevation GmbH |
2 |
# Authors: |
3 |
# Bernhard Herzog <[email protected]> |
4 |
# |
5 |
# This program is free software under the GPL (>=v2) |
6 |
# Read the file COPYING coming with the software for details. |
7 |
|
8 |
"""Test cases for the mockgeo helper objects""" |
9 |
|
10 |
__version__ = "$Revision$" |
11 |
# $Source$ |
12 |
# $Id$ |
13 |
|
14 |
import unittest |
15 |
|
16 |
import mockgeo |
17 |
|
18 |
import support |
19 |
|
20 |
class TestAffineProjection(unittest.TestCase, support.FloatComparisonMixin): |
21 |
|
22 |
def test_forward(self): |
23 |
"""Test AffineProjection.Forward()""" |
24 |
proj = mockgeo.AffineProjection((0.25, 0.1, 2, 0.125, 100.75, 123.25)) |
25 |
self.assertEquals(proj.Forward(0, 0), (100.75, 123.25)) |
26 |
self.assertEquals(proj.Forward(10.0, 20.0), (143.25, 126.75)) |
27 |
self.assertEquals(proj.Forward(30, 0.125), (108.5, 126.265625)) |
28 |
|
29 |
def test_inverse(self): |
30 |
"""Test AffineProjection.Inverse()""" |
31 |
proj = mockgeo.AffineProjection((0.25, 0.1, 2, 0.125, 100.75, 123.25)) |
32 |
self.assertEquals(proj.Inverse(100.75, 123.25), (0, 0)) |
33 |
self.assertEquals(proj.Inverse(143.25, 126.75), (10.0, 20.0)) |
34 |
self.assertFloatSeqEqual(proj.Inverse(108.5, 126.265625), (30, 0.125)) |
35 |
|
36 |
def test_int_coeff(self): |
37 |
"""Test AffineProjection with integer coefficients""" |
38 |
proj = mockgeo.AffineProjection((1, 1, -1, 1, 0, 0)) |
39 |
# The determinant is an int too but must be treated as a float |
40 |
# when dividing by it otherwise some coefficients in the inverse |
41 |
# become wrong. |
42 |
self.assertEquals(proj.Inverse(10, 10), (10, 0)) |
43 |
|
44 |
|
45 |
|
46 |
if __name__ == "__main__": |
47 |
support.run_tests() |