mirror of
https://github.com/rastapasta/mapscii.git
synced 2024-11-07 08:44:14 +01:00
Remove bluebird (#94)
This commit is contained in:
parent
a7e7621705
commit
247122f684
@ -91,7 +91,6 @@ If your terminal supports mouse events you can drag the map and use your scroll
|
||||
* [`simplify-js`](https://github.com/mourner/simplify-js) for polyline simplifications
|
||||
|
||||
#### Handling the flow
|
||||
* [`bluebird`](https://github.com/petkaantonov/bluebird) for all the asynchronous [Promise](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Promise) magic
|
||||
* [`node-fetch`](https://github.com/bitinn/node-fetch) for HTTP requests
|
||||
* [`env-paths`](https://github.com/sindresorhus/env-paths) to determine where to persist downloaded tiles
|
||||
|
||||
|
5
package-lock.json
generated
5
package-lock.json
generated
@ -1107,11 +1107,6 @@
|
||||
"tweetnacl": "^0.14.3"
|
||||
}
|
||||
},
|
||||
"bluebird": {
|
||||
"version": "3.7.2",
|
||||
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
|
||||
"integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg=="
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
|
@ -31,7 +31,6 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@mapbox/vector-tile": "^1.3.1",
|
||||
"bluebird": "^3.7.2",
|
||||
"bresenham": "0.0.4",
|
||||
"earcut": "^2.2.2",
|
||||
"env-paths": "^2.2.0",
|
||||
|
@ -5,7 +5,6 @@
|
||||
The Console Vector Tile renderer - bäm!
|
||||
*/
|
||||
'use strict';
|
||||
const Promise = require('bluebird');
|
||||
const x256 = require('x256');
|
||||
const simplify = require('simplify-js');
|
||||
|
||||
@ -30,7 +29,7 @@ class Renderer {
|
||||
this.canvas = new Canvas(width, height);
|
||||
}
|
||||
|
||||
draw(center, zoom) {
|
||||
async draw(center, zoom) {
|
||||
if (this.isDrawing) return Promise.reject();
|
||||
this.isDrawing = true;
|
||||
|
||||
@ -49,21 +48,20 @@ class Renderer {
|
||||
|
||||
this.canvas.clear();
|
||||
|
||||
return Promise.resolve(this._visibleTiles(center, zoom)).map((tile) => {
|
||||
return this._getTile(tile);
|
||||
}).map((tile) => {
|
||||
return this._getTileFeatures(tile, zoom);
|
||||
}).then((tiles) => {
|
||||
this._renderTiles(tiles);
|
||||
}).then(() => {
|
||||
try {
|
||||
let tiles = this._visibleTiles(center, zoom);
|
||||
await Promise.all(tiles.map(async(tile) => {
|
||||
await this._getTile(tile);
|
||||
this._getTileFeatures(tile, zoom);
|
||||
}));
|
||||
await this._renderTiles(tiles);
|
||||
return this._getFrame();
|
||||
}).catch((e) => {
|
||||
return console.log(e);
|
||||
}).finally((frame) => {
|
||||
} catch(e) {
|
||||
console.error(e);
|
||||
} finally {
|
||||
this.isDrawing = false;
|
||||
this.lastDrawAt = Date.now();
|
||||
return frame;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
_visibleTiles(center, zoom) {
|
||||
@ -104,13 +102,9 @@ class Renderer {
|
||||
return tiles;
|
||||
}
|
||||
|
||||
_getTile(tile) {
|
||||
return this.tileSource
|
||||
.getTile(tile.xyz.z, tile.xyz.x, tile.xyz.y)
|
||||
.then((data) => {
|
||||
tile.data = data;
|
||||
return tile;
|
||||
});
|
||||
async _getTile(tile) {
|
||||
tile.data = await this.tileSource.getTile(tile.xyz.z, tile.xyz.x, tile.xyz.y);
|
||||
return tile;
|
||||
}
|
||||
|
||||
_getTileFeatures(tile, zoom) {
|
||||
@ -140,6 +134,7 @@ class Renderer {
|
||||
|
||||
_renderTiles(tiles) {
|
||||
const labels = [];
|
||||
if (tiles.length === 0) return;
|
||||
|
||||
const drawOrder = this._generateDrawOrder(tiles[0].xyz.z);
|
||||
for (const layerId of drawOrder) {
|
||||
|
Loading…
Reference in New Issue
Block a user