From 6f0e4daf52f914dda8654f2322eac4e402117112 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 11 Jul 2013 18:32:54 +0100 Subject: [PATCH] Avoid rounding errors comparing envelopes --- tests/python_tests/map_query_test.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/python_tests/map_query_test.py b/tests/python_tests/map_query_test.py index 8181bb8b5..f1493a6e3 100644 --- a/tests/python_tests/map_query_test.py +++ b/tests/python_tests/map_query_test.py @@ -63,7 +63,11 @@ if 'shape' in mapnik.DatasourceCache.plugin_names(): m.zoom_all() #mapnik.render_to_file(m,'works2.png') # validate that aspect_fix_mode modified the bbox reasonably - eq_(str(m.envelope()),str(mapnik.Box2d(-179.999999975,-167.951396161,179.999999975,192.048603789))) + e = m.envelope() + assert_almost_equal(e.minx, -179.999999975, places=7) + assert_almost_equal(e.miny, -167.951396161, places=7) + assert_almost_equal(e.maxx, 179.999999975, places=7) + assert_almost_equal(e.maxy, 192.048603789, places=7) fs = m.query_point(0,-98.9264, 38.1432) # somewhere in kansas feat = fs.next() eq_(feat.attributes['NAME'],u'United States') @@ -86,7 +90,11 @@ if 'shape' in mapnik.DatasourceCache.plugin_names(): # caution - will go square due to evil aspect_fix_mode backhandedness m.zoom_all() # validate that aspect_fix_mode modified the bbox reasonably - eq_(str(m.envelope()),str(mapnik.Box2d(-179.999999975,-167.951396161,179.999999975,192.048603789))) + e = m.envelope() + assert_almost_equal(e.minx, -179.999999975, places=7) + assert_almost_equal(e.miny, -167.951396161, places=7) + assert_almost_equal(e.maxx, 179.999999975, places=7) + assert_almost_equal(e.maxy, 192.048603789, places=7) fs = m.query_map_point(0,55,100) # somewhere in Canada feat = fs.next() eq_(feat.attributes['NAME'],u'Canada')