Correctly generate child tile ranges for XYZ

Instead of incrementing and then doubling, calculate the child tile range by doubling and then incrementing.

With this change, tile coord [0, 0, 0] has the four following children:

    [1, 0, 0]    [1, 1, 0]

    [1, 0, 1]    [1, 1, 1]

Without this change, tile coord [0, 0, 0] had the nine following children:

    [1, 0, 0]    [1, 1, 0]    [1, 2, 0]

    [1, 0, 1]    [1, 1, 1]    [1, 2, 1]

    [1, 0, 2]    [1, 1, 2]    [1, 2, 2]
This commit is contained in:
Tim Schaub
2014-09-28 11:55:57 -06:00
parent b0b62c6ac3
commit 2ad27044a6
2 changed files with 73 additions and 2 deletions

View File

@@ -100,9 +100,11 @@ ol.tilegrid.XYZ.prototype.createTileCoordTransform = function(opt_options) {
ol.tilegrid.XYZ.prototype.getTileCoordChildTileRange =
function(tileCoord, opt_tileRange) {
if (tileCoord[0] < this.maxZoom) {
var doubleX = 2 * tileCoord[1];
var doubleY = 2 * tileCoord[2];
return ol.TileRange.createOrUpdate(
2 * tileCoord[1], 2 * (tileCoord[1] + 1),
2 * tileCoord[2], 2 * (tileCoord[2] + 1),
doubleX, doubleX + 1,
doubleY, doubleY + 1,
opt_tileRange);
} else {
return null;