mirror of
https://github.com/rastapasta/mapscii.git
synced 2024-11-21 15:43:08 +01:00
After ESLint in TileSource
This commit is contained in:
parent
1369140af4
commit
088b9a3b71
@ -20,11 +20,7 @@ const config = require('./config');
|
||||
let MBTiles = null;
|
||||
try {
|
||||
MBTiles = require('mbtiles');
|
||||
} catch (err) {}
|
||||
|
||||
const cache = {};
|
||||
const cacheSize = 16;
|
||||
const cached = [];
|
||||
} catch (err) {void 0;}
|
||||
|
||||
const modes = {
|
||||
MBTiles: 1,
|
||||
@ -53,13 +49,13 @@ class TileSource {
|
||||
|
||||
} else if (this.source.endsWith('.mbtiles')) {
|
||||
if (!MBTiles) {
|
||||
throw new Error("MBTiles support must be installed with following command: 'npm install -g mbtiles'");
|
||||
throw new Error('MBTiles support must be installed with following command: \'npm install -g mbtiles\'');
|
||||
}
|
||||
|
||||
this.mode = modes.MBTiles;
|
||||
this.loadMBtils(source);
|
||||
} else {
|
||||
throw new Error("source type isn't supported yet");
|
||||
throw new Error('source type isn\'t supported yet');
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,10 +77,10 @@ class TileSource {
|
||||
|
||||
getTile(z, x, y) {
|
||||
if (!this.mode) {
|
||||
throw new Error("no TileSource defined");
|
||||
throw new Error('no TileSource defined');
|
||||
}
|
||||
|
||||
const cached = this.cache[[z, x, y].join("-")];
|
||||
const cached = this.cache[[z, x, y].join('-')];
|
||||
if (cached) {
|
||||
return Promise.resolve(cached);
|
||||
}
|
||||
@ -111,13 +107,13 @@ class TileSource {
|
||||
promise = Promise.resolve(persistedTile);
|
||||
} else {
|
||||
promise = fetch(this.source + [z,x,y].join('/') + '.pbf')
|
||||
.then((res) => res.buffer())
|
||||
.then((buffer) => {
|
||||
if (config.persistDownloadedTiles) {
|
||||
this._persistTile(z, x, y, buffer);
|
||||
return buffer;
|
||||
}
|
||||
});
|
||||
.then((res) => res.buffer())
|
||||
.then((buffer) => {
|
||||
if (config.persistDownloadedTiles) {
|
||||
this._persistTile(z, x, y, buffer);
|
||||
return buffer;
|
||||
}
|
||||
});
|
||||
}
|
||||
return promise.then((buffer) => {
|
||||
return this._createTile(z, x, y, buffer);
|
||||
@ -172,7 +168,7 @@ class TileSource {
|
||||
fs.mkdirSync(path);
|
||||
return true;
|
||||
} catch (error) {
|
||||
return error.code === "EEXIST";
|
||||
return error.code === 'EEXIST';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user