tileserver-gl-light 5.1.2 → 5.2.0-pre.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,3 +14,4 @@ jobs:
14
14
  - uses: fastify/github-action-merge-dependabot@v3
15
15
  with:
16
16
  github-token: ${{ secrets.GITHUB_TOKEN }}
17
+ target: minor
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # tileserver-gl changelog
2
2
 
3
+ ## 5.2.0-pre.0
4
+ * Use npm packages for public/resources (https://github.com/maptiler/tileserver-gl/pull/1427) by @okimiko
5
+ * use ttf files of googlefonts/opensans (https://github.com/maptiler/tileserver-gl/pull/1447) by @okimiko
6
+ * fix memory leak on SIGHUP (https://github.com/maptiler/tileserver-gl/pull/1455) by @okimiko
7
+ * Limit Elevation Lat/Long Output Length (https://github.com/maptiler/tileserver-gl/pull/1457) by @okimiko
8
+
9
+ ## 5.1.3
10
+ * Fix SIGHUP (broken since 5.1.x) (https://github.com/maptiler/tileserver-gl/pull/1452) by @okimiko
11
+
3
12
  ## 5.1.2
4
13
  * Fix broken light (invalid use of heavy dependencies) (https://github.com/maptiler/tileserver-gl/pull/1449) by @okimiko
5
14
 
package/Dockerfile CHANGED
@@ -5,49 +5,46 @@ ENV \
5
5
  CHOKIDAR_USEPOLLING=1 \
6
6
  CHOKIDAR_INTERVAL=500
7
7
 
8
- RUN set -ex; \
9
- export DEBIAN_FRONTEND=noninteractive; \
10
- groupadd -r node; \
11
- useradd -r -g node node; \
12
- apt-get -qq update; \
13
- apt-get -y --no-install-recommends install \
8
+ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
9
+
10
+ RUN export DEBIAN_FRONTEND=noninteractive && \
11
+ groupadd -r node && \
12
+ useradd -r -g node node && \
13
+ apt-get -qq update && \
14
+ apt-get install -y --no-install-recommends --no-install-suggests \
14
15
  ca-certificates \
15
16
  curl \
16
- gnupg; \
17
- mkdir -p /etc/apt/keyrings; \
18
- curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg; \
19
- echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list; \
20
- apt-get -qq update; \
21
- apt-get install -y nodejs; \
22
- npm i -g npm@latest; \
23
- apt-get -y remove curl gnupg; \
24
- apt-get -y --purge autoremove; \
25
- apt-get clean; \
26
- rm -rf /var/lib/apt/lists/*;
27
-
28
- EXPOSE 8080
29
-
30
- RUN mkdir -p /data; \
31
- chown node:node /data; \
32
- mkdir -p /usr/src/app;
33
-
17
+ gnupg && \
18
+ mkdir -p /etc/apt/keyrings && \
19
+ curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
20
+ echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
21
+ apt-get -qq update && \
22
+ apt-get install -y --no-install-recommends --no-install-suggests nodejs && \
23
+ npm i -g npm@latest && \
24
+ apt-get -y remove curl gnupg && \
25
+ apt-get -y --purge autoremove && \
26
+ apt-get clean && \
27
+ rm -rf /var/lib/apt/lists/*
28
+
29
+ WORKDIR /usr/src/app
30
+ COPY . .
31
+
32
+ RUN npm config set maxsockets 1 && \
33
+ npm config set fetch-retries 5 && \
34
+ npm config set fetch-retry-mintimeout 100000 && \
35
+ npm config set fetch-retry-maxtimeout 600000 && \
36
+ npm install --omit=dev && \
37
+ chown -R root:root . && \
38
+ chmod +x ./docker-entrypoint.sh
39
+
40
+ RUN mkdir -p /data && chown node:node /data
34
41
  VOLUME /data
35
-
36
42
  WORKDIR /data
37
43
 
38
- COPY / /usr/src/app
39
-
40
- RUN cd /usr/src/app; \
41
- npm config set maxsockets 1; \
42
- npm config set fetch-retries 5; \
43
- npm config set fetch-retry-mintimeout 100000; \
44
- npm config set fetch-retry-maxtimeout 600000; \
45
- npm install --omit=dev; \
46
- chown -R root:root /usr/src/app; \
47
- chmod +x /usr/src/app/docker-entrypoint.sh;
44
+ EXPOSE 8080
48
45
 
49
46
  USER node:node
50
47
 
51
48
  ENTRYPOINT ["/usr/src/app/docker-entrypoint.sh"]
52
49
 
53
- HEALTHCHECK CMD node /usr/src/app/src/healthcheck.js
50
+ HEALTHCHECK CMD node /usr/src/app/src/healthcheck.js
@@ -0,0 +1,38 @@
1
+ FROM ubuntu:jammy AS builder
2
+
3
+ ENV NODE_ENV="devel"
4
+
5
+ RUN export DEBIAN_FRONTEND=noninteractive && \
6
+ apt-get update && \
7
+ apt-get install -y --no-install-recommends --no-install-suggests \
8
+ build-essential \
9
+ ca-certificates \
10
+ curl \
11
+ gnupg \
12
+ pkg-config \
13
+ xvfb \
14
+ libglfw3-dev \
15
+ libuv1-dev \
16
+ libjpeg-turbo8 \
17
+ libicu70 \
18
+ libcairo2-dev \
19
+ libpango1.0-dev \
20
+ libjpeg-dev \
21
+ libgif-dev \
22
+ librsvg2-dev \
23
+ gir1.2-rsvg-2.0 \
24
+ librsvg2-2 \
25
+ librsvg2-common \
26
+ libcurl4-openssl-dev \
27
+ libpixman-1-dev \
28
+ libpixman-1-0 && \
29
+ mkdir -p /etc/apt/keyrings && \
30
+ curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
31
+ echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
32
+ apt-get -qq update && \
33
+ apt-get install -y --no-install-recommends --no-install-suggests nodejs && \
34
+ npm i -g npm@latest && \
35
+ apt-get -y remove curl gnupg && \
36
+ apt-get -y --purge autoremove && \
37
+ apt-get clean && \
38
+ rm -rf /var/lib/apt/lists/*
@@ -1,2 +1,5 @@
1
- * Fix broken light (invalid use of heavy dependencies) (https://github.com/maptiler/tileserver-gl/pull/1449) by @okimiko
1
+ * Use npm packages for public/resources (https://github.com/maptiler/tileserver-gl/pull/1427) by @okimiko
2
+ * use ttf files of googlefonts/opensans (https://github.com/maptiler/tileserver-gl/pull/1447) by @okimiko
3
+ * fix memory leak on SIGHUP (https://github.com/maptiler/tileserver-gl/pull/1455) by @okimiko
4
+ * Limit Elevation Lat/Long Output Length (https://github.com/maptiler/tileserver-gl/pull/1457) by @okimiko
2
5
 
package/package.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "name": "tileserver-gl-light",
3
- "version": "5.1.2",
3
+ "version": "5.2.0-pre.0",
4
4
  "description": "Map tile server for JSON GL styles - serving vector tiles",
5
5
  "main": "src/main.js",
6
6
  "bin": "src/main.js",
7
7
  "type": "module",
8
8
  "scripts": {
9
+ "copy:maplibre": "copyfiles -EVf node_modules/maplibre-gl/dist/maplibre-gl.js node_modules/maplibre-gl/dist/maplibre-gl.js.map node_modules/maplibre-gl/dist/maplibre-gl.css public/resources/",
10
+ "copy:maplibre-inspect": "copyfiles -EVf node_modules/@maplibre/maplibre-gl-inspect/dist/maplibre-gl-inspect.js node_modules/@maplibre/maplibre-gl-inspect/dist/maplibre-gl-inspect.js.map node_modules/@maplibre/maplibre-gl-inspect/dist/maplibre-gl-inspect.css public/resources/",
11
+ "copy:mapbox-rtl-text": "copyfiles -EVf node_modules/@mapbox/mapbox-gl-rtl-text/dist/mapbox-gl-rtl-text.js public/resources/",
12
+ "copy:leaflet": "copyfiles -EVf node_modules/leaflet/dist/leaflet.js node_modules/leaflet/dist/leaflet.js.map node_modules/leaflet/dist/leaflet.css node_modules/leaflet/dist/leaflet-hash.js public/resources/",
13
+ "copy:leaflet-hash": "copyfiles -EVf node_modules/leaflet-hash/leaflet-hash.js public/resources/",
9
14
  "test": "mocha test/**.js --timeout 10000 --exit",
10
15
  "test-docker": "xvfb-run npm test",
11
16
  "lint:yml": "yamllint --schema=CORE_SCHEMA *.{yml,yaml}",
@@ -19,10 +24,12 @@
19
24
  },
20
25
  "dependencies": {
21
26
  "@jsse/pbfont": "^0.2.2",
27
+ "@mapbox/mapbox-gl-rtl-text": "0.3.0",
22
28
  "@mapbox/mbtiles": "0.12.1",
23
29
  "@mapbox/polyline": "^1.2.1",
24
30
  "@mapbox/sphericalmercator": "1.2.0",
25
31
  "@mapbox/vector-tile": "2.0.3",
32
+ "@maplibre/maplibre-gl-inspect": "1.7.0",
26
33
  "@maplibre/maplibre-gl-style-spec": "20.3.1",
27
34
  "@sindresorhus/fnv1a": "3.1.0",
28
35
  "advanced-pool": "0.3.3",
@@ -35,6 +42,9 @@
35
42
  "express": "5.0.1",
36
43
  "handlebars": "4.7.8",
37
44
  "http-shutdown": "1.2.2",
45
+ "leaflet": "1.9.4",
46
+ "leaflet-hash": "0.2.1",
47
+ "maplibre-gl": "4.7.1",
38
48
  "morgan": "1.10.0",
39
49
  "pbf": "4.0.1",
40
50
  "pmtiles": "3.0.7",
@@ -18,7 +18,7 @@ class ElevationInfoControl {
18
18
 
19
19
  map.on('click', (e) => {
20
20
  var url = this.url;
21
- var coord = {"z": Math.floor(map.getZoom()), "x": e.lngLat["lng"], "y": e.lngLat["lat"]};
21
+ var coord = {"z": Math.floor(map.getZoom()), "x": e.lngLat["lng"].toFixed(7), "y": e.lngLat["lat"].toFixed(7)};
22
22
  for(var key in coord) {
23
23
  url = url.replace(new RegExp('{'+ key +'}','g'), coord[key]);
24
24
  }
package/src/serve_data.js CHANGED
@@ -259,8 +259,8 @@ export const serve_data = {
259
259
 
260
260
  let data = fetchTile.data;
261
261
  var param = {
262
- long: bbox[0],
263
- lat: bbox[1],
262
+ long: bbox[0].toFixed(7),
263
+ lat: bbox[1].toFixed(7),
264
264
  encoding,
265
265
  format,
266
266
  tile_size: TILE_SIZE,
@@ -6,6 +6,7 @@ export const serve_rendered = {
6
6
  init: (options, repo, programOpts) => {},
7
7
  add: (options, repo, params, id, programOpts, dataResolver) => {},
8
8
  remove: (repo, id) => {},
9
+ clear: (repo) => {},
9
10
  getTerrainElevation: (data, param) => {
10
11
  param['elevation'] = 'not supported in light';
11
12
  return param;
@@ -15,7 +15,6 @@ import '@maplibre/maplibre-gl-native';
15
15
  import advancedPool from 'advanced-pool';
16
16
  import path from 'path';
17
17
  import url from 'url';
18
- import util from 'util';
19
18
  import sharp from 'sharp';
20
19
  import clone from 'clone';
21
20
  import Color from 'color';
@@ -1458,7 +1457,25 @@ export const serve_rendered = {
1458
1457
  }
1459
1458
  delete repo[id];
1460
1459
  },
1461
-
1460
+ /**
1461
+ * Removes all items from the repository.
1462
+ * @param {object} repo Repository object.
1463
+ * @returns {void}
1464
+ */
1465
+ clear: function (repo) {
1466
+ Object.keys(repo).forEach((id) => {
1467
+ const item = repo[id];
1468
+ if (item) {
1469
+ item.map.renderers.forEach((pool) => {
1470
+ pool.close();
1471
+ });
1472
+ item.map.renderersStatic.forEach((pool) => {
1473
+ pool.close();
1474
+ });
1475
+ }
1476
+ delete repo[id];
1477
+ });
1478
+ },
1462
1479
  /**
1463
1480
  * Get the elevation of terrain tile data by rendering it to a canvas image
1464
1481
  * @param {object} data The background color (or empty string for transparent).
package/src/server.js CHANGED
@@ -743,6 +743,7 @@ async function start(opts) {
743
743
  app,
744
744
  server,
745
745
  startupPromise,
746
+ serving,
746
747
  };
747
748
  }
748
749
  /**
@@ -775,10 +776,15 @@ export async function server(opts) {
775
776
  console.log(`Caught signal ${signal}, refreshing`);
776
777
  console.log('Stopping server and reloading config');
777
778
 
778
- running.server.shutdown(() => {
779
- const restarted = start(opts);
779
+ running.server.shutdown(async () => {
780
+ const restarted = await start(opts);
781
+ if (!isLight) {
782
+ serve_rendered.clear(running.serving.rendered);
783
+ }
780
784
  running.server = restarted.server;
781
785
  running.app = restarted.app;
786
+ running.startupPromise = restarted.startupPromise;
787
+ running.serving = restarted.serving;
782
788
  });
783
789
  });
784
790
  return running;
@@ -1,162 +0,0 @@
1
- (function(window) {
2
- var HAS_HASHCHANGE = (function() {
3
- var doc_mode = window.documentMode;
4
- return ('onhashchange' in window) &&
5
- (doc_mode === undefined || doc_mode > 7);
6
- })();
7
-
8
- L.Hash = function(map) {
9
- this.onHashChange = L.Util.bind(this.onHashChange, this);
10
-
11
- if (map) {
12
- this.init(map);
13
- }
14
- };
15
-
16
- L.Hash.parseHash = function(hash) {
17
- if(hash.indexOf('#') === 0) {
18
- hash = hash.substr(1);
19
- }
20
- var args = hash.split("/");
21
- if (args.length == 3) {
22
- var zoom = parseInt(args[0], 10),
23
- lat = parseFloat(args[1]),
24
- lon = parseFloat(args[2]);
25
- if (isNaN(zoom) || isNaN(lat) || isNaN(lon)) {
26
- return false;
27
- } else {
28
- return {
29
- center: new L.LatLng(lat, lon),
30
- zoom: zoom
31
- };
32
- }
33
- } else {
34
- return false;
35
- }
36
- };
37
-
38
- L.Hash.formatHash = function(map) {
39
- var center = map.getCenter(),
40
- zoom = map.getZoom(),
41
- precision = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
42
-
43
- return "#" + [zoom,
44
- center.lat.toFixed(precision),
45
- center.lng.toFixed(precision)
46
- ].join("/");
47
- },
48
-
49
- L.Hash.prototype = {
50
- map: null,
51
- lastHash: null,
52
-
53
- parseHash: L.Hash.parseHash,
54
- formatHash: L.Hash.formatHash,
55
-
56
- init: function(map) {
57
- this.map = map;
58
-
59
- // reset the hash
60
- this.lastHash = null;
61
- this.onHashChange();
62
-
63
- if (!this.isListening) {
64
- this.startListening();
65
- }
66
- },
67
-
68
- removeFrom: function(map) {
69
- if (this.changeTimeout) {
70
- clearTimeout(this.changeTimeout);
71
- }
72
-
73
- if (this.isListening) {
74
- this.stopListening();
75
- }
76
-
77
- this.map = null;
78
- },
79
-
80
- onMapMove: function() {
81
- // bail if we're moving the map (updating from a hash),
82
- // or if the map is not yet loaded
83
-
84
- if (this.movingMap || !this.map._loaded) {
85
- return false;
86
- }
87
-
88
- var hash = this.formatHash(this.map);
89
- if (this.lastHash != hash) {
90
- location.replace(hash);
91
- this.lastHash = hash;
92
- }
93
- },
94
-
95
- movingMap: false,
96
- update: function() {
97
- var hash = location.hash;
98
- if (hash === this.lastHash) {
99
- return;
100
- }
101
- var parsed = this.parseHash(hash);
102
- if (parsed) {
103
- this.movingMap = true;
104
-
105
- this.map.setView(parsed.center, parsed.zoom);
106
-
107
- this.movingMap = false;
108
- } else {
109
- this.onMapMove(this.map);
110
- }
111
- },
112
-
113
- // defer hash change updates every 100ms
114
- changeDefer: 100,
115
- changeTimeout: null,
116
- onHashChange: function() {
117
- // throttle calls to update() so that they only happen every
118
- // `changeDefer` ms
119
- if (!this.changeTimeout) {
120
- var that = this;
121
- this.changeTimeout = setTimeout(function() {
122
- that.update();
123
- that.changeTimeout = null;
124
- }, this.changeDefer);
125
- }
126
- },
127
-
128
- isListening: false,
129
- hashChangeInterval: null,
130
- startListening: function() {
131
- this.map.on("moveend", this.onMapMove, this);
132
-
133
- if (HAS_HASHCHANGE) {
134
- L.DomEvent.addListener(window, "hashchange", this.onHashChange);
135
- } else {
136
- clearInterval(this.hashChangeInterval);
137
- this.hashChangeInterval = setInterval(this.onHashChange, 50);
138
- }
139
- this.isListening = true;
140
- },
141
-
142
- stopListening: function() {
143
- this.map.off("moveend", this.onMapMove, this);
144
-
145
- if (HAS_HASHCHANGE) {
146
- L.DomEvent.removeListener(window, "hashchange", this.onHashChange);
147
- } else {
148
- clearInterval(this.hashChangeInterval);
149
- }
150
- this.isListening = false;
151
- }
152
- };
153
- L.hash = function(map) {
154
- return new L.Hash(map);
155
- };
156
- L.Map.prototype.addHash = function() {
157
- this._hash = L.hash(this);
158
- };
159
- L.Map.prototype.removeHash = function() {
160
- this._hash.removeFrom();
161
- };
162
- })(window);