Merge pull request #450 from elemoine/projection-null
Do not pass tile grid to getTile and tileUrlFunc
This commit is contained in:
@@ -195,7 +195,7 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
|
||||
|
||||
var getTileIfLoaded = this.createGetTileIfLoadedFunction(function(tile) {
|
||||
return !goog.isNull(tile) && tile.getState() == ol.TileState.LOADED;
|
||||
}, tileSource, tileGrid, projection);
|
||||
}, tileSource, projection);
|
||||
var findLoadedTiles = goog.bind(tileSource.findLoadedTiles, tileSource,
|
||||
tilesToDrawByZ, getTileIfLoaded);
|
||||
|
||||
@@ -204,7 +204,7 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
|
||||
for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
|
||||
for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
|
||||
|
||||
tile = tileSource.getTile(z, x, y, tileGrid, projection);
|
||||
tile = tileSource.getTile(z, x, y, projection);
|
||||
tileState = tile.getState();
|
||||
if (tileState == ol.TileState.LOADED || tileState == ol.TileState.EMPTY) {
|
||||
tilesToDrawByZ[z][tile.tileCoord.toString()] = tile;
|
||||
|
||||
@@ -107,7 +107,7 @@ ol.renderer.dom.TileLayer.prototype.renderFrame =
|
||||
|
||||
var getTileIfLoaded = this.createGetTileIfLoadedFunction(function(tile) {
|
||||
return !goog.isNull(tile) && tile.getState() == ol.TileState.LOADED;
|
||||
}, tileSource, tileGrid, projection);
|
||||
}, tileSource, projection);
|
||||
var findLoadedTiles = goog.bind(tileSource.findLoadedTiles, tileSource,
|
||||
tilesToDrawByZ, getTileIfLoaded);
|
||||
|
||||
@@ -116,7 +116,7 @@ ol.renderer.dom.TileLayer.prototype.renderFrame =
|
||||
for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
|
||||
for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
|
||||
|
||||
tile = tileSource.getTile(z, x, y, tileGrid, projection);
|
||||
tile = tileSource.getTile(z, x, y, projection);
|
||||
tileState = tile.getState();
|
||||
if (tileState == ol.TileState.LOADED) {
|
||||
tilesToDrawByZ[z][tile.tileCoord.toString()] = tile;
|
||||
|
||||
@@ -249,15 +249,14 @@ ol.renderer.Layer.prototype.updateUsedTiles =
|
||||
* @param {function(ol.Tile): boolean} isLoadedFunction Function to
|
||||
* determine if the tile is loaded.
|
||||
* @param {ol.source.TileSource} tileSource Tile source.
|
||||
* @param {ol.tilegrid.TileGrid} tileGrid Tile grid.
|
||||
* @param {ol.Projection} projection Projection.
|
||||
* @return {function(number, number, number): ol.Tile} Returns a tile if it is
|
||||
* loaded.
|
||||
*/
|
||||
ol.renderer.Layer.prototype.createGetTileIfLoadedFunction =
|
||||
function(isLoadedFunction, tileSource, tileGrid, projection) {
|
||||
function(isLoadedFunction, tileSource, projection) {
|
||||
return function(z, x, y) {
|
||||
var tile = tileSource.getTile(z, x, y, tileGrid, projection);
|
||||
var tile = tileSource.getTile(z, x, y, projection);
|
||||
return isLoadedFunction(tile) ? tile : null;
|
||||
};
|
||||
};
|
||||
@@ -314,7 +313,7 @@ ol.renderer.Layer.prototype.manageTilePyramid = function(
|
||||
for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
|
||||
for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
|
||||
if (currentZ - z <= preload) {
|
||||
tile = tileSource.getTile(z, x, y, tileGrid, projection);
|
||||
tile = tileSource.getTile(z, x, y, projection);
|
||||
if (tile.getState() == ol.TileState.IDLE) {
|
||||
wantedTiles[tile.tileCoord.toString()] = true;
|
||||
if (!tileQueue.isKeyQueued(tile.getKey())) {
|
||||
|
||||
@@ -205,7 +205,7 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
|
||||
var getTileIfLoaded = this.createGetTileIfLoadedFunction(function(tile) {
|
||||
return !goog.isNull(tile) && tile.getState() == ol.TileState.LOADED &&
|
||||
mapRenderer.isTileTextureLoaded(tile);
|
||||
}, tileSource, tileGrid, projection);
|
||||
}, tileSource, projection);
|
||||
var findLoadedTiles = goog.bind(tileSource.findLoadedTiles, tileSource,
|
||||
tilesToDrawByZ, getTileIfLoaded);
|
||||
|
||||
@@ -214,7 +214,7 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
|
||||
for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
|
||||
for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
|
||||
|
||||
tile = tileSource.getTile(z, x, y, tileGrid, projection);
|
||||
tile = tileSource.getTile(z, x, y, projection);
|
||||
tileState = tile.getState();
|
||||
if (tileState == ol.TileState.LOADED) {
|
||||
if (mapRenderer.isTileTextureLoaded(tile)) {
|
||||
|
||||
@@ -103,7 +103,9 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
|
||||
var imageUrl = resource.imageUrl
|
||||
.replace('{subdomain}', subdomain)
|
||||
.replace('{culture}', culture);
|
||||
return function(tileCoord) {
|
||||
return function(tileCoord, projection) {
|
||||
goog.asserts.assert(ol.projection.equivalent(
|
||||
projection, this.getProjection()));
|
||||
if (goog.isNull(tileCoord)) {
|
||||
return undefined;
|
||||
} else {
|
||||
|
||||
@@ -87,16 +87,14 @@ ol.source.ImageTileSource.prototype.expireCache = function(usedTiles) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.source.ImageTileSource.prototype.getTile =
|
||||
function(z, x, y, tileGrid, projection) {
|
||||
ol.source.ImageTileSource.prototype.getTile = function(z, x, y, projection) {
|
||||
var tileCoordKey = ol.TileCoord.getKeyZXY(z, x, y);
|
||||
if (this.tileCache_.containsKey(tileCoordKey)) {
|
||||
return /** @type {!ol.Tile} */ (this.tileCache_.get(tileCoordKey));
|
||||
} else {
|
||||
goog.asserts.assert(tileGrid);
|
||||
goog.asserts.assert(projection);
|
||||
var tileCoord = new ol.TileCoord(z, x, y);
|
||||
var tileUrl = this.tileUrlFunction(tileCoord, tileGrid, projection);
|
||||
var tileUrl = this.tileUrlFunction(tileCoord, projection);
|
||||
var tile = new ol.ImageTile(
|
||||
tileCoord,
|
||||
goog.isDef(tileUrl) ? ol.TileState.IDLE : ol.TileState.EMPTY,
|
||||
|
||||
@@ -42,7 +42,11 @@ ol.source.TiledWMS = function(tiledWMSOptions) {
|
||||
tiledWMSOptions.params['TRANSPARENT'] : true;
|
||||
var extent = tiledWMSOptions.extent;
|
||||
|
||||
var tileCoordTransform = function(tileCoord, tileGrid, projection) {
|
||||
var tileCoordTransform = function(tileCoord, projection) {
|
||||
var tileGrid = this.getTileGrid();
|
||||
if (goog.isNull(tileGrid)) {
|
||||
tileGrid = ol.tilegrid.getForProjection(projection);
|
||||
}
|
||||
if (tileGrid.getResolutions().length <= tileCoord.z) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,6 @@ ol.source.TileSource.prototype.getResolutions = function() {
|
||||
* @param {number} z Tile coordinate z.
|
||||
* @param {number} x Tile coordinate x.
|
||||
* @param {number} y Tile coordinate y.
|
||||
* @param {ol.tilegrid.TileGrid=} opt_tileGrid Tile grid.
|
||||
* @param {ol.Projection=} opt_projection Projection.
|
||||
* @return {!ol.Tile} Tile.
|
||||
*/
|
||||
|
||||
@@ -112,7 +112,9 @@ ol.source.WMTS = function(wmtsOptions) {
|
||||
}
|
||||
|
||||
tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
|
||||
function(tileCoord, tileGrid, projection) {
|
||||
function(tileCoord, projection) {
|
||||
var tileGrid = this.getTileGrid();
|
||||
goog.asserts.assert(!goog.isNull(tileGrid));
|
||||
if (tileGrid.getResolutions().length <= tileCoord.z) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -4,11 +4,10 @@ goog.provide('ol.TileUrlFunctionType');
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.math');
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.tilegrid.TileGrid');
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {function(this:ol.source.Source, ol.TileCoord, ol.tilegrid.TileGrid,
|
||||
* @typedef {function(this:ol.source.ImageTileSource, ol.TileCoord,
|
||||
* ol.Projection): (string|undefined)}
|
||||
*/
|
||||
ol.TileUrlFunctionType;
|
||||
@@ -49,12 +48,12 @@ ol.TileUrlFunction.createFromTileUrlFunctions = function(tileUrlFunctions) {
|
||||
if (tileUrlFunctions.length === 1) {
|
||||
return tileUrlFunctions[0];
|
||||
}
|
||||
return function(tileCoord, tileGrid, projection) {
|
||||
return function(tileCoord, projection) {
|
||||
if (goog.isNull(tileCoord)) {
|
||||
return undefined;
|
||||
} else {
|
||||
var index = goog.math.modulo(tileCoord.hash(), tileUrlFunctions.length);
|
||||
return tileUrlFunctions[index](tileCoord, tileGrid, projection);
|
||||
return tileUrlFunctions[index].call(this, tileCoord, projection);
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -63,20 +62,24 @@ ol.TileUrlFunction.createFromTileUrlFunctions = function(tileUrlFunctions) {
|
||||
/**
|
||||
* @param {string} baseUrl Base URL (may have query data).
|
||||
* @param {Object.<string,*>} params to encode in the url.
|
||||
* @param {function(string, Object.<string,*>, ol.Extent, ol.Size,
|
||||
* ol.Projection)} paramsFunction params function.
|
||||
* @param {function(this: ol.source.ImageTileSource, string, Object.<string,*>,
|
||||
* ol.Extent, ol.Size, ol.Projection)} paramsFunction params function.
|
||||
* @return {ol.TileUrlFunctionType} Tile URL function.
|
||||
*/
|
||||
ol.TileUrlFunction.createFromParamsFunction =
|
||||
function(baseUrl, params, paramsFunction) {
|
||||
return function(tileCoord, tileGrid, projection) {
|
||||
return function(tileCoord, projection) {
|
||||
if (goog.isNull(tileCoord)) {
|
||||
return undefined;
|
||||
} else {
|
||||
var tileGrid = this.getTileGrid();
|
||||
if (goog.isNull(tileGrid)) {
|
||||
tileGrid = ol.tilegrid.getForProjection(projection);
|
||||
}
|
||||
var size = tileGrid.getTileSize(tileCoord.z);
|
||||
var extent = tileGrid.getTileCoordExtent(tileCoord);
|
||||
return paramsFunction(
|
||||
baseUrl, params, extent, size, projection);
|
||||
return paramsFunction.call(this, baseUrl, params,
|
||||
extent, size, projection);
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -84,27 +87,28 @@ ol.TileUrlFunction.createFromParamsFunction =
|
||||
|
||||
/**
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
* @param {ol.Projection} projection Projection.
|
||||
* @return {string|undefined} Tile URL.
|
||||
*/
|
||||
ol.TileUrlFunction.nullTileUrlFunction = function(tileCoord) {
|
||||
ol.TileUrlFunction.nullTileUrlFunction = function(tileCoord, projection) {
|
||||
return undefined;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {function(ol.TileCoord, ol.tilegrid.TileGrid, ol.Projection):
|
||||
* ol.TileCoord} transformFn Transform.function.
|
||||
* @param {function(this:ol.source.ImageTileSource, ol.TileCoord,
|
||||
* ol.Projection) : ol.TileCoord} transformFn Transform function.
|
||||
* @param {ol.TileUrlFunctionType} tileUrlFunction Tile URL function.
|
||||
* @return {ol.TileUrlFunctionType} Tile URL function.
|
||||
*/
|
||||
ol.TileUrlFunction.withTileCoordTransform =
|
||||
function(transformFn, tileUrlFunction) {
|
||||
return function(tileCoord, tileGrid, projection) {
|
||||
return function(tileCoord, projection) {
|
||||
if (goog.isNull(tileCoord)) {
|
||||
return undefined;
|
||||
} else {
|
||||
return tileUrlFunction.call(this,
|
||||
transformFn(tileCoord, tileGrid, projection), tileGrid, projection);
|
||||
transformFn.call(this, tileCoord, projection), projection);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user