[ol.layer.XYZ] a tiling fix

This commit is contained in:
Éric Lemoine
2012-06-20 15:13:22 +02:00
parent e989c61e63
commit 2890a55ee7
2 changed files with 9 additions and 14 deletions

View File

@@ -130,26 +130,22 @@ ol.layer.XYZ.prototype.getData = function(bounds, resolution) {
offsetY = Math.floor(
(tileOriginY - boundsMaxY) / tileHeightGeo),
gridWidth = Math.ceil(
(boundsMaxX - boundsMinX) / tileWidthGeo),
gridHeight = Math.ceil(
(boundsMaxY - boundsMinY) / tileHeightGeo);
gridLeft = tileOriginX + tileWidthGeo * offsetX,
gridTop = tileOriginY - tileHeightGeo * offsetY;
var tiles = [],
tile,
url,
i, ii,
j, jj;
for (i=0, ii=gridWidth; i<ii; i++) {
var tiles = [], tile, url, i = 0, j;
while (gridTop - (i * tileHeightGeo) > boundsMinY) {
tiles[i] = [];
for (j=0, jj=gridHeight; j<jj; j++) {
j = 0;
while (gridLeft + (j * tileWidthGeo) < boundsMaxX) {
url = me.url_.replace('{x}', offsetX + i + '')
.replace('{y}', offsetY + j + '')
.replace('{z}', zoom);
tile = new ol.Tile(url);
tiles[i][j] = tile;
j++;
}
i++;
}
return new ol.TileSet(tiles, tileWidth, tileHeight, resolution);

View File

@@ -64,7 +64,6 @@ describe('ol.layer.XYZ', function() {
});
});
/*
describe('extent -64,-64,64,64, resolution 0.5', function() {
it('returns the expected data', function() {
@@ -94,6 +93,6 @@ describe('ol.layer.XYZ', function() {
expect(tile.getImg()).toBeDefined();
});
});
*/
});
});