Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

mbtiles-server

DenisCarriere139MIT3.3.4TypeScript support: included

Provides a compatible WMTS Tile Server from MBTiles.

gis, geo, geojs, geospatial, geography, map, mbtiles, server

readme

MBTiles Server

Build Status Coverage Status npm version MIT licensed

Standard - JavaScript Style Guide

Provides a compatible WMTS Tile Server from MBTiles.

Install

$ npm install -g mbtiles-server

Quickstart

$ mbtiles-server --cache /Users/mac/mbtiles --verbose --port 3000
MBTiles Server Service

  cache:         /Users/mac/mbtiles
  protocol:      http
  port:          3000
  domain:        localhost
  verbose:       true

Benchmark

  • 1 Active User => 400 requests/min
  • 1 Passive User => 50 requests/min
Requests Response Time
1 33.460ms
10 45.223ms
100 374.217ms
1K 2.698s
10K 25.457s

Total 24,000 requests / min

Using mbtiles-server you could easily sustain 60 active users and up to 480 passive users. These tests were done on the server locally, network traffic and switches could slow down these results significantly.

CLI Help

For any additional help using the CLI, use the --help flag.

  Provides a compatible WMTS Tile Server from MBTiles.

  Usage
    $ mbtiles-server

  Options
    --cache           [~/mbtiles] Cache
    --protocol        [http] Protocol
    --port            [5000] Port
    --domain          [localhost] Domain
    --verbose         [false] Verbose output
    --sslkey          [~/mbtiles/server.key] Path to the file certification (.key). For https protocol only  
    --sslcert         [~/mbtiles/server.cert] Path to the file certification (.cert). For https protocol only

  Examples
    $ mbtiles-server --cache /Users/mac/mbtiles --port 5000 --verbose

Environment Variables

Environment variables can be defined instead of entering your options via the CLI.

  • MBTILES_SERVER_CACHE
  • MBTILES_SERVER_PROTOCOL
  • MBTILES_SERVER_PORT
  • MBTILES_SERVER_DOMAIN
  • MBTILES_SERVER_VERBOSE
  • MBTILES_SERVER_SSL_KEY
  • MBTILES_SERVER_SSL_CERT

Docker

A Dockerfile is provided for easy Docker deployment

$ docker build -t mbtiles-server .
$ docker run --rm -it \
  -p 5000:5000 \
  -v ~/mbtiles/:/root/mbtiles \
  mbtiles-server

Start containers automatically

https://docs.docker.com/engine/admin/host_integration/

$ docker run -d \
  --name mbtiles-server \
  -p 5000:5000 \
  -v ~/mbtiles/:/root/mbtiles \
  mbtiles-server

WMTS

The goal of providing a WMTS enabled service is to be performance oriented and scalable. Therefore, servers must be able to return tiles quickly. A good way to achieve that is to use locally stored pre-rendered tiles that will not require any image manipulation or geo-processing.

API

Server

Parameters

  • options [string] Server Options
    • options.cache [string] CACHE file path (optional, default ~/mbtiles)
    • options.domain [string] URL Domain (optional, default 'localhost')
    • options.port [string] URL Port (optional, default 5000)

Examples

server({cache: '/Users/mac/mbtiles', port: 5000, verbose: true})

changelog

Changelog

3.1.0 - 2017-07-26

  • Add watch files as an option
  • Server does not restart automatically if watch is not provided

3.0.0 - 2017-07-05

  • Update mbtiles-offline to version 3
  • Support lastest versions of Electron

2.3.0 - 2017-06-27

  • Add SQLite support for NodeJS 8
  • Update Dockerfile
  • Add environment variables to configuration
  • Add favicon to server

2.2.0 - 2017-06-15

  • Add Mercator Bounding Box WMTS
  • No need to restart server to access new MBTiles

2.1.0 - 2017-06-12

  • ~Enforce Strict WMTS GetCapabilities & GetTile rules for KVP requests~

2.0.0 - 2017-06-03

  • Add Docker instructions
  • Add Benchmark reults (1K requests => 2.5s)
  • Restart server if file changes
  • Refactored library to use EventEmitters
  • Dropped background service support in favor of Docker

1.11.0 - 2017-05-04

  • Refactored WMTS & MBTiles routes

1.10.0 - 2017-04-06

  • Change default domain to 127.0.0.1 (less chances of proxy errors vs. using localhost)

1.9.0 - 2017-03-30

  • Add config store conf
  • Update options start()

1.7.0 - 2017-02-13

  • Add options to windows service (start/stop/restart)
  • Add Docker build instructions

1.6.0 - 2017-02-10

  • Run background services for Windows/MacOS/Linux
  • Upgrade WMTS schema (ESRI wasn't compatible)

1.5.1 - 2017-02-06

  • Add Typescript definition
  • Upgrade mbtiles-offline

1.4.0 - 2017-02-01

  • Added KVP support for request Tile 1.0.0
  • Updated WMTS capabilites with extra metadata

1.3.0 - 2017-01-10

  • Major refactoring
  • Improve CLI using meow
  • Update dependencies (including mbtiles-offline)

1.2.0 - 2016-12-5

  • Add Metadata in utils
  • Replace dev dependencies to Jest

1.1.1 - 2016-11-03

  • Add default export for Typescript

1.1.0 - 2016-11-01

  • Add MBTiles Metadata route

1.0.1 - 2016-10-31

  • Add WMTS library
  • First functional release

0.1.0 - 2016-10-26

  • Project initialized