Merge pull request #3398 from ahocevar/safe-wrapx

Make sure that the return value of wrapX() is stable
This commit is contained in:
Andreas Hocevar
2015-03-25 16:21:53 +01:00
+3 -6
View File
@@ -142,23 +142,20 @@ ol.tilecoord.toString = function(tileCoord) {
/** /**
* @param {ol.TileCoord} tileCoord Tile coordinate. * @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {ol.tilegrid.TileGrid} tilegrid Tile grid. * @param {ol.tilegrid.TileGrid} tileGrid Tile grid.
* @param {ol.proj.Projection} projection Projection. * @param {ol.proj.Projection} projection Projection.
* @return {ol.TileCoord} Tile coordinate. * @return {ol.TileCoord} Tile coordinate.
*/ */
ol.tilecoord.wrapX = (function() { ol.tilecoord.wrapX = function(tileCoord, tileGrid, projection) {
var tmpTileCoord = [0, 0, 0];
return function(tileCoord, tileGrid, projection) {
var z = tileCoord[0]; var z = tileCoord[0];
var x = tileCoord[1]; var x = tileCoord[1];
var tileRange = tileGrid.getTileRange(z, projection); var tileRange = tileGrid.getTileRange(z, projection);
if (x < tileRange.minX || x > tileRange.maxX) { if (x < tileRange.minX || x > tileRange.maxX) {
x = goog.math.modulo(x, tileRange.getWidth()); x = goog.math.modulo(x, tileRange.getWidth());
return ol.tilecoord.createOrUpdate(z, x, tileCoord[2], tmpTileCoord); return [z, x, tileCoord[2]];
} }
return tileCoord; return tileCoord;
}; };
})();
/** /**