Do not pass tile grid to getTile and tileUrlFunc

getTile and the tileUrlFunc are functions of the source, so they do need to be passed the tile grid. The tile source knows its tile grid, and can get the projection's tile grid if it doesn't have a tile grid.
This commit is contained in:
Éric Lemoine
2013-04-02 11:00:39 +02:00
parent 676bcc6cc7
commit e128bab625
12 changed files with 54 additions and 48 deletions

View File

@@ -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 {

View File

@@ -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,

View File

@@ -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;
}

View File

@@ -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.
*/

View File

@@ -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;
}