Make sure that the return value of wrapX() is stable

This commit is contained in:
Andreas Hocevar
2015-03-25 15:59:59 +01:00
parent bb87b8e7ce
commit 1df8cba753
+11 -14
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]; var z = tileCoord[0];
return function(tileCoord, tileGrid, projection) { var x = tileCoord[1];
var z = tileCoord[0]; var tileRange = tileGrid.getTileRange(z, projection);
var x = tileCoord[1]; if (x < tileRange.minX || x > tileRange.maxX) {
var tileRange = tileGrid.getTileRange(z, projection); x = goog.math.modulo(x, tileRange.getWidth());
if (x < tileRange.minX || x > tileRange.maxX) { return [z, x, tileCoord[2]];
x = goog.math.modulo(x, tileRange.getWidth()); }
return ol.tilecoord.createOrUpdate(z, x, tileCoord[2], tmpTileCoord); return tileCoord;
} };
return tileCoord;
};
})();
/** /**