Allow extents to restrict tile ranges requested from the server
The addition of full extent tile ranges also allows us to simplify wrapX handling for tile layers. By limiting wrapX to true and false as possible values, we can remove a lot of guessing logic.
This commit is contained in:
@@ -11,7 +11,6 @@ goog.require('ol.TileUrlFunctionType');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.source.TileImage');
|
||||
goog.require('ol.tilecoord');
|
||||
goog.require('ol.tilegrid.WMTS');
|
||||
|
||||
|
||||
@@ -181,31 +180,8 @@ ol.source.WMTS = function(options) {
|
||||
goog.array.map(this.urls_, createFromWMTSTemplate)) :
|
||||
ol.TileUrlFunction.nullTileUrlFunction;
|
||||
|
||||
var tmpExtent = ol.extent.createEmpty();
|
||||
tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
|
||||
/**
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
* @param {ol.proj.Projection} projection Projection.
|
||||
* @param {ol.TileCoord=} opt_tileCoord Tile coordinate.
|
||||
* @return {ol.TileCoord} Tile coordinate.
|
||||
*/
|
||||
function(tileCoord, projection, opt_tileCoord) {
|
||||
goog.asserts.assert(!goog.isNull(tileGrid),
|
||||
'tileGrid must not be null');
|
||||
if (tileGrid.getResolutions().length <= tileCoord[0]) {
|
||||
return null;
|
||||
}
|
||||
var x = tileCoord[1];
|
||||
var y = -tileCoord[2] - 1;
|
||||
var tileExtent = tileGrid.getTileCoordExtent(tileCoord, tmpExtent);
|
||||
var extent = projection.getExtent();
|
||||
|
||||
if (!ol.extent.intersects(tileExtent, extent) ||
|
||||
ol.extent.touches(tileExtent, extent)) {
|
||||
return null;
|
||||
}
|
||||
return ol.tilecoord.createOrUpdate(tileCoord[0], x, y, opt_tileCoord);
|
||||
},
|
||||
ol.tilegrid.createOriginTopLeftTileCoordTransform(tileGrid),
|
||||
tileUrlFunction);
|
||||
|
||||
goog.base(this, {
|
||||
@@ -450,9 +426,6 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
goog.asserts.assert(!goog.isNull(matrixSetObj),
|
||||
'found matrixSet in Contents/TileMatrixSet');
|
||||
|
||||
var tileGrid = ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet(
|
||||
matrixSetObj);
|
||||
|
||||
var projection;
|
||||
if (goog.isDef(config['projection'])) {
|
||||
projection = ol.proj.get(config['projection']);
|
||||
@@ -461,6 +434,19 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3'));
|
||||
}
|
||||
|
||||
var projectionExtent = projection.getExtent();
|
||||
var extent;
|
||||
if (!goog.isNull(projectionExtent)) {
|
||||
var projectionExtentWgs84 = ol.proj.transformExtent(
|
||||
projectionExtent, projection, 'EPSG:4326');
|
||||
if (ol.extent.containsExtent(projectionExtentWgs84, wgs84BoundingBox)) {
|
||||
extent = ol.proj.transformExtent(
|
||||
wgs84BoundingBox, 'EPSG:4326', projection);
|
||||
}
|
||||
}
|
||||
var tileGrid = ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet(
|
||||
matrixSetObj, extent);
|
||||
|
||||
/** @type {!Array.<string>} */
|
||||
var urls = [];
|
||||
var requestEncoding = config['requestEncoding'];
|
||||
|
||||
Reference in New Issue
Block a user