[OpenLayers-Commits] r11118 - in trunk/openlayers: lib/OpenLayers/Layer lib/OpenLayers/Layer/Google tests/Layer/Google

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Mon Feb 14 08:10:39 EST 2011


Author: ahocevar
Date: 2011-02-14 05:10:39 -0800 (Mon, 14 Feb 2011)
New Revision: 11118

Modified:
   trunk/openlayers/lib/OpenLayers/Layer/Google/v3.js
   trunk/openlayers/lib/OpenLayers/Layer/SphericalMercator.js
   trunk/openlayers/lib/OpenLayers/Layer/XYZ.js
   trunk/openlayers/tests/Layer/Google/v3.html
Log:
use the correct maxResolution of 156543.03390625. r=bartvde (closes #3058)

Modified: trunk/openlayers/lib/OpenLayers/Layer/Google/v3.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/Google/v3.js	2011-02-14 12:07:02 UTC (rev 11117)
+++ trunk/openlayers/lib/OpenLayers/Layer/Google/v3.js	2011-02-14 13:10:39 UTC (rev 11118)
@@ -26,13 +26,13 @@
      * (code)
      * {
      *     maxExtent: new OpenLayers.Bounds(
-     *         -128 * 156543.0339,
-     *         -128 * 156543.0339,
-     *         128 * 156543.0339,
-     *         128 * 156543.0339
+     *         -128 * 156543.03390625,
+     *         -128 * 156543.03390625,
+     *         128 * 156543.03390625,
+     *         128 * 156543.03390625
      *     ),
      *     sphericalMercator: true,
-     *     maxResolution: 156543.0339,
+     *     maxResolution: 156543.03390625,
      *     units: "m",
      *     projection: "EPSG:900913"
      * }
@@ -40,13 +40,13 @@
      */
     DEFAULTS: {
         maxExtent: new OpenLayers.Bounds(
-            -128 * 156543.0339,
-            -128 * 156543.0339,
-            128 * 156543.0339,
-            128 * 156543.0339
+            -128 * 156543.03390625,
+            -128 * 156543.03390625,
+            128 * 156543.03390625,
+            128 * 156543.03390625
         ),
         sphericalMercator: true,
-        maxResolution: 156543.0339,
+        maxResolution: 156543.03390625,
         units: "m",
         projection: "EPSG:900913"
     },

Modified: trunk/openlayers/lib/OpenLayers/Layer/SphericalMercator.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/SphericalMercator.js	2011-02-14 12:07:02 UTC (rev 11117)
+++ trunk/openlayers/lib/OpenLayers/Layer/SphericalMercator.js	2011-02-14 13:10:39 UTC (rev 11118)
@@ -95,7 +95,7 @@
     initMercatorParameters: function() {
         // set up properties for Mercator - assume EPSG:900913
         this.RESOLUTIONS = [];
-        var maxResolution = 156543.0339;
+        var maxResolution = 156543.03390625;
         for(var zoom=0; zoom<=this.MAX_ZOOM_LEVEL; ++zoom) {
             this.RESOLUTIONS[zoom] = maxResolution / Math.pow(2, zoom);
         }

Modified: trunk/openlayers/lib/OpenLayers/Layer/XYZ.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/XYZ.js	2011-02-14 12:07:02 UTC (rev 11117)
+++ trunk/openlayers/lib/OpenLayers/Layer/XYZ.js	2011-02-14 13:10:39 UTC (rev 11118)
@@ -65,12 +65,12 @@
         if (options && options.sphericalMercator || this.sphericalMercator) {
             options = OpenLayers.Util.extend({
                 maxExtent: new OpenLayers.Bounds(
-                    -128 * 156543.0339,
-                    -128 * 156543.0339,
-                    128 * 156543.0339,
-                    128 * 156543.0339
+                    -128 * 156543.03390625,
+                    -128 * 156543.03390625,
+                    128 * 156543.03390625,
+                    128 * 156543.03390625
                 ),
-                maxResolution: 156543.0339,
+                maxResolution: 156543.03390625,
                 numZoomLevels: 19,
                 units: "m",
                 projection: "EPSG:900913"

Modified: trunk/openlayers/tests/Layer/Google/v3.html
===================================================================
--- trunk/openlayers/tests/Layer/Google/v3.html	2011-02-14 12:07:02 UTC (rev 11117)
+++ trunk/openlayers/tests/Layer/Google/v3.html	2011-02-14 13:10:39 UTC (rev 11118)
@@ -3,6 +3,7 @@
     <script src="http://maps.google.com/maps/api/js?sensor=false"></script>
     <script src="../../../lib/OpenLayers.js"></script>
     <script type="text/javascript">
+
     var layer; 
                    
     function test_Layer_Google_constructor (t) {
@@ -265,6 +266,12 @@
 
          t.plan(8);
 
+         var origPrecision = OpenLayers.Util.DEFAULT_PRECISION;
+         // GMaps v3 seems to use a default precision of 13, which is lower
+         // than what we use in OpenLayers.
+         // See http://trac.osgeo.org/openlayers/ticket/3059
+         OpenLayers.Util.DEFAULT_PRECISION = 13;
+
          var map = new OpenLayers.Map('map', {allOverlays: true});
 
          var gmap = new OpenLayers.Layer.Google("Google Streets");
@@ -275,16 +282,18 @@
          map.setCenter(origin, 4);
          var resolution = map.getResolution();
          
-         var dx, dy, center, expectedX, expectedY;
+         var dx, dy, center, expected;
 
          // confirm that panning works with Google visible
          dx = 100, dy = -100;
          map.pan(dx, dy, {animate: false});
          center = map.getCenter();
-         expectedX = origin.lon + (resolution * dx);
-         expectedY = origin.lat - (resolution * dy);
-         t.eq(center.lon, expectedX, "x panning with Google visible " + dx + ", " + dy);
-         t.eq(center.lat, expectedY, "y panning with Google visible " + dx + ", " + dy);
+         expected = new OpenLayers.LonLat(
+             origin.lon + (resolution * dx),
+             origin.lat - (resolution * dy)
+         );
+         t.eq(center.lon, expected.lon, "x panning with Google visible " + dx + ", " + dy);
+         t.eq(center.lat, expected.lat, "y panning with Google visible " + dx + ", " + dy);
          map.pan(-dx, -dy, {animate: false});
          center = map.getCenter();
          t.eq(center.lon, origin.lon, "x panning with Google visible " + (-dx) + ", " + (-dy));
@@ -295,22 +304,30 @@
          dx = 100, dy = -100;
          map.pan(dx, dy, {animate: false});
          center = map.getCenter();
-         expectedX = origin.lon + (resolution * dx);
-         expectedY = origin.lat - (resolution * dy);
-         t.eq(center.lon, expectedX, "x panning with Google invisible " + dx + ", " + dy);
-         t.eq(center.lat, expectedY, "y panning with Google invisible " + dx + ", " + dy);
+         expected = new OpenLayers.LonLat(
+             origin.lon + (resolution * dx),
+             origin.lat - (resolution * dy)
+         );
+         t.eq(center.lon, expected.lon, "x panning with Google invisible " + dx + ", " + dy);
+         t.eq(center.lat, expected.lat, "y panning with Google invisible " + dx + ", " + dy);
          map.pan(-dx, -dy, {animate: false});
          center = map.getCenter();
          t.eq(center.lon, origin.lon, "x panning with Google invisible " + (-dx) + ", " + (-dy));
          t.eq(center.lat, origin.lat, "y panning with Google invisible " + (-dx) + ", " + (-dy));
-         
+
          map.destroy();
-
+         OpenLayers.Util.DEFAULT_PRECISION = origPrecision;
      }
      
      function test_wrapDateLine(t) {
          t.plan(2);
 
+         var origPrecision = OpenLayers.Util.DEFAULT_PRECISION;
+         // GMaps v3 seems to use a default precision of 13, which is lower
+         // than what we use in OpenLayers.
+         // See http://trac.osgeo.org/openlayers/ticket/3059
+         OpenLayers.Util.DEFAULT_PRECISION = 13;
+
          var map = new OpenLayers.Map("map");
 
          var gmap = new OpenLayers.Layer.Google("Google Streets");
@@ -322,14 +339,15 @@
          // pan to the edge of the world
          map.pan(256, 0, {animate: false});
          center = map.getCenter();
-         t.eq(center.lon, 20037508.3392, "edge of the world");
+         t.eq(center.lon, 20037508.34, "edge of the world");
          // pan off the edge of the world
          map.pan(100, 0, {animate: false});
          center = map.getCenter();
-         t.eq(center.lon, -12210356.6442, "magically back in the western hemisphere");
+         var expect = OpenLayers.Util.toFloat(100 * map.getResolution() - 20037508.34);
+         t.eq(center.lon, expect, "magically back in the western hemisphere");
          
          map.destroy();
-         
+         OpenLayers.Util.DEFAULT_PRECISION = origPrecision;         
      }
 
      function test_respectDateLine(t) {
@@ -346,16 +364,16 @@
          // pan to the edge of the world
          map.pan(256, 0, {animate: false});
          center = map.getCenter();
-         t.eq(center.lon, 20037508.3392, "edge of the world");
+         t.eq(center.lon, 20037508.34, "edge of the world");
          // pan off the edge of the world
          map.pan(100, 0, {animate: false});
          center = map.getCenter();
-         t.eq(center.lon, 20037508.3392, "whew, still on the edge");
+         t.eq(center.lon, 20037508.34, "whew, still on the edge");
          
          map.destroy();
          
      }
-
+     
   </script>
 </head>
 <body>



More information about the Commits mailing list