make sure the for loop for lods is not messed up by frameworks changing the Array.prototype, p=dzwarg, r=me (closes #3474)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@12269 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
bartvde
2011-08-24 06:18:55 +00:00
parent bb41c99524
commit 50704395bb
2 changed files with 42 additions and 14 deletions

View File

@@ -172,21 +172,23 @@ OpenLayers.Layer.ArcGISCache = OpenLayers.Class(OpenLayers.Layer.XYZ, {
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 end = this.getContainingTileCoords(bottomRight, lod.resolution);
lod.endTileCol = end.x;
lod.endTileRow = end.y;
this.lods.push(lod);
}
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);
}
this.maxExtent = this.calculateMaxExtentWithLOD(this.lods[0]);

View File

@@ -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>