tileserver-gl-light 4.6.6 → 4.7.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.
- package/.eslintrc.cjs +4 -0
- package/.github/workflows/ct.yml +1 -1
- package/.github/workflows/release.yml +1 -1
- package/README.md +2 -2
- package/docs/config.rst +20 -1
- package/docs/endpoints.rst +8 -8
- package/package.json +5 -5
- package/public/resources/images/marker-icon-2x.png +0 -0
- package/public/resources/images/marker-icon.png +0 -0
- package/public/resources/images/marker-shadow.png +0 -0
- package/public/resources/leaflet.css +6 -1
- package/public/resources/leaflet.js +3 -3
- package/public/resources/leaflet.js.map +1 -1
- package/public/resources/maplibre-gl.js +4 -4
- package/public/resources/maplibre-gl.js.map +1 -1
- package/public/templates/data.tmpl +0 -1
- package/public/templates/index.tmpl +1 -4
- package/public/templates/viewer.tmpl +0 -1
- package/src/healthcheck.js +3 -3
- package/src/main.js +30 -29
- package/src/pmtiles_adapter.js +9 -9
- package/src/render.js +303 -0
- package/src/serve_data.js +12 -12
- package/src/serve_font.js +25 -44
- package/src/serve_rendered.js +234 -613
- package/src/serve_style.js +5 -17
- package/src/server.js +24 -29
- package/src/utils.js +22 -3
- package/test/setup.js +0 -1
- package/public/resources/L.TileLayer.NoGap.js +0 -243
package/src/serve_font.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
import express from 'express';
|
|
4
|
-
import fs from 'node:fs';
|
|
5
|
-
import path from 'path';
|
|
6
4
|
|
|
7
|
-
import { getFontsPbf } from './utils.js';
|
|
5
|
+
import { getFontsPbf, listFonts } from './utils.js';
|
|
8
6
|
|
|
9
|
-
export const serve_font = (options, allowedFonts) => {
|
|
7
|
+
export const serve_font = async (options, allowedFonts) => {
|
|
10
8
|
const app = express().disable('x-powered-by');
|
|
11
9
|
|
|
12
10
|
const lastModified = new Date().toUTCString();
|
|
@@ -14,49 +12,30 @@ export const serve_font = (options, allowedFonts) => {
|
|
|
14
12
|
const fontPath = options.paths.fonts;
|
|
15
13
|
|
|
16
14
|
const existingFonts = {};
|
|
17
|
-
const fontListingPromise = new Promise((resolve, reject) => {
|
|
18
|
-
fs.readdir(options.paths.fonts, (err, files) => {
|
|
19
|
-
if (err) {
|
|
20
|
-
reject(err);
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
for (const file of files) {
|
|
24
|
-
fs.stat(path.join(fontPath, file), (err, stats) => {
|
|
25
|
-
if (err) {
|
|
26
|
-
reject(err);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if (
|
|
30
|
-
stats.isDirectory() &&
|
|
31
|
-
fs.existsSync(path.join(fontPath, file, '0-255.pbf'))
|
|
32
|
-
) {
|
|
33
|
-
existingFonts[path.basename(file)] = true;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
resolve();
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
15
|
|
|
41
|
-
app.get(
|
|
42
|
-
|
|
43
|
-
|
|
16
|
+
app.get(
|
|
17
|
+
'/fonts/:fontstack/:range([\\d]+-[\\d]+).pbf',
|
|
18
|
+
async (req, res, next) => {
|
|
19
|
+
const fontstack = decodeURI(req.params.fontstack);
|
|
20
|
+
const range = req.params.range;
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
const concatenated = await getFontsPbf(
|
|
24
|
+
options.serveAllFonts ? null : allowedFonts,
|
|
25
|
+
fontPath,
|
|
26
|
+
fontstack,
|
|
27
|
+
range,
|
|
28
|
+
existingFonts,
|
|
29
|
+
);
|
|
44
30
|
|
|
45
|
-
getFontsPbf(
|
|
46
|
-
options.serveAllFonts ? null : allowedFonts,
|
|
47
|
-
fontPath,
|
|
48
|
-
fontstack,
|
|
49
|
-
range,
|
|
50
|
-
existingFonts,
|
|
51
|
-
).then(
|
|
52
|
-
(concated) => {
|
|
53
31
|
res.header('Content-type', 'application/x-protobuf');
|
|
54
32
|
res.header('Last-Modified', lastModified);
|
|
55
|
-
return res.send(
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
33
|
+
return res.send(concatenated);
|
|
34
|
+
} catch (err) {
|
|
35
|
+
res.status(400).header('Content-Type', 'text/plain').send(err);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
);
|
|
60
39
|
|
|
61
40
|
app.get('/fonts.json', (req, res, next) => {
|
|
62
41
|
res.header('Content-type', 'application/json');
|
|
@@ -65,5 +44,7 @@ export const serve_font = (options, allowedFonts) => {
|
|
|
65
44
|
);
|
|
66
45
|
});
|
|
67
46
|
|
|
68
|
-
|
|
47
|
+
const fonts = await listFonts(options.paths.fonts);
|
|
48
|
+
Object.assign(existingFonts, fonts);
|
|
49
|
+
return app;
|
|
69
50
|
};
|