mirror of
https://github.com/rastapasta/mapscii.git
synced 2024-11-25 01:23:58 +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",
|
||||
"gl-matrix": "^2.3.2",
|
||||
"keypress": "^0.2.1",
|
||||
"mbtiles": "^0.9.0",
|
||||
"pbf": "^3.0.0",
|
||||
"rbush": "^2.0.1",
|
||||
"request": "^2.76.0",
|
||||
|
@ -8,7 +8,6 @@
|
||||
###
|
||||
|
||||
Promise = require 'bluebird'
|
||||
MBTiles = require 'mbtiles'
|
||||
userhome = require 'userhome'
|
||||
request = require 'request'
|
||||
rp = require 'request-promise'
|
||||
@ -16,6 +15,14 @@ fs = require 'fs'
|
||||
|
||||
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
|
||||
config:
|
||||
persistDownloadedTiles: true
|
||||
@ -37,6 +44,9 @@ module.exports = class TileSource
|
||||
@mode = @modes.HTTP
|
||||
|
||||
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
|
||||
@loadMBtils source
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user