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
This commit is contained in:
@@ -128,6 +128,23 @@
|
||||
window.location.host);
|
||||
}
|
||||
}
|
||||
|
||||
function test_Layer_Goole_forwardMercator(t){
|
||||
t.plan(2);
|
||||
//Just test that the fowardMercator function still exists.
|
||||
var layer = new OpenLayers.Layer.Google('Test Layer', {'sphericalMercator': true});
|
||||
layer.forwardMercator = function(evt) {
|
||||
t.ok( true, "GoogleMercator.forwardMercator was called and executed." );
|
||||
return;
|
||||
}
|
||||
layer.forwardMercator();
|
||||
//Now test the fowardMercator returns the expected LonLat object
|
||||
var layer = new OpenLayers.Layer.Google('Test Layer', {'sphericalMercator': true});
|
||||
var lonlat2 = new OpenLayers.LonLat(Math.random(),Math.random());
|
||||
var result = layer.forwardMercator(lonlat2.lon, lonlat2.lat);
|
||||
t.ok( result instanceof OpenLayers.LonLat, "OpenLayers.Google.fowardMercator returns LonLat object" );
|
||||
|
||||
}
|
||||
|
||||
function test_Layer_Google_overlay(t) {
|
||||
// Test for #849.
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<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>
|
||||
@@ -40,6 +40,7 @@
|
||||
<li>Layer/test_EventPane.html</li>
|
||||
<li>Layer/test_FixedZoomLevels.html</li>
|
||||
<li>Layer/test_GeoRSS.html</li>
|
||||
<li>Layer/test_SphericalMercator.html</li>
|
||||
<li>Layer/test_Google.html</li>
|
||||
<li>Layer/test_Grid.html</li>
|
||||
<li>Layer/test_HTTPRequest.html</li>
|
||||
|
||||
Reference in New Issue
Block a user