@basemaps/lambda-tiler 6.40.0 → 6.41.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/CHANGELOG.md +27 -0
- package/build/__tests__/wmts.capability.test.js +98 -65
- package/build/__tests__/wmts.capability.test.js.map +1 -1
- package/build/cli/render.tile.js +13 -10
- package/build/cli/render.tile.js.map +1 -1
- package/build/routes/__tests__/attribution.test.js +2 -2
- package/build/routes/__tests__/attribution.test.js.map +1 -1
- package/build/routes/attribution.d.ts +1 -2
- package/build/routes/attribution.d.ts.map +1 -1
- package/build/routes/attribution.js +16 -14
- package/build/routes/attribution.js.map +1 -1
- package/build/routes/tile.wmts.d.ts.map +1 -1
- package/build/routes/tile.wmts.js +11 -8
- package/build/routes/tile.wmts.js.map +1 -1
- package/build/util/validate.d.ts.map +1 -1
- package/build/util/validate.js +4 -3
- package/build/util/validate.js.map +1 -1
- package/build/wmts.capability.d.ts +58 -28
- package/build/wmts.capability.d.ts.map +1 -1
- package/build/wmts.capability.js +167 -93
- package/build/wmts.capability.js.map +1 -1
- package/dist/index.js +110 -82
- package/dist/node_modules/.package-lock.json +10 -10
- package/dist/node_modules/detect-libc/README.md +4 -1
- package/dist/node_modules/detect-libc/index.d.ts +3 -0
- package/dist/node_modules/detect-libc/lib/detect-libc.js +105 -4
- package/dist/node_modules/detect-libc/lib/filesystem.js +41 -0
- package/dist/node_modules/detect-libc/lib/process.js +3 -0
- package/dist/node_modules/detect-libc/package.json +7 -3
- package/dist/node_modules/node-abi/.github/workflows/semantic.yml +26 -0
- package/dist/node_modules/node-abi/abi_registry.json +25 -1
- package/dist/node_modules/node-abi/package.json +1 -1
- package/dist/node_modules/node-abi/scripts/update-abi-registry.js +2 -2
- package/dist/node_modules/semver/README.md +70 -1
- package/dist/node_modules/semver/bin/semver.js +16 -2
- package/dist/node_modules/semver/classes/comparator.js +39 -34
- package/dist/node_modules/semver/classes/range.js +45 -28
- package/dist/node_modules/semver/classes/semver.js +32 -17
- package/dist/node_modules/semver/functions/coerce.js +1 -1
- package/dist/node_modules/semver/functions/diff.js +58 -16
- package/dist/node_modules/semver/functions/inc.js +3 -2
- package/dist/node_modules/semver/functions/parse.js +5 -22
- package/dist/node_modules/semver/index.js +1 -0
- package/dist/node_modules/semver/internal/constants.js +20 -2
- package/dist/node_modules/semver/internal/parse-options.js +14 -10
- package/dist/node_modules/semver/internal/re.js +34 -4
- package/dist/node_modules/semver/package.json +8 -7
- package/dist/node_modules/semver/ranges/intersects.js +1 -1
- package/dist/node_modules/semver/ranges/subset.js +6 -3
- package/dist/package-lock.json +11 -11
- package/dist/package.json +1 -2
- package/package.json +9 -10
- package/src/__tests__/wmts.capability.test.ts +110 -65
- package/src/cli/render.tile.ts +13 -10
- package/src/routes/__tests__/attribution.test.ts +2 -2
- package/src/routes/attribution.ts +16 -12
- package/src/routes/tile.wmts.ts +12 -7
- package/src/util/validate.ts +4 -3
- package/src/wmts.capability.ts +209 -121
- package/tsconfig.tsbuildinfo +1 -1
package/dist/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basemaps/lambda-tiler",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.41.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@basemaps/lambda-tiler",
|
|
9
|
-
"version": "6.
|
|
9
|
+
"version": "6.41.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"sharp": "0.30.7"
|
|
@@ -132,9 +132,9 @@
|
|
|
132
132
|
}
|
|
133
133
|
},
|
|
134
134
|
"node_modules/detect-libc": {
|
|
135
|
-
"version": "2.0.
|
|
136
|
-
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.
|
|
137
|
-
"integrity": "sha512-
|
|
135
|
+
"version": "2.0.2",
|
|
136
|
+
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.2.tgz",
|
|
137
|
+
"integrity": "sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw==",
|
|
138
138
|
"engines": {
|
|
139
139
|
"node": ">=8"
|
|
140
140
|
}
|
|
@@ -240,9 +240,9 @@
|
|
|
240
240
|
"integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg=="
|
|
241
241
|
},
|
|
242
242
|
"node_modules/node-abi": {
|
|
243
|
-
"version": "3.
|
|
244
|
-
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.
|
|
245
|
-
"integrity": "sha512-
|
|
243
|
+
"version": "3.45.0",
|
|
244
|
+
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.45.0.tgz",
|
|
245
|
+
"integrity": "sha512-iwXuFrMAcFVi/ZoZiqq8BzAdsLw9kxDfTC0HMyjXfSL/6CSDAGD5UmR7azrAgWV1zKYq7dUUMj4owusBWKLsiQ==",
|
|
246
246
|
"dependencies": {
|
|
247
247
|
"semver": "^7.3.5"
|
|
248
248
|
},
|
|
@@ -344,9 +344,9 @@
|
|
|
344
344
|
]
|
|
345
345
|
},
|
|
346
346
|
"node_modules/semver": {
|
|
347
|
-
"version": "7.
|
|
348
|
-
"resolved": "https://registry.npmjs.org/semver/-/semver-7.
|
|
349
|
-
"integrity": "sha512-
|
|
347
|
+
"version": "7.5.4",
|
|
348
|
+
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
|
|
349
|
+
"integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==",
|
|
350
350
|
"dependencies": {
|
|
351
351
|
"lru-cache": "^6.0.0"
|
|
352
352
|
},
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basemaps/lambda-tiler",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.41.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/linz/basemaps.git",
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
"entry": "src/index.ts",
|
|
28
28
|
"outdir": "dist/",
|
|
29
29
|
"external": [
|
|
30
|
-
"aws-sdk",
|
|
31
30
|
"pino-pretty",
|
|
32
31
|
"sharp"
|
|
33
32
|
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basemaps/lambda-tiler",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.41.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/linz/basemaps.git",
|
|
@@ -22,15 +22,15 @@
|
|
|
22
22
|
"types": "./build/index.d.ts",
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@basemaps/config": "^6.
|
|
26
|
-
"@basemaps/geo": "^6.
|
|
27
|
-
"@basemaps/shared": "^6.
|
|
28
|
-
"@basemaps/tiler": "^6.
|
|
29
|
-
"@basemaps/tiler-sharp": "^6.
|
|
25
|
+
"@basemaps/config": "^6.41.0",
|
|
26
|
+
"@basemaps/geo": "^6.41.0",
|
|
27
|
+
"@basemaps/shared": "^6.41.0",
|
|
28
|
+
"@basemaps/tiler": "^6.41.0",
|
|
29
|
+
"@basemaps/tiler-sharp": "^6.41.0",
|
|
30
30
|
"@chunkd/fs": "^10.0.2",
|
|
31
31
|
"@cogeotiff/core": "^7.2.0",
|
|
32
32
|
"@cotar/core": "^5.4.0",
|
|
33
|
-
"@linzjs/geojson": "^6.
|
|
33
|
+
"@linzjs/geojson": "^6.41.0",
|
|
34
34
|
"@linzjs/lambda": "^4.0.0",
|
|
35
35
|
"p-limit": "^4.0.0",
|
|
36
36
|
"path-to-regexp": "^6.1.0",
|
|
@@ -41,7 +41,6 @@
|
|
|
41
41
|
"entry": "src/index.ts",
|
|
42
42
|
"outdir": "dist/",
|
|
43
43
|
"external": [
|
|
44
|
-
"aws-sdk",
|
|
45
44
|
"pino-pretty",
|
|
46
45
|
"sharp"
|
|
47
46
|
]
|
|
@@ -51,12 +50,12 @@
|
|
|
51
50
|
"bundle": "./bundle.sh"
|
|
52
51
|
},
|
|
53
52
|
"devDependencies": {
|
|
54
|
-
"@basemaps/attribution": "^6.
|
|
53
|
+
"@basemaps/attribution": "^6.41.0",
|
|
55
54
|
"@chunkd/source-memory": "^10.0.0",
|
|
56
55
|
"@types/aws-lambda": "^8.10.75",
|
|
57
56
|
"@types/pixelmatch": "^5.0.0",
|
|
58
57
|
"@types/sharp": "^0.30.3",
|
|
59
58
|
"pretty-json-log": "^1.0.0"
|
|
60
59
|
},
|
|
61
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "a466cbcc9859b1585e6ca32894615b3eb6ad04b0"
|
|
62
61
|
}
|
|
@@ -24,15 +24,17 @@ o.spec('WmtsCapabilities', () => {
|
|
|
24
24
|
o('should output the requested formats', () => {
|
|
25
25
|
const wmts = new WmtsCapabilities({
|
|
26
26
|
httpBase: 'https://basemaps.test',
|
|
27
|
-
provider: Provider,
|
|
28
|
-
tileMatrix: [GoogleTms],
|
|
29
|
-
tileSet: TileSetAerial,
|
|
30
|
-
imagery: allImagery,
|
|
31
27
|
apiKey,
|
|
32
|
-
|
|
33
|
-
}).toVNode();
|
|
28
|
+
});
|
|
34
29
|
|
|
35
|
-
|
|
30
|
+
wmts.addTileMatrix(GoogleTms);
|
|
31
|
+
for (const im of allImagery.values()) wmts.addImagery(im);
|
|
32
|
+
wmts.addFormats(ImageFormat.Avif);
|
|
33
|
+
wmts.addProvider(Provider);
|
|
34
|
+
wmts.addTileSet(TileSetAerial);
|
|
35
|
+
const wmtsCapability = wmts.toVNode();
|
|
36
|
+
|
|
37
|
+
const urls = tags(wmtsCapability, 'ResourceURL');
|
|
36
38
|
o(urls.length).equals(1);
|
|
37
39
|
o(urls[0].attrs.format).equals('image/avif');
|
|
38
40
|
o(urls[0].attrs.template).equals(
|
|
@@ -43,16 +45,18 @@ o.spec('WmtsCapabilities', () => {
|
|
|
43
45
|
o('should include config location', () => {
|
|
44
46
|
const wmts = new WmtsCapabilities({
|
|
45
47
|
httpBase: 'https://basemaps.test',
|
|
46
|
-
provider: Provider,
|
|
47
|
-
tileMatrix: [GoogleTms],
|
|
48
|
-
tileSet: TileSetAerial,
|
|
49
|
-
imagery: allImagery,
|
|
50
48
|
apiKey,
|
|
51
49
|
config: 's3://linz-basemaps/config.json',
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
wmts.addTileMatrix(GoogleTms);
|
|
53
|
+
for (const im of allImagery.values()) wmts.addImagery(im);
|
|
54
|
+
wmts.addFormats(ImageFormat.Avif);
|
|
55
|
+
wmts.addProvider(Provider);
|
|
56
|
+
wmts.addTileSet(TileSetAerial);
|
|
57
|
+
const wmtsCapability = wmts.toVNode();
|
|
54
58
|
|
|
55
|
-
const urls = tags(
|
|
59
|
+
const urls = tags(wmtsCapability, 'ResourceURL');
|
|
56
60
|
o(urls.length).equals(1);
|
|
57
61
|
o(urls[0].attrs.format).equals('image/avif');
|
|
58
62
|
o(urls[0].attrs.template).equals(
|
|
@@ -60,16 +64,20 @@ o.spec('WmtsCapabilities', () => {
|
|
|
60
64
|
);
|
|
61
65
|
});
|
|
62
66
|
|
|
63
|
-
o('should be
|
|
64
|
-
const
|
|
67
|
+
o('should be adding encoding to utf-8', () => {
|
|
68
|
+
const wmts = new WmtsCapabilities({
|
|
65
69
|
httpBase: 'https://basemaps.test',
|
|
70
|
+
apiKey,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
wmts.fromParams({
|
|
66
74
|
provider: Provider,
|
|
67
75
|
tileMatrix: [GoogleTms],
|
|
68
76
|
tileSet: TileSetAerial,
|
|
69
77
|
imagery: allImagery,
|
|
70
|
-
apiKey,
|
|
71
78
|
formats: [ImageFormat.Avif],
|
|
72
|
-
})
|
|
79
|
+
});
|
|
80
|
+
const xml = wmts.toXml();
|
|
73
81
|
|
|
74
82
|
o(xml.split('\n')[0]).deepEquals('<?xml version="1.0" encoding="utf-8"?>');
|
|
75
83
|
});
|
|
@@ -79,23 +87,26 @@ o.spec('WmtsCapabilities', () => {
|
|
|
79
87
|
tileSet.name = '🦄_🌈_2022_0-5m';
|
|
80
88
|
tileSet.title = '🦄 🌈 Imagery (2022)';
|
|
81
89
|
tileSet.description = '🦄 🌈 Description';
|
|
90
|
+
|
|
82
91
|
const wmts = new WmtsCapabilities({
|
|
83
92
|
httpBase: 'https://basemaps.test',
|
|
84
|
-
provider: Provider,
|
|
85
|
-
tileMatrix: [GoogleTms],
|
|
86
|
-
tileSet,
|
|
87
|
-
imagery: allImagery,
|
|
88
93
|
apiKey,
|
|
89
|
-
|
|
90
|
-
}).toVNode();
|
|
94
|
+
});
|
|
91
95
|
|
|
92
|
-
|
|
96
|
+
wmts.addTileMatrix(GoogleTms);
|
|
97
|
+
for (const im of allImagery.values()) wmts.addImagery(im);
|
|
98
|
+
wmts.addFormats(ImageFormat.Avif);
|
|
99
|
+
wmts.addProvider(Provider);
|
|
100
|
+
wmts.addTileSet(tileSet);
|
|
101
|
+
const wmtsCapability = wmts.toVNode();
|
|
102
|
+
|
|
103
|
+
const urls = tags(wmtsCapability, 'ResourceURL');
|
|
93
104
|
o(urls.length).equals(1);
|
|
94
105
|
o(urls[0].attrs.template).equals(
|
|
95
106
|
'https://basemaps.test/v1/tiles/🦄-🌈-2022-0.5m/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.avif?api=secret1234',
|
|
96
107
|
);
|
|
97
108
|
|
|
98
|
-
const layer = tags(
|
|
109
|
+
const layer = tags(wmtsCapability, 'Layer')[0];
|
|
99
110
|
|
|
100
111
|
const title = layer.find('ows:Title')?.toString();
|
|
101
112
|
o(title).equals('<ows:Title>🦄 🌈 Imagery (2022)</ows:Title>');
|
|
@@ -133,32 +144,36 @@ o.spec('WmtsCapabilities', () => {
|
|
|
133
144
|
|
|
134
145
|
const wmts = new WmtsCapabilities({
|
|
135
146
|
httpBase: 'https://basemaps.test',
|
|
136
|
-
provider: Provider,
|
|
137
|
-
tileMatrix: [GoogleTms],
|
|
138
|
-
tileSet,
|
|
139
|
-
imagery,
|
|
140
147
|
apiKey,
|
|
141
|
-
|
|
142
|
-
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
wmts.addTileMatrix(GoogleTms);
|
|
151
|
+
for (const im of imagery.values()) wmts.addImagery(im);
|
|
152
|
+
wmts.addProvider(Provider);
|
|
153
|
+
wmts.addTileSet(tileSet);
|
|
154
|
+
wmts.addLayers(tileSet.layers);
|
|
155
|
+
const wmtsCapability = wmts.toVNode();
|
|
143
156
|
|
|
144
|
-
const layers = tags(
|
|
157
|
+
const layers = tags(wmtsCapability, 'Layer').map((c) => c.find('ows:Title')?.textContent);
|
|
145
158
|
|
|
146
159
|
// The base layer "Aerial Imagery" should always be first then all sub layers after
|
|
147
160
|
o(layers).deepEquals(['Aerial Imagery', 'aaaa', 'bbbb', 'Ōtorohanga 0.1m Urban Aerial Photos (2021)']);
|
|
148
161
|
});
|
|
149
162
|
|
|
150
|
-
o('should build capability xml for
|
|
163
|
+
o('should build capability xml for tileSet and projection', () => {
|
|
151
164
|
const imagery = new Map();
|
|
152
165
|
imagery.set(Imagery3857.id, Imagery3857);
|
|
166
|
+
|
|
153
167
|
const wmts = new WmtsCapabilities({
|
|
154
168
|
httpBase: 'https://basemaps.test',
|
|
155
|
-
provider: Provider,
|
|
156
|
-
tileMatrix: [GoogleTms],
|
|
157
|
-
tileSet: TileSetAerial,
|
|
158
|
-
imagery,
|
|
159
169
|
apiKey,
|
|
160
170
|
});
|
|
161
171
|
|
|
172
|
+
wmts.addTileMatrix(GoogleTms);
|
|
173
|
+
for (const im of imagery.values()) wmts.addImagery(im);
|
|
174
|
+
wmts.addProvider(Provider);
|
|
175
|
+
wmts.addTileSet(TileSetAerial);
|
|
176
|
+
wmts.addLayers(TileSetAerial.layers);
|
|
162
177
|
const raw = wmts.toVNode();
|
|
163
178
|
const serviceId = raw.find('ows:ServiceIdentification');
|
|
164
179
|
|
|
@@ -201,14 +216,17 @@ o.spec('WmtsCapabilities', () => {
|
|
|
201
216
|
});
|
|
202
217
|
|
|
203
218
|
o('should include output the correct TileMatrix', () => {
|
|
204
|
-
const
|
|
219
|
+
const wmts = new WmtsCapabilities({
|
|
205
220
|
httpBase: 'https://basemaps.test',
|
|
206
|
-
provider: Provider,
|
|
207
|
-
tileMatrix: [GoogleTms],
|
|
208
|
-
tileSet: TileSetAerial,
|
|
209
|
-
imagery: allImagery,
|
|
210
221
|
apiKey,
|
|
211
|
-
})
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
wmts.addTileMatrix(GoogleTms);
|
|
225
|
+
for (const im of allImagery.values()) wmts.addImagery(im);
|
|
226
|
+
wmts.addProvider(Provider);
|
|
227
|
+
wmts.addTileSet(TileSetAerial);
|
|
228
|
+
const raw = wmts.toVNode();
|
|
229
|
+
|
|
212
230
|
const layer = raw.find('Contents', 'Layer');
|
|
213
231
|
|
|
214
232
|
o(layer?.find('TileMatrixSetLink', 'TileMatrixSet')?.textContent).equals('WebMercatorQuad');
|
|
@@ -243,19 +261,25 @@ o.spec('WmtsCapabilities', () => {
|
|
|
243
261
|
compareMatrix(tileMatrices[10], '10', 1024, 545978.773465544);
|
|
244
262
|
});
|
|
245
263
|
|
|
246
|
-
o('should output individual imagery
|
|
264
|
+
o('should output individual imagery adds', () => {
|
|
247
265
|
const imagery = new Map<string, ConfigImagery>();
|
|
248
266
|
imagery.set(Imagery3857.id, Imagery3857);
|
|
249
267
|
imagery.set(Imagery2193.id, Imagery2193);
|
|
250
|
-
|
|
268
|
+
|
|
269
|
+
const wmts = new WmtsCapabilities({
|
|
251
270
|
httpBase: 'https://basemaps.test',
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
wmts.fromParams({
|
|
252
274
|
provider: Provider,
|
|
253
275
|
tileMatrix: [GoogleTms],
|
|
254
276
|
tileSet: TileSetAerial,
|
|
255
|
-
imagery
|
|
256
|
-
formats: [ImageFormat.Png],
|
|
277
|
+
imagery,
|
|
257
278
|
layers: TileSetAerial.layers,
|
|
258
|
-
|
|
279
|
+
formats: [ImageFormat.Png],
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
const raw = wmts.toVNode();
|
|
259
283
|
|
|
260
284
|
const tms = raw?.find('TileMatrixSet', 'ows:Identifier');
|
|
261
285
|
|
|
@@ -286,15 +310,20 @@ o.spec('WmtsCapabilities', () => {
|
|
|
286
310
|
const imagery = new Map<string, ConfigImagery>();
|
|
287
311
|
imagery.set(Imagery3857.id, Imagery3857);
|
|
288
312
|
imagery.set(Imagery2193.id, Imagery2193);
|
|
289
|
-
|
|
313
|
+
|
|
314
|
+
const wmts = new WmtsCapabilities({
|
|
290
315
|
httpBase: 'https://basemaps.test',
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
wmts.fromParams({
|
|
291
319
|
provider: Provider,
|
|
292
320
|
tileMatrix: [GoogleTms, Nztm2000QuadTms],
|
|
293
321
|
tileSet: TileSetAerial,
|
|
294
322
|
imagery: imagery,
|
|
295
323
|
formats: [ImageFormat.Png],
|
|
296
|
-
})
|
|
324
|
+
});
|
|
297
325
|
|
|
326
|
+
const raw = wmts.toVNode();
|
|
298
327
|
const layers = tags(raw, 'Layer');
|
|
299
328
|
o(layers.length).equals(1);
|
|
300
329
|
const layer = layers[0];
|
|
@@ -321,11 +350,11 @@ o.spec('WmtsCapabilities', () => {
|
|
|
321
350
|
);
|
|
322
351
|
o(layer.find('ows:Identifier')?.textContent).equals('aerial');
|
|
323
352
|
|
|
324
|
-
const
|
|
353
|
+
const adds = tags(layer, 'TileMatrixSet');
|
|
325
354
|
|
|
326
|
-
o(
|
|
327
|
-
o(
|
|
328
|
-
o(
|
|
355
|
+
o(adds.length).equals(2);
|
|
356
|
+
o(adds[0].toString()).equals('<TileMatrixSet>WebMercatorQuad</TileMatrixSet>');
|
|
357
|
+
o(adds[1].toString()).equals('<TileMatrixSet>NZTM2000Quad</TileMatrixSet>');
|
|
329
358
|
|
|
330
359
|
const boundingBoxes = tags(layer, 'ows:BoundingBox');
|
|
331
360
|
o(boundingBoxes.length).equals(2);
|
|
@@ -347,37 +376,45 @@ o.spec('WmtsCapabilities', () => {
|
|
|
347
376
|
|
|
348
377
|
o('should only output imagery if exists', () => {
|
|
349
378
|
const imagery = new Map<string, ConfigImagery>();
|
|
350
|
-
const
|
|
379
|
+
const wmtsA = new WmtsCapabilities({
|
|
351
380
|
httpBase: 'https://basemaps.test',
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
wmtsA.fromParams({
|
|
352
384
|
provider: Provider,
|
|
353
385
|
tileMatrix: [Nztm2000QuadTms],
|
|
354
386
|
tileSet: TileSetAerial,
|
|
355
387
|
imagery: imagery,
|
|
356
388
|
formats: [ImageFormat.Png],
|
|
357
389
|
layers: TileSetAerial.layers,
|
|
358
|
-
})
|
|
390
|
+
});
|
|
359
391
|
|
|
360
|
-
const
|
|
392
|
+
const rawA = wmtsA.toVNode();
|
|
393
|
+
|
|
394
|
+
const layers = tags(rawA, 'Layer');
|
|
361
395
|
o(layers.length).equals(1);
|
|
362
396
|
|
|
363
397
|
imagery.set(Imagery3857.id, Imagery3857);
|
|
364
|
-
const
|
|
398
|
+
const wmtsB = new WmtsCapabilities({
|
|
365
399
|
httpBase: 'https://basemaps.test',
|
|
400
|
+
});
|
|
401
|
+
wmtsB.fromParams({
|
|
366
402
|
provider: Provider,
|
|
367
403
|
tileMatrix: [Nztm2000QuadTms],
|
|
368
404
|
tileSet: TileSetAerial,
|
|
369
405
|
imagery: imagery,
|
|
370
406
|
formats: [ImageFormat.Png],
|
|
371
407
|
layers: TileSetAerial.layers,
|
|
372
|
-
})
|
|
408
|
+
});
|
|
373
409
|
|
|
410
|
+
const rawB = wmtsB.toVNode();
|
|
374
411
|
const layersB = tags(rawB, 'Layer');
|
|
375
412
|
o(layersB.length).equals(1);
|
|
376
413
|
});
|
|
377
414
|
|
|
378
415
|
o('should cover the entire WebMercatorBounds', () => {
|
|
379
416
|
const halfSize = GoogleTms.extent.width / 2;
|
|
380
|
-
// Create two fake imagery
|
|
417
|
+
// Create two fake imagery adds one covers tile z1 x0 y0 another covers tile z1 x1 y1
|
|
381
418
|
// so the entire bounding box should be tile z0 x0 y0 or the full extent
|
|
382
419
|
const imagery = new Map();
|
|
383
420
|
const imageTopLeft = { ...Imagery3857, id: 'im_top_left', name: 'top_left' };
|
|
@@ -394,15 +431,19 @@ o.spec('WmtsCapabilities', () => {
|
|
|
394
431
|
{ 3857: imageBottomRight.id, name: 'b_bottom_right', title: 'B Bottom Right' },
|
|
395
432
|
];
|
|
396
433
|
|
|
397
|
-
const
|
|
434
|
+
const wmts = new WmtsCapabilities({
|
|
398
435
|
httpBase: 'https://basemaps.test',
|
|
436
|
+
});
|
|
437
|
+
wmts.fromParams({
|
|
399
438
|
provider: Provider,
|
|
400
439
|
tileMatrix: [GoogleTms],
|
|
401
440
|
tileSet,
|
|
402
441
|
imagery,
|
|
403
442
|
formats: [ImageFormat.Png],
|
|
404
443
|
layers: tileSet.layers,
|
|
405
|
-
})
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
const raw = wmts.toVNode();
|
|
406
447
|
|
|
407
448
|
const boundingBox = tags(raw, 'ows:WGS84BoundingBox').map((c) =>
|
|
408
449
|
c
|
|
@@ -433,15 +474,19 @@ o.spec('WmtsCapabilities', () => {
|
|
|
433
474
|
const tileSet = { ...TileSetAerial };
|
|
434
475
|
tileSet.layers = [{ 3857: imageBottomRight.id, name: 'b_bottom_right', title: 'B Bottom Right' }];
|
|
435
476
|
|
|
436
|
-
const
|
|
477
|
+
const wmts = new WmtsCapabilities({
|
|
437
478
|
httpBase: 'https://basemaps.test',
|
|
479
|
+
});
|
|
480
|
+
wmts.fromParams({
|
|
438
481
|
provider: Provider,
|
|
439
482
|
tileMatrix: [GoogleTms],
|
|
440
483
|
tileSet,
|
|
441
484
|
imagery,
|
|
442
485
|
formats: [ImageFormat.Png],
|
|
443
486
|
layers: tileSet.layers,
|
|
444
|
-
})
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
const raw = wmts.toVNode();
|
|
445
490
|
|
|
446
491
|
const boundingBox = tags(raw, 'ows:WGS84BoundingBox').map((c) =>
|
|
447
492
|
roundNumbersInString(c.toString(), 4)
|
package/src/cli/render.tile.ts
CHANGED
|
@@ -1,38 +1,41 @@
|
|
|
1
1
|
import { ConfigProviderMemory } from '@basemaps/config';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { initConfigFromUrls } from '@basemaps/config/build/json/tiff.config.js';
|
|
3
|
+
import { GoogleTms, ImageFormat } from '@basemaps/geo';
|
|
4
4
|
import { LogConfig, setDefaultConfig } from '@basemaps/shared';
|
|
5
5
|
import { fsa } from '@chunkd/fs';
|
|
6
6
|
import { LambdaHttpRequest, LambdaUrlRequest, UrlEvent } from '@linzjs/lambda';
|
|
7
7
|
import { Context } from 'aws-lambda';
|
|
8
8
|
import { TileXyzRaster } from '../routes/tile.xyz.raster.js';
|
|
9
|
+
import { pathToFileURL } from 'url';
|
|
9
10
|
|
|
10
|
-
const target = `/home/blacha/tmp/basemaps
|
|
11
|
-
const tile = { z:
|
|
12
|
-
const tileMatrix =
|
|
11
|
+
const target = pathToFileURL(`/home/blacha/tmp/basemaps/white-lines/nz-0.5m/`);
|
|
12
|
+
const tile = { z: 10, x: 1013, y: 633 };
|
|
13
|
+
const tileMatrix = GoogleTms;
|
|
14
|
+
const imageFormat = ImageFormat.Webp;
|
|
13
15
|
|
|
14
16
|
async function main(): Promise<void> {
|
|
15
17
|
const log = LogConfig.get();
|
|
16
18
|
const provider = new ConfigProviderMemory();
|
|
17
19
|
setDefaultConfig(provider);
|
|
18
|
-
const { tileSet, imagery } = await
|
|
20
|
+
const { tileSet, imagery } = await initConfigFromUrls(provider, [target]);
|
|
19
21
|
|
|
20
22
|
if (tileSet.layers.length === 0) throw new Error('No imagery found in path: ' + target);
|
|
21
23
|
log.info({ tileSet: tileSet.name, layers: tileSet.layers.length }, 'TileSet:Loaded');
|
|
22
24
|
for (const im of imagery) {
|
|
23
|
-
log.info({
|
|
25
|
+
log.info({ url: im.uri, title: im.title, tileMatrix: im.tileMatrix, files: im.files.length }, 'Imagery:Loaded');
|
|
24
26
|
}
|
|
25
27
|
const request = new LambdaUrlRequest({ headers: {} } as UrlEvent, {} as Context, log) as LambdaHttpRequest;
|
|
26
28
|
|
|
29
|
+
tileSet.background = { r: 255, g: 255, b: 255, alpha: 1 };
|
|
27
30
|
const res = await TileXyzRaster.tile(request, tileSet, {
|
|
28
31
|
tile,
|
|
29
32
|
tileMatrix,
|
|
30
33
|
tileSet: tileSet.id,
|
|
31
|
-
tileType:
|
|
34
|
+
tileType: imageFormat,
|
|
32
35
|
});
|
|
33
36
|
|
|
34
|
-
await fsa.write(`./${tile.z}_${tile.x}_${tile.y}
|
|
35
|
-
log.info({ path: `./${tile.z}_${tile.x}_${tile.y}
|
|
37
|
+
await fsa.write(`./${tile.z}_${tile.x}_${tile.y}.${imageFormat}`, Buffer.from(res.body, 'base64'));
|
|
38
|
+
log.info({ path: `./${tile.z}_${tile.x}_${tile.y}.${imageFormat}` }, 'Tile:Write');
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
main();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Attribution } from '@basemaps/attribution';
|
|
2
2
|
import { ConfigProviderMemory } from '@basemaps/config';
|
|
3
|
-
import { GoogleTms, Nztm2000QuadTms } from '@basemaps/geo';
|
|
4
|
-
import { LogConfig
|
|
3
|
+
import { GoogleTms, Nztm2000QuadTms, Projection } from '@basemaps/geo';
|
|
4
|
+
import { LogConfig } from '@basemaps/shared';
|
|
5
5
|
import { BBox } from '@linzjs/geojson';
|
|
6
6
|
import { HttpHeader } from '@linzjs/lambda';
|
|
7
7
|
import o from 'ospec';
|
|
@@ -6,13 +6,14 @@ import {
|
|
|
6
6
|
Bounds,
|
|
7
7
|
GoogleTms,
|
|
8
8
|
NamedBounds,
|
|
9
|
+
Projection,
|
|
9
10
|
Stac,
|
|
10
11
|
StacExtent,
|
|
11
12
|
StacProvider,
|
|
12
13
|
TileMatrixSet,
|
|
13
14
|
} from '@basemaps/geo';
|
|
14
|
-
import { extractYearRangeFromName, extractYearRangeFromTitle, Projection } from '@basemaps/shared';
|
|
15
15
|
import { BBox, MultiPolygon, multiPolygonToWgs84, Pair, union, Wgs84 } from '@linzjs/geojson';
|
|
16
|
+
import { extractYearRangeFromName, extractYearRangeFromTitle } from '@basemaps/shared';
|
|
16
17
|
import { HttpHeader, LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
|
|
17
18
|
import { ConfigLoader } from '../util/config.loader.js';
|
|
18
19
|
|
|
@@ -88,16 +89,21 @@ async function tileSetAttribution(
|
|
|
88
89
|
const host = await config.Provider.get(config.Provider.id('linz'));
|
|
89
90
|
|
|
90
91
|
for (const layer of filteredLayers) {
|
|
91
|
-
if (layer.disabled) continue;
|
|
92
92
|
const imgId = layer[proj.epsg.code];
|
|
93
93
|
if (imgId == null) continue;
|
|
94
94
|
const im = imagery.get(imgId);
|
|
95
95
|
if (im == null) continue;
|
|
96
96
|
const title = im.title;
|
|
97
|
+
const years = extractYearRangeFromTitle(im.title) ?? extractYearRangeFromName(im.name);
|
|
98
|
+
if (years == null) continue;
|
|
99
|
+
const interval = yearRangeToInterval(years);
|
|
97
100
|
|
|
98
101
|
const bbox = proj.boundsToWgs84BoundingBox(im.bounds).map(roundNumber) as BBox;
|
|
99
102
|
|
|
100
|
-
const extent: StacExtent = {
|
|
103
|
+
const extent: StacExtent = {
|
|
104
|
+
spatial: { bbox: [bbox] },
|
|
105
|
+
temporal: { interval: [[interval[0].toISOString(), interval[1].toISOString()]] },
|
|
106
|
+
};
|
|
101
107
|
|
|
102
108
|
const item: AttributionItem = {
|
|
103
109
|
type: 'Feature',
|
|
@@ -111,19 +117,16 @@ async function tileSetAttribution(
|
|
|
111
117
|
properties: {
|
|
112
118
|
title,
|
|
113
119
|
category: im.category,
|
|
120
|
+
datetime: null,
|
|
121
|
+
start_datetime: interval[0].toISOString(),
|
|
122
|
+
end_datetime: interval[1].toISOString(),
|
|
114
123
|
},
|
|
115
124
|
};
|
|
116
|
-
|
|
117
|
-
if (years) {
|
|
118
|
-
const interval = yearRangeToInterval(years);
|
|
119
|
-
extent.temporal = { interval: [[interval[0].toISOString(), interval[1].toISOString()]] };
|
|
120
|
-
item.properties.datetime = null;
|
|
121
|
-
item.properties.start_datetime = interval[0].toISOString();
|
|
122
|
-
item.properties.end_datetime = interval[1].toISOString();
|
|
123
|
-
}
|
|
125
|
+
|
|
124
126
|
items.push(item);
|
|
125
127
|
|
|
126
|
-
const
|
|
128
|
+
const minZoom = layer.disabled ? 32 : layer.minZoom;
|
|
129
|
+
const zoomMin = TileMatrixSet.convertZoomLevel(minZoom ? minZoom : 0, GoogleTms, tileMatrix, true);
|
|
127
130
|
const zoomMax = TileMatrixSet.convertZoomLevel(layer.maxZoom ? layer.maxZoom : 32, GoogleTms, tileMatrix, true);
|
|
128
131
|
cols.push({
|
|
129
132
|
stac_version: Stac.Version,
|
|
@@ -138,6 +141,7 @@ async function tileSetAttribution(
|
|
|
138
141
|
'linz:category': im.category,
|
|
139
142
|
'linz:zoom': { min: zoomMin, max: zoomMax },
|
|
140
143
|
'linz:priority': [1000 + tileSet.layers.indexOf(layer)],
|
|
144
|
+
'linz:disabled': layer.disabled ? true : false,
|
|
141
145
|
},
|
|
142
146
|
});
|
|
143
147
|
}
|
package/src/routes/tile.wmts.ts
CHANGED
|
@@ -55,18 +55,23 @@ export async function wmtsCapabilitiesGet(req: LambdaHttpRequest<WmtsCapabilitie
|
|
|
55
55
|
);
|
|
56
56
|
req.timer.end('imagery:load');
|
|
57
57
|
|
|
58
|
-
const
|
|
58
|
+
const wmts = new WmtsCapabilities({
|
|
59
59
|
httpBase: host,
|
|
60
|
+
apiKey,
|
|
61
|
+
config: ConfigLoader.extract(req),
|
|
62
|
+
filters: getFilters(req),
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
wmts.fromParams({
|
|
60
66
|
provider: provider ?? undefined,
|
|
61
67
|
tileSet,
|
|
62
68
|
tileMatrix,
|
|
63
69
|
imagery,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}).toXml();
|
|
70
|
+
formats: Validate.getRequestedFormats(req) ?? [],
|
|
71
|
+
layers: req.params.tileMatrix == null ? filterLayers(req, tileSet.layers) : undefined,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const xml = wmts.toXml();
|
|
70
75
|
if (xml == null) return NotFound();
|
|
71
76
|
|
|
72
77
|
const data = Buffer.from(xml);
|
package/src/util/validate.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ImageFormat, TileMatrixSet, TileMatrixSets, VectorFormat } from '@basemaps/geo';
|
|
2
|
-
import { Const, isValidApiKey,
|
|
1
|
+
import { ImageFormat, Projection, TileMatrixSet, TileMatrixSets, VectorFormat } from '@basemaps/geo';
|
|
2
|
+
import { Const, isValidApiKey, truncateApiKey } from '@basemaps/shared';
|
|
3
3
|
import { getImageFormat } from '@basemaps/tiler';
|
|
4
4
|
import { LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
|
|
5
5
|
import { TileXyzGet } from '../routes/tile.xyz';
|
|
@@ -25,7 +25,8 @@ export const Validate = {
|
|
|
25
25
|
const valid = isValidApiKey(apiKey);
|
|
26
26
|
|
|
27
27
|
if (!valid.valid) throw new LambdaHttpResponse(400, 'API Key Invalid: ' + valid.message);
|
|
28
|
-
|
|
28
|
+
// Truncate the API Key so we are not logging the full key
|
|
29
|
+
req.set('api', truncateApiKey(apiKey));
|
|
29
30
|
return apiKey as string;
|
|
30
31
|
},
|
|
31
32
|
|