From 8d1fe36b0f4bd4e593d132626de96f5430c8a16c Mon Sep 17 00:00:00 2001 From: euzuro Date: Thu, 17 Aug 2006 17:43:27 +0000 Subject: [PATCH] add comments for spiralTileLoad() function git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1285 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Layer/Grid.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index 6d1b698116..09ac8e31be 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -246,8 +246,16 @@ OpenLayers.Layer.Grid.prototype = this.spiralTileLoad(); }, - /** + /** + * @private * + * Starts at the top right corner of the grid and proceeds in a spiral + * towards the center, adding tiles one at a time to the beginning of a + * queue. + * + * Once all the grid's tiles have been added to the queue, we go back + * and iterate through the queue (thus reversing the spiral order from + * outside-in to inside-out), calling draw() on each tile. */ spiralTileLoad: function() { var tileQueue = new Array(); @@ -279,6 +287,8 @@ OpenLayers.Layer.Grid.prototype = break; } + // if the test grid coordinates are within the bounds of the + // grid, get a reference to the tile. var tile = null; if ((testRow < this.grid.length) && (testCell < this.grid[0].length)) { @@ -286,12 +296,16 @@ OpenLayers.Layer.Grid.prototype = } if ((tile != null) && (!tile.queued)) { + //add tile to beginning of queue, mark it as queued. tileQueue.unshift(tile); tile.queued = true; + + //restart the directions counter and take on the new coords directionsTried = 0; iRow = testRow; iCell = testCell; } else { + //need to try to load a tile in a different direction direction = (direction + 1) % 4; directionsTried++; } @@ -301,6 +315,7 @@ OpenLayers.Layer.Grid.prototype = for(var i=0; i < tileQueue.length; i++) { var tile = tileQueue[i] tile.draw(); + //mark tile as unqueued for the next time (since tiles are reused) tile.queued = false; } },