Move factorizable code in ol.TileUrlFunction.expandUrl
This commit is contained in:
@@ -120,3 +120,24 @@ ol.TileUrlFunction.withTileCoordTransform =
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} url Url.
|
||||
* @return {Array.<string>} Array of urls.
|
||||
*/
|
||||
ol.TileUrlFunction.expandUrl = function(url) {
|
||||
var urls = [];
|
||||
var match = /\{(\d)-(\d)\}/.exec(url) || /\{([a-z])-([a-z])\}/.exec(url);
|
||||
if (match) {
|
||||
var startCharCode = match[1].charCodeAt(0);
|
||||
var stopCharCode = match[2].charCodeAt(0);
|
||||
var charCode;
|
||||
for (charCode = startCharCode; charCode <= stopCharCode; ++charCode) {
|
||||
urls.push(url.replace(match[0], String.fromCharCode(charCode)));
|
||||
}
|
||||
} else {
|
||||
urls.push(url);
|
||||
}
|
||||
return urls;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user