From f8db509725cbb43ff4a7c2c3fcd1e0867c8a6075 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Wed, 23 Feb 2011 22:24:35 +0000 Subject: [PATCH] Test that getLonLatFromPixel and getPixelFromLonLat are inverses of each other (within a reasonable tolerance) git-svn-id: http://svn.openlayers.org/trunk/openlayers@11374 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- tests/Map.html | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/Map.html b/tests/Map.html index 13712f81af..12841e7cfd 100644 --- a/tests/Map.html +++ b/tests/Map.html @@ -1667,6 +1667,25 @@ map.destroy(); } + function test_pixel_lonlat(t) { + + t.plan(4); + + var map = new OpenLayers.Map({ + div: "map", + layers: [ + new OpenLayers.Layer("name", {isBaseLayer:true}) + ] + }); + map.zoomToMaxExtent(); + var px = map.getPixelFromLonLat(map.getLonLatFromPixel(new OpenLayers.Pixel(100, 100))); + t.eq(px.x, 100, "x is the same in and ot"); + t.eq(px.y, 100, "y is the same in and out"); + var ll = map.getLonLatFromPixel(map.getPixelFromLonLat(new OpenLayers.LonLat(100, 100))); + t.ok((ll.lon > (100 -map.getResolution()) && (ll.lon < (100 + map.getResolution()))), "lon is the same in and ot"); + t.ok((ll.lat > (100 -map.getResolution()) && (ll.lat < (100 + map.getResolution()))), "lat is the same in and ot"); + map.destroy(); + }