Add ol.source.Tile support for wrapping around the x-axis
This commit is contained in:
@@ -3,6 +3,7 @@ goog.provide('ol.tilecoord');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.math');
|
||||
|
||||
|
||||
/**
|
||||
@@ -137,3 +138,37 @@ ol.tilecoord.quadKey = function(tileCoord) {
|
||||
ol.tilecoord.toString = function(tileCoord) {
|
||||
return ol.tilecoord.getKeyZXY(tileCoord[0], tileCoord[1], tileCoord[2]);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
* @param {ol.tilegrid.TileGrid} tilegrid Tile grid.
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @return {ol.TileCoord} Tile coordinate.
|
||||
*/
|
||||
ol.tilecoord.wrapX = (function() {
|
||||
var tmpTileCoord = [0, 0, 0];
|
||||
return function(tileCoord, tileGrid, extent) {
|
||||
var z = tileCoord[0];
|
||||
var x = tileCoord[1];
|
||||
var tileRange = tileGrid.getTileRangeForExtentAndZ(extent, z);
|
||||
if (x < tileRange.minX || x > tileRange.maxX) {
|
||||
x = goog.math.modulo(x, tileRange.getWidth());
|
||||
return ol.tilecoord.createOrUpdate(z, x, tileCoord[2], tmpTileCoord);
|
||||
}
|
||||
return tileCoord;
|
||||
};
|
||||
})();
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
* @param {ol.tilegrid.TileGrid} tileGrid Tile grid.
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @return {ol.TileCoord} Tile coordinate.
|
||||
*/
|
||||
ol.tilecoord.clipX = function(tileCoord, tileGrid, extent) {
|
||||
var x = tileCoord[1];
|
||||
var tileRange = tileGrid.getTileRangeForExtentAndZ(extent, tileCoord[0]);
|
||||
return (x < tileRange.minX || x > tileRange.maxX) ? null : tileCoord;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user