mirror of
https://github.com/rastapasta/mapscii.git
synced 2024-11-28 19:13:42 +01:00
👷 making mbtiles library optional (install via npm install -g mbtiles)
This commit is contained in:
parent
ac1494636a
commit
a21d172a2c
@ -32,7 +32,6 @@
|
|||||||
"earcut": "^2.1.1",
|
"earcut": "^2.1.1",
|
||||||
"gl-matrix": "^2.3.2",
|
"gl-matrix": "^2.3.2",
|
||||||
"keypress": "^0.2.1",
|
"keypress": "^0.2.1",
|
||||||
"mbtiles": "^0.9.0",
|
|
||||||
"pbf": "^3.0.0",
|
"pbf": "^3.0.0",
|
||||||
"rbush": "^2.0.1",
|
"rbush": "^2.0.1",
|
||||||
"request": "^2.76.0",
|
"request": "^2.76.0",
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
###
|
###
|
||||||
|
|
||||||
Promise = require 'bluebird'
|
Promise = require 'bluebird'
|
||||||
MBTiles = require 'mbtiles'
|
|
||||||
userhome = require 'userhome'
|
userhome = require 'userhome'
|
||||||
request = require 'request'
|
request = require 'request'
|
||||||
rp = require 'request-promise'
|
rp = require 'request-promise'
|
||||||
@ -16,6 +15,14 @@ fs = require 'fs'
|
|||||||
|
|
||||||
Tile = require './Tile'
|
Tile = require './Tile'
|
||||||
|
|
||||||
|
# https://github.com/mapbox/node-mbtiles has native build dependencies (sqlite3)
|
||||||
|
# To maximize mapscii's compatibility, MBTiles support must be manually added via
|
||||||
|
# $> npm install -g mbtiles
|
||||||
|
MBTiles = try
|
||||||
|
require 'mbtiles'
|
||||||
|
catch
|
||||||
|
null
|
||||||
|
|
||||||
module.exports = class TileSource
|
module.exports = class TileSource
|
||||||
config:
|
config:
|
||||||
persistDownloadedTiles: true
|
persistDownloadedTiles: true
|
||||||
@ -37,6 +44,9 @@ module.exports = class TileSource
|
|||||||
@mode = @modes.HTTP
|
@mode = @modes.HTTP
|
||||||
|
|
||||||
else if @source.endsWith ".mbtiles"
|
else if @source.endsWith ".mbtiles"
|
||||||
|
unless MBTiles
|
||||||
|
throw new Error "MBTiles support must be installed with following command: 'npm install -g mbtiles'"
|
||||||
|
|
||||||
@mode = @modes.MBTiles
|
@mode = @modes.MBTiles
|
||||||
@loadMBtils source
|
@loadMBtils source
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user