Change endpoint URLs (close #154)

- styles at /style/{id}/style.json
- rendered tiles at /style/{id}/{z}/{x}/{y}.{format}
- TileJSONs at /style/{id}.json
This commit is contained in:
Petr Sloup
2017-06-22 16:36:08 +02:00
parent 8007f1386c
commit 698c527e94
9 changed files with 26 additions and 26 deletions
+5 -5
View File
@@ -310,7 +310,7 @@ module.exports = function(options, repo, params, id, dataResolver) {
repo[id] = tileJSON;
var tilePattern = '/rendered/:z(\\d+)/:x(\\d+)/:y(\\d+)' +
var tilePattern = '/' + id + '/:z(\\d+)/:x(\\d+)/:y(\\d+)' +
':scale(' + scalePattern + ')?\.:format([\\w]+)';
var respondImage = function(z, lon, lat, bearing, pitch,
@@ -544,7 +544,7 @@ module.exports = function(options, repo, params, id, dataResolver) {
if (options.serveStaticMaps !== false) {
var staticPattern =
'/static/:raw(raw)?/%s/:width(\\d+)x:height(\\d+)' +
'/' + id + '/static/:raw(raw)?/%s/:width(\\d+)x:height(\\d+)' +
':scale(' + scalePattern + ')?\.:format([\\w]+)';
var centerPattern =
@@ -628,7 +628,7 @@ module.exports = function(options, repo, params, id, dataResolver) {
app.get(util.format(staticPattern, boundsPattern), serveBounds);
app.get('/static/', function(req, res, next) {
app.get('/' + id + '/static/', function(req, res, next) {
for (var key in req.query) {
req.query[key.toLowerCase()] = req.query[key];
}
@@ -694,10 +694,10 @@ module.exports = function(options, repo, params, id, dataResolver) {
});
}
app.get('/rendered.json', function(req, res, next) {
app.get('/' + id + '.json', function(req, res, next) {
var info = clone(tileJSON);
info.tiles = utils.getTileUrls(req, info.tiles,
'styles/' + id + '/rendered', info.format);
'styles/' + id, info.format);
return res.send(info);
});
+1 -1
View File
@@ -62,7 +62,7 @@ module.exports = function(options, repo, params, id, reportTiles, reportFont) {
repo[id] = styleJSON;
app.get('/' + id + '.json', function(req, res, next) {
app.get('/' + id + '/style.json', function(req, res, next) {
var fixUrl = function(url, opt_nokey, opt_nostyle) {
if (!url || (typeof url !== 'string') || url.indexOf('local://') !== 0) {
return url;
+5 -5
View File
@@ -150,7 +150,7 @@ function start(opts) {
return mbtilesFile;
}
).then(function(sub) {
app.use('/styles/' + id + '/', sub);
app.use('/styles/', sub);
})
);
} else {
@@ -189,7 +189,7 @@ function start(opts) {
name: styleJSON.name,
id: id,
url: req.protocol + '://' + req.headers.host +
'/styles/' + id + '.json' + query
'/styles/' + id + '/style.json' + query
});
});
res.send(result);
@@ -200,7 +200,7 @@ function start(opts) {
var info = clone(serving[type][id]);
var path = '';
if (type == 'rendered') {
path = 'styles/' + id + '/rendered';
path = 'styles/' + id;
} else {
path = type + '/' + id;
}
@@ -288,11 +288,11 @@ function start(opts) {
var query = req.query.key ? ('?key=' + req.query.key) : '';
style.wmts_link = 'http://wmts.maptiler.com/' +
base64url('http://' + req.headers.host +
'/styles/' + id + '/rendered.json' + query) + '/wmts';
'/styles/' + id + '.json' + query) + '/wmts';
var tiles = utils.getTileUrls(
req, style.serving_rendered.tiles,
'styles/' + id + '/rendered', style.serving_rendered.format);
'styles/' + id, style.serving_rendered.format);
style.xyz_link = tiles[0];
}
});