@basemaps/lambda-tiler 7.0.0 → 7.1.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 +29 -0
- package/build/__tests__/config.data.d.ts +0 -1
- package/build/__tests__/config.data.js +2 -6
- package/build/__tests__/config.data.js.map +1 -1
- package/build/__tests__/index.test.d.ts +0 -1
- package/build/__tests__/index.test.js +28 -27
- package/build/__tests__/index.test.js.map +1 -1
- package/build/__tests__/tile.style.json.test.d.ts +0 -1
- package/build/__tests__/tile.style.json.test.js +38 -37
- package/build/__tests__/tile.style.json.test.js.map +1 -1
- package/build/__tests__/wmts.capability.test.d.ts +0 -1
- package/build/__tests__/wmts.capability.test.js +111 -122
- package/build/__tests__/wmts.capability.test.js.map +1 -1
- package/build/__tests__/xyz.util.d.ts +0 -1
- package/build/cli/render.preview.d.ts +0 -1
- package/build/cli/render.preview.js +13 -9
- package/build/cli/render.preview.js.map +1 -1
- package/build/cli/render.tile.d.ts +0 -1
- package/build/cli/render.tile.js +25 -17
- package/build/cli/render.tile.js.map +1 -1
- package/build/index.d.ts +0 -1
- package/build/index.js +24 -20
- package/build/index.js.map +1 -1
- package/build/routes/__tests__/attribution.test.d.ts +0 -1
- package/build/routes/__tests__/attribution.test.js +38 -37
- package/build/routes/__tests__/attribution.test.js.map +1 -1
- package/build/routes/__tests__/fonts.test.d.ts +0 -1
- package/build/routes/__tests__/fonts.test.js +61 -63
- package/build/routes/__tests__/fonts.test.js.map +1 -1
- package/build/routes/__tests__/health.test.d.ts +0 -1
- package/build/routes/__tests__/health.test.js +16 -16
- package/build/routes/__tests__/health.test.js.map +1 -1
- package/build/routes/__tests__/imagery.test.d.ts +0 -1
- package/build/routes/__tests__/imagery.test.js +10 -9
- package/build/routes/__tests__/imagery.test.js.map +1 -1
- package/build/routes/__tests__/memory.fs.d.ts +2 -3
- package/build/routes/__tests__/preview.index.test.d.ts +0 -1
- package/build/routes/__tests__/preview.index.test.js +88 -42
- package/build/routes/__tests__/preview.index.test.js.map +1 -1
- package/build/routes/__tests__/sprites.test.d.ts +0 -1
- package/build/routes/__tests__/sprites.test.js +34 -34
- package/build/routes/__tests__/sprites.test.js.map +1 -1
- package/build/routes/__tests__/tile.json.test.d.ts +0 -1
- package/build/routes/__tests__/tile.json.test.js +45 -51
- package/build/routes/__tests__/tile.json.test.js.map +1 -1
- package/build/routes/__tests__/tile.style.json.test.d.ts +0 -1
- package/build/routes/__tests__/tile.style.json.test.js +49 -50
- package/build/routes/__tests__/tile.style.json.test.js.map +1 -1
- package/build/routes/__tests__/wmts.test.d.ts +0 -1
- package/build/routes/__tests__/wmts.test.js +27 -20
- package/build/routes/__tests__/wmts.test.js.map +1 -1
- package/build/routes/__tests__/xyz.test.d.ts +0 -1
- package/build/routes/__tests__/xyz.test.js +97 -49
- package/build/routes/__tests__/xyz.test.js.map +1 -1
- package/build/routes/attribution.d.ts +1 -1
- package/build/routes/attribution.js +4 -5
- package/build/routes/attribution.js.map +1 -1
- package/build/routes/config.d.ts +0 -1
- package/build/routes/config.js +1 -2
- package/build/routes/config.js.map +1 -1
- package/build/routes/fonts.d.ts +0 -1
- package/build/routes/fonts.js +2 -3
- package/build/routes/fonts.js.map +1 -1
- package/build/routes/health.d.ts +1 -2
- package/build/routes/health.js +5 -15
- package/build/routes/health.js.map +1 -1
- package/build/routes/imagery.d.ts +0 -1
- package/build/routes/imagery.js +1 -1
- package/build/routes/imagery.js.map +1 -1
- package/build/routes/ping.d.ts +0 -1
- package/build/routes/ping.js +1 -1
- package/build/routes/ping.js.map +1 -1
- package/build/routes/preview.d.ts +6 -5
- package/build/routes/preview.index.d.ts +0 -1
- package/build/routes/preview.index.js +6 -5
- package/build/routes/preview.index.js.map +1 -1
- package/build/routes/preview.js +35 -10
- package/build/routes/preview.js.map +1 -1
- package/build/routes/sprites.d.ts +0 -1
- package/build/routes/sprites.js +2 -4
- package/build/routes/sprites.js.map +1 -1
- package/build/routes/tile.json.d.ts +0 -1
- package/build/routes/tile.json.js +10 -5
- package/build/routes/tile.json.js.map +1 -1
- package/build/routes/tile.style.json.d.ts +1 -1
- package/build/routes/tile.style.json.js +79 -16
- package/build/routes/tile.style.json.js.map +1 -1
- package/build/routes/tile.wmts.d.ts +0 -1
- package/build/routes/tile.wmts.js +8 -9
- package/build/routes/tile.wmts.js.map +1 -1
- package/build/routes/tile.xyz.d.ts +0 -1
- package/build/routes/tile.xyz.js.map +1 -1
- package/build/routes/tile.xyz.raster.d.ts +7 -8
- package/build/routes/tile.xyz.raster.js +17 -13
- package/build/routes/tile.xyz.raster.js.map +1 -1
- package/build/routes/tile.xyz.vector.d.ts +0 -1
- package/build/routes/tile.xyz.vector.js +4 -3
- package/build/routes/tile.xyz.vector.js.map +1 -1
- package/build/routes/version.d.ts +0 -1
- package/build/routes/version.js +3 -4
- package/build/routes/version.js.map +1 -1
- package/build/util/__test__/config.loader.test.d.ts +0 -1
- package/build/util/__test__/config.loader.test.js +35 -34
- package/build/util/__test__/config.loader.test.js.map +1 -1
- package/build/util/__test__/filter.test.d.ts +0 -1
- package/build/util/__test__/filter.test.js +17 -16
- package/build/util/__test__/filter.test.js.map +1 -1
- package/build/util/__test__/validate.test.d.ts +0 -1
- package/build/util/__test__/validate.test.js +26 -43
- package/build/util/__test__/validate.test.js.map +1 -1
- package/build/util/assets.provider.d.ts +5 -5
- package/build/util/assets.provider.js +8 -8
- package/build/util/assets.provider.js.map +1 -1
- package/build/util/config.cache.d.ts +2 -2
- package/build/util/config.cache.js +14 -3
- package/build/util/config.cache.js.map +1 -1
- package/build/util/config.loader.d.ts +0 -1
- package/build/util/config.loader.js +11 -12
- package/build/util/config.loader.js.map +1 -1
- package/build/util/cotar.serve.d.ts +3 -3
- package/build/util/cotar.serve.js +2 -2
- package/build/util/cotar.serve.js.map +1 -1
- package/build/util/etag.d.ts +0 -1
- package/build/util/etag.js.map +1 -1
- package/build/util/filter.d.ts +0 -1
- package/build/util/filter.js +4 -5
- package/build/util/filter.js.map +1 -1
- package/build/util/response.d.ts +0 -1
- package/build/util/source.cache.d.ts +8 -9
- package/build/util/source.cache.js +27 -24
- package/build/util/source.cache.js.map +1 -1
- package/build/util/swapping.lru.d.ts +0 -1
- package/build/util/swapping.lru.js +48 -7
- package/build/util/swapping.lru.js.map +1 -1
- package/build/util/validate.d.ts +17 -5
- package/build/util/validate.js +51 -15
- package/build/util/validate.js.map +1 -1
- package/build/wmts.capability.d.ts +1 -2
- package/build/wmts.capability.js +81 -12
- package/build/wmts.capability.js.map +1 -1
- package/bundle.sh +2 -2
- package/package.json +16 -18
- package/scripts/create.deployment.package.mjs +4 -11
- package/src/__tests__/config.data.ts +2 -6
- package/src/__tests__/index.test.ts +29 -27
- package/src/__tests__/tile.style.json.test.ts +40 -37
- package/src/__tests__/wmts.capability.test.ts +139 -120
- package/src/cli/render.preview.ts +14 -9
- package/src/cli/render.tile.ts +27 -18
- package/src/index.ts +28 -23
- package/src/routes/__tests__/attribution.test.ts +40 -37
- package/src/routes/__tests__/fonts.test.ts +68 -64
- package/src/routes/__tests__/health.test.ts +18 -17
- package/src/routes/__tests__/imagery.test.ts +11 -9
- package/src/routes/__tests__/preview.index.test.ts +114 -40
- package/src/routes/__tests__/sprites.test.ts +39 -34
- package/src/routes/__tests__/tile.json.test.ts +41 -39
- package/src/routes/__tests__/tile.style.json.test.ts +49 -46
- package/src/routes/__tests__/wmts.test.ts +28 -20
- package/src/routes/__tests__/xyz.test.ts +134 -55
- package/src/routes/attribution.ts +2 -2
- package/src/routes/config.ts +1 -0
- package/src/routes/fonts.ts +3 -3
- package/src/routes/health.ts +7 -13
- package/src/routes/imagery.ts +2 -1
- package/src/routes/ping.ts +1 -1
- package/src/routes/preview.index.ts +9 -5
- package/src/routes/preview.ts +44 -15
- package/src/routes/sprites.ts +4 -5
- package/src/routes/tile.json.ts +9 -2
- package/src/routes/tile.style.json.ts +89 -13
- package/src/routes/tile.wmts.ts +4 -3
- package/src/routes/tile.xyz.raster.ts +26 -22
- package/src/routes/tile.xyz.ts +1 -0
- package/src/routes/tile.xyz.vector.ts +5 -3
- package/src/routes/version.ts +3 -3
- package/src/util/__test__/config.loader.test.ts +38 -34
- package/src/util/__test__/filter.test.ts +19 -16
- package/src/util/__test__/validate.test.ts +28 -43
- package/src/util/assets.provider.ts +10 -9
- package/src/util/config.cache.ts +4 -3
- package/src/util/config.loader.ts +13 -13
- package/src/util/cotar.serve.ts +3 -2
- package/src/util/source.cache.ts +15 -26
- package/src/util/validate.ts +61 -14
- package/src/wmts.capability.ts +3 -3
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/__tests__/config.data.d.ts.map +0 -1
- package/build/__tests__/index.test.d.ts.map +0 -1
- package/build/__tests__/tile.style.json.test.d.ts.map +0 -1
- package/build/__tests__/wmts.capability.test.d.ts.map +0 -1
- package/build/__tests__/xyz.util.d.ts.map +0 -1
- package/build/cli/render.preview.d.ts.map +0 -1
- package/build/cli/render.tile.d.ts.map +0 -1
- package/build/index.d.ts.map +0 -1
- package/build/routes/__tests__/attribution.test.d.ts.map +0 -1
- package/build/routes/__tests__/fonts.test.d.ts.map +0 -1
- package/build/routes/__tests__/health.test.d.ts.map +0 -1
- package/build/routes/__tests__/imagery.test.d.ts.map +0 -1
- package/build/routes/__tests__/memory.fs.d.ts.map +0 -1
- package/build/routes/__tests__/preview.index.test.d.ts.map +0 -1
- package/build/routes/__tests__/sprites.test.d.ts.map +0 -1
- package/build/routes/__tests__/tile.json.test.d.ts.map +0 -1
- package/build/routes/__tests__/tile.style.json.test.d.ts.map +0 -1
- package/build/routes/__tests__/wmts.test.d.ts.map +0 -1
- package/build/routes/__tests__/xyz.test.d.ts.map +0 -1
- package/build/routes/attribution.d.ts.map +0 -1
- package/build/routes/config.d.ts.map +0 -1
- package/build/routes/fonts.d.ts.map +0 -1
- package/build/routes/health.d.ts.map +0 -1
- package/build/routes/imagery.d.ts.map +0 -1
- package/build/routes/ping.d.ts.map +0 -1
- package/build/routes/preview.d.ts.map +0 -1
- package/build/routes/preview.index.d.ts.map +0 -1
- package/build/routes/sprites.d.ts.map +0 -1
- package/build/routes/tile.json.d.ts.map +0 -1
- package/build/routes/tile.style.json.d.ts.map +0 -1
- package/build/routes/tile.wmts.d.ts.map +0 -1
- package/build/routes/tile.xyz.d.ts.map +0 -1
- package/build/routes/tile.xyz.raster.d.ts.map +0 -1
- package/build/routes/tile.xyz.vector.d.ts.map +0 -1
- package/build/routes/version.d.ts.map +0 -1
- package/build/util/__test__/config.loader.test.d.ts.map +0 -1
- package/build/util/__test__/filter.test.d.ts.map +0 -1
- package/build/util/__test__/validate.test.d.ts.map +0 -1
- package/build/util/assets.provider.d.ts.map +0 -1
- package/build/util/config.cache.d.ts.map +0 -1
- package/build/util/config.loader.d.ts.map +0 -1
- package/build/util/cotar.serve.d.ts.map +0 -1
- package/build/util/etag.d.ts.map +0 -1
- package/build/util/filter.d.ts.map +0 -1
- package/build/util/response.d.ts.map +0 -1
- package/build/util/source.cache.d.ts.map +0 -1
- package/build/util/source.tracer.d.ts +0 -18
- package/build/util/source.tracer.d.ts.map +0 -1
- package/build/util/source.tracer.js +0 -26
- package/build/util/source.tracer.js.map +0 -1
- package/build/util/swapping.lru.d.ts.map +0 -1
- package/build/util/validate.d.ts.map +0 -1
- package/build/wmts.capability.d.ts.map +0 -1
- package/src/util/source.tracer.ts +0 -38
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import { describe, it } from 'node:test';
|
|
3
|
+
|
|
1
4
|
import { ConfigImagery } from '@basemaps/config';
|
|
2
|
-
import { GoogleTms,
|
|
5
|
+
import { GoogleTms, Nztm2000QuadTms } from '@basemaps/geo';
|
|
3
6
|
import { V, VNodeElement } from '@basemaps/shared';
|
|
4
7
|
import { roundNumbersInString } from '@basemaps/test/build/rounding.js';
|
|
5
|
-
|
|
8
|
+
|
|
6
9
|
import { WmtsCapabilities } from '../wmts.capability.js';
|
|
7
10
|
import { Imagery2193, Imagery3857, Provider, TileSetAerial } from './config.data.js';
|
|
8
11
|
|
|
@@ -14,14 +17,14 @@ function listTag(node: VNodeElement | null | undefined, tag: string): string[] {
|
|
|
14
17
|
return tags(node, tag).map((n) => n.toString());
|
|
15
18
|
}
|
|
16
19
|
|
|
17
|
-
|
|
20
|
+
describe('WmtsCapabilities', () => {
|
|
18
21
|
const apiKey = 'secret1234';
|
|
19
22
|
|
|
20
23
|
const allImagery = new Map();
|
|
21
24
|
allImagery.set(Imagery2193.id, Imagery2193);
|
|
22
25
|
allImagery.set(Imagery3857.id, Imagery3857);
|
|
23
26
|
|
|
24
|
-
|
|
27
|
+
it('should output the requested formats', () => {
|
|
25
28
|
const wmts = new WmtsCapabilities({
|
|
26
29
|
httpBase: 'https://basemaps.test',
|
|
27
30
|
apiKey,
|
|
@@ -29,20 +32,21 @@ o.spec('WmtsCapabilities', () => {
|
|
|
29
32
|
|
|
30
33
|
wmts.addTileMatrix(GoogleTms);
|
|
31
34
|
for (const im of allImagery.values()) wmts.addImagery(im);
|
|
32
|
-
wmts.addFormats(
|
|
35
|
+
wmts.addFormats('avif');
|
|
33
36
|
wmts.addProvider(Provider);
|
|
34
37
|
wmts.addTileSet(TileSetAerial);
|
|
35
38
|
const wmtsCapability = wmts.toVNode();
|
|
36
39
|
|
|
37
40
|
const urls = tags(wmtsCapability, 'ResourceURL');
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
assert.equal(urls.length, 1);
|
|
42
|
+
assert.equal(urls[0].attrs['format'], 'image/avif');
|
|
43
|
+
assert.equal(
|
|
44
|
+
urls[0].attrs['template'],
|
|
41
45
|
'https://basemaps.test/v1/tiles/aerial/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.avif?api=secret1234',
|
|
42
46
|
);
|
|
43
47
|
});
|
|
44
48
|
|
|
45
|
-
|
|
49
|
+
it('should include config location', () => {
|
|
46
50
|
const wmts = new WmtsCapabilities({
|
|
47
51
|
httpBase: 'https://basemaps.test',
|
|
48
52
|
apiKey,
|
|
@@ -51,20 +55,21 @@ o.spec('WmtsCapabilities', () => {
|
|
|
51
55
|
|
|
52
56
|
wmts.addTileMatrix(GoogleTms);
|
|
53
57
|
for (const im of allImagery.values()) wmts.addImagery(im);
|
|
54
|
-
wmts.addFormats(
|
|
58
|
+
wmts.addFormats('avif');
|
|
55
59
|
wmts.addProvider(Provider);
|
|
56
60
|
wmts.addTileSet(TileSetAerial);
|
|
57
61
|
const wmtsCapability = wmts.toVNode();
|
|
58
62
|
|
|
59
63
|
const urls = tags(wmtsCapability, 'ResourceURL');
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
assert.equal(urls.length, 1);
|
|
65
|
+
assert.equal(urls[0].attrs['format'], 'image/avif');
|
|
66
|
+
assert.equal(
|
|
67
|
+
urls[0].attrs['template'],
|
|
63
68
|
'https://basemaps.test/v1/tiles/aerial/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.avif?api=secret1234&config=s3%3A%2F%2Flinz-basemaps%2Fconfig.json',
|
|
64
69
|
);
|
|
65
70
|
});
|
|
66
71
|
|
|
67
|
-
|
|
72
|
+
it('should be adding encoding to utf-8', () => {
|
|
68
73
|
const wmts = new WmtsCapabilities({
|
|
69
74
|
httpBase: 'https://basemaps.test',
|
|
70
75
|
apiKey,
|
|
@@ -75,14 +80,14 @@ o.spec('WmtsCapabilities', () => {
|
|
|
75
80
|
tileMatrix: [GoogleTms],
|
|
76
81
|
tileSet: TileSetAerial,
|
|
77
82
|
imagery: allImagery,
|
|
78
|
-
formats: [
|
|
83
|
+
formats: ['avif'],
|
|
79
84
|
});
|
|
80
85
|
const xml = wmts.toXml();
|
|
81
86
|
|
|
82
|
-
|
|
87
|
+
assert.deepEqual(xml.split('\n')[0], '<?xml version="1.0" encoding="utf-8"?>');
|
|
83
88
|
});
|
|
84
89
|
|
|
85
|
-
|
|
90
|
+
it('should support unicorns and rainbows', () => {
|
|
86
91
|
const tileSet = { ...TileSetAerial };
|
|
87
92
|
tileSet.name = '🦄_🌈_2022_0-5m';
|
|
88
93
|
tileSet.title = '🦄 🌈 Imagery (2022)';
|
|
@@ -95,30 +100,31 @@ o.spec('WmtsCapabilities', () => {
|
|
|
95
100
|
|
|
96
101
|
wmts.addTileMatrix(GoogleTms);
|
|
97
102
|
for (const im of allImagery.values()) wmts.addImagery(im);
|
|
98
|
-
wmts.addFormats(
|
|
103
|
+
wmts.addFormats('avif');
|
|
99
104
|
wmts.addProvider(Provider);
|
|
100
105
|
wmts.addTileSet(tileSet);
|
|
101
106
|
const wmtsCapability = wmts.toVNode();
|
|
102
107
|
|
|
103
108
|
const urls = tags(wmtsCapability, 'ResourceURL');
|
|
104
|
-
|
|
105
|
-
|
|
109
|
+
assert.equal(urls.length, 1);
|
|
110
|
+
assert.equal(
|
|
111
|
+
urls[0].attrs['template'],
|
|
106
112
|
'https://basemaps.test/v1/tiles/🦄-🌈-2022-0.5m/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.avif?api=secret1234',
|
|
107
113
|
);
|
|
108
114
|
|
|
109
115
|
const layer = tags(wmtsCapability, 'Layer')[0];
|
|
110
116
|
|
|
111
117
|
const title = layer.find('ows:Title')?.toString();
|
|
112
|
-
|
|
118
|
+
assert.equal(title, '<ows:Title>🦄 🌈 Imagery (2022)</ows:Title>');
|
|
113
119
|
|
|
114
120
|
const abstract = layer.find('ows:Abstract')?.toString();
|
|
115
|
-
|
|
121
|
+
assert.equal(abstract, '<ows:Abstract>🦄 🌈 Description</ows:Abstract>');
|
|
116
122
|
|
|
117
123
|
const identifier = layer.find('ows:Identifier')?.toString();
|
|
118
|
-
|
|
124
|
+
assert.equal(identifier, '<ows:Identifier>🦄-🌈-2022-0.5m</ows:Identifier>');
|
|
119
125
|
});
|
|
120
126
|
|
|
121
|
-
|
|
127
|
+
it('should sort the sub imagery layers', () => {
|
|
122
128
|
const imageryA = { ...Imagery3857 };
|
|
123
129
|
imageryA.id = 'im_a';
|
|
124
130
|
imageryA.name = 'aaaa';
|
|
@@ -157,10 +163,10 @@ o.spec('WmtsCapabilities', () => {
|
|
|
157
163
|
const layers = tags(wmtsCapability, 'Layer').map((c) => c.find('ows:Title')?.textContent);
|
|
158
164
|
|
|
159
165
|
// The base layer "Aerial Imagery" should always be first then all sub layers after
|
|
160
|
-
|
|
166
|
+
assert.deepEqual(layers, ['Aerial Imagery', 'aaaa', 'bbbb', 'Ōtorohanga 0.1m Urban Aerial Photos (2021)']);
|
|
161
167
|
});
|
|
162
168
|
|
|
163
|
-
|
|
169
|
+
it('should build capability xml for tileSet and projection', () => {
|
|
164
170
|
const imagery = new Map();
|
|
165
171
|
imagery.set(Imagery3857.id, Imagery3857);
|
|
166
172
|
|
|
@@ -177,45 +183,53 @@ o.spec('WmtsCapabilities', () => {
|
|
|
177
183
|
const raw = wmts.toVNode();
|
|
178
184
|
const serviceId = raw.find('ows:ServiceIdentification');
|
|
179
185
|
|
|
180
|
-
|
|
181
|
-
|
|
186
|
+
assert.equal(serviceId?.find('ows:Abstract')?.textContent, 'the description');
|
|
187
|
+
assert.equal(serviceId?.find('ows:Title')?.textContent, 'the title');
|
|
182
188
|
|
|
183
|
-
|
|
189
|
+
assert.deepEqual(
|
|
190
|
+
raw.find('TileMatrixSetLink')?.toString(),
|
|
184
191
|
V('TileMatrixSetLink', [V('TileMatrixSet', 'WebMercatorQuad')]).toString(),
|
|
185
192
|
);
|
|
186
193
|
|
|
187
194
|
const layer = raw.find('Contents', 'Layer');
|
|
188
195
|
|
|
189
|
-
|
|
196
|
+
assert.deepEqual(listTag(layer, 'Format'), [
|
|
190
197
|
V('Format', 'image/jpeg').toString(),
|
|
191
198
|
V('Format', 'image/webp').toString(),
|
|
192
199
|
V('Format', 'image/png').toString(),
|
|
193
200
|
]);
|
|
194
201
|
|
|
195
|
-
|
|
196
|
-
'
|
|
197
|
-
|
|
198
|
-
'
|
|
199
|
-
|
|
200
|
-
|
|
202
|
+
assert.deepEqual(
|
|
203
|
+
listTag(layer, 'ows:BoundingBox').map((s) => roundNumbersInString(s, 4)),
|
|
204
|
+
[
|
|
205
|
+
'<ows:BoundingBox crs="urn:ogc:def:crs:EPSG::3857">\n' +
|
|
206
|
+
' <ows:LowerCorner>19457809.9203 -4609458.5537</ows:LowerCorner>\n' +
|
|
207
|
+
' <ows:UpperCorner>19509787.0995 -4578883.7424</ows:UpperCorner>\n' +
|
|
208
|
+
'</ows:BoundingBox>',
|
|
209
|
+
],
|
|
210
|
+
);
|
|
201
211
|
|
|
202
|
-
|
|
203
|
-
'
|
|
204
|
-
|
|
205
|
-
'
|
|
206
|
-
|
|
207
|
-
|
|
212
|
+
assert.deepEqual(
|
|
213
|
+
listTag(layer, 'ows:WGS84BoundingBox').map((s) => roundNumbersInString(s, 4)),
|
|
214
|
+
[
|
|
215
|
+
'<ows:WGS84BoundingBox crs="urn:ogc:def:crs:OGC:2:84">\n' +
|
|
216
|
+
' <ows:LowerCorner>174.7925 -38.2123</ows:LowerCorner>\n' +
|
|
217
|
+
' <ows:UpperCorner>175.2594 -37.9962</ows:UpperCorner>\n' +
|
|
218
|
+
'</ows:WGS84BoundingBox>',
|
|
219
|
+
],
|
|
220
|
+
);
|
|
208
221
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
222
|
+
assert.equal(layer?.find('ows:Identifier')?.textContent, 'aerial');
|
|
223
|
+
assert.equal(layer?.find('ows:Title')?.textContent, 'Aerial Imagery');
|
|
224
|
+
assert.equal(layer?.find('ows:Abstract')?.textContent, 'aerial__description');
|
|
212
225
|
|
|
213
|
-
|
|
226
|
+
assert.equal(
|
|
227
|
+
layer?.find('Style')?.toString(),
|
|
214
228
|
V('Style', { isDefault: 'true' }, [V('ows:Title', 'Default Style'), V('ows:Identifier', 'default')]).toString(),
|
|
215
229
|
);
|
|
216
230
|
});
|
|
217
231
|
|
|
218
|
-
|
|
232
|
+
it('should include output the correct TileMatrix', () => {
|
|
219
233
|
const wmts = new WmtsCapabilities({
|
|
220
234
|
httpBase: 'https://basemaps.test',
|
|
221
235
|
apiKey,
|
|
@@ -229,39 +243,41 @@ o.spec('WmtsCapabilities', () => {
|
|
|
229
243
|
|
|
230
244
|
const layer = raw.find('Contents', 'Layer');
|
|
231
245
|
|
|
232
|
-
|
|
246
|
+
assert.equal(layer?.find('TileMatrixSetLink', 'TileMatrixSet')?.textContent, 'WebMercatorQuad');
|
|
233
247
|
|
|
234
248
|
const matrix = tags(raw, 'TileMatrixSet')[1];
|
|
235
249
|
const matrixId = raw?.find('Contents', 'TileMatrixSet', 'ows:Identifier') ?? null;
|
|
236
|
-
|
|
237
|
-
|
|
250
|
+
assert.equal(matrix.find('ows:Identifier'), matrixId);
|
|
251
|
+
assert.equal(matrixId?.textContent, 'WebMercatorQuad');
|
|
238
252
|
|
|
239
|
-
|
|
240
|
-
|
|
253
|
+
assert.deepEqual(matrix.find('ows:SupportedCRS')?.textContent, 'urn:ogc:def:crs:EPSG::3857');
|
|
254
|
+
assert.deepEqual(
|
|
255
|
+
matrix.find('WellKnownScaleSet')?.textContent,
|
|
241
256
|
'https://www.opengis.net/def/wkss/OGC/1.0/GoogleMapsCompatible',
|
|
242
257
|
);
|
|
243
258
|
|
|
244
259
|
const tileMatrices = Array.from(matrix.tags('TileMatrix'));
|
|
245
260
|
|
|
246
|
-
|
|
261
|
+
assert.equal(tileMatrices.length, 25);
|
|
247
262
|
|
|
248
263
|
function compareMatrix(x: VNodeElement, id: string, tileCount: number, scale: number): void {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
264
|
+
assert.equal(x.find('ows:Identifier')?.toString(), `<ows:Identifier>${id}</ows:Identifier>`);
|
|
265
|
+
assert.equal(x.find('ScaleDenominator')?.toString(), `<ScaleDenominator>${scale}</ScaleDenominator>`);
|
|
266
|
+
assert.equal(
|
|
267
|
+
x.find('TopLeftCorner')?.toString(),
|
|
252
268
|
`<TopLeftCorner>-20037508.3427892 20037508.3427892</TopLeftCorner>`,
|
|
253
269
|
);
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
270
|
+
assert.equal(x.find('TileWidth')?.toString(), `<TileWidth>256</TileWidth>`);
|
|
271
|
+
assert.equal(x.find('TileHeight')?.toString(), `<TileHeight>256</TileHeight>`);
|
|
272
|
+
assert.equal(x.find('MatrixWidth')?.toString(), `<MatrixWidth>${tileCount}</MatrixWidth>`);
|
|
273
|
+
assert.equal(x.find('MatrixHeight')?.toString(), `<MatrixHeight>${tileCount}</MatrixHeight>`);
|
|
258
274
|
}
|
|
259
275
|
|
|
260
276
|
compareMatrix(tileMatrices[0], '0', 1, 559082264.028717);
|
|
261
277
|
compareMatrix(tileMatrices[10], '10', 1024, 545978.773465544);
|
|
262
278
|
});
|
|
263
279
|
|
|
264
|
-
|
|
280
|
+
it('should output individual imagery adds', () => {
|
|
265
281
|
const imagery = new Map<string, ConfigImagery>();
|
|
266
282
|
imagery.set(Imagery3857.id, Imagery3857);
|
|
267
283
|
imagery.set(Imagery2193.id, Imagery2193);
|
|
@@ -276,37 +292,39 @@ o.spec('WmtsCapabilities', () => {
|
|
|
276
292
|
tileSet: TileSetAerial,
|
|
277
293
|
imagery,
|
|
278
294
|
layers: TileSetAerial.layers,
|
|
279
|
-
formats: [
|
|
295
|
+
formats: ['png'],
|
|
280
296
|
});
|
|
281
297
|
|
|
282
298
|
const raw = wmts.toVNode();
|
|
283
299
|
|
|
284
300
|
const tms = raw?.find('TileMatrixSet', 'ows:Identifier');
|
|
285
301
|
|
|
286
|
-
|
|
302
|
+
assert.equal(tms?.textContent, 'WebMercatorQuad');
|
|
287
303
|
|
|
288
304
|
const urls = Array.from(raw ? raw.tags('ResourceURL') : []);
|
|
289
|
-
|
|
290
|
-
|
|
305
|
+
assert.equal(urls.length, 2);
|
|
306
|
+
assert.deepEqual(
|
|
307
|
+
urls[0].toString(),
|
|
291
308
|
'<ResourceURL format="image/png" resourceType="tile" ' +
|
|
292
309
|
'template="https://basemaps.test/v1/tiles/aerial/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.png" />',
|
|
293
310
|
);
|
|
294
|
-
|
|
311
|
+
assert.deepEqual(
|
|
312
|
+
urls[1].toString(),
|
|
295
313
|
'<ResourceURL format="image/png" resourceType="tile" ' +
|
|
296
314
|
'template="https://basemaps.test/v1/tiles/ōtorohanga-urban-2021-0.1m/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.png" />',
|
|
297
315
|
);
|
|
298
316
|
|
|
299
317
|
const layers = [...raw.tags('Layer')];
|
|
300
318
|
|
|
301
|
-
|
|
302
|
-
|
|
319
|
+
assert.equal(layers.length, 2);
|
|
320
|
+
assert.equal(layers[0].find('ows:Title')?.textContent, 'Aerial Imagery');
|
|
303
321
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
322
|
+
assert.equal(layers[1].find('ows:Title')?.textContent, 'Ōtorohanga 0.1m Urban Aerial Photos (2021)');
|
|
323
|
+
assert.equal(layers[1].find('ows:Identifier')?.textContent, 'ōtorohanga-urban-2021-0.1m');
|
|
324
|
+
assert.equal(layers[1].find('ows:Keywords', 'ows:Keyword')?.textContent, 'Urban Aerial Photos');
|
|
307
325
|
});
|
|
308
326
|
|
|
309
|
-
|
|
327
|
+
it('should support multiple projections', () => {
|
|
310
328
|
const imagery = new Map<string, ConfigImagery>();
|
|
311
329
|
imagery.set(Imagery3857.id, Imagery3857);
|
|
312
330
|
imagery.set(Imagery2193.id, Imagery2193);
|
|
@@ -320,16 +338,16 @@ o.spec('WmtsCapabilities', () => {
|
|
|
320
338
|
tileMatrix: [GoogleTms, Nztm2000QuadTms],
|
|
321
339
|
tileSet: TileSetAerial,
|
|
322
340
|
imagery: imagery,
|
|
323
|
-
formats: [
|
|
341
|
+
formats: ['png'],
|
|
324
342
|
});
|
|
325
343
|
|
|
326
344
|
const raw = wmts.toVNode();
|
|
327
345
|
const layers = tags(raw, 'Layer');
|
|
328
|
-
|
|
346
|
+
assert.equal(layers.length, 1);
|
|
329
347
|
const layer = layers[0];
|
|
330
348
|
|
|
331
349
|
// ensure order is valid
|
|
332
|
-
|
|
350
|
+
assert.deepEqual(layer?.children.map((c) => (c instanceof VNodeElement ? c.tag : null)), [
|
|
333
351
|
'ows:Title',
|
|
334
352
|
'ows:Abstract',
|
|
335
353
|
'ows:Identifier',
|
|
@@ -344,37 +362,38 @@ o.spec('WmtsCapabilities', () => {
|
|
|
344
362
|
'ResourceURL',
|
|
345
363
|
]);
|
|
346
364
|
|
|
347
|
-
|
|
348
|
-
|
|
365
|
+
assert.equal(layer.find('ows:Title')?.textContent, 'Aerial Imagery');
|
|
366
|
+
assert.equal(
|
|
367
|
+
layer.find('ows:Keywords')?.toString(),
|
|
349
368
|
'<ows:Keywords>\n <ows:Keyword>Basemap</ows:Keyword>\n</ows:Keywords>',
|
|
350
369
|
);
|
|
351
|
-
|
|
370
|
+
assert.equal(layer.find('ows:Identifier')?.textContent, 'aerial');
|
|
352
371
|
|
|
353
372
|
const adds = tags(layer, 'TileMatrixSet');
|
|
354
373
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
374
|
+
assert.equal(adds.length, 2);
|
|
375
|
+
assert.equal(adds[0].toString(), '<TileMatrixSet>WebMercatorQuad</TileMatrixSet>');
|
|
376
|
+
assert.equal(adds[1].toString(), '<TileMatrixSet>NZTM2000Quad</TileMatrixSet>');
|
|
358
377
|
|
|
359
378
|
const boundingBoxes = tags(layer, 'ows:BoundingBox');
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
'19509787.0995 -4578883.7424',
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
'5793264.8304 1798321.5516',
|
|
370
|
-
|
|
379
|
+
assert.equal(boundingBoxes.length, 2);
|
|
380
|
+
assert.equal(boundingBoxes[0].attrs['crs'], 'urn:ogc:def:crs:EPSG::3857');
|
|
381
|
+
assert.deepEqual(
|
|
382
|
+
boundingBoxes[0].children.map((c) => c.textContent),
|
|
383
|
+
['19457809.9203 -4609458.5537', '19509787.0995 -4578883.7424'],
|
|
384
|
+
);
|
|
385
|
+
assert.equal(boundingBoxes[1].attrs['crs'], 'urn:ogc:def:crs:EPSG::2193');
|
|
386
|
+
assert.deepEqual(
|
|
387
|
+
boundingBoxes[1].children.map((c) => c.textContent),
|
|
388
|
+
['5766358.9964 1757351.3045', '5793264.8304 1798321.5516'],
|
|
389
|
+
);
|
|
371
390
|
|
|
372
391
|
const wgs84 = layer.find('ows:WGS84BoundingBox');
|
|
373
|
-
|
|
374
|
-
|
|
392
|
+
assert.equal(wgs84?.attrs['crs'], 'urn:ogc:def:crs:OGC:2:84');
|
|
393
|
+
assert.deepEqual(wgs84?.children.map((c) => c.textContent), ['174.79248 -38.212288', '175.259399 -37.996163']);
|
|
375
394
|
});
|
|
376
395
|
|
|
377
|
-
|
|
396
|
+
it('should only output imagery if exists', () => {
|
|
378
397
|
const imagery = new Map<string, ConfigImagery>();
|
|
379
398
|
const wmtsA = new WmtsCapabilities({
|
|
380
399
|
httpBase: 'https://basemaps.test',
|
|
@@ -385,14 +404,14 @@ o.spec('WmtsCapabilities', () => {
|
|
|
385
404
|
tileMatrix: [Nztm2000QuadTms],
|
|
386
405
|
tileSet: TileSetAerial,
|
|
387
406
|
imagery: imagery,
|
|
388
|
-
formats: [
|
|
407
|
+
formats: ['png'],
|
|
389
408
|
layers: TileSetAerial.layers,
|
|
390
409
|
});
|
|
391
410
|
|
|
392
411
|
const rawA = wmtsA.toVNode();
|
|
393
412
|
|
|
394
413
|
const layers = tags(rawA, 'Layer');
|
|
395
|
-
|
|
414
|
+
assert.equal(layers.length, 1);
|
|
396
415
|
|
|
397
416
|
imagery.set(Imagery3857.id, Imagery3857);
|
|
398
417
|
const wmtsB = new WmtsCapabilities({
|
|
@@ -403,16 +422,16 @@ o.spec('WmtsCapabilities', () => {
|
|
|
403
422
|
tileMatrix: [Nztm2000QuadTms],
|
|
404
423
|
tileSet: TileSetAerial,
|
|
405
424
|
imagery: imagery,
|
|
406
|
-
formats: [
|
|
425
|
+
formats: ['png'],
|
|
407
426
|
layers: TileSetAerial.layers,
|
|
408
427
|
});
|
|
409
428
|
|
|
410
429
|
const rawB = wmtsB.toVNode();
|
|
411
430
|
const layersB = tags(rawB, 'Layer');
|
|
412
|
-
|
|
431
|
+
assert.equal(layersB.length, 1);
|
|
413
432
|
});
|
|
414
433
|
|
|
415
|
-
|
|
434
|
+
it('should cover the entire WebMercatorBounds', () => {
|
|
416
435
|
const halfSize = GoogleTms.extent.width / 2;
|
|
417
436
|
// Create two fake imagery adds one covers tile z1 x0 y0 another covers tile z1 x1 y1
|
|
418
437
|
// so the entire bounding box should be tile z0 x0 y0 or the full extent
|
|
@@ -439,7 +458,7 @@ o.spec('WmtsCapabilities', () => {
|
|
|
439
458
|
tileMatrix: [GoogleTms],
|
|
440
459
|
tileSet,
|
|
441
460
|
imagery,
|
|
442
|
-
formats: [
|
|
461
|
+
formats: ['png'],
|
|
443
462
|
layers: tileSet.layers,
|
|
444
463
|
});
|
|
445
464
|
|
|
@@ -451,17 +470,17 @@ o.spec('WmtsCapabilities', () => {
|
|
|
451
470
|
.split('\n')
|
|
452
471
|
.map((c) => c.trim()),
|
|
453
472
|
);
|
|
454
|
-
|
|
455
|
-
|
|
473
|
+
assert.deepEqual(boundingBox[0][1], '<ows:LowerCorner>-180 -85.051129</ows:LowerCorner>');
|
|
474
|
+
assert.equal(boundingBox[0][2], '<ows:UpperCorner>180 85.051129</ows:UpperCorner>');
|
|
456
475
|
|
|
457
|
-
|
|
458
|
-
|
|
476
|
+
assert.deepEqual(boundingBox[1][1], '<ows:LowerCorner>-180 0</ows:LowerCorner>');
|
|
477
|
+
assert.equal(boundingBox[1][2], '<ows:UpperCorner>0 85.051129</ows:UpperCorner>');
|
|
459
478
|
|
|
460
|
-
|
|
461
|
-
|
|
479
|
+
assert.deepEqual(boundingBox[2][1], '<ows:LowerCorner>0 -85.051129</ows:LowerCorner>');
|
|
480
|
+
assert.equal(boundingBox[2][2], '<ows:UpperCorner>180 0</ows:UpperCorner>');
|
|
462
481
|
});
|
|
463
482
|
|
|
464
|
-
|
|
483
|
+
it('should work when crossing anti meridian', () => {
|
|
465
484
|
const halfSize = GoogleTms.extent.width / 2;
|
|
466
485
|
|
|
467
486
|
const imagery = new Map();
|
|
@@ -482,7 +501,7 @@ o.spec('WmtsCapabilities', () => {
|
|
|
482
501
|
tileMatrix: [GoogleTms],
|
|
483
502
|
tileSet,
|
|
484
503
|
imagery,
|
|
485
|
-
formats: [
|
|
504
|
+
formats: ['png'],
|
|
486
505
|
layers: tileSet.layers,
|
|
487
506
|
});
|
|
488
507
|
|
|
@@ -493,28 +512,28 @@ o.spec('WmtsCapabilities', () => {
|
|
|
493
512
|
.split('\n')
|
|
494
513
|
.map((c) => c.trim()),
|
|
495
514
|
);
|
|
496
|
-
|
|
497
|
-
|
|
515
|
+
assert.deepEqual(boundingBox[0][1], '<ows:LowerCorner>-180 -85.0511</ows:LowerCorner>');
|
|
516
|
+
assert.equal(boundingBox[0][2], '<ows:UpperCorner>180 0</ows:UpperCorner>');
|
|
498
517
|
|
|
499
|
-
|
|
500
|
-
|
|
518
|
+
assert.deepEqual(boundingBox[1][1], '<ows:LowerCorner>-180 -85.0511</ows:LowerCorner>');
|
|
519
|
+
assert.equal(boundingBox[1][2], '<ows:UpperCorner>180 0</ows:UpperCorner>');
|
|
501
520
|
});
|
|
502
521
|
|
|
503
|
-
|
|
522
|
+
it('should work with NZTM2000Quad', () => {
|
|
504
523
|
const wmts = new WmtsCapabilities({ tileMatrix: [] } as any);
|
|
505
524
|
|
|
506
525
|
// Full NZTM200Quad coverage
|
|
507
526
|
const bbox = wmts.buildWgs84BoundingBox(Nztm2000QuadTms, []);
|
|
508
|
-
|
|
509
|
-
|
|
527
|
+
assert.equal(bbox.children[0].textContent, '-180 -49.929855');
|
|
528
|
+
assert.equal(bbox.children[1].textContent, '180 2.938603');
|
|
510
529
|
|
|
511
530
|
// Full NZTM200Quad coverage at z1
|
|
512
531
|
const bboxB = wmts.buildWgs84BoundingBox(Nztm2000QuadTms, [
|
|
513
532
|
Nztm2000QuadTms.tileToSourceBounds({ z: 1, x: 0, y: 0 }),
|
|
514
533
|
Nztm2000QuadTms.tileToSourceBounds({ z: 1, x: 1, y: 1 }),
|
|
515
534
|
]);
|
|
516
|
-
|
|
517
|
-
|
|
535
|
+
assert.equal(bboxB.children[0].textContent, '-180 -49.929855');
|
|
536
|
+
assert.equal(bboxB.children[1].textContent, '180 2.938603');
|
|
518
537
|
|
|
519
538
|
// Full NZTM200Quad coverage at z5
|
|
520
539
|
const tileCount = Nztm2000QuadTms.zooms[5].matrixWidth;
|
|
@@ -522,7 +541,7 @@ o.spec('WmtsCapabilities', () => {
|
|
|
522
541
|
Nztm2000QuadTms.tileToSourceBounds({ z: 5, x: 0, y: 0 }),
|
|
523
542
|
Nztm2000QuadTms.tileToSourceBounds({ z: 5, x: tileCount - 1, y: tileCount - 1 }),
|
|
524
543
|
]);
|
|
525
|
-
|
|
526
|
-
|
|
544
|
+
assert.equal(bboxC.children[0].textContent, '-180 -49.929855');
|
|
545
|
+
assert.equal(bboxC.children[1].textContent, '180 2.938603');
|
|
527
546
|
});
|
|
528
547
|
});
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { ConfigProviderMemory } from '@basemaps/config';
|
|
2
|
-
import { initConfigFromUrls } from '@basemaps/config
|
|
3
|
-
import {
|
|
4
|
-
import { LogConfig, setDefaultConfig } from '@basemaps/shared';
|
|
5
|
-
import { fsa } from '@chunkd/fs';
|
|
2
|
+
import { initConfigFromUrls } from '@basemaps/config-loader';
|
|
3
|
+
import { TileMatrixSet, TileMatrixSets } from '@basemaps/geo';
|
|
4
|
+
import { fsa, LogConfig, setDefaultConfig } from '@basemaps/shared';
|
|
6
5
|
import { LambdaHttpRequest, LambdaUrlRequest, UrlEvent } from '@linzjs/lambda';
|
|
7
6
|
import { Context } from 'aws-lambda';
|
|
8
|
-
|
|
7
|
+
|
|
9
8
|
import { renderPreview } from '../routes/preview.js';
|
|
10
9
|
|
|
11
|
-
const target =
|
|
10
|
+
const target = fsa.toUrl(`/home/blacha/tmp/basemaps/bm-724/test-north-island_20230220_10m/`);
|
|
12
11
|
const location = { lat: -39.0852555, lon: 177.3998405 };
|
|
13
12
|
const z = 12;
|
|
14
13
|
|
|
15
|
-
const outputFormat =
|
|
14
|
+
const outputFormat = 'webp';
|
|
16
15
|
let tileMatrix: TileMatrixSet | null = null;
|
|
17
16
|
|
|
18
17
|
async function main(): Promise<void> {
|
|
@@ -35,8 +34,14 @@ async function main(): Promise<void> {
|
|
|
35
34
|
if (tileMatrix == null) throw new Error('No tileMatrix found');
|
|
36
35
|
|
|
37
36
|
const req = new LambdaUrlRequest({ headers: {} } as UrlEvent, {} as Context, LogConfig.get()) as LambdaHttpRequest;
|
|
38
|
-
const res = await renderPreview(req, {
|
|
39
|
-
|
|
37
|
+
const res = await renderPreview(req, {
|
|
38
|
+
tileMatrix,
|
|
39
|
+
tileSet,
|
|
40
|
+
location,
|
|
41
|
+
z,
|
|
42
|
+
output: { title: outputFormat, format: [outputFormat], name: 'rgba' },
|
|
43
|
+
});
|
|
44
|
+
const previewFile = fsa.toUrl(`./z${z}_${location.lon}_${location.lat}.${outputFormat}`);
|
|
40
45
|
await fsa.write(previewFile, Buffer.from(res.body, 'base64'));
|
|
41
46
|
log.info({ path: previewFile }, 'Tile:Write');
|
|
42
47
|
}
|