@basemaps/lambda-tiler 6.24.2 → 6.27.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 +55 -0
- package/build/__test__/tile.cache.key.test.js +2 -3
- package/build/__test__/wmts.capability.test.js +36 -9
- package/build/__test__/xyz.test.js +51 -28
- package/build/__test__/xyz.util.d.ts +4 -0
- package/build/__test__/xyz.util.d.ts.map +1 -1
- package/build/__test__/xyz.util.js +8 -1
- package/build/cli/dump.js +2 -3
- package/build/index.d.ts +3 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -1
- package/build/routes/__test__/attribution.test.js +1 -0
- package/build/routes/__test__/health.test.js +1 -2
- package/build/routes/__test__/wmts.test.d.ts +2 -0
- package/build/routes/__test__/wmts.test.d.ts.map +1 -0
- package/build/routes/__test__/wmts.test.js +31 -0
- package/build/routes/health.d.ts.map +1 -1
- package/build/routes/health.js +3 -4
- package/build/routes/tile.json.d.ts +0 -7
- package/build/routes/tile.json.d.ts.map +1 -1
- package/build/routes/tile.json.js +26 -18
- package/build/routes/tile.wmts.d.ts +2 -0
- package/build/routes/tile.wmts.d.ts.map +1 -1
- package/build/routes/tile.wmts.js +23 -1
- package/build/tile.set.cache.js +2 -2
- package/build/tile.set.raster.d.ts +3 -1
- package/build/tile.set.raster.d.ts.map +1 -1
- package/build/tile.set.raster.js +8 -4
- package/build/tile.set.vector.d.ts +4 -1
- package/build/tile.set.vector.d.ts.map +1 -1
- package/build/tile.set.vector.js +11 -1
- package/build/wmts.capability.d.ts +15 -5
- package/build/wmts.capability.d.ts.map +1 -1
- package/build/wmts.capability.js +11 -12
- package/package.json +10 -10
- package/src/__test__/tile.cache.key.test.ts +3 -3
- package/src/__test__/wmts.capability.test.ts +39 -8
- package/src/__test__/xyz.test.ts +55 -28
- package/src/__test__/xyz.util.ts +10 -2
- package/src/cli/dump.ts +2 -3
- package/src/index.ts +2 -1
- package/src/routes/__test__/attribution.test.ts +1 -0
- package/src/routes/__test__/health.test.ts +1 -3
- package/src/routes/__test__/wmts.test.ts +40 -0
- package/src/routes/health.ts +3 -4
- package/src/routes/tile.json.ts +26 -27
- package/src/routes/tile.wmts.ts +23 -2
- package/src/tile.set.cache.ts +2 -2
- package/src/tile.set.raster.ts +8 -4
- package/src/tile.set.vector.ts +12 -2
- package/src/wmts.capability.ts +20 -15
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,61 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [6.27.0](https://github.com/linz/basemaps/compare/v6.26.0...v6.27.0) (2022-05-29)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **lambda-tiler:** do not serve mvt in the wrong projection ([#2212](https://github.com/linz/basemaps/issues/2212)) ([a68e588](https://github.com/linz/basemaps/commit/a68e5889f2d0394676dcc41d831d00ede3df115d))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **cli:** allow overriding imagery names ([#2169](https://github.com/linz/basemaps/issues/2169)) ([5c3bdd8](https://github.com/linz/basemaps/commit/5c3bdd89b664dd85df2b48d709653b71bdc348f7))
|
|
17
|
+
* **cli:** Insert imagery and tileset config after cog creation complete ([#2191](https://github.com/linz/basemaps/issues/2191)) ([3ea5efd](https://github.com/linz/basemaps/commit/3ea5efd049b956f882a05c90471d764efb5d39fd))
|
|
18
|
+
* **cli:** make cogs will update the process job status if exists. ([#2180](https://github.com/linz/basemaps/issues/2180)) ([855ce1c](https://github.com/linz/basemaps/commit/855ce1cb1f7b8bff575be342184e5ac387684f09))
|
|
19
|
+
* **config:** add configuration parser and bundler ([#2200](https://github.com/linz/basemaps/issues/2200)) ([795e3f2](https://github.com/linz/basemaps/commit/795e3f224ee0b4cd1e66a242d05a1fd5357cae3a))
|
|
20
|
+
* **lambda-cog:** New lambda Cog for import api. ([#2207](https://github.com/linz/basemaps/issues/2207)) ([79f4ae7](https://github.com/linz/basemaps/commit/79f4ae70ea3fc16a37dd575b843a0b60a1365df4))
|
|
21
|
+
* **lambda-tiler:** Add file number limitation to import api. ([#2203](https://github.com/linz/basemaps/issues/2203)) ([4694e29](https://github.com/linz/basemaps/commit/4694e29a4444810391e72b290ec64f8b8541c369))
|
|
22
|
+
* **lambda-tiler:** allow selection of output format for wmts with ?format= ([#2211](https://github.com/linz/basemaps/issues/2211)) ([e32e1ed](https://github.com/linz/basemaps/commit/e32e1ed6f48f5d70c47b9fd81032ebc8662d3a72))
|
|
23
|
+
* **lambda-tiler:** Increase limit of total file size. ([#2205](https://github.com/linz/basemaps/issues/2205)) ([5246ea0](https://github.com/linz/basemaps/commit/5246ea0879a4bf6b20770fb633d63afac778d54d))
|
|
24
|
+
* **lambda-tiler:** increase the max number of tiffs to load at once to 25 ([#2219](https://github.com/linz/basemaps/issues/2219)) ([d7d30a8](https://github.com/linz/basemaps/commit/d7d30a843201be91933c8627d99988098d783cec))
|
|
25
|
+
* **lambda-tiler:** Load MaxImagePixelSize from import api. ([#2206](https://github.com/linz/basemaps/issues/2206)) ([b851934](https://github.com/linz/basemaps/commit/b85193401bc5df2ecb689c3801f62af71696cdf5))
|
|
26
|
+
* **server:** use a bundled `@basemaps/landing` to serve static assets ([#2202](https://github.com/linz/basemaps/issues/2202)) ([c60f518](https://github.com/linz/basemaps/commit/c60f518893fe037a03f8bfd489c84d8427481678))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# [6.26.0](https://github.com/linz/basemaps/compare/v6.25.0...v6.26.0) (2022-05-12)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### Bug Fixes
|
|
36
|
+
|
|
37
|
+
* **lambda-tiler:** Fix the insert of processing job config and actually start job after inserting config. ([#2182](https://github.com/linz/basemaps/issues/2182)) ([65d9c84](https://github.com/linz/basemaps/commit/65d9c841d3cbdde1c9a3753f3ae81fd67c5aef80))
|
|
38
|
+
* **lambda-tiler:** remove vector_layers as maplibre uses it as a validator ([#2189](https://github.com/linz/basemaps/issues/2189)) ([457d978](https://github.com/linz/basemaps/commit/457d978527f2c42408562021cef7b48ff9ce1afb))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Features
|
|
42
|
+
|
|
43
|
+
* **lambda-tiler:** Remove the job id to use ulid and update HTTP status code. ([#2188](https://github.com/linz/basemaps/issues/2188)) ([7d72f0c](https://github.com/linz/basemaps/commit/7d72f0c94ce4eefe0342b01b1ac2c8c153fc7c10))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# [6.25.0](https://github.com/linz/basemaps/compare/v6.24.2...v6.25.0) (2022-05-11)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
### Features
|
|
53
|
+
|
|
54
|
+
* **config:** serve tilejson 3.0.0 and allow raster imagery ([#2173](https://github.com/linz/basemaps/issues/2173)) ([29f5313](https://github.com/linz/basemaps/commit/29f53131e917fa0b3ce6f280e8f9e09f4fe6e957))
|
|
55
|
+
* **lambda-tiler:** Import api for import imagery jobs. ([#2170](https://github.com/linz/basemaps/issues/2170)) ([76b6175](https://github.com/linz/basemaps/commit/76b6175930db2a04f24437c7a05e7a70f160f7cd))
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
6
61
|
## [6.24.2](https://github.com/linz/basemaps/compare/v6.24.1...v6.24.2) (2022-04-20)
|
|
7
62
|
|
|
8
63
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { GoogleTms, Nztm2000Tms } from '@basemaps/geo';
|
|
1
|
+
import { GoogleTms, Nztm2000Tms, ImageFormat } from '@basemaps/geo';
|
|
2
2
|
import { TileType } from '@basemaps/shared';
|
|
3
3
|
import { TestTiff } from '@basemaps/test';
|
|
4
|
-
import { ImageFormat } from '@basemaps/tiler';
|
|
5
4
|
import o from 'ospec';
|
|
6
5
|
import { TileEtag } from '../routes/tile.etag.js';
|
|
7
6
|
o.spec('TileCacheKey', () => {
|
|
@@ -12,7 +11,7 @@ o.spec('TileCacheKey', () => {
|
|
|
12
11
|
z: 0,
|
|
13
12
|
tileMatrix: GoogleTms,
|
|
14
13
|
name: 'foo',
|
|
15
|
-
ext: ImageFormat.
|
|
14
|
+
ext: ImageFormat.Png,
|
|
16
15
|
type: TileType.Tile,
|
|
17
16
|
};
|
|
18
17
|
o.afterEach(() => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Bounds, Epsg, GoogleTms, Nztm2000QuadTms, Nztm2000Tms } from '@basemaps/geo';
|
|
1
|
+
import { Bounds, Epsg, GoogleTms, ImageFormat, Nztm2000QuadTms, Nztm2000Tms } from '@basemaps/geo';
|
|
2
2
|
import { TileSetName, V, VNodeElement } from '@basemaps/shared';
|
|
3
3
|
import { roundNumbersInString } from '@basemaps/test/build/rounding.js';
|
|
4
4
|
import { createHash } from 'crypto';
|
|
@@ -18,9 +18,27 @@ o.spec('WmtsCapabilities', () => {
|
|
|
18
18
|
const apiKey = 'secret1234';
|
|
19
19
|
const tileSet = new FakeTileSet(TileSetName.aerial, GoogleTms);
|
|
20
20
|
const tileSetImagery = new FakeTileSet('01E7PJFR9AMQFJ05X9G7FQ3XMW', GoogleTms);
|
|
21
|
+
o('should output the requested formats', () => {
|
|
22
|
+
const wmts = new WmtsCapabilities({
|
|
23
|
+
httpBase: 'https://basemaps.test',
|
|
24
|
+
provider: Provider,
|
|
25
|
+
layers: [tileSet],
|
|
26
|
+
apiKey,
|
|
27
|
+
formats: [ImageFormat.Avif],
|
|
28
|
+
}).toVNode();
|
|
29
|
+
const urls = tags(wmts, 'ResourceURL');
|
|
30
|
+
o(urls.length).equals(1);
|
|
31
|
+
o(urls[0].attrs.format).equals('image/avif');
|
|
32
|
+
o(urls[0].attrs.template).equals('https://basemaps.test/v1/tiles/aerial/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.avif?api=secret1234');
|
|
33
|
+
});
|
|
21
34
|
o('should build capability xml for tileset and projection', () => {
|
|
22
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l
|
|
23
|
-
const wmts = new WmtsCapabilities(
|
|
35
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
36
|
+
const wmts = new WmtsCapabilities({
|
|
37
|
+
httpBase: 'https://basemaps.test',
|
|
38
|
+
provider: Provider,
|
|
39
|
+
layers: [tileSet],
|
|
40
|
+
apiKey,
|
|
41
|
+
});
|
|
24
42
|
const raw = wmts.toVNode();
|
|
25
43
|
const serviceId = raw.find('ows:ServiceIdentification');
|
|
26
44
|
o((_a = serviceId === null || serviceId === void 0 ? void 0 : serviceId.find('ows:Abstract')) === null || _a === void 0 ? void 0 : _a.textContent).equals('the description');
|
|
@@ -73,12 +91,21 @@ o.spec('WmtsCapabilities', () => {
|
|
|
73
91
|
}
|
|
74
92
|
compareMatrix(tileMatrices[0], '0', 1, 559082264.028717);
|
|
75
93
|
compareMatrix(tileMatrices[10], '10', 1024, 545978.773465544);
|
|
76
|
-
const xml =
|
|
94
|
+
const xml = new WmtsCapabilities({
|
|
95
|
+
httpBase: 'https://basemaps.test',
|
|
96
|
+
provider: Provider,
|
|
97
|
+
layers: [tileSet],
|
|
98
|
+
apiKey,
|
|
99
|
+
}).toXml();
|
|
77
100
|
o(xml).deepEquals('<?xml version="1.0"?>\n' + (raw === null || raw === void 0 ? void 0 : raw.toString()));
|
|
78
101
|
o(createHash('sha256').update(Buffer.from(xml)).digest('base64')).equals('beknYyMt8v74vK4p84AS3c1OnBSJ+ZE0kan+mMVQS1A=');
|
|
79
102
|
});
|
|
80
103
|
o('should allow individual imagery sets', () => {
|
|
81
|
-
const raw = new WmtsCapabilities(
|
|
104
|
+
const raw = new WmtsCapabilities({
|
|
105
|
+
httpBase: 'https://basemaps.test',
|
|
106
|
+
provider: Provider,
|
|
107
|
+
layers: [tileSetImagery],
|
|
108
|
+
}).toVNode();
|
|
82
109
|
const tms = raw === null || raw === void 0 ? void 0 : raw.find('TileMatrixSet', 'ows:Identifier');
|
|
83
110
|
o(tms === null || tms === void 0 ? void 0 : tms.textContent).equals('EPSG:3857');
|
|
84
111
|
const urls = Array.from(raw ? raw.tags('ResourceURL') : []);
|
|
@@ -89,7 +116,7 @@ o.spec('WmtsCapabilities', () => {
|
|
|
89
116
|
o('should support multiple projections', () => {
|
|
90
117
|
var _a, _b, _c, _d;
|
|
91
118
|
const ts = [new FakeTileSet(TileSetName.aerial, Nztm2000Tms), new FakeTileSet(TileSetName.aerial, GoogleTms)];
|
|
92
|
-
const xml = new WmtsCapabilities('basemaps.test', Provider, ts);
|
|
119
|
+
const xml = new WmtsCapabilities({ httpBase: 'basemaps.test', provider: Provider, layers: ts });
|
|
93
120
|
const nodes = xml.toVNode();
|
|
94
121
|
const layers = tags(nodes, 'Layer');
|
|
95
122
|
o(layers.length).equals(1);
|
|
@@ -129,7 +156,7 @@ o.spec('WmtsCapabilities', () => {
|
|
|
129
156
|
new FakeTileSet(TileSetName.aerial, Nztm2000Tms, 'aerial-title'),
|
|
130
157
|
new FakeTileSet('01E7PJFR9AMQFJ05X9G7FQ3XMW', Nztm2000Tms, 'imagery-title'),
|
|
131
158
|
];
|
|
132
|
-
const nodes = new WmtsCapabilities('basemaps.test', Provider, ts).toVNode();
|
|
159
|
+
const nodes = new WmtsCapabilities({ httpBase: 'basemaps.test', provider: Provider, layers: ts }).toVNode();
|
|
133
160
|
const layers = tags(nodes, 'Layer');
|
|
134
161
|
o(layers.length).equals(2);
|
|
135
162
|
o((_a = layers[0].find('ows:Title')) === null || _a === void 0 ? void 0 : _a.textContent).equals('aerial-title');
|
|
@@ -142,7 +169,7 @@ o.spec('WmtsCapabilities', () => {
|
|
|
142
169
|
new FakeTileSet(`${TileSetName.aerial}:wairoa_urban_2014-2015_0-10m_RGBA`, Nztm2000Tms, 'wairoa_urban_2014-2015_0-10m_RGBA'),
|
|
143
170
|
new FakeTileSet(`${TileSetName.aerial}:west-coast_rural_2016-17_0-3m`, Nztm2000Tms, 'west-coast_rural_2016-17_0-3m'),
|
|
144
171
|
];
|
|
145
|
-
const nodes = new WmtsCapabilities('basemaps.test', Provider, ts).toVNode();
|
|
172
|
+
const nodes = new WmtsCapabilities({ httpBase: 'basemaps.test', provider: Provider, layers: ts }).toVNode();
|
|
146
173
|
const layers = tags(nodes, 'Layer');
|
|
147
174
|
o(layers.length).equals(2);
|
|
148
175
|
const boundingBoxes = tags(layers[0], 'ows:BoundingBox');
|
|
@@ -162,7 +189,7 @@ o.spec('WmtsCapabilities', () => {
|
|
|
162
189
|
];
|
|
163
190
|
ts[1].extentOverride = new Bounds(1, 2, 2, 2);
|
|
164
191
|
ts[2].tileSet.title = 'aerial_dunedin_urban';
|
|
165
|
-
const nodes = new WmtsCapabilities('basemaps.test', Provider, ts).toVNode();
|
|
192
|
+
const nodes = new WmtsCapabilities({ httpBase: 'basemaps.test', provider: Provider, layers: ts }).toVNode();
|
|
166
193
|
const allMatrixes = tags(nodes, 'TileMatrixSet');
|
|
167
194
|
o(allMatrixes[0].children[0].textContent).equals('EPSG:2193');
|
|
168
195
|
o(allMatrixes[1].children[0].textContent).equals('EPSG:2193');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TileMatrixSets } from '@basemaps/geo';
|
|
1
|
+
import { GoogleTms, Nztm2000QuadTms, TileMatrixSets } from '@basemaps/geo';
|
|
2
2
|
import { Config, Env, LogConfig, VNodeParser } from '@basemaps/shared';
|
|
3
3
|
import { round } from '@basemaps/test/build/rounding.js';
|
|
4
4
|
import o from 'ospec';
|
|
@@ -7,7 +7,7 @@ import { handleRequest } from '../index.js';
|
|
|
7
7
|
import { TileEtag } from '../routes/tile.etag.js';
|
|
8
8
|
import { TileSets } from '../tile.set.cache.js';
|
|
9
9
|
import { TileComposer } from '../tile.set.raster.js';
|
|
10
|
-
import { FakeTileSet, mockRequest, Provider } from './xyz.util.js';
|
|
10
|
+
import { FakeTileSet, FakeTileSetVector, mockRequest, Provider } from './xyz.util.js';
|
|
11
11
|
const sandbox = sinon.createSandbox();
|
|
12
12
|
const TileSetNames = ['aerial', 'aerial@head', 'aerial@beta', '01E7PJFR9AMQFJ05X9G7FQ3XMW'];
|
|
13
13
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
@@ -42,6 +42,7 @@ o.spec('LambdaXyz', () => {
|
|
|
42
42
|
tileSet.initTiffs = async () => [];
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
+
TileSets.add(new FakeTileSetVector('topographic', GoogleTms));
|
|
45
46
|
Config.Provider.get = async () => Provider;
|
|
46
47
|
});
|
|
47
48
|
o.afterEach(() => {
|
|
@@ -152,44 +153,66 @@ o.spec('LambdaXyz', () => {
|
|
|
152
153
|
});
|
|
153
154
|
});
|
|
154
155
|
o.spec('tileJson', () => {
|
|
155
|
-
o('should
|
|
156
|
-
|
|
157
|
-
const key = 'BBfQpNXA3Q90jlFrLSOZhxbvfOh7OpN1OEE+BylpbHw=';
|
|
158
|
-
const request = mockRequest('/v1/tiles/tile.json', 'get', { 'if-none-match': key, ...apiKeyHeader });
|
|
156
|
+
o('should 404 if invalid url is given', async () => {
|
|
157
|
+
const request = mockRequest('/v1/tiles/tile.json', 'get', apiKeyHeader);
|
|
159
158
|
const res = await handleRequest(request);
|
|
160
|
-
|
|
161
|
-
o(res.header('eTaG')).equals(key); // this line is useful for discovering the new etag
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
o(res.status).equals(304);
|
|
165
|
-
o(rasterMock.calls.length).equals(0);
|
|
166
|
-
o(request.logContext['cache']).deepEquals({ key, match: key, hit: true });
|
|
159
|
+
o(res.status).equals(404);
|
|
167
160
|
});
|
|
168
|
-
o('should
|
|
161
|
+
o('should serve tile json for tile_set', async () => {
|
|
169
162
|
var _a;
|
|
170
|
-
const
|
|
171
|
-
const request = mockRequest('/v1/tiles/tile.json', 'get', { 'if-none-match': key, ...apiKeyHeader });
|
|
163
|
+
const request = mockRequest('/v1/tiles/aerial/NZTM2000Quad/tile.json', 'get', apiKeyHeader);
|
|
172
164
|
const res = await handleRequest(request);
|
|
173
165
|
o(res.status).equals(200);
|
|
174
|
-
o(res.header('
|
|
175
|
-
const
|
|
176
|
-
o(
|
|
177
|
-
|
|
166
|
+
o(res.header('cache-control')).equals('no-store');
|
|
167
|
+
const body = Buffer.from((_a = res.body) !== null && _a !== void 0 ? _a : '', 'base64').toString();
|
|
168
|
+
o(JSON.parse(body)).deepEquals({
|
|
169
|
+
tiles: [`https://tiles.test/v1/tiles/aerial/NZTM2000Quad/{z}/{x}/{y}.webp?api=${apiKey}`],
|
|
170
|
+
tilejson: '3.0.0',
|
|
171
|
+
});
|
|
178
172
|
});
|
|
179
|
-
o('should serve
|
|
173
|
+
o('should serve vector tiles', async () => {
|
|
180
174
|
var _a;
|
|
181
|
-
const request = mockRequest('/v1/tiles/topographic/
|
|
175
|
+
const request = mockRequest('/v1/tiles/topographic/WebMercatorQuad/tile.json', 'get', apiKeyHeader);
|
|
182
176
|
const res = await handleRequest(request);
|
|
183
177
|
o(res.status).equals(200);
|
|
184
|
-
o(res.header('content-type')).equals('application/json');
|
|
185
|
-
o(res.header('cache-control')).equals('max-age=120');
|
|
186
178
|
const body = Buffer.from((_a = res.body) !== null && _a !== void 0 ? _a : '', 'base64').toString();
|
|
187
179
|
o(JSON.parse(body)).deepEquals({
|
|
188
|
-
tiles: [`https://tiles.test/v1/tiles/topographic/
|
|
189
|
-
|
|
180
|
+
tiles: [`https://tiles.test/v1/tiles/topographic/EPSG:3857/{z}/{x}/{y}.pbf?api=${apiKey}`],
|
|
181
|
+
tilejson: '3.0.0',
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
o('should serve vector tiles with min/max zoom', async () => {
|
|
185
|
+
var _a;
|
|
186
|
+
const fakeTileSet = new FakeTileSetVector('fake-vector', GoogleTms);
|
|
187
|
+
fakeTileSet.tileSet.maxZoom = 15;
|
|
188
|
+
fakeTileSet.tileSet.minZoom = 3;
|
|
189
|
+
TileSets.add(fakeTileSet);
|
|
190
|
+
const request = mockRequest('/v1/tiles/fake-vector/WebMercatorQuad/tile.json', 'get', apiKeyHeader);
|
|
191
|
+
const res = await handleRequest(request);
|
|
192
|
+
o(res.status).equals(200);
|
|
193
|
+
const body = Buffer.from((_a = res.body) !== null && _a !== void 0 ? _a : '', 'base64').toString();
|
|
194
|
+
o(JSON.parse(body)).deepEquals({
|
|
195
|
+
tiles: [`https://tiles.test/v1/tiles/fake-vector/EPSG:3857/{z}/{x}/{y}.pbf?api=${apiKey}`],
|
|
190
196
|
maxzoom: 15,
|
|
191
|
-
|
|
192
|
-
tilejson: '
|
|
197
|
+
minzoom: 3,
|
|
198
|
+
tilejson: '3.0.0',
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
o('should serve convert zoom to tile matrix', async () => {
|
|
202
|
+
var _a;
|
|
203
|
+
const fakeTileSet = new FakeTileSetVector('fake-vector', Nztm2000QuadTms);
|
|
204
|
+
fakeTileSet.tileSet.maxZoom = 15;
|
|
205
|
+
fakeTileSet.tileSet.minZoom = 1;
|
|
206
|
+
TileSets.add(fakeTileSet);
|
|
207
|
+
const request = mockRequest('/v1/tiles/fake-vector/NZTM2000Quad/tile.json', 'get', apiKeyHeader);
|
|
208
|
+
const res = await handleRequest(request);
|
|
209
|
+
o(res.status).equals(200);
|
|
210
|
+
const body = Buffer.from((_a = res.body) !== null && _a !== void 0 ? _a : '', 'base64').toString();
|
|
211
|
+
o(JSON.parse(body)).deepEquals({
|
|
212
|
+
tiles: [`https://tiles.test/v1/tiles/fake-vector/NZTM2000Quad/{z}/{x}/{y}.pbf?api=${apiKey}`],
|
|
213
|
+
maxzoom: 13,
|
|
214
|
+
minzoom: 0,
|
|
215
|
+
tilejson: '3.0.0',
|
|
193
216
|
});
|
|
194
217
|
});
|
|
195
218
|
});
|
|
@@ -2,9 +2,13 @@ import { ConfigProvider } from '@basemaps/config';
|
|
|
2
2
|
import { TileMatrixSet } from '@basemaps/geo';
|
|
3
3
|
import { LambdaHttpRequest } from '@linzjs/lambda';
|
|
4
4
|
import { TileSetRaster } from '../tile.set.raster.js';
|
|
5
|
+
import { TileSetVector } from '../tile.set.vector.js';
|
|
5
6
|
export declare function mockRequest(path: string, method?: string, headers?: Record<string, string>): LambdaHttpRequest;
|
|
6
7
|
export declare class FakeTileSet extends TileSetRaster {
|
|
7
8
|
constructor(name: string, tileMatrix: TileMatrixSet, title?: string, description?: string);
|
|
8
9
|
}
|
|
10
|
+
export declare class FakeTileSetVector extends TileSetVector {
|
|
11
|
+
constructor(name: string, tileMatrix: TileMatrixSet);
|
|
12
|
+
}
|
|
9
13
|
export declare const Provider: ConfigProvider;
|
|
10
14
|
//# sourceMappingURL=xyz.util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xyz.util.d.ts","sourceRoot":"","sources":["../../src/__test__/xyz.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"xyz.util.d.ts","sourceRoot":"","sources":["../../src/__test__/xyz.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAoB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAErE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,SAAQ,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAAG,iBAAiB,CAajH;AAED,qBAAa,WAAY,SAAQ,aAAa;gBAChC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,KAAK,SAAkB,EAAE,WAAW,SAAwB;CAIlH;AAED,qBAAa,iBAAkB,SAAQ,aAAa;gBACtC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa;CAIpD;AAED,eAAO,MAAM,QAAQ,EAAE,cA4BtB,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { LambdaAlbRequest } from '@linzjs/lambda';
|
|
2
1
|
import { LogConfig } from '@basemaps/shared';
|
|
2
|
+
import { LambdaAlbRequest } from '@linzjs/lambda';
|
|
3
3
|
import { TileSetRaster } from '../tile.set.raster.js';
|
|
4
|
+
import { TileSetVector } from '../tile.set.vector.js';
|
|
4
5
|
export function mockRequest(path, method = 'get', headers = {}) {
|
|
5
6
|
return new LambdaAlbRequest({
|
|
6
7
|
requestContext: null,
|
|
@@ -17,6 +18,12 @@ export class FakeTileSet extends TileSetRaster {
|
|
|
17
18
|
this.tileSet = { title, description };
|
|
18
19
|
}
|
|
19
20
|
}
|
|
21
|
+
export class FakeTileSetVector extends TileSetVector {
|
|
22
|
+
constructor(name, tileMatrix) {
|
|
23
|
+
super(name, tileMatrix);
|
|
24
|
+
this.tileSet = {};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
20
27
|
export const Provider = {
|
|
21
28
|
createdAt: Date.now(),
|
|
22
29
|
name: 'main',
|
package/build/cli/dump.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Nztm2000Tms } from '@basemaps/geo';
|
|
1
|
+
import { Nztm2000Tms, ImageFormat } from '@basemaps/geo';
|
|
2
2
|
import { LogConfig } from '@basemaps/shared';
|
|
3
|
-
import { ImageFormat } from '@basemaps/tiler';
|
|
4
3
|
import { LambdaAlbRequest } from '@linzjs/lambda';
|
|
5
4
|
import { promises as fs } from 'fs';
|
|
6
5
|
import { tileXyz } from '../routes/tile.xyz.js';
|
|
@@ -9,7 +8,7 @@ import { TileSetLocal } from './tile.set.local.js';
|
|
|
9
8
|
const xyz = { x: 0, y: 0, z: 0 };
|
|
10
9
|
const tileMatrix = Nztm2000Tms;
|
|
11
10
|
const tileSetName = 'aerial';
|
|
12
|
-
const ext = ImageFormat.
|
|
11
|
+
const ext = ImageFormat.Png;
|
|
13
12
|
/** Load a tileset form a file path otherwise default to the hard coded one from AWS */
|
|
14
13
|
async function getTileSet(filePath) {
|
|
15
14
|
if (filePath != null) {
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
|
|
2
2
|
export declare function handleRequest(req: LambdaHttpRequest): Promise<LambdaHttpResponse>;
|
|
3
|
-
export declare const handler: import("@linzjs/lambda/build/src/function").LambdaHandler<import("@linzjs/lambda/build/src/request.http").HttpRequestEvent, import("@linzjs/lambda/build/src/request.http").HttpResponse
|
|
3
|
+
export declare const handler: import("@linzjs/lambda/build/src/function").LambdaHandler<import("@linzjs/lambda/build/src/http/request.http").HttpRequestEvent, import("@linzjs/lambda/build/src/http/request.http").HttpResponse> & {
|
|
4
|
+
router: import("@linzjs/lambda/build/src/http/router").Router;
|
|
5
|
+
};
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAqB3E,wBAAsB,aAAa,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA2BvF;AAED,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAqB3E,wBAAsB,aAAa,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA2BvF;AAED,eAAO,MAAM,OAAO;;CAA2B,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -266,6 +266,7 @@ function makeImageRecord(id, name, x = 10) {
|
|
|
266
266
|
id,
|
|
267
267
|
name,
|
|
268
268
|
projection: EpsgCode.Google,
|
|
269
|
+
tileMatrix: 'WebMercatorQuad',
|
|
269
270
|
uri: 's3://bucket/path/' + name,
|
|
270
271
|
bounds: GoogleTms.tileToSourceBounds({ x, y: 10, z: 5 }),
|
|
271
272
|
files: [0, 1].map((i) => {
|
|
@@ -14,6 +14,7 @@ const ctx = new LambdaAlbRequest({
|
|
|
14
14
|
isBase64Encoded: false,
|
|
15
15
|
}, {}, LogConfig.get());
|
|
16
16
|
o.spec('health', async () => {
|
|
17
|
+
o.specTimeout(1000);
|
|
17
18
|
const sandbox = sinon.createSandbox();
|
|
18
19
|
const tileSet = new TileSetRaster('health', GoogleTms);
|
|
19
20
|
o.beforeEach(() => {
|
|
@@ -42,7 +43,6 @@ o.spec('health', async () => {
|
|
|
42
43
|
});
|
|
43
44
|
// Prepare mock test tile response based on the static test tiles
|
|
44
45
|
o('Should give a 200 response', async () => {
|
|
45
|
-
o.timeout(500);
|
|
46
46
|
// Given ... a series good get tile response
|
|
47
47
|
const callback = sandbox.stub(tileSet, 'tile');
|
|
48
48
|
callback.onCall(0).resolves(Response1);
|
|
@@ -54,7 +54,6 @@ o.spec('health', async () => {
|
|
|
54
54
|
o(res.statusDescription).equals('ok');
|
|
55
55
|
});
|
|
56
56
|
o('Should return mis-match tile response', async () => {
|
|
57
|
-
o.timeout(500);
|
|
58
57
|
// Given ... a bad get tile response for second get tile
|
|
59
58
|
const callback = sandbox.stub(tileSet, 'tile');
|
|
60
59
|
callback.onCall(0).resolves(Response1);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wmts.test.d.ts","sourceRoot":"","sources":["../../../src/routes/__test__/wmts.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ImageFormat } from '@basemaps/geo';
|
|
2
|
+
import { LogConfig } from '@basemaps/shared';
|
|
3
|
+
import { LambdaUrlRequest } from '@linzjs/lambda';
|
|
4
|
+
import o from 'ospec';
|
|
5
|
+
import { getImageFormats } from '../tile.wmts.js';
|
|
6
|
+
o.spec('GetImageFormats', () => {
|
|
7
|
+
function newRequest(path, query) {
|
|
8
|
+
return new LambdaUrlRequest({
|
|
9
|
+
requestContext: { http: { method: 'GET' } },
|
|
10
|
+
headers: {},
|
|
11
|
+
rawPath: path,
|
|
12
|
+
rawQueryString: query,
|
|
13
|
+
isBase64Encoded: false,
|
|
14
|
+
}, {}, LogConfig.get());
|
|
15
|
+
}
|
|
16
|
+
o('should parse all formats', () => {
|
|
17
|
+
const req = newRequest('/v1/blank', 'format=png&format=jpeg');
|
|
18
|
+
const formats = getImageFormats(req);
|
|
19
|
+
o(formats).deepEquals([ImageFormat.Png, ImageFormat.Jpeg]);
|
|
20
|
+
});
|
|
21
|
+
o('should ignore bad formats', () => {
|
|
22
|
+
const req = newRequest('/v1/blank', 'format=fake&format=mvt');
|
|
23
|
+
const formats = getImageFormats(req);
|
|
24
|
+
o(formats).equals(undefined);
|
|
25
|
+
});
|
|
26
|
+
o('should de-dupe formats', () => {
|
|
27
|
+
const req = newRequest('/v1/blank', 'format=png&format=jpeg&format=png&format=jpeg&format=png&format=jpeg');
|
|
28
|
+
const formats = getImageFormats(req);
|
|
29
|
+
o(formats).deepEquals([ImageFormat.Png, ImageFormat.Jpeg]);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/routes/health.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAY,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/routes/health.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAY,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAc,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAQnF,UAAU,QAAS,SAAQ,WAAW;IACpC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,SAAS,EAAE,QAAQ,EAG/B,CAAC;AAGF,wBAAsB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAYnE;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAO/G;AAED;;;;;;GAMG;AACH,wBAAsB,MAAM,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAgChF"}
|
package/build/routes/health.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { GoogleTms, Nztm2000QuadTms } from '@basemaps/geo';
|
|
1
|
+
import { GoogleTms, Nztm2000QuadTms, ImageFormat } from '@basemaps/geo';
|
|
2
2
|
import { TileType } from '@basemaps/shared';
|
|
3
|
-
import { ImageFormat } from '@basemaps/tiler';
|
|
4
3
|
import { HttpHeader, LambdaHttpResponse } from '@linzjs/lambda';
|
|
5
4
|
import * as fs from 'fs';
|
|
6
5
|
import * as path from 'path';
|
|
@@ -9,8 +8,8 @@ import Sharp from 'sharp';
|
|
|
9
8
|
import url from 'url';
|
|
10
9
|
import { TileSets } from '../tile.set.cache.js';
|
|
11
10
|
export const TestTiles = [
|
|
12
|
-
{ type: TileType.Tile, name: 'health', tileMatrix: GoogleTms, ext: ImageFormat.
|
|
13
|
-
{ type: TileType.Tile, name: 'health', tileMatrix: Nztm2000QuadTms, ext: ImageFormat.
|
|
11
|
+
{ type: TileType.Tile, name: 'health', tileMatrix: GoogleTms, ext: ImageFormat.Png, x: 252, y: 156, z: 8 },
|
|
12
|
+
{ type: TileType.Tile, name: 'health', tileMatrix: Nztm2000QuadTms, ext: ImageFormat.Png, x: 30, y: 33, z: 6 },
|
|
14
13
|
];
|
|
15
14
|
const TileSize = 256;
|
|
16
15
|
export async function getTestBuffer(test) {
|
|
@@ -1,10 +1,3 @@
|
|
|
1
1
|
import { LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
|
|
2
|
-
export interface TileJson {
|
|
3
|
-
tiles: string[];
|
|
4
|
-
minzoom: number;
|
|
5
|
-
maxzoom: number;
|
|
6
|
-
format: string;
|
|
7
|
-
tilejson: string;
|
|
8
|
-
}
|
|
9
2
|
export declare function tileJson(req: LambdaHttpRequest): Promise<LambdaHttpResponse>;
|
|
10
3
|
//# sourceMappingURL=tile.json.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tile.json.d.ts","sourceRoot":"","sources":["../../src/routes/tile.json.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tile.json.d.ts","sourceRoot":"","sources":["../../src/routes/tile.json.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAMnF,wBAAsB,QAAQ,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAkClF"}
|
|
@@ -1,30 +1,38 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GoogleTms, TileMatrixSet } from '@basemaps/geo';
|
|
2
|
+
import { Env, extractTileMatrixSet } from '@basemaps/shared';
|
|
2
3
|
import { HttpHeader, LambdaHttpResponse } from '@linzjs/lambda';
|
|
3
|
-
import { createHash } from 'crypto';
|
|
4
4
|
import { Router } from '../router.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { TileSets } from '../tile.set.cache.js';
|
|
6
|
+
import { getTileMatrixId } from '../wmts.capability.js';
|
|
7
|
+
import { NotFound } from './response.js';
|
|
7
8
|
export async function tileJson(req) {
|
|
8
|
-
var _a;
|
|
9
|
+
var _a, _b, _c;
|
|
9
10
|
const { version, rest, name } = Router.action(req);
|
|
11
|
+
if (rest.length !== 3)
|
|
12
|
+
return NotFound;
|
|
13
|
+
const tileMatrix = extractTileMatrixSet(rest[1]);
|
|
14
|
+
if (tileMatrix == null)
|
|
15
|
+
return NotFound;
|
|
16
|
+
req.timer.start('tileset:load');
|
|
17
|
+
const tileSet = await TileSets.get(rest[0], tileMatrix);
|
|
18
|
+
req.timer.end('tileset:load');
|
|
19
|
+
if (tileSet == null)
|
|
20
|
+
return NotFound;
|
|
10
21
|
const apiKey = Router.apiKey(req);
|
|
11
22
|
const host = (_a = Env.get(Env.PublicUrlBase)) !== null && _a !== void 0 ? _a : '';
|
|
12
|
-
const tileUrl =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
const tileUrl = [host, version, name, tileSet.fullName, getTileMatrixId(tileMatrix), '{z}', '{x}', '{y}'].join('/') +
|
|
24
|
+
`.${tileSet.format}?api=${apiKey}`;
|
|
25
|
+
const tileJson = { tiles: [tileUrl], tilejson: '3.0.0' };
|
|
26
|
+
const maxZoom = TileMatrixSet.convertZoomLevel((_b = tileSet.tileSet.maxZoom) !== null && _b !== void 0 ? _b : 30, GoogleTms, tileMatrix, true);
|
|
27
|
+
const minZoom = TileMatrixSet.convertZoomLevel((_c = tileSet.tileSet.minZoom) !== null && _c !== void 0 ? _c : 0, GoogleTms, tileMatrix, true);
|
|
28
|
+
if (tileSet.tileSet.maxZoom)
|
|
29
|
+
tileJson.maxzoom = maxZoom;
|
|
30
|
+
if (tileSet.tileSet.minZoom)
|
|
31
|
+
tileJson.minzoom = minZoom;
|
|
20
32
|
const json = JSON.stringify(tileJson);
|
|
21
33
|
const data = Buffer.from(json);
|
|
22
|
-
const cacheKey = createHash('sha256').update(data).digest('base64');
|
|
23
|
-
if (TileEtag.isNotModified(req, cacheKey))
|
|
24
|
-
return NotModified;
|
|
25
34
|
const response = new LambdaHttpResponse(200, 'ok');
|
|
26
|
-
response.header(HttpHeader.
|
|
27
|
-
response.header(HttpHeader.CacheControl, 'max-age=120');
|
|
35
|
+
response.header(HttpHeader.CacheControl, 'no-store');
|
|
28
36
|
response.buffer(data, 'application/json');
|
|
29
37
|
req.set('bytes', data.byteLength);
|
|
30
38
|
return response;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tile.wmts.d.ts","sourceRoot":"","sources":["../../src/routes/tile.wmts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tile.wmts.d.ts","sourceRoot":"","sources":["../../src/routes/tile.wmts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAiB,MAAM,eAAe,CAAC;AAG3D,OAAO,EAAc,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AASnF,wBAAgB,eAAe,CAAC,GAAG,EAAE,iBAAiB,GAAG,WAAW,EAAE,GAAG,SAAS,CAYjF;AAED;;;;;GAKG;AACH,wBAAsB,IAAI,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAoC9E"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Config, TileSetType } from '@basemaps/config';
|
|
2
2
|
import { Env, TileSetName, tileWmtsFromPath } from '@basemaps/shared';
|
|
3
|
+
import { getImageFormat } from '@basemaps/tiler';
|
|
3
4
|
import { HttpHeader, LambdaHttpResponse } from '@linzjs/lambda';
|
|
4
5
|
import { createHash } from 'crypto';
|
|
5
6
|
import { Router } from '../router.js';
|
|
@@ -7,6 +8,21 @@ import { TileSets } from '../tile.set.cache.js';
|
|
|
7
8
|
import { WmtsCapabilities } from '../wmts.capability.js';
|
|
8
9
|
import { NotFound, NotModified } from './response.js';
|
|
9
10
|
import { TileEtag } from './tile.etag.js';
|
|
11
|
+
export function getImageFormats(req) {
|
|
12
|
+
const formats = req.query.getAll('format');
|
|
13
|
+
if (formats == null || formats.length === 0)
|
|
14
|
+
return undefined;
|
|
15
|
+
const output = new Set();
|
|
16
|
+
for (const fmt of formats) {
|
|
17
|
+
const parsed = getImageFormat(fmt);
|
|
18
|
+
if (parsed == null)
|
|
19
|
+
continue;
|
|
20
|
+
output.add(parsed);
|
|
21
|
+
}
|
|
22
|
+
if (output.size === 0)
|
|
23
|
+
return undefined;
|
|
24
|
+
return [...output.values()];
|
|
25
|
+
}
|
|
10
26
|
/**
|
|
11
27
|
* Serve a WMTS request
|
|
12
28
|
*
|
|
@@ -30,7 +46,13 @@ export async function wmts(req) {
|
|
|
30
46
|
if (provider == null)
|
|
31
47
|
return NotFound;
|
|
32
48
|
const apiKey = Router.apiKey(req);
|
|
33
|
-
const xml = WmtsCapabilities
|
|
49
|
+
const xml = new WmtsCapabilities({
|
|
50
|
+
httpBase: host,
|
|
51
|
+
provider,
|
|
52
|
+
layers: tileSets,
|
|
53
|
+
apiKey,
|
|
54
|
+
formats: getImageFormats(req),
|
|
55
|
+
}).toXml();
|
|
34
56
|
if (xml == null)
|
|
35
57
|
return NotFound;
|
|
36
58
|
const data = Buffer.from(xml);
|
package/build/tile.set.cache.js
CHANGED
|
@@ -54,7 +54,7 @@ export class TileSetCache {
|
|
|
54
54
|
}
|
|
55
55
|
// If we already have a copy and it hasn't been modified just return it
|
|
56
56
|
const existing = this.tileSets.get(tileSetId);
|
|
57
|
-
if ((existing === null || existing === void 0 ? void 0 : existing.tileSet.updatedAt) === tileSet.updatedAt) {
|
|
57
|
+
if (existing != null && (existing === null || existing === void 0 ? void 0 : existing.tileSet.updatedAt) === tileSet.updatedAt) {
|
|
58
58
|
return existing;
|
|
59
59
|
}
|
|
60
60
|
if (Config.isTileSetRaster(tileSet)) {
|
|
@@ -64,7 +64,7 @@ export class TileSetCache {
|
|
|
64
64
|
return ts;
|
|
65
65
|
}
|
|
66
66
|
const ts = new TileSetVector(name, tileMatrix);
|
|
67
|
-
ts.tileSet
|
|
67
|
+
await ts.init(tileSet);
|
|
68
68
|
this.tileSets.set(tileSetId, ts);
|
|
69
69
|
return ts;
|
|
70
70
|
}
|