TileServer » History » Version 20
Philippe May, 13/10/2018 16:40
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. Configuration |
61 | 1 | Philippe May | |
62 | 17 | Philippe May | h3. Tamil Nadu: |
63 | 1 | Philippe May | |
64 | 17 | Philippe May | @/etc/tileserver/config-tn.json@: |
65 | 17 | Philippe May | |
66 | 1 | Philippe May | <pre> |
67 | 1 | Philippe May | { |
68 | 1 | Philippe May | "options": { |
69 | 1 | Philippe May | "paths": { |
70 | 1 | Philippe May | "root": "", |
71 | 1 | 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" |
72 | 1 | Philippe May | }, |
73 | 1 | Philippe May | "domains": [ |
74 | 20 | Philippe May | "gis.auroville.org.in/tiles" |
75 | 1 | Philippe May | ], |
76 | 1 | Philippe May | "styles": {} |
77 | 1 | Philippe May | }, |
78 | 1 | Philippe May | "data": { |
79 | 1 | Philippe May | "india-vector": { |
80 | 1 | Philippe May | "mbtiles": "/usr/local/asia_india_tn.mbtiles" |
81 | 1 | Philippe May | } |
82 | 1 | Philippe May | } |
83 | 1 | Philippe May | } |
84 | 1 | Philippe May | </pre> |
85 | 1 | Philippe May | |
86 | 17 | Philippe May | |
87 | 18 | Philippe May | h3. All India |
88 | 18 | Philippe May | |
89 | 18 | Philippe May | @/etc/tileserver/config.json@: |
90 | 17 | Philippe May | |
91 | 17 | Philippe May | <pre> |
92 | 17 | Philippe May | { |
93 | 17 | Philippe May | "options": { |
94 | 17 | Philippe May | "paths": { |
95 | 17 | Philippe May | "root": "", |
96 | 17 | 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" |
97 | 17 | Philippe May | }, |
98 | 17 | Philippe May | "domains": [ |
99 | 20 | Philippe May | "gis.auroville.org.in/tiles" |
100 | 17 | Philippe May | ], |
101 | 17 | Philippe May | "styles": {} |
102 | 17 | Philippe May | }, |
103 | 17 | Philippe May | "data": { |
104 | 17 | Philippe May | "india-vector": { |
105 | 17 | Philippe May | "mbtiles": "/usr/local/asia_india.mbtiles" |
106 | 17 | Philippe May | } |
107 | 17 | Philippe May | } |
108 | 17 | Philippe May | } |
109 | 17 | Philippe May | </pre> |
110 | 16 | Philippe May | |
111 | 16 | Philippe May | h2. Service |
112 | 16 | Philippe May | |
113 | 16 | Philippe May | A systemd service configuration file, in @/etc/systemd/system/tileserver-gl-light.service@. Adjust according to the tileserver config @-c@ option. |
114 | 16 | Philippe May | |
115 | 16 | Philippe May | <pre> |
116 | 16 | Philippe May | [Service] |
117 | 19 | 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 --no-cors -c /etc/tileserver/config-tn.json |
118 | 16 | Philippe May | Restart=always |
119 | 16 | Philippe May | User=www-data |
120 | 16 | Philippe May | Group=www-data |
121 | 16 | Philippe May | Environment=NODE_ENV=production |
122 | 16 | Philippe May | |
123 | 16 | Philippe May | [Install] |
124 | 16 | Philippe May | WantedBy=multi-user.target |
125 | 16 | Philippe May | </pre> |
126 | 16 | Philippe May | |
127 | 1 | Philippe May | |
128 | 1 | Philippe May | h2. Run the service |
129 | 1 | Philippe May | |
130 | 1 | Philippe May | <pre> |
131 | 1 | Philippe May | systemctl enable --now tileserver-gl-light.service |
132 | 1 | Philippe May | </pre> |
133 | 1 | Philippe May | |
134 | 1 | Philippe May | h4. nginx proxy |
135 | 1 | Philippe May | |
136 | 1 | Philippe May | In order the mbtiles to be served by tileserver, add in the nginx conf (adjust eventually): |
137 | 1 | Philippe May | |
138 | 1 | Philippe May | <pre> |
139 | 1 | Philippe May | location /tiles/ { |
140 | 1 | Philippe May | proxy_pass http://127.0.0.1:8080/; |
141 | 1 | Philippe May | } |
142 | 1 | Philippe May | </pre> |