Files
openlayers/tests/Layer/test_SphericalMercator.html
crschmidt 0aba585bc0 With review from elem, and oversight from tschaub, rolling in
SphericalMercator changes. Note that this explicitly does *not* include 
r4182 , so as to keep changes to a single logical set: that should be
filed in a seperate bug if it can be reproduced against trunk after this
commit. Hooray for Tim, thanks for all the feedback, onward and upward!
(Closes #686)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@4221 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2007-09-11 21:16:28 +00:00

51 lines
2.2 KiB
HTML

<html>
<head>
<!-- this gmaps key generated for http://openlayers.org/dev/ -->
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript">
function test_SphericalMercator_forwardProject(t) {
t.plan(12);
var arctic = OpenLayers.Layer.SphericalMercator.forwardMercator(0, 85);
var antarctic = OpenLayers.Layer.SphericalMercator.forwardMercator(0, -85);
var hawaii = OpenLayers.Layer.SphericalMercator.forwardMercator(-180, 0);
var phillipines = OpenLayers.Layer.SphericalMercator.forwardMercator(180, 0);
var ne = OpenLayers.Layer.SphericalMercator.forwardMercator(180, 90);
var sw = OpenLayers.Layer.SphericalMercator.forwardMercator(-180, -90);
t.eq(arctic.lon, 0, "Arctic longitude is correct");
t.eq(Math.round(arctic.lat), 19971869, "Arctic latitude is correct");
t.eq(antarctic.lon, 0, "Antarctic longitude is correct");
t.eq(Math.round(antarctic.lat), -19971869, "Antarctic latitude is correct");
t.eq(Math.round(hawaii.lat), 0, "Hawaiian lat is correct");
t.eq(hawaii.lon, -20037508.34, "Hawaiian lon is correct");
t.eq(Math.round(phillipines.lat), 0, "Phillipines lat is correct");
t.eq(phillipines.lon, 20037508.340, "Phillipines lon is correct");
// Rounding errors make this not infinity
t.ok(ne.lat > 50000000, "NE lat is correct");
t.eq(ne.lon, 20037508.34, "NE lon is correct");
t.eq(sw.lat, -Infinity, "SW lat is correct");
t.eq(sw.lon, -20037508.34, "SW lon is correct");
}
function test_sphericalMercator_inverseProject(t) {
t.plan(4);
var sw = OpenLayers.Layer.SphericalMercator.inverseMercator(-20037508.34, -20037508.34);
var ne = OpenLayers.Layer.SphericalMercator.inverseMercator(20037508.34, 20037508.34);
t.eq(sw.lon, -180, "Southwest lon correct");
t.eq(ne.lon, 180, "Northeast lon correct");
t.eq(sw.lat, -85.05112877980659, "Southwest lat correct");
t.eq(ne.lat, 85.05112877980660, "Northeast lat correct");
}
</script>
</head>
<body>
</body>
</html>