From 0e69af847e3928943497771d80b088ebd9c94957 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Tue, 30 Apr 2013 21:34:23 +0200 Subject: [PATCH] Improve type checking in ol.source.WMTS --- src/ol/source/wmtssource.js | 47 ++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/src/ol/source/wmtssource.js b/src/ol/source/wmtssource.js index 91fed7ba60..9fdc72427d 100644 --- a/src/ol/source/wmtssource.js +++ b/src/ol/source/wmtssource.js @@ -73,27 +73,32 @@ ol.source.WMTS = function(options) { * @return {ol.TileUrlFunctionType} Tile URL function. */ function createFromWMTSTemplate(template) { - return function(tileCoord) { - if (goog.isNull(tileCoord)) { - return undefined; - } else { - var localContext = { - 'TileMatrix': tileGrid.getMatrixId(tileCoord.z), - 'TileCol': tileCoord.x, - 'TileRow': tileCoord.y - }; - if (requestEncoding != ol.source.WMTSRequestEncoding.KVP) { - goog.object.extend(localContext, context); - } - var url = template; - for (var key in localContext) { - // FIXME: should we filter properties with hasOwnProperty? - url = url.replace('{' + key + '}', localContext[key]) - .replace('%7B' + key + '%7D', localContext[key]); - } - return url; - } - }; + return ( + /** + * @param {ol.TileCoord} tileCoord Tile coordinate. + * @return {string|undefined} Tile URL. + */ + function(tileCoord) { + if (goog.isNull(tileCoord)) { + return undefined; + } else { + var localContext = { + 'TileMatrix': tileGrid.getMatrixId(tileCoord.z), + 'TileCol': tileCoord.x, + 'TileRow': tileCoord.y + }; + if (requestEncoding != ol.source.WMTSRequestEncoding.KVP) { + goog.object.extend(localContext, context); + } + var url = template; + for (var key in localContext) { + // FIXME: should we filter properties with hasOwnProperty? + url = url.replace('{' + key + '}', localContext[key]) + .replace('%7B' + key + '%7D', localContext[key]); + } + return url; + } + }); } var tileUrlFunction = ol.TileUrlFunction.nullTileUrlFunction;