TileServer » History » Version 14
Philippe May, 13/10/2018 15:08
1 | 1 | Philippe May | h1. TileServer |
---|---|---|---|
2 | 1 | Philippe May | |
3 | 3 | Philippe May | > For updates, see also: #6907 |
4 | 1 | Philippe May | |
5 | 1 | Philippe May | "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. |
6 | 1 | Philippe May | |
7 | 1 | Philippe May | 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). |
8 | 1 | Philippe May | |
9 | 1 | Philippe May | h2. Install tileserver-gl-light |
10 | 1 | Philippe May | |
11 | 10 | Philippe May | Unfortunately, it requires a much older version of node (6.x). |
12 | 1 | Philippe May | |
13 | 10 | Philippe May | h3. Install node V6: |
14 | 10 | Philippe May | |
15 | 1 | Philippe May | <pre> |
16 | 10 | Philippe May | cd /usr/local |
17 | 10 | Philippe May | curl -O https://nodejs.org/download/release/v6.14.4/node-v6.14.4-linux-x64.tar.xz |
18 | 10 | Philippe May | tar xf node-v6.14.4-linux-x64.tar.xz |
19 | 10 | Philippe May | </pre> |
20 | 10 | Philippe May | |
21 | 10 | Philippe May | h3. Install TileServer |
22 | 10 | Philippe May | |
23 | 10 | Philippe May | <pre> |
24 | 10 | Philippe May | export PATH=/usr/local/node-v6.14.4-linux-x64/bin:$PATH |
25 | 2 | Philippe May | npm install -g tileserver-gl-light |
26 | 1 | Philippe May | </pre> |
27 | 1 | Philippe May | |
28 | 1 | Philippe May | |
29 | 1 | Philippe May | h2. Download the mbtiles |
30 | 1 | Philippe May | |
31 | 4 | Philippe May | h3. From openmaptiles (outdated versions only) |
32 | 3 | Philippe May | |
33 | 1 | Philippe May | 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@) |
34 | 1 | Philippe May | |
35 | 4 | Philippe May | h3. Directly from osm (updated) |
36 | 3 | Philippe May | |
37 | 9 | Philippe May | Prerequisite: gdal version 2.3.2 (Not available on Stretch: use Buster) |
38 | 8 | Philippe May | |
39 | 8 | Philippe May | <pre> |
40 | 8 | Philippe May | apt install gdal-bin |
41 | 8 | Philippe May | </pre> |
42 | 8 | Philippe May | |
43 | 1 | Philippe May | Download and convert to MBTiles: |
44 | 1 | Philippe May | |
45 | 10 | Philippe May | All India: |
46 | 10 | Philippe May | <pre> |
47 | 10 | Philippe May | cd /usr/local |
48 | 10 | Philippe May | curl -O http://download.geofabrik.de/asia/india-latest.osm.bz2 |
49 | 10 | Philippe May | tar xvf india-latest.osm.bz2 |
50 | 13 | Philippe May | 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 |
51 | 10 | Philippe May | </pre> |
52 | 10 | Philippe May | |
53 | 10 | Philippe May | Tamil Nadu: |
54 | 3 | Philippe May | <pre> |
55 | 3 | Philippe May | cd /usr/local |
56 | 3 | Philippe May | curl -O http://download.openstreetmap.fr/extracts/asia/india/tamil_nadu.osm.pbf |
57 | 7 | Philippe May | 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 |
58 | 3 | Philippe May | </pre> |
59 | 3 | Philippe May | |
60 | 1 | Philippe May | h2. Service |
61 | 1 | Philippe May | |
62 | 14 | Philippe May | A systemd service configuration file, in @/etc/systemd/system/tileserver-gl-light.service@. Adjust according to the tileserver config -@-c@ option. |
63 | 1 | Philippe May | |
64 | 1 | Philippe May | <pre> |
65 | 1 | Philippe May | [Service] |
66 | 12 | Philippe May | 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 |
67 | 1 | Philippe May | Restart=always |
68 | 1 | Philippe May | User=www-data |
69 | 1 | Philippe May | Group=www-data |
70 | 1 | Philippe May | Environment=NODE_ENV=production |
71 | 1 | Philippe May | |
72 | 1 | Philippe May | [Install] |
73 | 1 | Philippe May | WantedBy=multi-user.target |
74 | 1 | Philippe May | </pre> |
75 | 1 | Philippe May | |
76 | 1 | Philippe May | h2. Configuration |
77 | 1 | Philippe May | |
78 | 1 | Philippe May | Eg, in @/etc/tileserver/conf.json@: |
79 | 1 | Philippe May | |
80 | 1 | Philippe May | <pre> |
81 | 1 | Philippe May | { |
82 | 1 | Philippe May | "options": { |
83 | 1 | Philippe May | "paths": { |
84 | 1 | Philippe May | "root": "", |
85 | 12 | Philippe May | "sprites": "/usr/local/node-v6.14.4-linux-x64/lib/node_modules/tileserver-gl-light/node_modules/tileserver-gl-styles/styles/osm-bright" |
86 | 1 | Philippe May | }, |
87 | 1 | Philippe May | "domains": [ |
88 | 1 | Philippe May | "gis.auroville.org.in" |
89 | 1 | Philippe May | ], |
90 | 1 | Philippe May | "styles": {} |
91 | 1 | Philippe May | }, |
92 | 1 | Philippe May | "data": { |
93 | 1 | Philippe May | "india-vector": { |
94 | 3 | Philippe May | "mbtiles": "/usr/local/asia_india_tn.mbtiles" |
95 | 1 | Philippe May | } |
96 | 1 | Philippe May | } |
97 | 1 | Philippe May | } |
98 | 1 | Philippe May | </pre> |
99 | 1 | Philippe May | |
100 | 1 | Philippe May | h2. Run the service |
101 | 1 | Philippe May | |
102 | 1 | Philippe May | <pre> |
103 | 1 | Philippe May | systemctl enable --now tileserver-gl-light.service |
104 | 1 | Philippe May | </pre> |
105 | 1 | Philippe May | |
106 | 1 | Philippe May | h4. nginx proxy |
107 | 1 | Philippe May | |
108 | 1 | Philippe May | In order the mbtiles to be served by tileserver, add in the nginx conf (adjust eventually): |
109 | 1 | Philippe May | |
110 | 1 | Philippe May | <pre> |
111 | 1 | Philippe May | location /tiles/ { |
112 | 1 | Philippe May | proxy_pass http://127.0.0.1:8080/; |
113 | 1 | Philippe May | } |
114 | 1 | Philippe May | </pre> |