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

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Wed Aug 24 02:18:56 EDT 2011


Author: bartvde
Date: 2011-08-23 23:18:55 -0700 (Tue, 23 Aug 2011)
New Revision: 12269

Modified:
   trunk/openlayers/lib/OpenLayers/Layer/ArcGISCache.js
   trunk/openlayers/tests/Layer/ArcGISCache.html
Log:
make sure the for loop for lods is not messed up by frameworks changing the Array.prototype, p=dzwarg, r=me (closes #3474)

Modified: trunk/openlayers/lib/OpenLayers/Layer/ArcGISCache.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/ArcGISCache.js	2011-08-22 10:10:46 UTC (rev 12268)
+++ trunk/openlayers/lib/OpenLayers/Layer/ArcGISCache.js	2011-08-24 06:18:55 UTC (rev 12269)
@@ -172,21 +172,23 @@
                 
                 this.lods = [];
                 for(var key in info.tileInfo.lods) {
-                    var lod = info.tileInfo.lods[key];
-                    if (this.useScales) {
-                        this.scales.push(lod.scale);
-                    } else {
-                        this.resolutions.push(lod.resolution);
-                    }
+                    if (info.tileInfo.lods.hasOwnProperty(key)) {
+                        var lod = info.tileInfo.lods[key];
+                        if (this.useScales) {
+                            this.scales.push(lod.scale);
+                        } else {
+                            this.resolutions.push(lod.resolution);
+                        }
                     
-                    var start = this.getContainingTileCoords(upperLeft, lod.resolution);
-                    lod.startTileCol = start.x;
-                    lod.startTileRow = start.y;
+                        var start = this.getContainingTileCoords(upperLeft, lod.resolution);
+                        lod.startTileCol = start.x;
+                        lod.startTileRow = start.y;
                     
-                    var end = this.getContainingTileCoords(bottomRight, lod.resolution);
-                    lod.endTileCol = end.x;
-                    lod.endTileRow = end.y;    
-                    this.lods.push(lod);
+                        var end = this.getContainingTileCoords(bottomRight, lod.resolution);
+                        lod.endTileCol = end.x;
+                        lod.endTileRow = end.y;    
+                        this.lods.push(lod);
+                    }
                 }
 
                 this.maxExtent = this.calculateMaxExtentWithLOD(this.lods[0]);

Modified: trunk/openlayers/tests/Layer/ArcGISCache.html
===================================================================
--- trunk/openlayers/tests/Layer/ArcGISCache.html	2011-08-22 10:10:46 UTC (rev 12268)
+++ trunk/openlayers/tests/Layer/ArcGISCache.html	2011-08-24 06:18:55 UTC (rev 12269)
@@ -219,6 +219,32 @@
         t.ok((tile.x >= 0 && tile.y >= 0), 'layer should not generate negative tile ranges for level of detail');
     }
 
+   /*  
+    * Test that functions don't end up in the lods of the layer. This messes up zooming when 
+    * resolutions are very small/scales are very large/zoomed way in. 
+    */ 
+    function test_Layer_ARCGISCACHE_lods (t) { 
+        t.plan( 2 ); 
+        var layerInfo = capabilitiesObject; 
+
+        lods = layerInfo.tileInfo.lods.length; 
+
+        // mess up the Array prototype
+        Array.prototype.foo = function() { };
+
+        t.ok( lods == layerInfo.tileInfo.lods.length, 'proper number of "Levels of Detail" before initialization' ); 
+
+        // initialize the layer using the JSON object from an arcgis server 
+        // see: ArcGISCache.json 
+        var layer = new OpenLayers.Layer.ArcGISCache(name, url, { 
+            layerInfo: layerInfo 
+        }); 
+
+        t.ok( lods == layer.lods.length, 'proper number of "Levels of Detail" after initialization.' );         
+        // restore the Array prototype
+        delete Array.prototype.foo;
+    } 
+
   </script>
 </head>
 <body>



More information about the Commits mailing list