Fix incorrect TileSize in index.json and data.json data urls. Add TileSize option to index.json and rendered.json endpoints for rendered urls. (#1160)
* fix: tilesize should not be added to data endpoint * fix: make tilesize and option of addtilejson urls * docs: update tilesize info for index.json and rendered.json * fix: lint
This commit is contained in:
parent
c34c5786bd
commit
fe111ed18f
2 changed files with 18 additions and 8 deletions
|
@ -102,7 +102,9 @@ Source data
|
||||||
|
|
||||||
TileJSON arrays
|
TileJSON arrays
|
||||||
===============
|
===============
|
||||||
Array of all TileJSONs is at ``/index.json`` (``/rendered.json``; ``/data.json``)
|
Array of all TileJSONs is at ``[/{tileSize}]/index.json`` (``[/{tileSize}]/rendered.json``; ``/data.json``)
|
||||||
|
|
||||||
|
* The optional tile size ``/{tileSize}`` (ex. ``/256``, ``/512``). if omitted, tileSize defaults to 256.
|
||||||
|
|
||||||
List of available fonts
|
List of available fonts
|
||||||
=======================
|
=======================
|
||||||
|
|
|
@ -354,9 +354,8 @@ function start(opts) {
|
||||||
res.send(result);
|
res.send(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
const addTileJSONs = (arr, req, type) => {
|
const addTileJSONs = (arr, req, type, tileSize) => {
|
||||||
for (const id of Object.keys(serving[type])) {
|
for (const id of Object.keys(serving[type])) {
|
||||||
const tileSize = 256;
|
|
||||||
const info = clone(serving[type][id].tileJSON);
|
const info = clone(serving[type][id].tileJSON);
|
||||||
let path = '';
|
let path = '';
|
||||||
if (type === 'rendered') {
|
if (type === 'rendered') {
|
||||||
|
@ -380,14 +379,23 @@ function start(opts) {
|
||||||
return arr;
|
return arr;
|
||||||
};
|
};
|
||||||
|
|
||||||
app.get('/rendered.json', (req, res, next) => {
|
app.get('/(:tileSize(256|512)/)?rendered.json', (req, res, next) => {
|
||||||
res.send(addTileJSONs([], req, 'rendered'));
|
const tileSize = parseInt(req.params.tileSize, 10) || 256;
|
||||||
|
res.send(addTileJSONs([], req, 'rendered', tileSize));
|
||||||
});
|
});
|
||||||
app.get('/data.json', (req, res, next) => {
|
app.get('/data.json', (req, res, next) => {
|
||||||
res.send(addTileJSONs([], req, 'data'));
|
res.send(addTileJSONs([], req, 'data', undefined));
|
||||||
});
|
});
|
||||||
app.get('/index.json', (req, res, next) => {
|
app.get('/(:tileSize(256|512)/)?index.json', (req, res, next) => {
|
||||||
res.send(addTileJSONs(addTileJSONs([], req, 'rendered'), req, 'data'));
|
const tileSize = parseInt(req.params.tileSize, 10) || 256;
|
||||||
|
res.send(
|
||||||
|
addTileJSONs(
|
||||||
|
addTileJSONs([], req, 'rendered', tileSize),
|
||||||
|
req,
|
||||||
|
'data',
|
||||||
|
undefined,
|
||||||
|
),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue