From a31ad69ec4c0cf530a5f52aad9ada649ea390204 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Tue, 25 Mar 2014 16:50:16 +0100 Subject: [PATCH] Make tile URL functions more general --- src/ol/source/bingmapssource.js | 4 ++-- src/ol/tileurlfunction.js | 19 ++++++------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/ol/source/bingmapssource.js b/src/ol/source/bingmapssource.js index edc223891a..fa93ddb4d5 100644 --- a/src/ol/source/bingmapssource.js +++ b/src/ol/source/bingmapssource.js @@ -91,6 +91,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = this.tileGrid = tileGrid; var culture = this.culture_; + var sourceProjection = this.getProjection(); this.tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform( tileGrid.createTileCoordTransform(), ol.TileUrlFunction.createFromTileUrlFunctions( @@ -102,7 +103,6 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = .replace('{culture}', culture); return ( /** - * @this {ol.source.BingMaps} * @param {ol.TileCoord} tileCoord Tile coordinate. * @param {number} pixelRatio Pixel ratio. * @param {ol.proj.Projection} projection Projection. @@ -110,7 +110,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = */ function(tileCoord, pixelRatio, projection) { goog.asserts.assert(ol.proj.equivalent( - projection, this.getProjection())); + projection, sourceProjection)); if (goog.isNull(tileCoord)) { return undefined; } else { diff --git a/src/ol/tileurlfunction.js b/src/ol/tileurlfunction.js index 0626f0ec80..f99bfbcee2 100644 --- a/src/ol/tileurlfunction.js +++ b/src/ol/tileurlfunction.js @@ -10,11 +10,10 @@ goog.require('ol.TileCoord'); * A function that takes an {@link ol.TileCoord} for the tile coordinate, * a `{number}` representing the pixel ratio and an {@link ol.proj.Projection} * for the projection as arguments and returns a `{string}` or - * undefined representing the tile URL. The this keyword inside the function - * references the {@link ol.source.TileImage}. + * undefined representing the tile URL. * - * @typedef {function(this: ol.source.TileImage, ol.TileCoord, - * number, ol.proj.Projection): (string|undefined)} + * @typedef {function(ol.TileCoord, number, + * ol.proj.Projection): (string|undefined)} * @todo stability experimental */ ol.TileUrlFunctionType; @@ -34,7 +33,6 @@ ol.TileCoordTransformType; ol.TileUrlFunction.createFromTemplate = function(template) { return ( /** - * @this {ol.source.TileImage} * @param {ol.TileCoord} tileCoord Tile Coordinate. * @param {number} pixelRatio Pixel ratio. * @param {ol.proj.Projection} projection Projection. @@ -72,7 +70,6 @@ ol.TileUrlFunction.createFromTileUrlFunctions = function(tileUrlFunctions) { } return ( /** - * @this {ol.source.TileImage} * @param {ol.TileCoord} tileCoord Tile Coordinate. * @param {number} pixelRatio Pixel ratio. * @param {ol.proj.Projection} projection Projection. @@ -84,15 +81,13 @@ ol.TileUrlFunction.createFromTileUrlFunctions = function(tileUrlFunctions) { } else { var index = goog.math.modulo(tileCoord.hash(), tileUrlFunctions.length); - return tileUrlFunctions[index].call( - this, tileCoord, pixelRatio, projection); + return tileUrlFunctions[index](tileCoord, pixelRatio, projection); } }); }; /** - * @this {ol.source.TileImage} * @param {ol.TileCoord} tileCoord Tile coordinate. * @param {number} pixelRatio Pixel ratio. * @param {ol.proj.Projection} projection Projection. @@ -114,7 +109,6 @@ ol.TileUrlFunction.withTileCoordTransform = var tmpTileCoord = new ol.TileCoord(0, 0, 0); return ( /** - * @this {ol.source.TileImage} * @param {ol.TileCoord} tileCoord Tile Coordinate. * @param {number} pixelRatio Pixel ratio. * @param {ol.proj.Projection} projection Projection. @@ -124,9 +118,8 @@ ol.TileUrlFunction.withTileCoordTransform = if (goog.isNull(tileCoord)) { return undefined; } else { - return tileUrlFunction.call( - this, - transformFn.call(this, tileCoord, projection, tmpTileCoord), + return tileUrlFunction( + transformFn(tileCoord, projection, tmpTileCoord), pixelRatio, projection); }