From 7e9eef8d075fa88068923404fa67c84bba79643e Mon Sep 17 00:00:00 2001 From: crschmidt Date: Fri, 22 Dec 2006 18:35:04 +0000 Subject: [PATCH] Commit a number of improvements to grid handling from #449. This adds support for buffer:0 on grids, and includes changes to Remove extra rows and columns from the grid in _initTiles when reusing an existing grid, which is a fix to #357 and #436. git-svn-id: http://svn.openlayers.org/trunk/openlayers@2091 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Layer/Grid.js | 56 ++++++++++++++++++++++++++++++------ lib/OpenLayers/Tile.js | 7 ++++- lib/OpenLayers/Tile/Image.js | 37 ++++++++++++------------ lib/OpenLayers/Tile/WFS.js | 12 ++++---- tests/test_Tile_Image.html | 9 +++--- 5 files changed, 80 insertions(+), 41 deletions(-) diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index 17d9696753..880f070acd 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -107,21 +107,33 @@ OpenLayers.Layer.Grid.prototype = || !this.getGridBounds().containsBounds(bounds, true)) { this._initTiles(); } else { + var buffer = (this.buffer) ? this.buffer*1.5 : 1; while (true) { var tlLayer = this.grid[0][0].position; var tlViewPort = this.map.getViewPortPxFromLayerPx(tlLayer); - if (tlViewPort.x > -this.tileSize.w * (this.buffer - 1)) { + if (tlViewPort.x > -this.tileSize.w * (buffer - 1)) { this.shiftColumn(true); - } else if (tlViewPort.x < -this.tileSize.w * this.buffer) { + } else if (tlViewPort.x < -this.tileSize.w * buffer) { this.shiftColumn(false); - } else if (tlViewPort.y > -this.tileSize.h * (this.buffer - 1)) { + } else if (tlViewPort.y > -this.tileSize.h * (buffer - 1)) { this.shiftRow(true); - } else if (tlViewPort.y < -this.tileSize.h * this.buffer) { + } else if (tlViewPort.y < -this.tileSize.h * buffer) { this.shiftRow(false); } else { break; } + }; + if (this.buffer == 0) { + for (var r=0, rl=this.grid.length; r= bounds.bottom - tilelat * this.buffer) - + } while((tileoffsetlat >= bounds.bottom - tilelat * this.buffer) + || rowidx < minRows) + + // remove extra rows + while (this.grid.length > rowidx) { + var row = this.grid.pop(); + for (var i=0, l=row.length; i colidx) { + for (var i=0, l=this.grid.length; i