[OpenLayers-Commits] r11696 - in trunk/openlayers:
lib/OpenLayers/Layer tests/Layer
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Fri Mar 11 13:34:56 EST 2011
Author: bartvde
Date: 2011-03-11 10:34:53 -0800 (Fri, 11 Mar 2011)
New Revision: 11696
Modified:
trunk/openlayers/lib/OpenLayers/Layer/ArcGISCache.js
trunk/openlayers/tests/Layer/ArcGISCache.html
Log:
ArcGISCache layer should not generate x and y values of less than 0, p=dmiddlecamp, r=me (closes #3169)
Modified: trunk/openlayers/lib/OpenLayers/Layer/ArcGISCache.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/ArcGISCache.js 2011-03-11 01:53:26 UTC (rev 11695)
+++ trunk/openlayers/lib/OpenLayers/Layer/ArcGISCache.js 2011-03-11 18:34:53 UTC (rev 11696)
@@ -214,8 +214,8 @@
*/
getContainingTileCoords: function(point, res) {
return new OpenLayers.Pixel(
- Math.floor((point.x - this.tileOrigin.lon) / (this.tileSize.w * res)),
- Math.floor((this.tileOrigin.lat - point.y) / (this.tileSize.h * res))
+ Math.max(Math.floor((point.x - this.tileOrigin.lon) / (this.tileSize.w * res)),0),
+ Math.max(Math.floor((this.tileOrigin.lat - point.y) / (this.tileSize.h * res)),0)
);
},
Modified: trunk/openlayers/tests/Layer/ArcGISCache.html
===================================================================
--- trunk/openlayers/tests/Layer/ArcGISCache.html 2011-03-11 01:53:26 UTC (rev 11695)
+++ trunk/openlayers/tests/Layer/ArcGISCache.html 2011-03-11 18:34:53 UTC (rev 11696)
@@ -199,6 +199,25 @@
t.ok('00000100' == layer.zeroPad(256, 8, 16), 'zeroPad should generate tile indexes properly ');
t.ok('00001000' == layer.zeroPad(4096, 8, 16), 'zeroPad should generate tile indexes properly ');
}
+
+ /**
+ * Check to ensure our LOD calculation will correctly avoid returning tile indexes less than zero
+ * (see http://trac.osgeo.org/openlayers/ticket/3169)
+ */
+ function test_Layer_ARCGISCACHE_tileBounds(t) {
+ t.plan(1);
+
+ var layer = new OpenLayers.Layer.ArcGISCache('test', null, { });
+ var res = 264.583862501058;
+ layer.tileOrigin = new OpenLayers.LonLat(0.0, 650000.0);
+ layer.tileSize = new OpenLayers.Size(512, 512);
+
+ // pick a point off the left of our tile origin (would be a negative tile index)
+ var point = new OpenLayers.Geometry.Point(-123308.94829, 393128.85817);
+
+ var tile = layer.getContainingTileCoords(point, res);
+ t.ok((tile.x >= 0 && tile.y >= 0), 'layer should not generate negative tile ranges for level of detail');
+ }
</script>
</head>
More information about the Commits
mailing list