fix: lint
Signed-off-by: Andrew Calcutt <acalcutt@techidiots.net>
This commit is contained in:
parent
371e757e5b
commit
08b3a943a6
2 changed files with 24 additions and 21 deletions
28
src/main.js
28
src/main.js
|
|
@ -117,7 +117,7 @@ const startWithInputFile = async (inputfile) => {
|
||||||
if (extension === 'pmtiles') {
|
if (extension === 'pmtiles') {
|
||||||
const info = await GetPMtilesInfo(inputfile);
|
const info = await GetPMtilesInfo(inputfile);
|
||||||
const metadata = info.metadata;
|
const metadata = info.metadata;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
metadata.format === 'pbf' &&
|
metadata.format === 'pbf' &&
|
||||||
metadata.name.toLowerCase().indexOf('openmaptiles') > -1
|
metadata.name.toLowerCase().indexOf('openmaptiles') > -1
|
||||||
|
|
@ -125,7 +125,7 @@ const startWithInputFile = async (inputfile) => {
|
||||||
config['data'][`v3`] = {
|
config['data'][`v3`] = {
|
||||||
mbtiles: path.basename(inputfile),
|
mbtiles: path.basename(inputfile),
|
||||||
};
|
};
|
||||||
|
|
||||||
const styles = fs.readdirSync(path.resolve(styleDir, 'styles'));
|
const styles = fs.readdirSync(path.resolve(styleDir, 'styles'));
|
||||||
for (const styleName of styles) {
|
for (const styleName of styles) {
|
||||||
const styleFileRel = styleName + '/style.json';
|
const styleFileRel = styleName + '/style.json';
|
||||||
|
|
@ -143,20 +143,17 @@ const startWithInputFile = async (inputfile) => {
|
||||||
console.log(
|
console.log(
|
||||||
`WARN: PMTiles not in "openmaptiles" format. Serving raw data only...`,
|
`WARN: PMTiles not in "openmaptiles" format. Serving raw data only...`,
|
||||||
);
|
);
|
||||||
config['data'][
|
config['data'][(metadata.id || 'mbtiles').replace(/[?/:]/g, '_')] = {
|
||||||
(metadata.id || 'mbtiles')
|
|
||||||
.replace(/[?/:]/g, '_')
|
|
||||||
] = {
|
|
||||||
mbtiles: path.basename(inputfile),
|
mbtiles: path.basename(inputfile),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts.verbose) {
|
if (opts.verbose) {
|
||||||
console.log(JSON.stringify(config, undefined, 2));
|
console.log(JSON.stringify(config, undefined, 2));
|
||||||
} else {
|
} else {
|
||||||
console.log('Run with --verbose to see the config file here.');
|
console.log('Run with --verbose to see the config file here.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return startServer(null, config);
|
return startServer(null, config);
|
||||||
} else {
|
} else {
|
||||||
const instance = new MBTiles(inputfile + '?mode=ro', (err) => {
|
const instance = new MBTiles(inputfile + '?mode=ro', (err) => {
|
||||||
|
|
@ -165,7 +162,7 @@ const startWithInputFile = async (inputfile) => {
|
||||||
console.log(`Make sure ${path.basename(inputfile)} is valid MBTiles.`);
|
console.log(`Make sure ${path.basename(inputfile)} is valid MBTiles.`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
instance.getInfo((err, info) => {
|
instance.getInfo((err, info) => {
|
||||||
if (err || !info) {
|
if (err || !info) {
|
||||||
console.log('ERROR: Metadata missing in the MBTiles.');
|
console.log('ERROR: Metadata missing in the MBTiles.');
|
||||||
|
|
@ -175,7 +172,7 @@ const startWithInputFile = async (inputfile) => {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
const bounds = info.bounds;
|
const bounds = info.bounds;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
info.format === 'pbf' &&
|
info.format === 'pbf' &&
|
||||||
info.name.toLowerCase().indexOf('openmaptiles') > -1
|
info.name.toLowerCase().indexOf('openmaptiles') > -1
|
||||||
|
|
@ -183,7 +180,7 @@ const startWithInputFile = async (inputfile) => {
|
||||||
config['data'][`v3`] = {
|
config['data'][`v3`] = {
|
||||||
mbtiles: path.basename(inputfile),
|
mbtiles: path.basename(inputfile),
|
||||||
};
|
};
|
||||||
|
|
||||||
const styles = fs.readdirSync(path.resolve(styleDir, 'styles'));
|
const styles = fs.readdirSync(path.resolve(styleDir, 'styles'));
|
||||||
for (const styleName of styles) {
|
for (const styleName of styles) {
|
||||||
const styleFileRel = styleName + '/style.json';
|
const styleFileRel = styleName + '/style.json';
|
||||||
|
|
@ -201,20 +198,17 @@ const startWithInputFile = async (inputfile) => {
|
||||||
console.log(
|
console.log(
|
||||||
`WARN: MBTiles not in "openmaptiles" format. Serving raw data only...`,
|
`WARN: MBTiles not in "openmaptiles" format. Serving raw data only...`,
|
||||||
);
|
);
|
||||||
config['data'][
|
config['data'][(info.id || 'mbtiles').replace(/[?/:]/g, '_')] = {
|
||||||
(info.id || 'mbtiles')
|
|
||||||
.replace(/[?/:]/g, '_')
|
|
||||||
] = {
|
|
||||||
mbtiles: path.basename(inputfile),
|
mbtiles: path.basename(inputfile),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts.verbose) {
|
if (opts.verbose) {
|
||||||
console.log(JSON.stringify(config, undefined, 2));
|
console.log(JSON.stringify(config, undefined, 2));
|
||||||
} else {
|
} else {
|
||||||
console.log('Run with --verbose to see the config file here.');
|
console.log('Run with --verbose to see the config file here.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return startServer(null, config);
|
return startServer(null, config);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1221,7 +1221,7 @@ export const serve_rendered = {
|
||||||
ratio: ratio,
|
ratio: ratio,
|
||||||
request: async (req, callback) => {
|
request: async (req, callback) => {
|
||||||
const protocol = req.url.split(':')[0];
|
const protocol = req.url.split(':')[0];
|
||||||
console.log('Handling request:', req);
|
console.log('Handling request:', req);
|
||||||
if (protocol === 'sprites') {
|
if (protocol === 'sprites') {
|
||||||
const dir = options.paths[protocol];
|
const dir = options.paths[protocol];
|
||||||
const file = unescape(req.url).substring(protocol.length + 3);
|
const file = unescape(req.url).substring(protocol.length + 3);
|
||||||
|
|
@ -1257,13 +1257,22 @@ export const serve_rendered = {
|
||||||
const y = parts[5].split('.')[0] | 0;
|
const y = parts[5].split('.')[0] | 0;
|
||||||
const format = parts[5].split('.')[1];
|
const format = parts[5].split('.')[1];
|
||||||
|
|
||||||
if (typeof map.sources[sourceId] === 'string' && map.sources[sourceId].split('.').pop().toLowerCase() === 'pmtiles') {
|
if (
|
||||||
let tileinfo = await GetPMtilesTile(map.sources[sourceId], z, x, y);
|
typeof map.sources[sourceId] === 'string' &&
|
||||||
|
map.sources[sourceId].split('.').pop().toLowerCase() ===
|
||||||
|
'pmtiles'
|
||||||
|
) {
|
||||||
|
let tileinfo = await GetPMtilesTile(
|
||||||
|
map.sources[sourceId],
|
||||||
|
z,
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
);
|
||||||
let data = tileinfo.data;
|
let data = tileinfo.data;
|
||||||
let headers = tileinfo.header;
|
let headers = tileinfo.header;
|
||||||
if (data == undefined) {
|
if (data == undefined) {
|
||||||
if (options.verbose)
|
if (options.verbose)
|
||||||
console.log('MBTiles error, serving empty', err);
|
console.log('MBTiles error, serving empty', err);
|
||||||
createEmptyResponse(
|
createEmptyResponse(
|
||||||
sourceInfo.format,
|
sourceInfo.format,
|
||||||
sourceInfo.color,
|
sourceInfo.color,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue