Homogenize wmts tileUrlFunction relative to other sources

This commit is contained in:
Bruno Binet
2013-03-13 16:39:49 +01:00
parent 5eaf4baaa4
commit 317676a68f
+17 -16
View File
@@ -66,12 +66,6 @@ ol.source.WMTS = function(wmtsOptions) {
goog.object.extend(kvpParams, context); goog.object.extend(kvpParams, context);
} }
var urls = wmtsOptions.urls;
if (!goog.isDef(urls)) {
goog.asserts.assert(goog.isDef(wmtsOptions.url));
urls = ol.TileUrlFunction.expandUrl(wmtsOptions.url);
}
/** /**
* @param {string} template Template. * @param {string} template Template.
* @return {ol.TileUrlFunctionType} Tile URL function. * @return {ol.TileUrlFunctionType} Tile URL function.
@@ -100,16 +94,23 @@ ol.source.WMTS = function(wmtsOptions) {
}; };
} }
var tileUrlFunction = ol.TileUrlFunction.createFromTileUrlFunctions( var tileUrlFunction = ol.TileUrlFunction.nullTileUrlFunction;
goog.array.map(urls, function(url) { var urls = wmtsOptions.urls;
if (goog.isDef(kvpParams)) { if (!goog.isDef(urls) && goog.isDef(wmtsOptions.url)) {
// TODO: we may want to create our own appendParams function urls = ol.TileUrlFunction.expandUrl(wmtsOptions.url);
// so that params order conforms to wmts spec guidance, }
// and so that we can avoid to escape special template params if (goog.isDef(urls)) {
url = goog.uri.utils.appendParamsFromMap(url, kvpParams); tileUrlFunction = ol.TileUrlFunction.createFromTileUrlFunctions(
} goog.array.map(urls, function(url) {
return createFromWMTSTemplate(url); if (goog.isDef(kvpParams)) {
})); // TODO: we may want to create our own appendParams function
// so that params order conforms to wmts spec guidance,
// and so that we can avoid to escape special template params
url = goog.uri.utils.appendParamsFromMap(url, kvpParams);
}
return createFromWMTSTemplate(url);
}));
}
tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform( tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
function(tileCoord, tileGrid, projection) { function(tileCoord, tileGrid, projection) {