remove trailing commas
This commit is contained in:
parent
fff69f2483
commit
dbfe411796
11 changed files with 76 additions and 73 deletions
|
|
@ -8,4 +8,7 @@ parserOptions:
|
||||||
sourceType: module
|
sourceType: module
|
||||||
ignorePatterns:
|
ignorePatterns:
|
||||||
- /public/resources
|
- /public/resources
|
||||||
rules: {}
|
rules:
|
||||||
|
comma-dangle:
|
||||||
|
- error
|
||||||
|
- never
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
// SYNC THE `light` FOLDER
|
// SYNC THE `light` FOLDER
|
||||||
require('child_process').execSync('rsync -av --exclude="light" --exclude=".git" --exclude="node_modules" --delete . light', {
|
require('child_process').execSync('rsync -av --exclude="light" --exclude=".git" --exclude="node_modules" --delete . light', {
|
||||||
stdio: 'inherit',
|
stdio: 'inherit'
|
||||||
});
|
});
|
||||||
|
|
||||||
// PATCH `package.json`
|
// PATCH `package.json`
|
||||||
|
|
@ -45,10 +45,10 @@ if (process.argv.length > 2 && process.argv[2] == '--no-publish') {
|
||||||
|
|
||||||
// tileserver-gl
|
// tileserver-gl
|
||||||
require('child_process').execSync('npm publish .', {
|
require('child_process').execSync('npm publish .', {
|
||||||
stdio: 'inherit',
|
stdio: 'inherit'
|
||||||
});
|
});
|
||||||
|
|
||||||
// tileserver-gl-light
|
// tileserver-gl-light
|
||||||
require('child_process').execSync('npm publish light', {
|
require('child_process').execSync('npm publish light', {
|
||||||
stdio: 'inherit',
|
stdio: 'inherit'
|
||||||
});
|
});
|
||||||
|
|
|
||||||
38
src/main.js
38
src/main.js
|
|
@ -26,50 +26,50 @@ program
|
||||||
.option(
|
.option(
|
||||||
'--mbtiles <file>',
|
'--mbtiles <file>',
|
||||||
'MBTiles file (uses demo configuration);\n' +
|
'MBTiles file (uses demo configuration);\n' +
|
||||||
'\t ignored if the configuration file is also specified',
|
'\t ignored if the configuration file is also specified'
|
||||||
)
|
)
|
||||||
.option(
|
.option(
|
||||||
'-c, --config <file>',
|
'-c, --config <file>',
|
||||||
'Configuration file [config.json]',
|
'Configuration file [config.json]',
|
||||||
'config.json',
|
'config.json'
|
||||||
)
|
)
|
||||||
.option(
|
.option(
|
||||||
'-b, --bind <address>',
|
'-b, --bind <address>',
|
||||||
'Bind address',
|
'Bind address'
|
||||||
)
|
)
|
||||||
.option(
|
.option(
|
||||||
'-p, --port <port>',
|
'-p, --port <port>',
|
||||||
'Port [8080]',
|
'Port [8080]',
|
||||||
8080,
|
8080,
|
||||||
parseInt,
|
parseInt
|
||||||
)
|
)
|
||||||
.option(
|
.option(
|
||||||
'-C|--no-cors',
|
'-C|--no-cors',
|
||||||
'Disable Cross-origin resource sharing headers',
|
'Disable Cross-origin resource sharing headers'
|
||||||
)
|
)
|
||||||
.option(
|
.option(
|
||||||
'-u|--public_url <url>',
|
'-u|--public_url <url>',
|
||||||
'Enable exposing the server on subpaths, not necessarily the root of the domain',
|
'Enable exposing the server on subpaths, not necessarily the root of the domain'
|
||||||
)
|
)
|
||||||
.option(
|
.option(
|
||||||
'-V, --verbose',
|
'-V, --verbose',
|
||||||
'More verbose output',
|
'More verbose output'
|
||||||
)
|
)
|
||||||
.option(
|
.option(
|
||||||
'-s, --silent',
|
'-s, --silent',
|
||||||
'Less verbose output',
|
'Less verbose output'
|
||||||
)
|
)
|
||||||
.option(
|
.option(
|
||||||
'-l|--log_file <file>',
|
'-l|--log_file <file>',
|
||||||
'output log file (defaults to standard out)',
|
'output log file (defaults to standard out)'
|
||||||
)
|
)
|
||||||
.option(
|
.option(
|
||||||
'-f|--log_format <format>',
|
'-f|--log_format <format>',
|
||||||
'define the log format: https://github.com/expressjs/morgan#morganformat-options',
|
'define the log format: https://github.com/expressjs/morgan#morganformat-options'
|
||||||
)
|
)
|
||||||
.version(
|
.version(
|
||||||
packageJson.version,
|
packageJson.version,
|
||||||
'-v, --version',
|
'-v, --version'
|
||||||
);
|
);
|
||||||
program.parse(process.argv);
|
program.parse(process.argv);
|
||||||
const opts = program.opts();
|
const opts = program.opts();
|
||||||
|
|
@ -90,7 +90,7 @@ const startServer = (configPath, config) => {
|
||||||
silent: opts.silent,
|
silent: opts.silent,
|
||||||
logFile: opts.log_file,
|
logFile: opts.log_file,
|
||||||
logFormat: opts.log_format,
|
logFormat: opts.log_format,
|
||||||
publicUrl: publicUrl,
|
publicUrl: publicUrl
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -129,17 +129,17 @@ const startWithMBTiles = (mbtilesFile) => {
|
||||||
'root': styleDir,
|
'root': styleDir,
|
||||||
'fonts': 'fonts',
|
'fonts': 'fonts',
|
||||||
'styles': 'styles',
|
'styles': 'styles',
|
||||||
'mbtiles': path.dirname(mbtilesFile),
|
'mbtiles': path.dirname(mbtilesFile)
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
'styles': {},
|
'styles': {},
|
||||||
'data': {},
|
'data': {}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (info.format === 'pbf' &&
|
if (info.format === 'pbf' &&
|
||||||
info.name.toLowerCase().indexOf('openmaptiles') > -1) {
|
info.name.toLowerCase().indexOf('openmaptiles') > -1) {
|
||||||
config['data'][`v3`] = {
|
config['data'][`v3`] = {
|
||||||
'mbtiles': path.basename(mbtilesFile),
|
'mbtiles': path.basename(mbtilesFile)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -151,8 +151,8 @@ const startWithMBTiles = (mbtilesFile) => {
|
||||||
config['styles'][styleName] = {
|
config['styles'][styleName] = {
|
||||||
'style': styleFileRel,
|
'style': styleFileRel,
|
||||||
'tilejson': {
|
'tilejson': {
|
||||||
'bounds': bounds,
|
'bounds': bounds
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -162,7 +162,7 @@ const startWithMBTiles = (mbtilesFile) => {
|
||||||
.replace(/\//g, '_')
|
.replace(/\//g, '_')
|
||||||
.replace(/:/g, '_')
|
.replace(/:/g, '_')
|
||||||
.replace(/\?/g, '_')] = {
|
.replace(/\?/g, '_')] = {
|
||||||
'mbtiles': path.basename(mbtilesFile),
|
'mbtiles': path.basename(mbtilesFile)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ export const serve_data = {
|
||||||
const tile = new VectorTile(new Pbf(data));
|
const tile = new VectorTile(new Pbf(data));
|
||||||
const geojson = {
|
const geojson = {
|
||||||
'type': 'FeatureCollection',
|
'type': 'FeatureCollection',
|
||||||
'features': [],
|
'features': []
|
||||||
};
|
};
|
||||||
for (const layerName in tile.layers) {
|
for (const layerName in tile.layers) {
|
||||||
const layer = tile.layers[layerName];
|
const layer = tile.layers[layerName];
|
||||||
|
|
@ -110,7 +110,7 @@ export const serve_data = {
|
||||||
const info = clone(item.tileJSON);
|
const info = clone(item.tileJSON);
|
||||||
info.tiles = getTileUrls(req, info.tiles,
|
info.tiles = getTileUrls(req, info.tiles,
|
||||||
`data/${req.params.id}`, info.format, item.publicUrl, {
|
`data/${req.params.id}`, info.format, item.publicUrl, {
|
||||||
'pbf': options.pbfAlias,
|
'pbf': options.pbfAlias
|
||||||
});
|
});
|
||||||
return res.send(info);
|
return res.send(info);
|
||||||
});
|
});
|
||||||
|
|
@ -120,7 +120,7 @@ export const serve_data = {
|
||||||
add: (options, repo, params, id, publicUrl) => {
|
add: (options, repo, params, id, publicUrl) => {
|
||||||
const mbtilesFile = path.resolve(options.paths.mbtiles, params.mbtiles);
|
const mbtilesFile = path.resolve(options.paths.mbtiles, params.mbtiles);
|
||||||
let tileJSON = {
|
let tileJSON = {
|
||||||
'tiles': params.domains || options.domains,
|
'tiles': params.domains || options.domains
|
||||||
};
|
};
|
||||||
|
|
||||||
const mbtilesFileStats = fs.statSync(mbtilesFile);
|
const mbtilesFileStats = fs.statSync(mbtilesFile);
|
||||||
|
|
@ -165,8 +165,8 @@ export const serve_data = {
|
||||||
repo[id] = {
|
repo[id] = {
|
||||||
tileJSON,
|
tileJSON,
|
||||||
publicUrl,
|
publicUrl,
|
||||||
source,
|
source
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -45,14 +45,14 @@ export const serve_font = (options, allowedFonts) => {
|
||||||
res.header('Content-type', 'application/x-protobuf');
|
res.header('Content-type', 'application/x-protobuf');
|
||||||
res.header('Last-Modified', lastModified);
|
res.header('Last-Modified', lastModified);
|
||||||
return res.send(concated);
|
return res.send(concated);
|
||||||
}, (err) => res.status(400).send(err),
|
}, (err) => res.status(400).send(err)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/fonts.json', (req, res, next) => {
|
app.get('/fonts.json', (req, res, next) => {
|
||||||
res.header('Content-type', 'application/json');
|
res.header('Content-type', 'application/json');
|
||||||
return res.send(
|
return res.send(
|
||||||
Object.keys(options.serveAllFonts ? existingFonts : allowedFonts).sort(),
|
Object.keys(options.serveAllFonts ? existingFonts : allowedFonts).sort()
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,5 +6,5 @@ export const serve_rendered = {
|
||||||
add: (options, repo, params, id, publicUrl, dataResolver) => {
|
add: (options, repo, params, id, publicUrl, dataResolver) => {
|
||||||
},
|
},
|
||||||
remove: (repo, id) => {
|
remove: (repo, id) => {
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ const extensionToFormat = {
|
||||||
'.jpg': 'jpeg',
|
'.jpg': 'jpeg',
|
||||||
'.jpeg': 'jpeg',
|
'.jpeg': 'jpeg',
|
||||||
'.png': 'png',
|
'.png': 'png',
|
||||||
'.webp': 'webp',
|
'.webp': 'webp'
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -46,7 +46,7 @@ const extensionToFormat = {
|
||||||
* string is for unknown or unsupported formats.
|
* string is for unknown or unsupported formats.
|
||||||
*/
|
*/
|
||||||
const cachedEmptyResponses = {
|
const cachedEmptyResponses = {
|
||||||
'': Buffer.alloc(0),
|
'': Buffer.alloc(0)
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -83,8 +83,8 @@ function createEmptyResponse(format, color, callback) {
|
||||||
raw: {
|
raw: {
|
||||||
width: 1,
|
width: 1,
|
||||||
height: 1,
|
height: 1,
|
||||||
channels: channels,
|
channels: channels
|
||||||
},
|
}
|
||||||
}).toFormat(format).toBuffer((err, buffer, info) => {
|
}).toFormat(format).toBuffer((err, buffer, info) => {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
cachedEmptyResponses[cacheKey] = buffer;
|
cachedEmptyResponses[cacheKey] = buffer;
|
||||||
|
|
@ -182,7 +182,7 @@ const calcZForBBox = (bbox, w, h, query) => {
|
||||||
|
|
||||||
z -= Math.max(
|
z -= Math.max(
|
||||||
Math.log((maxCorner[0] - minCorner[0]) / w_),
|
Math.log((maxCorner[0] - minCorner[0]) / w_),
|
||||||
Math.log((maxCorner[1] - minCorner[1]) / h_),
|
Math.log((maxCorner[1] - minCorner[1]) / h_)
|
||||||
) / Math.LN2;
|
) / Math.LN2;
|
||||||
|
|
||||||
z = Math.max(Math.log(Math.max(w, h) / 256) / Math.LN2, Math.min(25, z));
|
z = Math.max(Math.log(Math.max(w, h) / 256) / Math.LN2, Math.min(25, z));
|
||||||
|
|
@ -253,7 +253,7 @@ export const serve_rendered = {
|
||||||
bearing: bearing,
|
bearing: bearing,
|
||||||
pitch: pitch,
|
pitch: pitch,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height
|
||||||
};
|
};
|
||||||
if (z === 0) {
|
if (z === 0) {
|
||||||
params.width *= 2;
|
params.width *= 2;
|
||||||
|
|
@ -293,8 +293,8 @@ export const serve_rendered = {
|
||||||
raw: {
|
raw: {
|
||||||
width: params.width * scale,
|
width: params.width * scale,
|
||||||
height: params.height * scale,
|
height: params.height * scale,
|
||||||
channels: 4,
|
channels: 4
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (z > 2 && tileMargin > 0) {
|
if (z > 2 && tileMargin > 0) {
|
||||||
|
|
@ -304,7 +304,7 @@ export const serve_rendered = {
|
||||||
left: tileMargin * scale,
|
left: tileMargin * scale,
|
||||||
top: (tileMargin + yoffset) * scale,
|
top: (tileMargin + yoffset) * scale,
|
||||||
width: width * scale,
|
width: width * scale,
|
||||||
height: height * scale,
|
height: height * scale
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -346,7 +346,7 @@ export const serve_rendered = {
|
||||||
|
|
||||||
res.set({
|
res.set({
|
||||||
'Last-Modified': item.lastModified,
|
'Last-Modified': item.lastModified,
|
||||||
'Content-Type': `image/${format}`,
|
'Content-Type': `image/${format}`
|
||||||
});
|
});
|
||||||
return res.status(200).send(buffer);
|
return res.status(200).send(buffer);
|
||||||
});
|
});
|
||||||
|
|
@ -379,7 +379,7 @@ export const serve_rendered = {
|
||||||
const tileSize = 256;
|
const tileSize = 256;
|
||||||
const tileCenter = mercator.ll([
|
const tileCenter = mercator.ll([
|
||||||
((x + 0.5) / (1 << z)) * (256 << z),
|
((x + 0.5) / (1 << z)) * (256 << z),
|
||||||
((y + 0.5) / (1 << z)) * (256 << z),
|
((y + 0.5) / (1 << z)) * (256 << z)
|
||||||
], z);
|
], z);
|
||||||
return respondImage(item, z, tileCenter[0], tileCenter[1], 0, 0,
|
return respondImage(item, z, tileCenter[0], tileCenter[1], 0, 0,
|
||||||
tileSize, tileSize, scale, format, res, next);
|
tileSize, tileSize, scale, format, res, next);
|
||||||
|
|
@ -533,7 +533,7 @@ export const serve_rendered = {
|
||||||
|
|
||||||
const bbox_ = mercator.convert(bbox, '900913');
|
const bbox_ = mercator.convert(bbox, '900913');
|
||||||
const center = mercator.inverse(
|
const center = mercator.inverse(
|
||||||
[(bbox_[0] + bbox_[2]) / 2, (bbox_[1] + bbox_[3]) / 2],
|
[(bbox_[0] + bbox_[2]) / 2, (bbox_[1] + bbox_[3]) / 2]
|
||||||
);
|
);
|
||||||
|
|
||||||
const z = calcZForBBox(bbox, w, h, req.query);
|
const z = calcZForBBox(bbox, w, h, req.query);
|
||||||
|
|
@ -564,7 +564,7 @@ export const serve_rendered = {
|
||||||
add: (options, repo, params, id, publicUrl, dataResolver) => {
|
add: (options, repo, params, id, publicUrl, dataResolver) => {
|
||||||
const map = {
|
const map = {
|
||||||
renderers: [],
|
renderers: [],
|
||||||
sources: {},
|
sources: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
let styleJSON;
|
let styleJSON;
|
||||||
|
|
@ -587,7 +587,7 @@ export const serve_rendered = {
|
||||||
const fontstack = unescape(parts[2]);
|
const fontstack = unescape(parts[2]);
|
||||||
const range = parts[3].split('.')[0];
|
const range = parts[3].split('.')[0];
|
||||||
getFontsPbf(
|
getFontsPbf(
|
||||||
null, options.paths[protocol], fontstack, range, existingFonts,
|
null, options.paths[protocol], fontstack, range, existingFonts
|
||||||
).then((concated) => {
|
).then((concated) => {
|
||||||
callback(null, {data: concated});
|
callback(null, {data: concated});
|
||||||
}, (err) => {
|
}, (err) => {
|
||||||
|
|
@ -634,7 +634,7 @@ export const serve_rendered = {
|
||||||
request({
|
request({
|
||||||
url: req.url,
|
url: req.url,
|
||||||
encoding: null,
|
encoding: null,
|
||||||
gzip: true,
|
gzip: true
|
||||||
}, (err, res, body) => {
|
}, (err, res, body) => {
|
||||||
const parts = url.parse(req.url);
|
const parts = url.parse(req.url);
|
||||||
const extension = path.extname(parts.pathname).toLowerCase();
|
const extension = path.extname(parts.pathname).toLowerCase();
|
||||||
|
|
@ -660,7 +660,7 @@ export const serve_rendered = {
|
||||||
callback(null, response);
|
callback(null, response);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
renderer.load(styleJSON);
|
renderer.load(styleJSON);
|
||||||
createCallback(null, renderer);
|
createCallback(null, renderer);
|
||||||
|
|
@ -671,7 +671,7 @@ export const serve_rendered = {
|
||||||
create: createRenderer.bind(null, ratio),
|
create: createRenderer.bind(null, ratio),
|
||||||
destroy: (renderer) => {
|
destroy: (renderer) => {
|
||||||
renderer.release();
|
renderer.release();
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -715,7 +715,7 @@ export const serve_rendered = {
|
||||||
'maxzoom': 20,
|
'maxzoom': 20,
|
||||||
'bounds': [-180, -85.0511, 180, 85.0511],
|
'bounds': [-180, -85.0511, 180, 85.0511],
|
||||||
'format': 'png',
|
'format': 'png',
|
||||||
'type': 'baselayer',
|
'type': 'baselayer'
|
||||||
};
|
};
|
||||||
const attributionOverride = params.tilejson && params.tilejson.attribution;
|
const attributionOverride = params.tilejson && params.tilejson.attribution;
|
||||||
Object.assign(tileJSON, params.tilejson || {});
|
Object.assign(tileJSON, params.tilejson || {});
|
||||||
|
|
@ -728,7 +728,7 @@ export const serve_rendered = {
|
||||||
map,
|
map,
|
||||||
dataProjWGStoInternalWGS: null,
|
dataProjWGStoInternalWGS: null,
|
||||||
lastModified: new Date().toUTCString(),
|
lastModified: new Date().toUTCString(),
|
||||||
watermark: params.watermark || options.watermark,
|
watermark: params.watermark || options.watermark
|
||||||
};
|
};
|
||||||
repo[id] = repoobj;
|
repo[id] = repoobj;
|
||||||
|
|
||||||
|
|
@ -783,7 +783,7 @@ export const serve_rendered = {
|
||||||
source.type = type;
|
source.type = type;
|
||||||
source.tiles = [
|
source.tiles = [
|
||||||
// meta url which will be detected when requested
|
// meta url which will be detected when requested
|
||||||
`mbtiles://${name}/{z}/{x}/{y}.${info.format || 'pbf'}`,
|
`mbtiles://${name}/{z}/{x}/{y}.${info.format || 'pbf'}`
|
||||||
];
|
];
|
||||||
delete source.scheme;
|
delete source.scheme;
|
||||||
|
|
||||||
|
|
@ -830,5 +830,5 @@ export const serve_rendered = {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
delete repo[id];
|
delete repo[id];
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ export const serve_style = {
|
||||||
spritePath = path.join(options.paths.sprites,
|
spritePath = path.join(options.paths.sprites,
|
||||||
styleJSON.sprite
|
styleJSON.sprite
|
||||||
.replace('{style}', path.basename(styleFile, '.json'))
|
.replace('{style}', path.basename(styleFile, '.json'))
|
||||||
.replace('{styleJsonFolder}', path.relative(options.paths.sprites, path.dirname(styleFile))),
|
.replace('{styleJsonFolder}', path.relative(options.paths.sprites, path.dirname(styleFile)))
|
||||||
);
|
);
|
||||||
styleJSON.sprite = `local://styles/${id}/sprite`;
|
styleJSON.sprite = `local://styles/${id}/sprite`;
|
||||||
}
|
}
|
||||||
|
|
@ -150,9 +150,9 @@ export const serve_style = {
|
||||||
styleJSON,
|
styleJSON,
|
||||||
spritePath,
|
spritePath,
|
||||||
publicUrl,
|
publicUrl,
|
||||||
name: styleJSON.name,
|
name: styleJSON.name
|
||||||
};
|
};
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ export function server(opts) {
|
||||||
styles: {},
|
styles: {},
|
||||||
rendered: {},
|
rendered: {},
|
||||||
data: {},
|
data: {},
|
||||||
fonts: {},
|
fonts: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
app.enable('trust proxy');
|
app.enable('trust proxy');
|
||||||
|
|
@ -48,7 +48,7 @@ export function server(opts) {
|
||||||
const logFormat = opts.logFormat || defaultLogFormat;
|
const logFormat = opts.logFormat || defaultLogFormat;
|
||||||
app.use(morgan(logFormat, {
|
app.use(morgan(logFormat, {
|
||||||
stream: opts.logFile ? fs.createWriteStream(opts.logFile, {flags: 'a'}) : process.stdout,
|
stream: opts.logFile ? fs.createWriteStream(opts.logFile, {flags: 'a'}) : process.stdout,
|
||||||
skip: (req, res) => opts.silent && (res.statusCode === 200 || res.statusCode === 304),
|
skip: (req, res) => opts.silent && (res.statusCode === 200 || res.statusCode === 304)
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,7 +112,7 @@ export function server(opts) {
|
||||||
serve_rendered.init(options, serving.rendered)
|
serve_rendered.init(options, serving.rendered)
|
||||||
.then((sub) => {
|
.then((sub) => {
|
||||||
app.use('/styles/', sub);
|
app.use('/styles/', sub);
|
||||||
}),
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -143,7 +143,7 @@ export function server(opts) {
|
||||||
let id = mbtiles.substr(0, mbtiles.lastIndexOf('.')) || mbtiles;
|
let id = mbtiles.substr(0, mbtiles.lastIndexOf('.')) || mbtiles;
|
||||||
while (data[id]) id += '_';
|
while (data[id]) id += '_';
|
||||||
data[id] = {
|
data[id] = {
|
||||||
'mbtiles': mbtiles,
|
'mbtiles': mbtiles
|
||||||
};
|
};
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
@ -165,7 +165,7 @@ export function server(opts) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mbtilesFile;
|
return mbtilesFile;
|
||||||
},
|
}
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
item.serve_rendered = false;
|
item.serve_rendered = false;
|
||||||
|
|
@ -186,7 +186,7 @@ export function server(opts) {
|
||||||
startupPromises.push(
|
startupPromises.push(
|
||||||
serve_font(options, serving.fonts).then((sub) => {
|
serve_font(options, serving.fonts).then((sub) => {
|
||||||
app.use('/', sub);
|
app.use('/', sub);
|
||||||
}),
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const id of Object.keys(data)) {
|
for (const id of Object.keys(data)) {
|
||||||
|
|
@ -197,7 +197,7 @@ export function server(opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
startupPromises.push(
|
startupPromises.push(
|
||||||
serve_data.add(options, serving.data, item, id, opts.publicUrl),
|
serve_data.add(options, serving.data, item, id, opts.publicUrl)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -211,7 +211,7 @@ export function server(opts) {
|
||||||
path.extname(file.name).toLowerCase() == '.json') {
|
path.extname(file.name).toLowerCase() == '.json') {
|
||||||
const id = path.basename(file.name, '.json');
|
const id = path.basename(file.name, '.json');
|
||||||
const item = {
|
const item = {
|
||||||
style: file.name,
|
style: file.name
|
||||||
};
|
};
|
||||||
addStyle(id, item, false, false);
|
addStyle(id, item, false, false);
|
||||||
}
|
}
|
||||||
|
|
@ -234,7 +234,7 @@ export function server(opts) {
|
||||||
|
|
||||||
if (eventType == 'add' || eventType == 'change') {
|
if (eventType == 'add' || eventType == 'change') {
|
||||||
const item = {
|
const item = {
|
||||||
style: filename,
|
style: filename
|
||||||
};
|
};
|
||||||
addStyle(id, item, false, false);
|
addStyle(id, item, false, false);
|
||||||
}
|
}
|
||||||
|
|
@ -251,7 +251,7 @@ export function server(opts) {
|
||||||
version: styleJSON.version,
|
version: styleJSON.version,
|
||||||
name: styleJSON.name,
|
name: styleJSON.name,
|
||||||
id: id,
|
id: id,
|
||||||
url: `${getPublicUrl(opts.publicUrl, req)}styles/${id}/style.json${query}`,
|
url: `${getPublicUrl(opts.publicUrl, req)}styles/${id}/style.json${query}`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
res.send(result);
|
res.send(result);
|
||||||
|
|
@ -267,7 +267,7 @@ export function server(opts) {
|
||||||
path = `${type}/${id}`;
|
path = `${type}/${id}`;
|
||||||
}
|
}
|
||||||
info.tiles = getTileUrls(req, info.tiles, path, info.format, opts.publicUrl, {
|
info.tiles = getTileUrls(req, info.tiles, path, info.format, opts.publicUrl, {
|
||||||
'pbf': options.pbfAlias,
|
'pbf': options.pbfAlias
|
||||||
});
|
});
|
||||||
arr.push(info);
|
arr.push(info);
|
||||||
}
|
}
|
||||||
|
|
@ -368,7 +368,7 @@ export function server(opts) {
|
||||||
|
|
||||||
data_.xyz_link = getTileUrls(
|
data_.xyz_link = getTileUrls(
|
||||||
req, tilejson.tiles, `data/${id}`, tilejson.format, opts.publicUrl, {
|
req, tilejson.tiles, `data/${id}`, tilejson.format, opts.publicUrl, {
|
||||||
'pbf': options.pbfAlias,
|
'pbf': options.pbfAlias
|
||||||
})[0];
|
})[0];
|
||||||
}
|
}
|
||||||
if (data_.filesize) {
|
if (data_.filesize) {
|
||||||
|
|
@ -387,7 +387,7 @@ export function server(opts) {
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
styles: Object.keys(styles).length ? styles : null,
|
styles: Object.keys(styles).length ? styles : null,
|
||||||
data: Object.keys(data).length ? data : null,
|
data: Object.keys(data).length ? data : null
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -462,7 +462,7 @@ export function server(opts) {
|
||||||
return {
|
return {
|
||||||
app: app,
|
app: app,
|
||||||
server: server,
|
server: server,
|
||||||
startupPromise: startupPromise,
|
startupPromise: startupPromise
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,8 +70,8 @@ export const fixTileJSONCenter = (tileJSON) => {
|
||||||
(tileJSON.bounds[1] + tileJSON.bounds[3]) / 2,
|
(tileJSON.bounds[1] + tileJSON.bounds[3]) / 2,
|
||||||
Math.round(
|
Math.round(
|
||||||
-Math.log((tileJSON.bounds[2] - tileJSON.bounds[0]) / 360 / tiles) /
|
-Math.log((tileJSON.bounds[2] - tileJSON.bounds[0]) / 360 / tiles) /
|
||||||
Math.LN2,
|
Math.LN2
|
||||||
),
|
)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -121,7 +121,7 @@ export const getFontsPbf = (allowedFonts, fontPath, names, range, fallbacks) =>
|
||||||
const queue = [];
|
const queue = [];
|
||||||
for (const font of fonts) {
|
for (const font of fonts) {
|
||||||
queue.push(
|
queue.push(
|
||||||
getFontPbf(allowedFonts, fontPath, font, range, clone(allowedFonts || fallbacks)),
|
getFontPbf(allowedFonts, fontPath, font, range, clone(allowedFonts || fallbacks))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ before(function() {
|
||||||
const running = server({
|
const running = server({
|
||||||
configPath: 'config.json',
|
configPath: 'config.json',
|
||||||
port: 8888,
|
port: 8888,
|
||||||
publicUrl: '/test/',
|
publicUrl: '/test/'
|
||||||
});
|
});
|
||||||
global.app = running.app;
|
global.app = running.app;
|
||||||
global.server = running.server;
|
global.server = running.server;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue