@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,31 +1,34 @@
|
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import { afterEach, before, beforeEach, describe, it } from 'node:test';
|
|
3
|
+
|
|
1
4
|
import { ConfigProviderMemory, StyleJson } from '@basemaps/config';
|
|
2
5
|
import { Env } from '@basemaps/shared';
|
|
3
|
-
import o from 'ospec';
|
|
4
6
|
import { createSandbox } from 'sinon';
|
|
5
|
-
|
|
6
|
-
import { ConfigLoader } from '../../util/config.loader.js';
|
|
7
|
+
|
|
7
8
|
import { FakeData } from '../../__tests__/config.data.js';
|
|
8
9
|
import { Api, mockRequest, mockUrlRequest } from '../../__tests__/xyz.util.js';
|
|
10
|
+
import { handler } from '../../index.js';
|
|
11
|
+
import { ConfigLoader } from '../../util/config.loader.js';
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
describe('/v1/styles', () => {
|
|
11
14
|
const host = 'https://tiles.test';
|
|
12
15
|
const config = new ConfigProviderMemory();
|
|
13
16
|
const sandbox = createSandbox();
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
before(() => {
|
|
16
19
|
process.env[Env.PublicUrlBase] = host;
|
|
17
20
|
});
|
|
18
|
-
|
|
21
|
+
beforeEach(() => {
|
|
19
22
|
sandbox.stub(ConfigLoader, 'getDefaultConfig').resolves(config);
|
|
20
23
|
});
|
|
21
|
-
|
|
24
|
+
afterEach(() => {
|
|
22
25
|
sandbox.restore();
|
|
23
26
|
config.objects.clear();
|
|
24
27
|
});
|
|
25
|
-
|
|
28
|
+
it('should not found style json', async () => {
|
|
26
29
|
const request = mockRequest('/v1/tiles/topographic/Google/style/topographic.json', 'get', Api.header);
|
|
27
30
|
const res = await handler.router.handle(request);
|
|
28
|
-
|
|
31
|
+
assert.equal(res.status, 404);
|
|
29
32
|
});
|
|
30
33
|
|
|
31
34
|
const fakeStyle: StyleJson = {
|
|
@@ -100,26 +103,26 @@ o.spec('/v1/styles', () => {
|
|
|
100
103
|
style: fakeStyle,
|
|
101
104
|
};
|
|
102
105
|
|
|
103
|
-
|
|
106
|
+
it('should serve style json', async () => {
|
|
104
107
|
config.put(fakeRecord);
|
|
105
108
|
|
|
106
109
|
const request = mockRequest('/v1/tiles/topographic/Google/style/topographic.json', 'get', Api.header);
|
|
107
110
|
|
|
108
111
|
const res = await handler.router.handle(request);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
+
assert.equal(res.status, 200, res.statusDescription);
|
|
113
|
+
assert.equal(res.header('content-type'), 'application/json');
|
|
114
|
+
assert.equal(res.header('cache-control'), 'no-store');
|
|
112
115
|
|
|
113
116
|
const body = Buffer.from(res.body ?? '', 'base64').toString();
|
|
114
|
-
fakeStyle.sources
|
|
117
|
+
fakeStyle.sources['basemaps_vector'] = {
|
|
115
118
|
type: 'vector',
|
|
116
119
|
url: `${host}/vector?api=${Api.key}`,
|
|
117
120
|
};
|
|
118
|
-
fakeStyle.sources
|
|
121
|
+
fakeStyle.sources['basemaps_raster'] = {
|
|
119
122
|
type: 'raster',
|
|
120
123
|
tiles: [`${host}/raster?api=${Api.key}`],
|
|
121
124
|
};
|
|
122
|
-
fakeStyle.sources
|
|
125
|
+
fakeStyle.sources['basemaps_raster_encode'] = {
|
|
123
126
|
type: 'raster',
|
|
124
127
|
tiles: [`${host}/raster/{z}/{x}/{y}.webp?api=${Api.key}`],
|
|
125
128
|
};
|
|
@@ -127,10 +130,10 @@ o.spec('/v1/styles', () => {
|
|
|
127
130
|
fakeStyle.sprite = `${host}/sprite`;
|
|
128
131
|
fakeStyle.glyphs = `${host}/glyphs`;
|
|
129
132
|
|
|
130
|
-
|
|
133
|
+
assert.deepEqual(JSON.parse(body), fakeStyle);
|
|
131
134
|
});
|
|
132
135
|
|
|
133
|
-
|
|
136
|
+
it('should serve style json with excluded layers', async () => {
|
|
134
137
|
config.put(fakeRecord);
|
|
135
138
|
const request = mockUrlRequest(
|
|
136
139
|
'/v1/tiles/topographic/Google/style/topographic.json',
|
|
@@ -139,20 +142,20 @@ o.spec('/v1/styles', () => {
|
|
|
139
142
|
);
|
|
140
143
|
|
|
141
144
|
const res = await handler.router.handle(request);
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
+
assert.equal(res.status, 200, res.statusDescription);
|
|
146
|
+
assert.equal(res.header('content-type'), 'application/json');
|
|
147
|
+
assert.equal(res.header('cache-control'), 'no-store');
|
|
145
148
|
|
|
146
149
|
const body = Buffer.from(res.body ?? '', 'base64').toString();
|
|
147
|
-
fakeStyle.sources
|
|
150
|
+
fakeStyle.sources['basemaps_vector'] = {
|
|
148
151
|
type: 'vector',
|
|
149
152
|
url: `${host}/vector?api=${Api.key}`,
|
|
150
153
|
};
|
|
151
|
-
fakeStyle.sources
|
|
154
|
+
fakeStyle.sources['basemaps_raster'] = {
|
|
152
155
|
type: 'raster',
|
|
153
156
|
tiles: [`${host}/raster?api=${Api.key}`],
|
|
154
157
|
};
|
|
155
|
-
fakeStyle.sources
|
|
158
|
+
fakeStyle.sources['basemaps_raster_encode'] = {
|
|
156
159
|
type: 'raster',
|
|
157
160
|
tiles: [`${host}/raster/{z}/{x}/{y}.webp?api=${Api.key}`],
|
|
158
161
|
};
|
|
@@ -161,60 +164,60 @@ o.spec('/v1/styles', () => {
|
|
|
161
164
|
fakeStyle.glyphs = `${host}/glyphs`;
|
|
162
165
|
fakeStyle.layers = [fakeStyle.layers[2]];
|
|
163
166
|
|
|
164
|
-
|
|
167
|
+
assert.deepEqual(JSON.parse(body), fakeStyle);
|
|
165
168
|
});
|
|
166
169
|
|
|
167
|
-
|
|
170
|
+
it('should create raster styles', async () => {
|
|
168
171
|
const request = mockUrlRequest('/v1/styles/aerial.json', '', Api.header);
|
|
169
172
|
const tileSet = FakeData.tileSetRaster('aerial');
|
|
170
173
|
config.put(tileSet);
|
|
171
174
|
const res = await handler.router.handle(request);
|
|
172
|
-
|
|
175
|
+
assert.equal(res.status, 200, res.statusDescription);
|
|
173
176
|
|
|
174
177
|
const body = JSON.parse(Buffer.from(res.body, 'base64').toString());
|
|
175
178
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
+
assert.equal(body.version, 8);
|
|
180
|
+
assert.deepEqual(body.sources['basemaps-aerial'].type, 'raster');
|
|
181
|
+
assert.deepEqual(body.sources['basemaps-aerial'].tiles, [
|
|
179
182
|
`https://tiles.test/v1/tiles/aerial/WebMercatorQuad/{z}/{x}/{y}.webp?api=${Api.key}`,
|
|
180
183
|
]);
|
|
181
|
-
|
|
182
|
-
|
|
184
|
+
assert.deepEqual(body.sources['basemaps-aerial'].tileSize, 256);
|
|
185
|
+
assert.deepEqual(body.layers, [{ id: 'basemaps-aerial', type: 'raster', source: 'basemaps-aerial' }]);
|
|
183
186
|
});
|
|
184
187
|
|
|
185
|
-
|
|
188
|
+
it('should support parameters', async () => {
|
|
186
189
|
const request = mockUrlRequest('/v1/styles/aerial.json', '?tileMatrix=NZTM2000Quad&format=jpg', Api.header);
|
|
187
190
|
const tileSet = FakeData.tileSetRaster('aerial');
|
|
188
191
|
config.put(tileSet);
|
|
189
192
|
const res = await handler.router.handle(request);
|
|
190
|
-
|
|
193
|
+
assert.equal(res.status, 200, res.statusDescription);
|
|
191
194
|
|
|
192
195
|
const body = JSON.parse(Buffer.from(res.body, 'base64').toString());
|
|
193
196
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
+
assert.equal(body.version, 8);
|
|
198
|
+
assert.deepEqual(body.sources['basemaps-aerial'].type, 'raster');
|
|
199
|
+
assert.deepEqual(body.sources['basemaps-aerial'].tiles, [
|
|
197
200
|
`https://tiles.test/v1/tiles/aerial/NZTM2000Quad/{z}/{x}/{y}.jpeg?api=${Api.key}`,
|
|
198
201
|
]);
|
|
199
|
-
|
|
200
|
-
|
|
202
|
+
assert.deepEqual(body.sources['basemaps-aerial'].tileSize, 256);
|
|
203
|
+
assert.deepEqual(body.layers, [{ id: 'basemaps-aerial', type: 'raster', source: 'basemaps-aerial' }]);
|
|
201
204
|
});
|
|
202
205
|
|
|
203
|
-
|
|
206
|
+
it('should create raster styles from custom config', async () => {
|
|
204
207
|
const configId = FakeData.bundle([FakeData.tileSetRaster('aerial')]);
|
|
205
208
|
const request = mockUrlRequest('/v1/styles/aerial.json', `?config=${configId}`, Api.header);
|
|
206
209
|
|
|
207
210
|
const res = await handler.router.handle(request);
|
|
208
|
-
|
|
211
|
+
assert.equal(res.status, 200, res.statusDescription);
|
|
209
212
|
|
|
210
213
|
const body = JSON.parse(Buffer.from(res.body, 'base64').toString());
|
|
211
214
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
+
assert.equal(body.version, 8);
|
|
216
|
+
assert.deepEqual(body.sources['basemaps-aerial'].type, 'raster');
|
|
217
|
+
assert.deepEqual(body.sources['basemaps-aerial'].tiles, [
|
|
215
218
|
`https://tiles.test/v1/tiles/aerial/WebMercatorQuad/{z}/{x}/{y}.webp?api=${Api.key}&config=${configId}`,
|
|
216
219
|
]);
|
|
217
|
-
|
|
218
|
-
|
|
220
|
+
assert.deepEqual(body.sources['basemaps-aerial'].tileSize, 256);
|
|
221
|
+
assert.deepEqual(body.layers, [{ id: 'basemaps-aerial', type: 'raster', source: 'basemaps-aerial' }]);
|
|
219
222
|
});
|
|
220
223
|
});
|
|
@@ -1,18 +1,26 @@
|
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import { afterEach, beforeEach, describe, it } from 'node:test';
|
|
3
|
+
|
|
1
4
|
import { ConfigProviderMemory } from '@basemaps/config';
|
|
2
|
-
import
|
|
5
|
+
import { Env } from '@basemaps/shared';
|
|
3
6
|
import { createSandbox } from 'sinon';
|
|
4
|
-
|
|
5
|
-
import { ConfigLoader } from '../../util/config.loader.js';
|
|
7
|
+
|
|
6
8
|
import { Imagery2193, Imagery3857, Provider, TileSetAerial } from '../../__tests__/config.data.js';
|
|
7
9
|
import { Api, mockUrlRequest } from '../../__tests__/xyz.util.js';
|
|
10
|
+
import { handler } from '../../index.js';
|
|
11
|
+
import { ConfigLoader } from '../../util/config.loader.js';
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
describe('WMTSRouting', () => {
|
|
10
14
|
const sandbox = createSandbox();
|
|
11
15
|
const config = new ConfigProviderMemory();
|
|
12
16
|
const imagery = new Map();
|
|
13
17
|
|
|
14
|
-
|
|
18
|
+
beforeEach(() => {
|
|
15
19
|
sandbox.stub(ConfigLoader, 'load').resolves(config);
|
|
20
|
+
sandbox.stub(Env, 'get').callsFake((arg) => {
|
|
21
|
+
if (arg === Env.PublicUrlBase) return 'https://tiles.test';
|
|
22
|
+
return process.env[arg];
|
|
23
|
+
});
|
|
16
24
|
|
|
17
25
|
imagery.set(Imagery3857.id, Imagery3857);
|
|
18
26
|
imagery.set(Imagery2193.id, Imagery2193);
|
|
@@ -23,24 +31,24 @@ o.spec('WMTSRouting', () => {
|
|
|
23
31
|
config.put(Provider);
|
|
24
32
|
});
|
|
25
33
|
|
|
26
|
-
|
|
34
|
+
afterEach(() => {
|
|
27
35
|
config.objects.clear();
|
|
28
36
|
sandbox.restore();
|
|
29
37
|
});
|
|
30
38
|
|
|
31
|
-
|
|
39
|
+
it('should default to the aerial layer', async () => {
|
|
32
40
|
const req = mockUrlRequest(
|
|
33
41
|
'/v1/tiles/WMTSCapabilities.xml',
|
|
34
42
|
`format=png&api=${Api.key}&config=s3://linz-basemaps/config.json`,
|
|
35
43
|
);
|
|
36
44
|
const res = await handler.router.handle(req);
|
|
37
45
|
|
|
38
|
-
|
|
46
|
+
assert.equal(res.status, 200);
|
|
39
47
|
const lines = Buffer.from(res.body, 'base64').toString().split('\n');
|
|
40
48
|
|
|
41
49
|
const titles = lines.filter((f) => f.startsWith(' <ows:Title>')).map((f) => f.trim());
|
|
42
50
|
|
|
43
|
-
|
|
51
|
+
assert.deepEqual(titles, [
|
|
44
52
|
'<ows:Title>Aerial Imagery</ows:Title>',
|
|
45
53
|
'<ows:Title>Ōtorohanga 0.1m Urban Aerial Photos (2021)</ows:Title>',
|
|
46
54
|
'<ows:Title>Google Maps Compatible for the World</ows:Title>',
|
|
@@ -48,60 +56,60 @@ o.spec('WMTSRouting', () => {
|
|
|
48
56
|
]);
|
|
49
57
|
|
|
50
58
|
const resourceURLs = lines.filter((f) => f.includes('<ResourceURL')).map((f) => f.trim());
|
|
51
|
-
|
|
59
|
+
assert.deepEqual(resourceURLs, [
|
|
52
60
|
'<ResourceURL format="image/png" resourceType="tile" template="https://tiles.test/v1/tiles/aerial/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.png?api=d01f7w7rnhdzg0p7fyrc9v9ard1&config=Q5pC4UjWdtFLU1CYtLcRSmB49RekgDgMa5EGJnB2M" />',
|
|
53
61
|
'<ResourceURL format="image/png" resourceType="tile" template="https://tiles.test/v1/tiles/ōtorohanga-urban-2021-0.1m/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.png?api=d01f7w7rnhdzg0p7fyrc9v9ard1&config=Q5pC4UjWdtFLU1CYtLcRSmB49RekgDgMa5EGJnB2M" />',
|
|
54
62
|
]);
|
|
55
63
|
});
|
|
56
64
|
|
|
57
|
-
|
|
65
|
+
it('should filter out date[after] by year', async () => {
|
|
58
66
|
const req = mockUrlRequest(
|
|
59
67
|
'/v1/tiles/WMTSCapabilities.xml',
|
|
60
68
|
`format=png&api=${Api.key}&config=s3://linz-basemaps/config.json&date[after]=2022`,
|
|
61
69
|
);
|
|
62
70
|
const res = await handler.router.handle(req);
|
|
63
71
|
|
|
64
|
-
|
|
72
|
+
assert.equal(res.status, 200);
|
|
65
73
|
const lines = Buffer.from(res.body, 'base64').toString().split('\n');
|
|
66
74
|
const titles = lines.filter((f) => f.startsWith(' <ows:Title>')).map((f) => f.trim());
|
|
67
75
|
|
|
68
|
-
|
|
76
|
+
assert.deepEqual(titles, [
|
|
69
77
|
'<ows:Title>Aerial Imagery</ows:Title>',
|
|
70
78
|
'<ows:Title>Google Maps Compatible for the World</ows:Title>',
|
|
71
79
|
'<ows:Title>LINZ NZTM2000 Map Tile Grid V2</ows:Title>',
|
|
72
80
|
]);
|
|
73
81
|
});
|
|
74
82
|
|
|
75
|
-
|
|
83
|
+
it('should filter out date[before] by year', async () => {
|
|
76
84
|
const req = mockUrlRequest(
|
|
77
85
|
'/v1/tiles/WMTSCapabilities.xml',
|
|
78
86
|
`format=png&api=${Api.key}&config=s3://linz-basemaps/config.json&date[before]=2020`,
|
|
79
87
|
);
|
|
80
88
|
const res = await handler.router.handle(req);
|
|
81
89
|
|
|
82
|
-
|
|
90
|
+
assert.equal(res.status, 200);
|
|
83
91
|
const lines = Buffer.from(res.body, 'base64').toString().split('\n');
|
|
84
92
|
const titles = lines.filter((f) => f.startsWith(' <ows:Title>')).map((f) => f.trim());
|
|
85
93
|
|
|
86
|
-
|
|
94
|
+
assert.deepEqual(titles, [
|
|
87
95
|
'<ows:Title>Aerial Imagery</ows:Title>',
|
|
88
96
|
'<ows:Title>Google Maps Compatible for the World</ows:Title>',
|
|
89
97
|
'<ows:Title>LINZ NZTM2000 Map Tile Grid V2</ows:Title>',
|
|
90
98
|
]);
|
|
91
99
|
});
|
|
92
100
|
|
|
93
|
-
|
|
101
|
+
it('should filter inclusive date[before] by year', async () => {
|
|
94
102
|
const req = mockUrlRequest(
|
|
95
103
|
'/v1/tiles/WMTSCapabilities.xml',
|
|
96
104
|
`format=png&api=${Api.key}&config=s3://linz-basemaps/config.json&date[before]=2021`,
|
|
97
105
|
);
|
|
98
106
|
const res = await handler.router.handle(req);
|
|
99
107
|
|
|
100
|
-
|
|
108
|
+
assert.equal(res.status, 200);
|
|
101
109
|
const lines = Buffer.from(res.body, 'base64').toString().split('\n');
|
|
102
110
|
const titles = lines.filter((f) => f.startsWith(' <ows:Title>')).map((f) => f.trim());
|
|
103
111
|
|
|
104
|
-
|
|
112
|
+
assert.deepEqual(titles, [
|
|
105
113
|
'<ows:Title>Aerial Imagery</ows:Title>',
|
|
106
114
|
'<ows:Title>Ōtorohanga 0.1m Urban Aerial Photos (2021)</ows:Title>',
|
|
107
115
|
'<ows:Title>Google Maps Compatible for the World</ows:Title>',
|
|
@@ -109,7 +117,7 @@ o.spec('WMTSRouting', () => {
|
|
|
109
117
|
]);
|
|
110
118
|
|
|
111
119
|
const resourceURLs = lines.filter((f) => f.includes('<ResourceURL')).map((f) => f.trim());
|
|
112
|
-
|
|
120
|
+
assert.deepEqual(resourceURLs, [
|
|
113
121
|
'<ResourceURL format="image/png" resourceType="tile" template="https://tiles.test/v1/tiles/aerial/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.png?api=d01f7w7rnhdzg0p7fyrc9v9ard1&config=Q5pC4UjWdtFLU1CYtLcRSmB49RekgDgMa5EGJnB2M&date%5Bbefore%5D=2021" />',
|
|
114
122
|
'<ResourceURL format="image/png" resourceType="tile" template="https://tiles.test/v1/tiles/ōtorohanga-urban-2021-0.1m/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.png?api=d01f7w7rnhdzg0p7fyrc9v9ard1&config=Q5pC4UjWdtFLU1CYtLcRSmB49RekgDgMa5EGJnB2M" />',
|
|
115
123
|
]);
|
|
@@ -1,121 +1,200 @@
|
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import { afterEach, beforeEach, describe, it } from 'node:test';
|
|
3
|
+
|
|
1
4
|
import { ConfigProviderMemory } from '@basemaps/config';
|
|
2
5
|
import { LogConfig } from '@basemaps/shared';
|
|
3
6
|
import { round } from '@basemaps/test/build/rounding.js';
|
|
4
|
-
|
|
5
|
-
import
|
|
7
|
+
|
|
8
|
+
import { FakeData } from '../../__tests__/config.data.js';
|
|
9
|
+
import { Api, mockRequest, mockUrlRequest } from '../../__tests__/xyz.util.js';
|
|
6
10
|
import { handler } from '../../index.js';
|
|
7
11
|
import { ConfigLoader } from '../../util/config.loader.js';
|
|
8
12
|
import { Etag } from '../../util/etag.js';
|
|
9
|
-
import { FakeData } from '../../__tests__/config.data.js';
|
|
10
|
-
import { Api, mockRequest } from '../../__tests__/xyz.util.js';
|
|
11
|
-
|
|
12
|
-
const sandbox = sinon.createSandbox();
|
|
13
13
|
|
|
14
14
|
const TileSetNames = ['aerial', 'aerial:ōtorohanga_urban_2021_0-1m_RGB', '01FYWKAJ86W9P7RWM1VB62KD0H'];
|
|
15
|
-
|
|
15
|
+
describe('/v1/tiles', () => {
|
|
16
16
|
const config = new ConfigProviderMemory();
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
beforeEach(() => {
|
|
19
19
|
LogConfig.get().level = 'silent';
|
|
20
|
-
sandbox.stub(ConfigLoader, 'getDefaultConfig').resolves(config);
|
|
21
|
-
config.objects.clear();
|
|
22
|
-
|
|
23
20
|
for (const tileSetName of TileSetNames) config.put(FakeData.tileSetRaster(tileSetName));
|
|
24
|
-
|
|
25
|
-
sandbox.stub(Etag, 'key').returns('fakeEtag');
|
|
26
21
|
});
|
|
27
22
|
|
|
28
|
-
|
|
23
|
+
afterEach(() => {
|
|
29
24
|
config.objects.clear();
|
|
30
|
-
sandbox.restore();
|
|
31
25
|
});
|
|
32
26
|
|
|
33
|
-
|
|
27
|
+
it('should export handler', async () => {
|
|
34
28
|
const base = await import('../../index.js');
|
|
35
|
-
|
|
29
|
+
assert.equal(typeof base.handler, 'function');
|
|
36
30
|
});
|
|
37
31
|
|
|
38
32
|
TileSetNames.forEach((tileSetName) => {
|
|
39
|
-
|
|
33
|
+
it(`should generate a tile/v1/tiles/${tileSetName}/global-mercator/0/0/0.png`, async (t) => {
|
|
34
|
+
t.mock.method(ConfigLoader, 'getDefaultConfig', () => Promise.resolve(config));
|
|
35
|
+
t.mock.method(Etag, 'key', () => 'fakeEtag');
|
|
36
|
+
|
|
40
37
|
const request = mockRequest(`/v1/tiles/${tileSetName}/global-mercator/0/0/0.png`, 'get', Api.header);
|
|
41
38
|
const res = await handler.router.handle(request);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
assert.equal(res.status, 200);
|
|
40
|
+
assert.equal(res.header('content-type'), 'image/png');
|
|
41
|
+
assert.equal(res.header('eTaG'), 'fakeEtag');
|
|
45
42
|
|
|
46
43
|
// Validate the session information has been set correctly
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
assert.equal(request.logContext['tileSet'], tileSetName);
|
|
45
|
+
assert.deepEqual(request.logContext['xyz'], { x: 0, y: 0, z: 0 });
|
|
46
|
+
assert.deepEqual(round(request.logContext['location']), { lat: 0, lon: 0 });
|
|
50
47
|
});
|
|
51
48
|
});
|
|
52
49
|
|
|
53
|
-
|
|
50
|
+
it('should generate a tile 0,0,0 for webp', async (t) => {
|
|
51
|
+
t.mock.method(ConfigLoader, 'getDefaultConfig', () => Promise.resolve(config));
|
|
52
|
+
t.mock.method(Etag, 'key', () => 'fakeEtag');
|
|
53
|
+
|
|
54
54
|
const request = mockRequest('/v1/tiles/aerial/3857/0/0/0.webp', 'get', Api.header);
|
|
55
55
|
const res = await handler.router.handle(request);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
|
|
57
|
+
assert.equal(res.status, 200, res.statusDescription);
|
|
58
|
+
assert.equal(res.header('content-type'), 'image/webp');
|
|
59
|
+
assert.equal(res.header('eTaG'), 'fakeEtag');
|
|
59
60
|
// o(res.body).equals(rasterMockBuffer.toString('base64'));
|
|
60
61
|
|
|
61
62
|
// Validate the session information has been set correctly
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
assert.deepEqual(request.logContext['xyz'], { x: 0, y: 0, z: 0 });
|
|
64
|
+
assert.deepEqual(round(request.logContext['location']), { lat: 0, lon: 0 });
|
|
64
65
|
});
|
|
65
66
|
|
|
66
67
|
['png', 'webp', 'jpeg', 'avif'].forEach((fmt) => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
it(`should 200 with empty ${fmt} if a tile is out of bounds`, async (t) => {
|
|
69
|
+
t.mock.method(ConfigLoader, 'getDefaultConfig', () => Promise.resolve(config));
|
|
70
|
+
|
|
71
|
+
const request = mockRequest(`/v1/tiles/aerial/global-mercator/0/0/0.${fmt}`, 'get', Api.header);
|
|
72
|
+
const res = await handler.router.handle(request);
|
|
73
|
+
assert.equal(res.status, 200, res.statusDescription);
|
|
74
|
+
assert.equal(res.header('content-type'), `image/${fmt}`);
|
|
75
|
+
assert.notEqual(res.header('etag'), undefined);
|
|
76
|
+
assert.equal(res.header('cache-control'), 'public, max-age=604800, stale-while-revalidate=86400');
|
|
77
|
+
assert.deepEqual(request.logContext['pipeline'], 'rgba');
|
|
77
78
|
});
|
|
78
79
|
});
|
|
79
80
|
|
|
80
|
-
|
|
81
|
+
it('should 304 if a tile is not modified', async (t) => {
|
|
82
|
+
t.mock.method(ConfigLoader, 'getDefaultConfig', () => Promise.resolve(config));
|
|
83
|
+
t.mock.method(Etag, 'key', () => 'fakeEtag');
|
|
84
|
+
|
|
81
85
|
const key = 'fakeEtag';
|
|
82
86
|
const request = mockRequest('/v1/tiles/aerial/global-mercator/0/0/0.png', 'get', {
|
|
83
87
|
'if-none-match': key,
|
|
84
88
|
...Api.header,
|
|
85
89
|
});
|
|
86
90
|
const res = await handler.router.handle(request);
|
|
87
|
-
|
|
88
|
-
|
|
91
|
+
assert.equal(res.status, 304);
|
|
92
|
+
assert.equal(res.header('eTaG'), undefined);
|
|
89
93
|
|
|
90
|
-
|
|
94
|
+
assert.deepEqual(request.logContext['cache'], { match: key, hit: true });
|
|
91
95
|
});
|
|
92
96
|
|
|
93
|
-
|
|
97
|
+
it('should 404 if a tile is outside of the range', async (t) => {
|
|
98
|
+
t.mock.method(ConfigLoader, 'getDefaultConfig', () => Promise.resolve(config));
|
|
99
|
+
|
|
94
100
|
const res = await handler.router.handle(
|
|
95
101
|
mockRequest('/v1/tiles/aerial/global-mercator/25/0/0.png', 'get', Api.header),
|
|
96
102
|
);
|
|
97
|
-
|
|
103
|
+
assert.equal(res.status, 404);
|
|
98
104
|
|
|
99
105
|
const resB = await handler.router.handle(mockRequest('/v1/tiles/aerial/2193/17/0/0.png', 'get', Api.header));
|
|
100
|
-
|
|
106
|
+
assert.equal(resB.status, 404);
|
|
101
107
|
});
|
|
102
108
|
|
|
103
|
-
|
|
109
|
+
it('should support utf8 tilesets', async (t) => {
|
|
110
|
+
t.mock.method(ConfigLoader, 'getDefaultConfig', () => Promise.resolve(config));
|
|
111
|
+
|
|
104
112
|
const fakeTileSet = FakeData.tileSetRaster('🦄 🌈');
|
|
105
113
|
config.put(fakeTileSet);
|
|
106
114
|
const req = mockRequest('/v1/tiles/🦄 🌈/global-mercator/0/0/0.png', 'get', Api.header);
|
|
107
|
-
|
|
115
|
+
assert.equal(req.path, '/v1/tiles/%F0%9F%A6%84%20%F0%9F%8C%88/global-mercator/0/0/0.png');
|
|
108
116
|
const res = await handler.router.handle(req);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
117
|
+
assert.equal(res.status, 200, res.statusDescription);
|
|
118
|
+
assert.equal(res.header('content-type'), 'image/png');
|
|
119
|
+
assert.notEqual(res.header('etag'), undefined);
|
|
120
|
+
assert.equal(res.header('cache-control'), 'public, max-age=604800, stale-while-revalidate=86400');
|
|
113
121
|
});
|
|
114
122
|
|
|
115
123
|
['/favicon.ico', '/index.html', '/foo/bar'].forEach((path) => {
|
|
116
|
-
|
|
124
|
+
it('should 404 on invalid paths: ' + path, async (t) => {
|
|
125
|
+
t.mock.method(ConfigLoader, 'getDefaultConfig', () => Promise.resolve(config));
|
|
126
|
+
|
|
117
127
|
const res = await handler.router.handle(mockRequest(path, 'get', Api.header));
|
|
118
|
-
|
|
128
|
+
assert.equal(res.status, 404);
|
|
119
129
|
});
|
|
120
130
|
});
|
|
131
|
+
|
|
132
|
+
it('should 404 if pipelines are defined but one is not requested', async (t) => {
|
|
133
|
+
t.mock.method(ConfigLoader, 'getDefaultConfig', () => Promise.resolve(config));
|
|
134
|
+
|
|
135
|
+
const elevation = FakeData.tileSetRaster('elevation');
|
|
136
|
+
|
|
137
|
+
elevation.outputs = [{ title: 'Terrain RGB', name: 'terrain-rgb' }];
|
|
138
|
+
config.put(elevation);
|
|
139
|
+
|
|
140
|
+
const request = mockRequest('/v1/tiles/elevation/3857/11/2022/1283.webp', 'get', Api.header);
|
|
141
|
+
|
|
142
|
+
const res = await handler.router.handle(request);
|
|
143
|
+
|
|
144
|
+
assert.equal(res.status, 404, res.statusDescription);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('should generate a terrain-rgb 11/2022/1283 in webp', async (t) => {
|
|
148
|
+
t.mock.method(ConfigLoader, 'getDefaultConfig', () => Promise.resolve(config));
|
|
149
|
+
|
|
150
|
+
const elevation = FakeData.tileSetRaster('elevation');
|
|
151
|
+
|
|
152
|
+
elevation.outputs = [{ title: 'Terrain RGB', name: 'terrain-rgb', format: ['png', 'webp'] }];
|
|
153
|
+
config.put(elevation);
|
|
154
|
+
|
|
155
|
+
const request = mockUrlRequest('/v1/tiles/elevation/3857/11/2022/1283.webp', '?pipeline=terrain-rgb', Api.header);
|
|
156
|
+
|
|
157
|
+
const res = await handler.router.handle(request);
|
|
158
|
+
|
|
159
|
+
assert.equal(res.status, 200, res.statusDescription);
|
|
160
|
+
// Validate the session information has been set correctly
|
|
161
|
+
assert.deepEqual(request.logContext['xyz'], { x: 2022, y: 1283, z: 11 });
|
|
162
|
+
assert.deepEqual(request.logContext['pipeline'], 'terrain-rgb');
|
|
163
|
+
assert.deepEqual(round(request.logContext['location']), { lat: -41.44272638, lon: 175.51757812 });
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('should validate lossless if pipelines are defined but one is not requested', async (t) => {
|
|
167
|
+
t.mock.method(ConfigLoader, 'getDefaultConfig', () => Promise.resolve(config));
|
|
168
|
+
|
|
169
|
+
const elevation = FakeData.tileSetRaster('elevation');
|
|
170
|
+
|
|
171
|
+
elevation.outputs = [{ title: 'Terrain RGB', name: 'terrain-rgb', format: ['png'] }];
|
|
172
|
+
config.put(elevation);
|
|
173
|
+
|
|
174
|
+
// JPEG is not lossless
|
|
175
|
+
const res = await handler.router.handle(
|
|
176
|
+
mockUrlRequest('/v1/tiles/elevation/3857/11/2022/1283.jpeg', '?pipeline=terrain-rgb', Api.header),
|
|
177
|
+
);
|
|
178
|
+
assert.equal(res.status, 400, res.statusDescription);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('should validate not allow random extensions', async (t) => {
|
|
182
|
+
t.mock.method(ConfigLoader, 'getDefaultConfig', () => Promise.resolve(config));
|
|
183
|
+
|
|
184
|
+
const elevation = FakeData.tileSetRaster('elevation');
|
|
185
|
+
|
|
186
|
+
elevation.outputs = [{ title: 'Terrain RGB', name: 'terrain-rgb' }];
|
|
187
|
+
config.put(elevation);
|
|
188
|
+
|
|
189
|
+
// JPEG is not lossless
|
|
190
|
+
const resPbf = await handler.router.handle(
|
|
191
|
+
mockUrlRequest('/v1/tiles/elevation/3857/11/2022/1283.pbf', '?pipeline=terrain-rgb', Api.header),
|
|
192
|
+
);
|
|
193
|
+
assert.equal(resPbf.status, 400, resPbf.statusDescription);
|
|
194
|
+
|
|
195
|
+
const resZz = await handler.router.handle(
|
|
196
|
+
mockUrlRequest('/v1/tiles/elevation/3857/11/2022/1283.zzz', '?pipeline=terrain-rgb', Api.header),
|
|
197
|
+
);
|
|
198
|
+
assert.equal(resZz.status, 400, resZz.statusDescription);
|
|
199
|
+
});
|
|
121
200
|
});
|
|
@@ -12,11 +12,11 @@ import {
|
|
|
12
12
|
StacProvider,
|
|
13
13
|
TileMatrixSet,
|
|
14
14
|
} from '@basemaps/geo';
|
|
15
|
-
import { BBox, MultiPolygon, multiPolygonToWgs84, Pair, union, Wgs84 } from '@linzjs/geojson';
|
|
16
15
|
import { extractYearRangeFromName, extractYearRangeFromTitle } from '@basemaps/shared';
|
|
16
|
+
import { BBox, MultiPolygon, multiPolygonToWgs84, Pair, union, Wgs84 } from '@linzjs/geojson';
|
|
17
17
|
import { HttpHeader, LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
|
|
18
|
-
import { ConfigLoader } from '../util/config.loader.js';
|
|
19
18
|
|
|
19
|
+
import { ConfigLoader } from '../util/config.loader.js';
|
|
20
20
|
import { Etag } from '../util/etag.js';
|
|
21
21
|
import { filterLayers, yearRangeToInterval } from '../util/filter.js';
|
|
22
22
|
import { NotFound, NotModified } from '../util/response.js';
|
package/src/routes/config.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { standardizeLayerName } from '@basemaps/config';
|
|
2
2
|
import { GoogleTms, TileMatrixSets } from '@basemaps/geo';
|
|
3
3
|
import { HttpHeader, LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
|
|
4
|
+
|
|
4
5
|
import { ConfigLoader } from '../util/config.loader.js';
|
|
5
6
|
import { Etag } from '../util/etag.js';
|
|
6
7
|
import { NotFound, NotModified } from '../util/response.js';
|
package/src/routes/fonts.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { assetProvider } from '../util/assets.provider.js';
|
|
4
4
|
|
|
5
5
|
interface FontGet {
|
|
@@ -7,10 +7,10 @@ interface FontGet {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export async function fontGet(req: LambdaHttpRequest<FontGet>): Promise<LambdaHttpResponse> {
|
|
10
|
-
const targetFile =
|
|
10
|
+
const targetFile = `fonts/${req.params.fontStack}/${req.params.range}.pbf`;
|
|
11
11
|
return assetProvider.serve(req, targetFile, 'application/x-protobuf');
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export async function fontList(req: LambdaHttpRequest): Promise<LambdaHttpResponse> {
|
|
15
|
-
return assetProvider.serve(req,
|
|
15
|
+
return assetProvider.serve(req, 'fonts/fonts.json', 'application/json');
|
|
16
16
|
}
|