[OpenLayers-Commits] r4795 - in branches/openlayers/2.5: lib/OpenLayers tests tests/Control tests/Layer

commits at openlayers.org commits at openlayers.org
Wed Oct 3 16:42:39 EDT 2007


Author: crschmidt
Date: 2007-10-03 16:42:35 -0400 (Wed, 03 Oct 2007)
New Revision: 4795

Modified:
   branches/openlayers/2.5/lib/OpenLayers/Layer.js
   branches/openlayers/2.5/lib/OpenLayers/Map.js
   branches/openlayers/2.5/tests/Control/test_OverviewMap.html
   branches/openlayers/2.5/tests/Layer/test_Grid.html
   branches/openlayers/2.5/tests/Layer/test_KaMap.html
   branches/openlayers/2.5/tests/Layer/test_TMS.html
   branches/openlayers/2.5/tests/Layer/test_TileCache.html
   branches/openlayers/2.5/tests/Layer/test_WrapDateLine.html
   branches/openlayers/2.5/tests/test_Layer.html
Log:
Pullup fix for zooms to branch. (Closes #1043) 4791:4792 


Modified: branches/openlayers/2.5/lib/OpenLayers/Layer.js
===================================================================
--- branches/openlayers/2.5/lib/OpenLayers/Layer.js	2007-10-03 20:27:15 UTC (rev 4794)
+++ branches/openlayers/2.5/lib/OpenLayers/Layer.js	2007-10-03 20:42:35 UTC (rev 4795)
@@ -731,19 +731,24 @@
      * 
      * Parameters:
      * bounds - {<OpenLayers.Bounds>}
+     * closest - {Boolean} Find the zoom level that most closely fits the 
+     *     specified bounds. Note that this may result in a zoom that does 
+     *     not exactly contain the entire extent.
+     *     Default is false.
      *
      * Returns:
      * {Integer} The index of the zoomLevel (entry in the resolutions array) 
-     *     that still contains the passed-in extent. We do this by calculating
-     *     the ideal resolution for the given exteng (based on the map size)
-     *     and then find the closest resolution to this ideal resolution.
+     *     for the passed-in extent. We do this by calculating the ideal 
+     *     resolution for the given extent (based on the map size) and then 
+     *     calling getZoomForResolution(), passing along the 'closest'
+     *     parameter.
      */
-    getZoomForExtent: function(extent) {
+    getZoomForExtent: function(extent, closest) {
         var viewSize = this.map.getSize();
         var idealResolution = Math.max( extent.getWidth()  / viewSize.w,
                                         extent.getHeight() / viewSize.h );
 
-        return this.getZoomForResolution(idealResolution);
+        return this.getZoomForResolution(idealResolution, closest);
     },
     
     /** 
@@ -760,28 +765,39 @@
 
     /**
      * APIMethod: getZoomForResolution
-     * Get the index for the closest resolution in the layers resolutions array.
      * 
      * Parameters:
-     * resolution - {Float} Map units per pixel.
+     * resolution - {Float}
+     * closest - {Boolean} Find the zoom level that corresponds to the absolute 
+     *     closest resolution, which may result in a zoom whose corresponding
+     *     resolution is actually smaller than we would have desired (if this
+     *     is being called from a getZoomForExtent() call, then this means that
+     *     the returned zoom index might not actually contain the entire 
+     *     extent specified... but it'll be close).
+     *     Default is false.
      * 
      * Returns:
      * {Integer} The index of the zoomLevel (entry in the resolutions array) 
-     *     that is the closest to the passed-in resolution.
+     *     that corresponds to the best fit resolution given the passed in 
+     *     value and the 'closest' specification.
      */
-    getZoomForResolution: function(resolution) {
-        var zoom, diff;
+    getZoomForResolution: function(resolution, closest) {
+        var diff;
         var minDiff = Number.POSITIVE_INFINITY;
-        for(var i=0; i < this.resolutions.length; i++) {
-            diff = Math.abs(this.resolutions[i] - resolution);
-            if(diff < minDiff) {
-                zoom = i;
+        for(var i=0; i < this.resolutions.length; i++) {            
+            if (closest) {
+                diff = Math.abs(this.resolutions[i] - resolution);
+                if (diff > minDiff) {
+                    break;
+                }
                 minDiff = diff;
-            } else if(diff > minDiff) {
-                break;
+            } else {
+                if (this.resolutions[i] < resolution) {
+                    break;
+                }
             }
         }
-        return zoom;
+        return Math.max(0, i-1);
     },
     
     /**

Modified: branches/openlayers/2.5/lib/OpenLayers/Map.js
===================================================================
--- branches/openlayers/2.5/lib/OpenLayers/Map.js	2007-10-03 20:27:15 UTC (rev 4794)
+++ branches/openlayers/2.5/lib/OpenLayers/Map.js	2007-10-03 20:42:35 UTC (rev 4795)
@@ -707,7 +707,7 @@
                     } else {
                         // zoom to oldExtent *and* force zoom change
                         this.setCenter(oldExtent.getCenterLonLat(), 
-                                       this.getZoomForExtent(oldExtent),
+                                       this.getZoomForExtent(oldExtent, true),
                                        false, true);
                     }
                 }
@@ -1356,15 +1356,19 @@
      * 
      * Parameters: 
      * bounds - {<OpenLayers.Bounds>}
+     * closest - {Boolean} Find the zoom level that most closely fits the 
+     *     specified bounds. Note that this may result in a zoom that does 
+     *     not exactly contain the entire extent.
+     *     Default is false.
      * 
      * Returns:
      * {Integer} A suitable zoom level for the specified bounds.
      *           If no baselayer is set, returns null.
      */
-    getZoomForExtent: function (bounds) {
+    getZoomForExtent: function (bounds, closest) {
         var zoom = null;
         if (this.baseLayer != null) {
-            zoom = this.baseLayer.getZoomForExtent(bounds);
+            zoom = this.baseLayer.getZoomForExtent(bounds, closest);
         }
         return zoom;
     },
@@ -1374,15 +1378,22 @@
      * 
      * Parameter:
      * resolution - {Float}
+     * closest - {Boolean} Find the zoom level that corresponds to the absolute 
+     *     closest resolution, which may result in a zoom whose corresponding
+     *     resolution is actually smaller than we would have desired (if this
+     *     is being called from a getZoomForExtent() call, then this means that
+     *     the returned zoom index might not actually contain the entire 
+     *     extent specified... but it'll be close).
+     *     Default is false.
      * 
      * Returns:
      * {Integer} A suitable zoom level for the specified resolution.
      *           If no baselayer is set, returns null.
      */
-    getZoomForResolution: function(resolution) {
+    getZoomForResolution: function(resolution, closest) {
         var zoom = null;
         if (this.baseLayer != null) {
-            zoom = this.baseLayer.getZoomForResolution(resolution);
+            zoom = this.baseLayer.getZoomForResolution(resolution, closest);
         }
         return zoom;
     },

Modified: branches/openlayers/2.5/tests/Control/test_OverviewMap.html
===================================================================
--- branches/openlayers/2.5/tests/Control/test_OverviewMap.html	2007-10-03 20:27:15 UTC (rev 4794)
+++ branches/openlayers/2.5/tests/Control/test_OverviewMap.html	2007-10-03 20:42:35 UTC (rev 4795)
@@ -43,33 +43,21 @@
         var overviewZoom = control.ovmap.getZoom();
         t.eq(overviewCenter.lon, -71, "Overviewmap center lon correct");
         t.eq(overviewCenter.lat, 42, "Overviewmap center lat correct");
-        t.eq(overviewZoom, 9, "Overviewmap zoomcorrect");
+        t.eq(overviewZoom, 8, "Overviewmap zoomcorrect");
         
         control.mapDivClick({'xy':new OpenLayers.Pixel(5,5)});
         
-        // There are box model issues that keep browsers from giving us
-        // identical results here.  Test the normalized difference against
-        // a tolerance instead of testing equality.
-        function normalizedDiff(a, b) {
-            return Math.abs((a - b) / (a + b));
-        }
-        var tolerance = 1e-4;
-        
         var cent = map.getCenter();
-        t.ok(normalizedDiff(cent.lon, -71.00390625) < tolerance,
-             "Clicking on the Overview Map has the correct effect on map lon");
-        t.ok(normalizedDiff(cent.lat, 42.00390625) < tolerance,
-             "Clicking on the Overview Map has the correct effect on map lat");
+        t.eq(cent.lon, -71.3515625, "Clicking on the Overview Map has the correct effect on map lon");
+        t.eq(cent.lat, 42.17578125, "Clicking on the Overview Map has the correct effect on map lat");
 
         control.rectMouseDown({'xy':new OpenLayers.Pixel(5,5), 'which':1});
         control.rectMouseMove({'xy':new OpenLayers.Pixel(15,15), 'which':1});
         control.rectMouseUp({'xy':new OpenLayers.Pixel(15,15), 'which':1});
         
         var cent = map.getCenter();
-        t.ok(normalizedDiff(cent.lon, -70.83984375) < tolerance,
-             "Dragging on the Overview Map has the correct effect on map lon");
-        t.ok(normalizedDiff(cent.lat, 41.84765625) < tolerance,
-             "Dragging on the Overview Map has the correct effect on map lat");
+        t.eq(cent.lon, -71.2734375, "Dragging on the Overview Map has the correct effect on map lon");
+        t.eq(cent.lat, 42.09765625, "Dragging on the Overview Map has the correct effect on map lat");
         
         map.setCenter(new OpenLayers.LonLat(0,0), 0);
         var overviewCenter = control.ovmap.getCenter();

Modified: branches/openlayers/2.5/tests/Layer/test_Grid.html
===================================================================
--- branches/openlayers/2.5/tests/Layer/test_Grid.html	2007-10-03 20:27:15 UTC (rev 4794)
+++ branches/openlayers/2.5/tests/Layer/test_Grid.html	2007-10-03 20:42:35 UTC (rev 4795)
@@ -150,26 +150,12 @@
         bounds = new OpenLayers.Bounds(10,10,12,12);
         zoom = layer.getZoomForExtent(bounds);
 
-        /**
-         * ideal resolution: 2 map units / 500px = 0.004
-         * layer.resolutions = [1.40625, 0.703125, 0.3515625, 0.17578125,
-         *                      0.087890625, 0.0439453125, 0.02197265625,
-         *                      0.010986328125, 0.0054931640625, 0.00274658203125,
-         *                      0.001373291015625, 0.0006866455078125, 0.00034332275390625,
-         *                      0.000171661376953125, 0.0000858306884765625, 0.00004291534423828125]
-         *
-         * So, we expect a zoom of 9 because it is the closest resolution.
-         */
-        t.eq( zoom, 9, "getZoomForExtent() returns correct value");
+        t.eq( zoom, 8, "getZoomForExtent() returns correct value");
 
         bounds = new OpenLayers.Bounds(10,10,100,100);
         zoom = layer.getZoomForExtent(bounds);
 
-        /**
-         * ideal resolution: 90 map units / 500px = 0.18
-         * So, we expect a zoom of 3 because it is the closest.
-         */
-        t.eq( zoom, 3, "getZoomForExtent() returns correct value");
+        t.eq( zoom, 2, "getZoomForExtent() returns correct value");
     }   
     
     function test_07_Layer_Grid_moveTo(t) {
@@ -555,10 +541,10 @@
         map.zoomToMaxExtent();
         map.zoomIn();
         var bounds = layer.getTileBounds(new OpenLayers.Pixel(200,200));
-        t.eq(bounds.toBBOX(), "-90,0,0,90", "get tile bounds returns correct bounds"); 
+        t.eq(bounds.toBBOX(), "-180,-90,0,90", "get tile bounds returns correct bounds"); 
         map.pan(200,0);
         var bounds = layer.getTileBounds(new OpenLayers.Pixel(200,200));
-        t.eq(bounds.toBBOX(), "0,0,90,90", "get tile bounds returns correct bounds after pan"); 
+        t.eq(bounds.toBBOX(), "0,-90,180,90", "get tile bounds returns correct bounds after pan"); 
     }
 
     function test_Layer_Grid_moveTo_buffer_calculation (t) {

Modified: branches/openlayers/2.5/tests/Layer/test_KaMap.html
===================================================================
--- branches/openlayers/2.5/tests/Layer/test_KaMap.html	2007-10-03 20:27:15 UTC (rev 4794)
+++ branches/openlayers/2.5/tests/Layer/test_KaMap.html	2007-10-03 20:42:35 UTC (rev 4795)
@@ -128,26 +128,12 @@
         bounds = new OpenLayers.Bounds(10,10,12,12);
         zoom = layer.getZoomForExtent(bounds);
 
-        /**
-         * ideal resolution: 2 map units / 500px = 0.004
-         * layer.resolutions = [1.40625, 0.703125, 0.3515625, 0.17578125,
-         *                      0.087890625, 0.0439453125, 0.02197265625,
-         *                      0.010986328125, 0.0054931640625, 0.00274658203125,
-         *                      0.001373291015625, 0.0006866455078125, 0.00034332275390625,
-         *                      0.000171661376953125, 0.0000858306884765625, 0.00004291534423828125]
-         *
-         * So, we expect a zoom of 9 because it is the closest resolution.
-         */
-        t.eq( zoom, 9, "getZoomForExtent() returns correct value");
+        t.eq( zoom, 8, "getZoomForExtent() returns correct value");
 
         bounds = new OpenLayers.Bounds(10,10,100,100);
         zoom = layer.getZoomForExtent(bounds);
 
-        /**
-         * ideal resolution: 90 map units / 500px = 0.18
-         * So, we expect a zoom of 3 because it is the closest.
-         */
-        t.eq( zoom, 3, "getZoomForExtent() returns correct value");
+        t.eq( zoom, 2, "getZoomForExtent() returns correct value");
     }   
     
     function test_06_Layer_kaMap_mergeNewParams (t) {
@@ -250,10 +236,10 @@
         map.zoomToMaxExtent();
         map.zoomIn();
         var bounds = layer.getTileBounds(new OpenLayers.Pixel(200,200));
-        t.eq(bounds.toBBOX(), "-90,0,0,90", "get tile bounds returns correct bounds"); 
+        t.eq(bounds.toBBOX(), "-180,0,0,180", "get tile bounds returns correct bounds"); 
         map.pan(200,0);
         var bounds = layer.getTileBounds(new OpenLayers.Pixel(200,200));
-        t.eq(bounds.toBBOX(), "0,0,90,90", "get tile bounds returns correct bounds after pan"); 
+        t.eq(bounds.toBBOX(), "0,0,180,180", "get tile bounds returns correct bounds after pan"); 
     }
 
     function test_99_Layer_KaMap_destroy (t) {

Modified: branches/openlayers/2.5/tests/Layer/test_TMS.html
===================================================================
--- branches/openlayers/2.5/tests/Layer/test_TMS.html	2007-10-03 20:27:15 UTC (rev 4794)
+++ branches/openlayers/2.5/tests/Layer/test_TMS.html	2007-10-03 20:42:35 UTC (rev 4795)
@@ -77,26 +77,13 @@
 
         bounds = new OpenLayers.Bounds(10,10,12,12);
         zoom = layer.getZoomForExtent(bounds);
-        /**
-         * ideal resolution: 2 map units / 500px = 0.004
-         * layer.resolutions = [1.40625, 0.703125, 0.3515625, 0.17578125,
-         *                      0.087890625, 0.0439453125, 0.02197265625,
-         *                      0.010986328125, 0.0054931640625, 0.00274658203125,
-         *                      0.001373291015625, 0.0006866455078125, 0.00034332275390625,
-         *                      0.000171661376953125, 0.0000858306884765625, 0.00004291534423828125]
-         *
-         * So, we expect a zoom of 9 because it is the closest resolution.
-         */
-        
-        t.eq( zoom, 9, "getZoomForExtent() returns correct value");
 
+        t.eq( zoom, 8, "getZoomForExtent() returns correct value");
+
         bounds = new OpenLayers.Bounds(10,10,100,100);
         zoom = layer.getZoomForExtent(bounds);
-        /**
-         * ideal resolution: 90 map units / 500px = 0.18
-         * So, we expect a zoom of 3 because it is the closest.
-         */
-        t.eq( zoom, 3, "getZoomForExtent() returns correct value");
+
+        t.eq( zoom, 2, "getZoomForExtent() returns correct value");
     }   
 
 

Modified: branches/openlayers/2.5/tests/Layer/test_TileCache.html
===================================================================
--- branches/openlayers/2.5/tests/Layer/test_TileCache.html	2007-10-03 20:27:15 UTC (rev 4794)
+++ branches/openlayers/2.5/tests/Layer/test_TileCache.html	2007-10-03 20:42:35 UTC (rev 4795)
@@ -78,27 +78,13 @@
 
         bounds = new OpenLayers.Bounds(10,10,12,12);
         zoom = layer.getZoomForExtent(bounds);
-        /**
-         * ideal resolution: 2 map units / 500px = 0.004
-         * layer.resolutions = [0.703125, 0.3515625, 0.17578125,
-         *                      0.087890625, 0.0439453125, 0.02197265625,
-         *                      0.010986328125, 0.0054931640625, 0.00274658203125,
-         *                      0.001373291015625, 0.0006866455078125, 0.00034332275390625,
-         *                      0.000171661376953125, 0.0000858306884765625, 0.00004291534423828125,
-         *                      0.000021457672119140625]
-         *
-         * So, we expect a zoom of 8 because it is the closest resolution.
-         */
-        t.eq( zoom, 8, "getZoomForExtent() returns correct value");
 
+        t.eq( zoom, 7, "getZoomForExtent() returns correct value");
+
         bounds = new OpenLayers.Bounds(10,10,100,100);
         zoom = layer.getZoomForExtent(bounds);
-        /**
-         * ideal resolution: 90 map units / 500px = 0.18
-         * So, we expect a zoom of 2 because it is the closest.
-         */
 
-        t.eq( zoom, 2, "getZoomForExtent() returns correct value");
+        t.eq( zoom, 1, "getZoomForExtent() returns correct value");
     }   
 
 

Modified: branches/openlayers/2.5/tests/Layer/test_WrapDateLine.html
===================================================================
--- branches/openlayers/2.5/tests/Layer/test_WrapDateLine.html	2007-10-03 20:27:15 UTC (rev 4794)
+++ branches/openlayers/2.5/tests/Layer/test_WrapDateLine.html	2007-10-03 20:42:35 UTC (rev 4795)
@@ -131,9 +131,9 @@
         var m = new OpenLayers.Map('map');
         m.addLayer(layer);
         m.zoomToMaxExtent();
-        t.eq(layer.grid[3][0].url, "http://octo.metacarta.com/cgi-bin/mapserv?MAP=%2Fmapdata%2Fvmap_wms.map&LAYERS=basic&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326&BBOX=0%2C0%2C90%2C90&WIDTH=256&HEIGHT=256", "cell [3][0] is wrapped around the world.");
-        t.eq(layer.grid[0][0].url, "http://octo.metacarta.com/cgi-bin/mapserv?MAP=%2Fmapdata%2Fvmap_wms.map&LAYERS=basic&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326&BBOX=0%2C270%2C90%2C360&WIDTH=256&HEIGHT=256", "cell [0][0] is wrapped around the world lon, but not lat");
-        t.eq(layer.grid[0][3].url, "http://octo.metacarta.com/cgi-bin/mapserv?MAP=%2Fmapdata%2Fvmap_wms.map&LAYERS=basic&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326&BBOX=-90%2C270%2C0%2C360&WIDTH=256&HEIGHT=256", "cell [3][0] is not wrapped at all.");
+        t.eq(layer.grid[3][0].url, "http://octo.metacarta.com/cgi-bin/mapserv?MAP=%2Fmapdata%2Fvmap_wms.map&LAYERS=basic&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326&BBOX=0%2C-90%2C180%2C90&WIDTH=256&HEIGHT=256", "cell [3][0] is wrapped around the world.");
+        t.eq(layer.grid[0][0].url, "http://octo.metacarta.com/cgi-bin/mapserv?MAP=%2Fmapdata%2Fvmap_wms.map&LAYERS=basic&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326&BBOX=0%2C450%2C180%2C630&WIDTH=256&HEIGHT=256", "cell [0][0] is wrapped around the world lon, but not lat");
+        t.eq(layer.grid[0][3].url, "http://octo.metacarta.com/cgi-bin/mapserv?MAP=%2Fmapdata%2Fvmap_wms.map&LAYERS=basic&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326&BBOX=-180%2C450%2C0%2C630&WIDTH=256&HEIGHT=256", "cell [3][0] is not wrapped at all.");
 
     }
     function test_Layer_WrapDateLine_KaMap (t) {
@@ -146,9 +146,9 @@
         var m = new OpenLayers.Map('map');
         m.addLayer(layer);
         m.zoomToMaxExtent();
-        t.eq(layer.grid[0][0].url, "http://www.openlayers.org/world/index.php?g=satellite&map=world&i=jpeg&t=-1280&l=0&s=110735960.625", "grid[0][0] kamap is okay");
-        t.eq(layer.grid[0][3].url, "http://www.openlayers.org/world/index.php?g=satellite&map=world&i=jpeg&t=-1280&l=-256&s=110735960.625", "grid[0][3] kamap is okay");
-        t.eq(layer.grid[3][0].url, "http://www.openlayers.org/world/index.php?g=satellite&map=world&i=jpeg&t=-512&l=0&s=110735960.625", "grid[3][0] is okay");
+        t.eq(layer.grid[0][0].url, "http://www.openlayers.org/world/index.php?g=satellite&map=world&i=jpeg&t=-1280&l=0&s=221471921.25", "grid[0][0] kamap is okay");
+        t.eq(layer.grid[0][3].url, "http://www.openlayers.org/world/index.php?g=satellite&map=world&i=jpeg&t=-1280&l=-256&s=221471921.25", "grid[0][3] kamap is okay");
+        t.eq(layer.grid[3][0].url, "http://www.openlayers.org/world/index.php?g=satellite&map=world&i=jpeg&t=-512&l=0&s=221471921.25", "grid[3][0] is okay");
     }
     function test_Layer_WrapDateLine_WMS_Overlay (t) {
         t.plan( 3 );
@@ -163,9 +163,9 @@
         var m = new OpenLayers.Map('map');
         m.addLayers([baselayer,layer]);
         m.zoomToMaxExtent();
-        t.eq(layer.grid[0][0].url, "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap?LAYERS=bathymetry%2Cland_fn%2Cpark%2Cdrain_fn%2Cdrainage%2Cprov_bound%2Cfedlimit%2Crail%2Croad%2Cpopplace&TRANSPARENT=true&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326&BBOX=0%2C270%2C90%2C360&WIDTH=256&HEIGHT=256", "grid[0][0] wms overlay is okay");
-        t.eq(layer.grid[0][3].url, "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap?LAYERS=bathymetry%2Cland_fn%2Cpark%2Cdrain_fn%2Cdrainage%2Cprov_bound%2Cfedlimit%2Crail%2Croad%2Cpopplace&TRANSPARENT=true&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326&BBOX=-90%2C270%2C0%2C360&WIDTH=256&HEIGHT=256", "grid[0][3] wms overlay is okay");
-        t.eq(layer.grid[3][0].url, "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap?LAYERS=bathymetry%2Cland_fn%2Cpark%2Cdrain_fn%2Cdrainage%2Cprov_bound%2Cfedlimit%2Crail%2Croad%2Cpopplace&TRANSPARENT=true&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326&BBOX=0%2C0%2C90%2C90&WIDTH=256&HEIGHT=256", "grid[3][0] wms overlay okay");
+        t.eq(layer.grid[0][0].url, "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap?LAYERS=bathymetry%2Cland_fn%2Cpark%2Cdrain_fn%2Cdrainage%2Cprov_bound%2Cfedlimit%2Crail%2Croad%2Cpopplace&TRANSPARENT=true&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326&BBOX=0%2C450%2C180%2C630&WIDTH=256&HEIGHT=256", "grid[0][0] wms overlay is okay");
+        t.eq(layer.grid[0][3].url, "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap?LAYERS=bathymetry%2Cland_fn%2Cpark%2Cdrain_fn%2Cdrainage%2Cprov_bound%2Cfedlimit%2Crail%2Croad%2Cpopplace&TRANSPARENT=true&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326&BBOX=-180%2C450%2C0%2C630&WIDTH=256&HEIGHT=256", "grid[0][3] wms overlay is okay");
+        t.eq(layer.grid[3][0].url, "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap?LAYERS=bathymetry%2Cland_fn%2Cpark%2Cdrain_fn%2Cdrainage%2Cprov_bound%2Cfedlimit%2Crail%2Croad%2Cpopplace&TRANSPARENT=true&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326&BBOX=0%2C-90%2C180%2C90&WIDTH=256&HEIGHT=256", "grid[3][0] wms overlay okay");
     }
 
   </script>

Modified: branches/openlayers/2.5/tests/test_Layer.html
===================================================================
--- branches/openlayers/2.5/tests/test_Layer.html	2007-10-03 20:27:15 UTC (rev 4794)
+++ branches/openlayers/2.5/tests/test_Layer.html	2007-10-03 20:42:35 UTC (rev 4795)
@@ -155,7 +155,7 @@
 
     function test_06_Layer_getZoomForResolution(t) {
 
-        t.plan(6);
+        t.plan(8);
 
         var layer = new OpenLayers.Layer('Test Layer');
             
@@ -163,12 +163,16 @@
         layer.resolutions = [128, 64, 32, 16, 8, 4, 2];
         
         t.eq(layer.getZoomForResolution(200), 0, "zoom all the way out");
-        t.eq(layer.getZoomForResolution(65), 1, "index closest to 65");
-        t.eq(layer.getZoomForResolution(63), 1, "index closest to 63");
         t.eq(layer.getZoomForResolution(25), 2, "zoom in middle");
         t.eq(layer.getZoomForResolution(3), 5, "zoom allmost all the way in");
         t.eq(layer.getZoomForResolution(1), 6, "zoom  all the way in");
 
+        t.eq(layer.getZoomForResolution(65), 0, "smallest containing res");
+        t.eq(layer.getZoomForResolution(63), 1, "smallest containing res");
+
+        t.eq(layer.getZoomForResolution(65, true), 1, "closest res");
+        t.eq(layer.getZoomForResolution(63, true), 1, "closest res");
+
     }
     
     function test_07_Layer_redraw(t) {



More information about the Commits mailing list