TileServer » History » Version 2
Philippe May, 13/10/2018 12:17
1 | 1 | Philippe May | h1. TileServer |
---|---|---|---|
2 | 1 | Philippe May | |
3 | 1 | Philippe May | |
4 | 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. |
5 | 1 | Philippe May | |
6 | 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). |
7 | 1 | Philippe May | |
8 | 1 | Philippe May | h2. Install tileserver-gl-light |
9 | 1 | Philippe May | |
10 | 1 | Philippe May | Unfortunately, it requires a much older version of node (6.x). |
11 | 1 | Philippe May | |
12 | 1 | Philippe May | <pre> |
13 | 2 | Philippe May | export PATH=/usr/local/node-v6.14.3-linux-x64/bin:$PATH |
14 | 2 | Philippe May | npm install -g tileserver-gl-light |
15 | 1 | Philippe May | </pre> |
16 | 1 | Philippe May | |
17 | 1 | Philippe May | |
18 | 1 | Philippe May | h2. Download the mbtiles |
19 | 1 | Philippe May | |
20 | 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@) |
21 | 1 | Philippe May | |
22 | 1 | Philippe May | h2. Service |
23 | 1 | Philippe May | |
24 | 1 | Philippe May | A systemd service configuration file, in @/etc/systemd/system/tileserver-gl-light.service@: |
25 | 1 | Philippe May | |
26 | 1 | Philippe May | <pre> |
27 | 1 | Philippe May | [Service] |
28 | 1 | Philippe May | ExecStart=/usr/bin/node /usr/lib/node_modules/tileserver-gl-light/src/main.js --cors true -c /etc/tileserver/conf.json |
29 | 1 | Philippe May | Restart=always |
30 | 1 | Philippe May | User=www-data |
31 | 1 | Philippe May | Group=www-data |
32 | 1 | Philippe May | Environment=NODE_ENV=production |
33 | 1 | Philippe May | |
34 | 1 | Philippe May | [Install] |
35 | 1 | Philippe May | WantedBy=multi-user.target |
36 | 1 | Philippe May | </pre> |
37 | 1 | Philippe May | |
38 | 1 | Philippe May | h2. Configuration |
39 | 1 | Philippe May | |
40 | 1 | Philippe May | Eg, in @/etc/tileserver/conf.json@: |
41 | 1 | Philippe May | |
42 | 1 | Philippe May | <pre> |
43 | 1 | Philippe May | { |
44 | 1 | Philippe May | "options": { |
45 | 1 | Philippe May | "paths": { |
46 | 1 | Philippe May | "root": "", |
47 | 1 | Philippe May | "sprites": "/usr/lib/node_modules/tileserver-gl-light/node_modules/tileserver-gl-styles/styles/osm-bright" |
48 | 1 | Philippe May | }, |
49 | 1 | Philippe May | "domains": [ |
50 | 1 | Philippe May | "gis.auroville.org.in" |
51 | 1 | Philippe May | ], |
52 | 1 | Philippe May | "styles": {} |
53 | 1 | Philippe May | }, |
54 | 1 | Philippe May | "data": { |
55 | 1 | Philippe May | "india-vector": { |
56 | 1 | Philippe May | "mbtiles": "/usr/local/2017-07-03_asia_india.mbtiles" |
57 | 1 | Philippe May | } |
58 | 1 | Philippe May | } |
59 | 1 | Philippe May | } |
60 | 1 | Philippe May | </pre> |
61 | 1 | Philippe May | |
62 | 1 | Philippe May | h2. Run the service |
63 | 1 | Philippe May | |
64 | 1 | Philippe May | <pre> |
65 | 1 | Philippe May | systemctl enable --now tileserver-gl-light.service |
66 | 1 | Philippe May | </pre> |
67 | 1 | Philippe May | |
68 | 1 | Philippe May | h4. nginx proxy |
69 | 1 | Philippe May | |
70 | 1 | Philippe May | In order the mbtiles to be served by tileserver, add in the nginx conf (adjust eventually): |
71 | 1 | Philippe May | |
72 | 1 | Philippe May | <pre> |
73 | 1 | Philippe May | location /tiles/ { |
74 | 1 | Philippe May | proxy_pass http://127.0.0.1:8080/; |
75 | 1 | Philippe May | } |
76 | 1 | Philippe May | </pre> |