tileserver-gl-light 4.1.2 → 4.2.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 +32 -0
- package/.gitattributes +11 -0
- package/.husky/commit-msg +21 -0
- package/.husky/pre-push +4 -0
- package/Dockerfile +4 -1
- package/commitlint.config.cjs +3 -0
- package/docker-entrypoint.sh +1 -1
- package/docs/installation.rst +1 -1
- package/lint-staged.config.cjs +4 -0
- package/package.json +28 -11
- package/prettier.config.cjs +13 -0
- package/publish.js +17 -9
- package/run.sh +1 -1
- package/src/healthcheck.js +18 -0
- package/src/main.js +57 -65
- package/src/serve_data.js +99 -82
- package/src/serve_font.js +19 -10
- package/src/serve_light.js +5 -6
- package/src/serve_rendered.js +550 -309
- package/src/serve_style.js +31 -16
- package/src/server.js +248 -156
- package/src/utils.js +62 -43
- package/test/metadata.js +44 -43
- package/test/setup.js +8 -7
- package/test/static.js +127 -31
- package/test/style.js +31 -26
- package/test/tiles_data.js +5 -5
- package/test/tiles_rendered.js +7 -7
package/src/serve_style.js
CHANGED
|
@@ -5,14 +5,14 @@ import fs from 'node:fs';
|
|
|
5
5
|
|
|
6
6
|
import clone from 'clone';
|
|
7
7
|
import express from 'express';
|
|
8
|
-
import {validate} from '@maplibre/maplibre-gl-style-spec';
|
|
8
|
+
import { validate } from '@maplibre/maplibre-gl-style-spec';
|
|
9
9
|
|
|
10
|
-
import {getPublicUrl} from './utils.js';
|
|
10
|
+
import { getPublicUrl } from './utils.js';
|
|
11
11
|
|
|
12
12
|
const httpTester = /^(http(s)?:)?\/\//;
|
|
13
13
|
|
|
14
14
|
const fixUrl = (req, url, publicUrl, opt_nokey) => {
|
|
15
|
-
if (!url ||
|
|
15
|
+
if (!url || typeof url !== 'string' || url.indexOf('local://') !== 0) {
|
|
16
16
|
return url;
|
|
17
17
|
}
|
|
18
18
|
const queryParams = [];
|
|
@@ -23,8 +23,7 @@ const fixUrl = (req, url, publicUrl, opt_nokey) => {
|
|
|
23
23
|
if (queryParams.length) {
|
|
24
24
|
query = `?${queryParams.join('&')}`;
|
|
25
25
|
}
|
|
26
|
-
return url.replace(
|
|
27
|
-
'local://', getPublicUrl(publicUrl, req)) + query;
|
|
26
|
+
return url.replace('local://', getPublicUrl(publicUrl, req)) + query;
|
|
28
27
|
};
|
|
29
28
|
|
|
30
29
|
export const serve_style = {
|
|
@@ -43,10 +42,20 @@ export const serve_style = {
|
|
|
43
42
|
}
|
|
44
43
|
// mapbox-gl-js viewer cannot handle sprite urls with query
|
|
45
44
|
if (styleJSON_.sprite) {
|
|
46
|
-
styleJSON_.sprite = fixUrl(
|
|
45
|
+
styleJSON_.sprite = fixUrl(
|
|
46
|
+
req,
|
|
47
|
+
styleJSON_.sprite,
|
|
48
|
+
item.publicUrl,
|
|
49
|
+
false,
|
|
50
|
+
);
|
|
47
51
|
}
|
|
48
52
|
if (styleJSON_.glyphs) {
|
|
49
|
-
styleJSON_.glyphs = fixUrl(
|
|
53
|
+
styleJSON_.glyphs = fixUrl(
|
|
54
|
+
req,
|
|
55
|
+
styleJSON_.glyphs,
|
|
56
|
+
item.publicUrl,
|
|
57
|
+
false,
|
|
58
|
+
);
|
|
50
59
|
}
|
|
51
60
|
return res.send(styleJSON_);
|
|
52
61
|
});
|
|
@@ -89,7 +98,9 @@ export const serve_style = {
|
|
|
89
98
|
|
|
90
99
|
const validationErrors = validate(styleFileData);
|
|
91
100
|
if (validationErrors.length > 0) {
|
|
92
|
-
console.log(
|
|
101
|
+
console.log(
|
|
102
|
+
`The file "${params.style}" is not valid a valid style file:`,
|
|
103
|
+
);
|
|
93
104
|
for (const err of validationErrors) {
|
|
94
105
|
console.log(`${err.line}: ${err.message}`);
|
|
95
106
|
}
|
|
@@ -102,8 +113,8 @@ export const serve_style = {
|
|
|
102
113
|
const url = source.url;
|
|
103
114
|
if (url && url.lastIndexOf('mbtiles:', 0) === 0) {
|
|
104
115
|
let mbtilesFile = url.substring('mbtiles://'.length);
|
|
105
|
-
const fromData =
|
|
106
|
-
mbtilesFile[mbtilesFile.length - 1] === '}';
|
|
116
|
+
const fromData =
|
|
117
|
+
mbtilesFile[0] === '{' && mbtilesFile[mbtilesFile.length - 1] === '}';
|
|
107
118
|
|
|
108
119
|
if (fromData) {
|
|
109
120
|
mbtilesFile = mbtilesFile.substr(1, mbtilesFile.length - 2);
|
|
@@ -135,10 +146,14 @@ export const serve_style = {
|
|
|
135
146
|
let spritePath;
|
|
136
147
|
|
|
137
148
|
if (styleJSON.sprite && !httpTester.test(styleJSON.sprite)) {
|
|
138
|
-
spritePath = path.join(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
149
|
+
spritePath = path.join(
|
|
150
|
+
options.paths.sprites,
|
|
151
|
+
styleJSON.sprite
|
|
152
|
+
.replace('{style}', path.basename(styleFile, '.json'))
|
|
153
|
+
.replace(
|
|
154
|
+
'{styleJsonFolder}',
|
|
155
|
+
path.relative(options.paths.sprites, path.dirname(styleFile)),
|
|
156
|
+
),
|
|
142
157
|
);
|
|
143
158
|
styleJSON.sprite = `local://styles/${id}/sprite`;
|
|
144
159
|
}
|
|
@@ -150,9 +165,9 @@ export const serve_style = {
|
|
|
150
165
|
styleJSON,
|
|
151
166
|
spritePath,
|
|
152
167
|
publicUrl,
|
|
153
|
-
name: styleJSON.name
|
|
168
|
+
name: styleJSON.name,
|
|
154
169
|
};
|
|
155
170
|
|
|
156
171
|
return true;
|
|
157
|
-
}
|
|
172
|
+
},
|
|
158
173
|
};
|