Project

General

Profile

TileServer » History » Version 15

Version 14 (Philippe May, 13/10/2018 15:08) → Version 15/22 (Philippe May, 13/10/2018 15:08)

h1. TileServer

> For updates, see also: #6907

"TileServer-gl":https://github.com/klokantech/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).

h2. Install tileserver-gl-light

Unfortunately, it requires a much older version of node (6.x).

h3. Install node V6:

<pre>
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
</pre>

h3. Install TileServer

<pre>
export PATH=/usr/local/node-v6.14.4-linux-x64/bin:$PATH
npm install -g tileserver-gl-light
</pre>

h2. Download the mbtiles

h3. 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@)

h3. Directly from osm (updated)

Prerequisite: gdal version 2.3.2 (Not available on Stretch: use Buster)

<pre>
apt install gdal-bin
</pre>

Download and convert to MBTiles:

All India:
<pre>
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
</pre>

Tamil Nadu:
<pre>
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
</pre>

h2. Service

A systemd service configuration file, in @/etc/systemd/system/tileserver-gl-light.service@. Adjust according to the tileserver config @-c@ -@-c@ option.

<pre>
[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 -c /etc/tileserver/config-tn.json
Restart=always
User=www-data
Group=www-data
Environment=NODE_ENV=production

[Install]
WantedBy=multi-user.target
</pre>

h2. Configuration

Eg, in @/etc/tileserver/conf.json@:

<pre>
{
"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"
],
"styles": {}
},
"data": {
"india-vector": {
"mbtiles": "/usr/local/asia_india_tn.mbtiles"
}
}
}
</pre>

h2. Run the service

<pre>
systemctl enable --now tileserver-gl-light.service
</pre>

h4. nginx proxy

In order the mbtiles to be served by tileserver, add in the nginx conf (adjust eventually):

<pre>
location /tiles/ {
proxy_pass http://127.0.0.1:8080/;
}
</pre>