2009-04-16 19:22:38 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
from nose.tools import *
|
|
|
|
|
2011-12-03 00:21:35 +01:00
|
|
|
import mapnik
|
2009-04-16 19:22:38 +02:00
|
|
|
|
|
|
|
# Tests that exercise map projections.
|
|
|
|
|
2011-05-17 21:05:15 +02:00
|
|
|
def test_normalizing_definition():
|
2011-11-23 12:33:58 +01:00
|
|
|
p = mapnik.Projection('+init=epsg:4326')
|
2011-05-17 21:05:15 +02:00
|
|
|
expanded = p.expanded()
|
|
|
|
eq_('+proj=longlat' in expanded,True)
|
|
|
|
|
|
|
|
|
2009-04-16 19:22:38 +02:00
|
|
|
# Trac Ticket #128
|
|
|
|
def test_wgs84_inverse_forward():
|
2011-11-23 12:33:58 +01:00
|
|
|
p = mapnik.Projection('+init=epsg:4326')
|
2009-04-16 19:22:38 +02:00
|
|
|
|
2011-11-23 12:33:58 +01:00
|
|
|
c = mapnik.Coord(3.01331418311, 43.3333092669)
|
|
|
|
e = mapnik.Box2d(-122.54345245, 45.12312553, 68.2335581353, 48.231231233)
|
2009-04-16 19:22:38 +02:00
|
|
|
|
|
|
|
# It appears that the y component changes very slightly, is this OK?
|
2009-06-11 23:31:06 +02:00
|
|
|
# so we test for 'almost equal float values'
|
2012-02-24 22:13:56 +01:00
|
|
|
|
2009-06-11 23:31:06 +02:00
|
|
|
assert_almost_equal(p.inverse(c).y, c.y)
|
|
|
|
assert_almost_equal(p.inverse(c).x, c.x)
|
2009-04-16 19:22:38 +02:00
|
|
|
|
2009-06-11 23:31:06 +02:00
|
|
|
assert_almost_equal(p.forward(c).y, c.y)
|
|
|
|
assert_almost_equal(p.forward(c).x, c.x)
|
2009-04-16 19:22:38 +02:00
|
|
|
|
2009-06-11 23:31:06 +02:00
|
|
|
assert_almost_equal(p.inverse(e).center().y, e.center().y)
|
|
|
|
assert_almost_equal(p.inverse(e).center().x, e.center().x)
|
2009-04-16 19:22:38 +02:00
|
|
|
|
2009-06-11 23:31:06 +02:00
|
|
|
assert_almost_equal(p.forward(e).center().y, e.center().y)
|
|
|
|
assert_almost_equal(p.forward(e).center().x, e.center().x)
|
|
|
|
|
|
|
|
assert_almost_equal(c.inverse(p).y, c.y)
|
|
|
|
assert_almost_equal(c.inverse(p).x, c.x)
|
|
|
|
|
|
|
|
assert_almost_equal(c.forward(p).y, c.y)
|
|
|
|
assert_almost_equal(c.forward(p).x, c.x)
|
|
|
|
|
|
|
|
assert_almost_equal(e.inverse(p).center().y, e.center().y)
|
|
|
|
assert_almost_equal(e.inverse(p).center().x, e.center().x)
|
|
|
|
|
|
|
|
assert_almost_equal(e.forward(p).center().y, e.center().y)
|
2009-12-16 21:02:06 +01:00
|
|
|
assert_almost_equal(e.forward(p).center().x, e.center().x)
|
2011-08-31 00:51:42 +02:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
[eval(run)() for run in dir() if 'test_' in run]
|