Move wrapX to ol.tilegrid to break circular dependency
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
goog.provide('ol.tilecoord');
|
||||
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.tilegrid');
|
||||
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
@@ -93,27 +90,6 @@ ol.tilecoord.quadKey = function(tileCoord) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
* @param {ol.tilegrid.TileGrid} tileGrid Tile grid.
|
||||
* @param {ol.proj.Projection} projection Projection.
|
||||
* @return {ol.TileCoord} Tile coordinate.
|
||||
*/
|
||||
ol.tilecoord.wrapX = function(tileCoord, tileGrid, projection) {
|
||||
var z = tileCoord[0];
|
||||
var center = tileGrid.getTileCoordCenter(tileCoord);
|
||||
var projectionExtent = ol.tilegrid.extentFromProjection(projection);
|
||||
if (!ol.extent.containsCoordinate(projectionExtent, center)) {
|
||||
var worldWidth = ol.extent.getWidth(projectionExtent);
|
||||
var worldsAway = Math.ceil((projectionExtent[0] - center[0]) / worldWidth);
|
||||
center[0] += worldWidth * worldsAway;
|
||||
return tileGrid.getTileCoordForCoordAndZ(center, z);
|
||||
} else {
|
||||
return tileCoord;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
* @param {!ol.tilegrid.TileGrid} tileGrid Tile grid.
|
||||
|
||||
Reference in New Issue
Block a user