Improved generation of TileJSONs

This commit is contained in:
Petr Sloup
2016-03-02 13:11:43 +01:00
parent 92b502af36
commit 565ed2dd74
4 changed files with 55 additions and 62 deletions

19
src/utils.js Normal file
View File

@@ -0,0 +1,19 @@
'use strict';
module.exports.getTileUrls = function(
protocol, domains, host, path, tilePath, format, key) {
domains = domains && domains.length > 0 ? domains : [host];
var query = (key && key.length > 0) ? ('?key=' + key) : '';
if (path == '/') {
path = '';
}
var uris = [];
domains.forEach(function(domain) {
uris.push(protocol + '://' + domain + path +
tilePath.replace('{format}', format).replace(/\/+/g, '/') +
query);
});
return uris;
};