From 2362137667dbcfeb89c4605a6f1b07b9f83846ec Mon Sep 17 00:00:00 2001 From: acalcutt Date: Wed, 14 Sep 2022 21:28:32 -0400 Subject: [PATCH 1/6] update commander --- package.json | 2 +- src/main.js | 122 ++++++++++++++++++++++++++------------------------- 2 files changed, 63 insertions(+), 61 deletions(-) diff --git a/package.json b/package.json index 6de09b1..60c4795 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "chokidar": "3.3.1", "clone": "2.1.2", "color": "3.1.2", - "commander": "4.1.1", + "commander": "9.4.0", "cors": "2.8.5", "esm": "3.2.25", "express": "4.17.1", diff --git a/src/main.js b/src/main.js index 2fb3723..ef44a3f 100644 --- a/src/main.js +++ b/src/main.js @@ -17,76 +17,78 @@ if (args.length >= 3 && args[2][0] !== '-') { args.splice(2, 0, '--mbtiles'); } -const opts = require('commander') - .description('tileserver-gl startup options') - .usage('tileserver-gl [mbtiles] [options]') - .option( - '--mbtiles ', - 'MBTiles file (uses demo configuration);\n' + - '\t ignored if the configuration file is also specified' - ) - .option( - '-c, --config ', - 'Configuration file [config.json]', - 'config.json' - ) - .option( - '-b, --bind
', - 'Bind address' - ) - .option( - '-p, --port ', - 'Port [8080]', - 8080, - parseInt - ) - .option( - '-C|--no-cors', - 'Disable Cross-origin resource sharing headers' - ) - .option( - '-u|--public_url ', - 'Enable exposing the server on subpaths, not necessarily the root of the domain' - ) - .option( - '-V, --verbose', - 'More verbose output' - ) - .option( - '-s, --silent', - 'Less verbose output' - ) - .option( - '-l|--log_file ', - 'output log file (defaults to standard out)' - ) - .option( - '-f|--log_format ', - 'define the log format: https://github.com/expressjs/morgan#morganformat-options' - ) - .version( - packageJson.version, - '-v, --version' - ) - .parse(args); +const { program } = require('commander'); +program + .description('tileserver-gl startup options') + .usage('tileserver-gl [mbtiles] [options]') + .option( + '--mbtiles ', + 'MBTiles file (uses demo configuration);\n' + + '\t ignored if the configuration file is also specified', + ) + .option( + '-c, --config ', + 'Configuration file [config.json]', + 'config.json', + ) + .option( + '-b, --bind
', + 'Bind address', + ) + .option( + '-p, --port ', + 'Port [8080]', + 8080, + parseInt, + ) + .option( + '-C|--no-cors', + 'Disable Cross-origin resource sharing headers', + ) + .option( + '-u|--public_url ', + 'Enable exposing the server on subpaths, not necessarily the root of the domain', + ) + .option( + '-V, --verbose', + 'More verbose output', + ) + .option( + '-s, --silent', + 'Less verbose output', + ) + .option( + '-l|--log_file ', + 'output log file (defaults to standard out)', + ) + .option( + '-f|--log_format ', + 'define the log format: https://github.com/expressjs/morgan#morganformat-options', + ) + .version( + packageJson.version, + '-v, --version', + ); +program.parse(process.argv); +const options = program.opts(); console.log(`Starting ${packageJson.name} v${packageJson.version}`); const startServer = (configPath, config) => { - let publicUrl = opts.public_url; + let publicUrl = options.public_url; if (publicUrl && publicUrl.lastIndexOf('/') !== publicUrl.length - 1) { publicUrl += '/'; } return require('./server')({ configPath: configPath, config: config, - bind: opts.bind, - port: opts.port, - cors: opts.cors, - verbose: opts.verbose, - silent: opts.silent, - logFile: opts.log_file, - logFormat: opts.log_format, + bind: options.bind, + port: options.port, + cors: options.cors, + verbose: options.verbose, + silent: options.silent, + logFile: options.log_file, + logFormat: options.log_format, publicUrl: publicUrl }); }; From b87a256e205dceb9c4ff5edaaeb6f49fa4efea61 Mon Sep 17 00:00:00 2001 From: acalcutt Date: Wed, 14 Sep 2022 21:31:02 -0400 Subject: [PATCH 2/6] use original variable name --- src/main.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main.js b/src/main.js index ef44a3f..4440dea 100644 --- a/src/main.js +++ b/src/main.js @@ -70,25 +70,25 @@ program '-v, --version', ); program.parse(process.argv); -const options = program.opts(); +const opts = program.opts(); console.log(`Starting ${packageJson.name} v${packageJson.version}`); const startServer = (configPath, config) => { - let publicUrl = options.public_url; + let publicUrl = opts.public_url; if (publicUrl && publicUrl.lastIndexOf('/') !== publicUrl.length - 1) { publicUrl += '/'; } return require('./server')({ configPath: configPath, config: config, - bind: options.bind, - port: options.port, - cors: options.cors, - verbose: options.verbose, - silent: options.silent, - logFile: options.log_file, - logFormat: options.log_format, + bind: opts.bind, + port: opts.port, + cors: opts.cors, + verbose: opts.verbose, + silent: opts.silent, + logFile: opts.log_file, + logFormat: opts.log_format, publicUrl: publicUrl }); }; From b4cd42b1865373bb0713daa35fb2030f81099dba Mon Sep 17 00:00:00 2001 From: acalcutt Date: Wed, 14 Sep 2022 21:36:03 -0400 Subject: [PATCH 3/6] fix spacing --- src/main.js | 100 ++++++++++++++++++++++++++-------------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/src/main.js b/src/main.js index 4440dea..a27e962 100644 --- a/src/main.js +++ b/src/main.js @@ -19,56 +19,56 @@ if (args.length >= 3 && args[2][0] !== '-') { const { program } = require('commander'); program - .description('tileserver-gl startup options') - .usage('tileserver-gl [mbtiles] [options]') - .option( - '--mbtiles ', - 'MBTiles file (uses demo configuration);\n' + - '\t ignored if the configuration file is also specified', - ) - .option( - '-c, --config ', - 'Configuration file [config.json]', - 'config.json', - ) - .option( - '-b, --bind
', - 'Bind address', - ) - .option( - '-p, --port ', - 'Port [8080]', - 8080, - parseInt, - ) - .option( - '-C|--no-cors', - 'Disable Cross-origin resource sharing headers', - ) - .option( - '-u|--public_url ', - 'Enable exposing the server on subpaths, not necessarily the root of the domain', - ) - .option( - '-V, --verbose', - 'More verbose output', - ) - .option( - '-s, --silent', - 'Less verbose output', - ) - .option( - '-l|--log_file ', - 'output log file (defaults to standard out)', - ) - .option( - '-f|--log_format ', - 'define the log format: https://github.com/expressjs/morgan#morganformat-options', - ) - .version( - packageJson.version, - '-v, --version', - ); + .description('tileserver-gl startup options') + .usage('tileserver-gl [mbtiles] [options]') + .option( + '--mbtiles ', + 'MBTiles file (uses demo configuration);\n' + + '\t ignored if the configuration file is also specified', + ) + .option( + '-c, --config ', + 'Configuration file [config.json]', + 'config.json', + ) + .option( + '-b, --bind
', + 'Bind address', + ) + .option( + '-p, --port ', + 'Port [8080]', + 8080, + parseInt, + ) + .option( + '-C|--no-cors', + 'Disable Cross-origin resource sharing headers', + ) + .option( + '-u|--public_url ', + 'Enable exposing the server on subpaths, not necessarily the root of the domain', + ) + .option( + '-V, --verbose', + 'More verbose output', + ) + .option( + '-s, --silent', + 'Less verbose output', + ) + .option( + '-l|--log_file ', + 'output log file (defaults to standard out)', + ) + .option( + '-f|--log_format ', + 'define the log format: https://github.com/expressjs/morgan#morganformat-options', + ) + .version( + packageJson.version, + '-v, --version', + ); program.parse(process.argv); const opts = program.opts(); From efb4b2c915b0c2d2b51d64bc2d87b4213ecb9091 Mon Sep 17 00:00:00 2001 From: acalcutt Date: Wed, 14 Sep 2022 21:39:35 -0400 Subject: [PATCH 4/6] orig formatting --- src/main.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main.js b/src/main.js index a27e962..c9725a2 100644 --- a/src/main.js +++ b/src/main.js @@ -24,51 +24,51 @@ program .option( '--mbtiles ', 'MBTiles file (uses demo configuration);\n' + - '\t ignored if the configuration file is also specified', + '\t ignored if the configuration file is also specified' ) .option( '-c, --config ', 'Configuration file [config.json]', - 'config.json', + 'config.json' ) .option( '-b, --bind
', - 'Bind address', + 'Bind address' ) .option( '-p, --port ', 'Port [8080]', 8080, - parseInt, + parseInt ) .option( '-C|--no-cors', - 'Disable Cross-origin resource sharing headers', + 'Disable Cross-origin resource sharing headers' ) .option( '-u|--public_url ', - 'Enable exposing the server on subpaths, not necessarily the root of the domain', + 'Enable exposing the server on subpaths, not necessarily the root of the domain' ) .option( '-V, --verbose', - 'More verbose output', + 'More verbose output' ) .option( '-s, --silent', - 'Less verbose output', + 'Less verbose output' ) .option( '-l|--log_file ', - 'output log file (defaults to standard out)', + 'output log file (defaults to standard out)' ) .option( '-f|--log_format ', - 'define the log format: https://github.com/expressjs/morgan#morganformat-options', + 'define the log format: https://github.com/expressjs/morgan#morganformat-options' ) .version( packageJson.version, - '-v, --version', - ); + '-v, --version' + ) program.parse(process.argv); const opts = program.opts(); From 70acddb40cf49a4bfa9e3b91ec4c32c2a9dda73a Mon Sep 17 00:00:00 2001 From: Andrew Calcutt Date: Wed, 21 Sep 2022 23:03:22 -0400 Subject: [PATCH 5/6] Readme update (#611) * Update README.md --- README.md | 65 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index d2f95a4..971250a 100644 --- a/README.md +++ b/README.md @@ -5,43 +5,79 @@ [![Build Status](https://travis-ci.org/maptiler/tileserver-gl.svg?branch=master)](https://travis-ci.org/maptiler/tileserver-gl) [![Docker Hub](https://img.shields.io/badge/docker-hub-blue.svg)](https://hub.docker.com/r/maptiler/tileserver-gl/) -Vector and raster maps with GL styles. Server-side rendering by Mapbox GL Native. Map tile server for MapLibre GL JS, Android, iOS, Leaflet, OpenLayers, GIS via WMTS, etc. +Vector and raster maps with GL styles. Server-side rendering by MapLibre GL Native. Map tile server for MapLibre GL JS, Android, iOS, Leaflet, OpenLayers, GIS via WMTS, etc. -## Get Started +Download vector tiles from [OpenMapTiles](https://data.maptiler.com/downloads/planet/). +## Getting Started with Node -Make sure you have Node.js version **10** installed (running `node -v` it should output something like `v10.17.0`). +Make sure you have Node.js version **14.20.0** or above installed. Node 16 is recommended. (running `node -v` it should output something like `v16.x.x`). Running without docker requires [Native dependencies](https://tileserver.readthedocs.io/en/latest/installation.html#npm) to be installed first. -Install `tileserver-gl` with server-side raster rendering of vector tiles with npm +Install `tileserver-gl` with server-side raster rendering of vector tiles with npm. ```bash npm install -g tileserver-gl ``` -Now download vector tiles from [OpenMapTiles](https://data.maptiler.com/downloads/planet/). +Once installed, you can use it like the following examples. +using a mbtiles file ```bash -curl -o zurich_switzerland.mbtiles https://[GET-YOUR-LINK]/extracts/zurich_switzerland.mbtiles +wget https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/zurich_switzerland.mbtiles +tileserver-gl --mbtiles zurich_switzerland.mbtiles +[in your browser, visit http://[server ip]:8080] ``` -Start `tileserver-gl` with the downloaded vector tiles. - +using a config.json + style + mbtiles file ```bash -tileserver-gl zurich_switzerland.mbtiles +wget https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/test_data.zip +unzip test_data.zip +tileserver-gl +[in your browser, visit http://[server ip]:8080] ``` -Alternatively, you can use the `tileserver-gl-light` package instead, which is pure javascript (does not have any native dependencies) and can run anywhere, but does not contain rasterization on the server side made with MapBox GL Native. +Alternatively, you can use the `tileserver-gl-light` npm package instead, which is pure javascript, does not have any native dependencies, and can run anywhere, but does not contain rasterization on the server side made with Maplibre GL Native. -## Using Docker +## Getting Started with Docker -An alternative to npm to start the packed software easier is to install [Docker](https://www.docker.com/) on your computer and then run in the directory with the downloaded MBTiles the command: +An alternative to npm to start the packed software easier is to install [Docker](https://www.docker.com/) on your computer and then run from the tileserver-gl directory +Example using a mbtiles file ```bash +wget https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/zurich_switzerland.mbtiles +docker run --rm -it -v $(pwd):/data -p 8080:80 maptiler/tileserver-gl --mbtiles zurich_switzerland.mbtiles +[in your browser, visit http://[server ip]:8080] +``` + +Example using a config.json + style + mbtiles file +```bash +wget https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/test_data.zip +unzip test_data.zip docker run --rm -it -v $(pwd):/data -p 8080:80 maptiler/tileserver-gl +[in your browser, visit http://[server ip]:8080] ``` -This will download and start a ready to use container on your computer and the maps are going to be available in webbrowser on localhost:8080. +Example using a different path +```bash +docker run --rm -it -v /your/local/config/path:/data -p 8080:80 maptiler/tileserver-gl +``` +replace '/your/local/config/path' with the path to your config file -On laptop, you can use [Docker Kitematic](https://kitematic.com/) and search "tileserver-gl" and run it, then drop in the 'data' folder the MBTiles. + +Alternatively, you can use the `maptiler/tileserver-gl-light` docker image instead, which is pure javascript, does not have any native dependencies, and can run anywhere, but does not contain rasterization on the server side made with Maplibre GL Native. + +## Getting Started with Linux cli + +Test from command line +```bash +wget https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/test_data.zip +unzip -q test_data.zip -d test_data +xvfb-run --server-args="-screen 0 1024x768x24" npm test +``` + +Run from command line +```bash +xvfb-run --server-args="-screen 0 1024x768x24" node . +``` ## Documentation @@ -50,3 +86,4 @@ You can read the full documentation of this project at https://tileserver.readth ## Alternative Discover MapTiler Server if you need a [map server with easy setup and user-friendly interface](https://www.maptiler.com/server/). + From 6a8ced5d9d28ee96c82d86f919d394fd074d8313 Mon Sep 17 00:00:00 2001 From: Andrew Calcutt Date: Wed, 21 Sep 2022 23:04:21 -0400 Subject: [PATCH 6/6] Update all packages to their latest release (#610) * Update all packages --- package.json | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 4f43b0e..6ac0768 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ }, "license": "BSD-2-Clause", "engines": { - "node": ">=10 <17" + "node": ">=14.15.0 <17" }, "scripts": { "test": "mocha test/**.js --timeout 10000", @@ -24,26 +24,26 @@ "@mapbox/sphericalmercator": "1.2.0", "@mapbox/vector-tile": "1.3.1", "advanced-pool": "0.3.3", - "canvas": "2.9.3", - "chokidar": "3.3.1", + "canvas": "2.10.1", + "chokidar": "3.5.3", "clone": "2.1.2", - "color": "3.1.2", + "color": "4.2.3", "commander": "9.4.0", "cors": "2.8.5", "esm": "3.2.25", - "express": "4.17.1", - "handlebars": "4.7.3", + "express": "4.18.1", + "handlebars": "4.7.7", "http-shutdown": "1.2.2", - "morgan": "1.9.1", + "morgan": "1.10.0", "pbf": "3.2.1", - "proj4": "2.6.0", + "proj4": "2.8.0", "request": "2.88.2", - "sharp": "0.26.2", + "sharp": "0.31.0", "tileserver-gl-styles": "2.0.0" }, "devDependencies": { - "mocha": "^7.1.0", + "mocha": "^10.0.0", "should": "^13.2.3", - "supertest": "^4.0.2" + "supertest": "^6.2.4" } }