[OpenLayers-Commits] r11374 - trunk/openlayers/tests
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Wed Feb 23 17:24:35 EST 2011
Author: crschmidt
Date: 2011-02-23 14:24:35 -0800 (Wed, 23 Feb 2011)
New Revision: 11374
Modified:
trunk/openlayers/tests/Map.html
Log:
Test that getLonLatFromPixel and getPixelFromLonLat are inverses of each
other (within a reasonable tolerance)
Modified: trunk/openlayers/tests/Map.html
===================================================================
--- trunk/openlayers/tests/Map.html 2011-02-23 18:51:34 UTC (rev 11373)
+++ trunk/openlayers/tests/Map.html 2011-02-23 22:24:35 UTC (rev 11374)
@@ -1667,7 +1667,26 @@
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();
+ }
+
</script>
</head>
<body>
More information about the Commits
mailing list