Add wrapX option for ol.source.WMTS
This commit is contained in:
@@ -3,7 +3,6 @@ goog.provide('ol.source.WMTSRequestEncoding');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.math');
|
||||
goog.require('goog.object');
|
||||
goog.require('goog.string');
|
||||
goog.require('goog.uri.utils');
|
||||
@@ -170,7 +169,6 @@ ol.source.WMTS = function(options) {
|
||||
}
|
||||
|
||||
var tmpExtent = ol.extent.createEmpty();
|
||||
var tmpTileCoord = [0, 0, 0];
|
||||
tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
|
||||
/**
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
@@ -188,16 +186,6 @@ ol.source.WMTS = function(options) {
|
||||
var tileExtent = tileGrid.getTileCoordExtent(tileCoord, tmpExtent);
|
||||
var extent = projection.getExtent();
|
||||
|
||||
if (!goog.isNull(extent) && projection.isGlobal()) {
|
||||
var numCols = Math.ceil(
|
||||
ol.extent.getWidth(extent) /
|
||||
ol.extent.getWidth(tileExtent));
|
||||
x = goog.math.modulo(x, numCols);
|
||||
tmpTileCoord[0] = tileCoord[0];
|
||||
tmpTileCoord[1] = x;
|
||||
tmpTileCoord[2] = tileCoord[2];
|
||||
tileExtent = tileGrid.getTileCoordExtent(tmpTileCoord, tmpExtent);
|
||||
}
|
||||
if (!ol.extent.intersects(tileExtent, extent) ||
|
||||
ol.extent.touches(tileExtent, extent)) {
|
||||
return null;
|
||||
@@ -215,7 +203,8 @@ ol.source.WMTS = function(options) {
|
||||
tileGrid: tileGrid,
|
||||
tileLoadFunction: options.tileLoadFunction,
|
||||
tilePixelRatio: options.tilePixelRatio,
|
||||
tileUrlFunction: tileUrlFunction
|
||||
tileUrlFunction: tileUrlFunction,
|
||||
wrapX: goog.isDef(options.wrapX) ? options.wrapX : false
|
||||
});
|
||||
|
||||
};
|
||||
@@ -348,7 +337,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
goog.asserts.assert(!goog.isNull(l));
|
||||
|
||||
goog.asserts.assert(l['TileMatrixSetLink'].length > 0);
|
||||
var idx, matrixSet;
|
||||
var idx, matrixSet, wrapX;
|
||||
if (l['TileMatrixSetLink'].length > 1) {
|
||||
idx = goog.array.findIndex(l['TileMatrixSetLink'],
|
||||
function(elt, index, array) {
|
||||
@@ -372,6 +361,13 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
|
||||
goog.asserts.assert(!goog.isNull(matrixSet));
|
||||
|
||||
var wgs84BoundingBox = l['WGS84BoundingBox'];
|
||||
if (goog.isDef(wgs84BoundingBox)) {
|
||||
var wgs84ProjectionExtent = ol.proj.get('EPSG:4326').getExtent();
|
||||
wrapX = (wgs84BoundingBox[0] == wgs84ProjectionExtent[0] &&
|
||||
wgs84BoundingBox[2] == wgs84ProjectionExtent[2]);
|
||||
}
|
||||
|
||||
var format = /** @type {string} */ (l['Format'][0]);
|
||||
if (goog.isDef(config['format'])) {
|
||||
format = config['format'];
|
||||
@@ -463,7 +459,8 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
requestEncoding: requestEncoding,
|
||||
tileGrid: tileGrid,
|
||||
style: style,
|
||||
dimensions: dimensions
|
||||
dimensions: dimensions,
|
||||
wrapX: wrapX
|
||||
};
|
||||
|
||||
/* jshint +W069 */
|
||||
|
||||
Reference in New Issue
Block a user