TileServer¶
For updates, see also: #6907
TileServer-gl is a small node application that can serve vector tiles (mbtiles) for mapbox without the need for an external provider.
The maps Gisaf base layers (the definition file being located in gisaf-app/src/app/map/base_styles.ts
) in can be parametered such that a base layer is hosted locally (see the gisaf config file).
Install tileserver-gl-light¶
Unfortunately, it requires a much older version of node (6.x).
Install node V6:¶
cd /usr/local curl -O https://nodejs.org/download/release/v6.14.4/node-v6.14.4-linux-x64.tar.xz tar xf node-v6.14.4-linux-x64.tar.xz
Install TileServer¶
export PATH=/usr/local/node-v6.14.4-linux-x64/bin:$PATH npm install -g tileserver-gl-light
Download the mbtiles¶
From openmaptiles (outdated versions only)¶
From: https://openmaptiles.com/downloads/planet/ , and store the relevant one on the server's filesystem (eg. /usr/local/2017-07-03_asia_india.mbtiles
)
Directly from osm (regular updates data from OSM)¶
Prerequisite: gdal version 2.3.2 (Not available on Debian Stretch: use Buster)
apt install gdal-bin
Download and convert to MBTiles:
All India:
cd /usr/local curl -O http://download.geofabrik.de/asia/india-latest.osm.bz2 tar xvf india-latest.osm.bz2 ogr2ogr -s_srs EPSG:4326 -t_srs EPSG:3857 -a_srs EPSG:3857 -f MBTILES asia_india.mbtiles india-latest.osm.pbf -dsco MAXZOOM=14
Tamil Nadu:
cd /usr/local curl -O http://download.openstreetmap.fr/extracts/asia/india/tamil_nadu.osm.pbf ogr2ogr -s_srs EPSG:4326 -t_srs EPSG:3857 -a_srs EPSG:3857 -f MBTILES asia_india_tn.mbtiles tamil_nadu.osm.pbf -dsco MAXZOOM=14
Configuration¶
Tamil Nadu:¶
/etc/tileserver/config-tn.json
:
{ "options": { "paths": { "root": "", "sprites": "/usr/local/node-v6.14.4-linux-x64/lib/node_modules/tileserver-gl-light/node_modules/tileserver-gl-styles/styles/osm-bright" }, "domains": [ "gis.auroville.org.in/tiles" ], "styles": {} }, "data": { "india-vector": { "mbtiles": "/usr/local/asia_india_tn.mbtiles" } } }
All India¶
/etc/tileserver/config.json
:
{ "options": { "paths": { "root": "", "sprites": "/usr/local/node-v6.14.4-linux-x64/lib/node_modules/tileserver-gl-light/node_modules/tileserver-gl-styles/styles/osm-bright" }, "domains": [ "gis.auroville.org.in/tiles" ], "styles": {} }, "data": { "india-vector": { "mbtiles": "/usr/local/asia_india.mbtiles" } } }
Service¶
A systemd service configuration file, in /etc/systemd/system/tileserver-gl-light.service
. Adjust according to the tileserver config -c
option.
[Service] ExecStart=/usr/local/node-v6.14.4-linux-x64/bin/node /usr/local/node-v6.14.4-linux-x64/lib/node_modules/tileserver-gl-light/src/main.js --no-cors -c /etc/tileserver/config-tn.json Restart=always User=www-data Group=www-data Environment=NODE_ENV=production [Install] WantedBy=multi-user.target
Run the service¶
systemctl enable --now tileserver-gl-light.service
nginx proxy¶
In order the mbtiles to be served by tileserver, add in the nginx conf (adjust eventually):
location /tiles/ { proxy_pass http://127.0.0.1:8080/; }