@basemaps/lambda-tiler 7.3.0 → 7.4.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 +16 -0
- package/build/__tests__/tile.style.json.test.js +71 -16
- package/build/__tests__/tile.style.json.test.js.map +1 -1
- package/build/routes/tile.style.json.d.ts +5 -4
- package/build/routes/tile.style.json.js +25 -20
- package/build/routes/tile.style.json.js.map +1 -1
- package/package.json +9 -9
- package/src/__tests__/tile.style.json.test.ts +92 -16
- package/src/routes/tile.style.json.ts +34 -18
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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
|
+
# [7.4.0](https://github.com/linz/basemaps/compare/v7.3.0...v7.4.0) (2024-06-13)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **lambda-tiler:** Remove the stylejson metadata, sprite, glphys if no required. ([#3280](https://github.com/linz/basemaps/issues/3280)) ([edaf034](https://github.com/linz/basemaps/commit/edaf03413eafabd7330bccd228956d678a5de95f))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **lambda-tiler:** Update the tileMatrix from stylejson source if exists. ([#3279](https://github.com/linz/basemaps/issues/3279)) ([07ee06c](https://github.com/linz/basemaps/commit/07ee06c9fdc8ab8ced4e8b327767cd2a77cfee63))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# [7.3.0](https://github.com/linz/basemaps/compare/v7.2.0...v7.3.0) (2024-05-02)
|
|
7
23
|
|
|
8
24
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import assert from 'node:assert';
|
|
2
2
|
import { afterEach, beforeEach, describe, it } from 'node:test';
|
|
3
|
+
import { GoogleTms, Nztm2000QuadTms } from '@basemaps/geo';
|
|
3
4
|
import { Env } from '@basemaps/shared';
|
|
4
5
|
import { convertRelativeUrl, convertStyleJson } from '../routes/tile.style.json.js';
|
|
5
6
|
describe('TileStyleJson', () => {
|
|
@@ -22,22 +23,28 @@ describe('TileStyleJson', () => {
|
|
|
22
23
|
assert.equal(convertRelativeUrl('/bar/baz/'), 'https://tiles.test/bar/baz/');
|
|
23
24
|
});
|
|
24
25
|
it('should only convert with api keys', () => {
|
|
25
|
-
assert.equal(convertRelativeUrl('/foo', 'abc'), 'https://tiles.test/foo?api=abc');
|
|
26
|
-
assert.equal(convertRelativeUrl('/bar/baz/', 'abc'), 'https://tiles.test/bar/baz/?api=abc');
|
|
26
|
+
assert.equal(convertRelativeUrl('/foo', undefined, 'abc'), 'https://tiles.test/foo?api=abc');
|
|
27
|
+
assert.equal(convertRelativeUrl('/bar/baz/', undefined, 'abc'), 'https://tiles.test/bar/baz/?api=abc');
|
|
27
28
|
});
|
|
28
29
|
it('should convert with other query params', () => {
|
|
29
|
-
assert.equal(convertRelativeUrl('/foo?bar=baz', 'abc'), 'https://tiles.test/foo?bar=baz&api=abc');
|
|
30
|
+
assert.equal(convertRelativeUrl('/foo?bar=baz', undefined, 'abc'), 'https://tiles.test/foo?bar=baz&api=abc');
|
|
30
31
|
});
|
|
31
32
|
it('should not convert full urls', () => {
|
|
32
|
-
assert.equal(convertRelativeUrl('https://foo.com/foo?bar=baz', 'abc'), 'https://foo.com/foo?bar=baz');
|
|
33
|
+
assert.equal(convertRelativeUrl('https://foo.com/foo?bar=baz', undefined, 'abc'), 'https://foo.com/foo?bar=baz');
|
|
34
|
+
});
|
|
35
|
+
it('should update tileMatrix if exists', () => {
|
|
36
|
+
assert.equal(convertRelativeUrl('/{tileMatrix}/{z}/{x}/{y}.webp', GoogleTms), 'https://tiles.test/WebMercatorQuad/{z}/{x}/{y}.webp');
|
|
37
|
+
assert.equal(convertRelativeUrl('/{tileMatrix}/{z}/{x}/{y}.webp', Nztm2000QuadTms), 'https://tiles.test/NZTM2000Quad/{z}/{x}/{y}.webp');
|
|
38
|
+
assert.equal(convertRelativeUrl('/WebMercatorQuad/{z}/{x}/{y}.webp'), 'https://tiles.test/WebMercatorQuad/{z}/{x}/{y}.webp');
|
|
33
39
|
});
|
|
34
40
|
const baseStyleJson = {
|
|
35
41
|
version: 8,
|
|
36
42
|
id: 'style.id',
|
|
37
43
|
name: 'style.name',
|
|
38
44
|
sources: {
|
|
39
|
-
vector: { type: 'vector', url: '/v1/tiles/topographic/
|
|
40
|
-
raster: { type: 'raster', tiles: ['/v1/tiles/aerial/
|
|
45
|
+
vector: { type: 'vector', url: '/v1/tiles/topographic/{tileMatrix}/tile.json' },
|
|
46
|
+
raster: { type: 'raster', tiles: ['/v1/tiles/aerial/{tileMatrix}/{z}/{x}/{y}.webp'] },
|
|
47
|
+
terrain: { type: 'raster-dem', tiles: ['/v1/tiles/elevation/{tileMatrix}/{z}/{x}/{y}.png'] },
|
|
41
48
|
},
|
|
42
49
|
layers: [],
|
|
43
50
|
metadata: {},
|
|
@@ -46,32 +53,80 @@ describe('TileStyleJson', () => {
|
|
|
46
53
|
};
|
|
47
54
|
it('should not destroy the original configuration', () => {
|
|
48
55
|
const apiKey = 'abc123';
|
|
49
|
-
const converted = convertStyleJson(baseStyleJson, apiKey, null);
|
|
56
|
+
const converted = convertStyleJson(baseStyleJson, GoogleTms, apiKey, null);
|
|
50
57
|
assert.deepEqual(converted.sources['vector'], {
|
|
51
58
|
type: 'vector',
|
|
52
|
-
url: 'https://tiles.test/v1/tiles/topographic/
|
|
59
|
+
url: 'https://tiles.test/v1/tiles/topographic/WebMercatorQuad/tile.json?api=abc123',
|
|
53
60
|
});
|
|
54
61
|
assert.deepEqual(converted.sources['raster'], {
|
|
55
62
|
type: 'raster',
|
|
56
|
-
tiles: ['https://tiles.test/v1/tiles/aerial/
|
|
63
|
+
tiles: ['https://tiles.test/v1/tiles/aerial/WebMercatorQuad/{z}/{x}/{y}.webp?api=abc123'],
|
|
64
|
+
});
|
|
65
|
+
assert.deepEqual(converted.sources['terrain'], {
|
|
66
|
+
type: 'raster-dem',
|
|
67
|
+
tiles: ['https://tiles.test/v1/tiles/elevation/WebMercatorQuad/{z}/{x}/{y}.png?api=abc123'],
|
|
57
68
|
});
|
|
58
69
|
assert.equal(JSON.stringify(baseStyleJson).includes(apiKey), false);
|
|
59
|
-
const convertedB = convertStyleJson(baseStyleJson, '0x1234', null);
|
|
70
|
+
const convertedB = convertStyleJson(baseStyleJson, GoogleTms, '0x1234', null);
|
|
60
71
|
assert.deepEqual(convertedB.sources['vector'], {
|
|
61
72
|
type: 'vector',
|
|
62
|
-
url: 'https://tiles.test/v1/tiles/topographic/
|
|
73
|
+
url: 'https://tiles.test/v1/tiles/topographic/WebMercatorQuad/tile.json?api=0x1234',
|
|
63
74
|
});
|
|
64
75
|
assert.deepEqual(convertedB.sources['raster'], {
|
|
65
76
|
type: 'raster',
|
|
66
|
-
tiles: ['https://tiles.test/v1/tiles/aerial/
|
|
77
|
+
tiles: ['https://tiles.test/v1/tiles/aerial/WebMercatorQuad/{z}/{x}/{y}.webp?api=0x1234'],
|
|
78
|
+
});
|
|
79
|
+
assert.deepEqual(convertedB.sources['terrain'], {
|
|
80
|
+
type: 'raster-dem',
|
|
81
|
+
tiles: ['https://tiles.test/v1/tiles/elevation/WebMercatorQuad/{z}/{x}/{y}.png?api=0x1234'],
|
|
67
82
|
});
|
|
68
83
|
assert.equal(JSON.stringify(baseStyleJson).includes('0x1234'), false);
|
|
69
84
|
assert.equal(JSON.stringify(baseStyleJson).includes(apiKey), false);
|
|
70
85
|
assert.equal(JSON.stringify(baseStyleJson).includes('?api='), false);
|
|
71
86
|
});
|
|
87
|
+
const rasterStyleJson = {
|
|
88
|
+
version: 8,
|
|
89
|
+
id: 'style.id',
|
|
90
|
+
name: 'style.name',
|
|
91
|
+
sources: {
|
|
92
|
+
raster: { type: 'raster', tiles: ['/v1/tiles/aerial/{tileMatrix}/{z}/{x}/{y}.webp'] },
|
|
93
|
+
terrain: { type: 'raster-dem', tiles: ['/v1/tiles/elevation/{tileMatrix}/{z}/{x}/{y}.png'] },
|
|
94
|
+
},
|
|
95
|
+
layers: [],
|
|
96
|
+
};
|
|
97
|
+
it('should cover raster style Json without metadata, sprite and glyphs', () => {
|
|
98
|
+
const apiKey = 'abc123';
|
|
99
|
+
const converted = convertStyleJson(rasterStyleJson, GoogleTms, apiKey, null);
|
|
100
|
+
assert.equal(converted.metadata, null);
|
|
101
|
+
assert.equal(converted.sprite, null);
|
|
102
|
+
assert.equal(converted.sprite, null);
|
|
103
|
+
});
|
|
104
|
+
it('should cover for raster styles for NZTM2000Quad', () => {
|
|
105
|
+
const rasterStyleJson = {
|
|
106
|
+
...baseStyleJson,
|
|
107
|
+
sources: {
|
|
108
|
+
raster: { type: 'raster', tiles: ['/v1/tiles/aerial/{tileMatrix}/{z}/{x}/{y}.webp'] },
|
|
109
|
+
terrain: { type: 'raster-dem', tiles: ['/v1/tiles/elevation/{tileMatrix}/{z}/{x}/{y}.png'] },
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
const converted = convertStyleJson(rasterStyleJson, Nztm2000QuadTms, 'abc123', null);
|
|
113
|
+
assert.deepEqual(converted.sources['raster'], {
|
|
114
|
+
type: 'raster',
|
|
115
|
+
tiles: ['https://tiles.test/v1/tiles/aerial/NZTM2000Quad/{z}/{x}/{y}.webp?api=abc123'],
|
|
116
|
+
});
|
|
117
|
+
assert.deepEqual(converted.sources['terrain'], {
|
|
118
|
+
type: 'raster-dem',
|
|
119
|
+
tiles: ['https://tiles.test/v1/tiles/elevation/NZTM2000Quad/{z}/{x}/{y}.png?api=abc123'],
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
it('should thrown error for NZTM2000Quad with vector source', () => {
|
|
123
|
+
const expected = new Error('TileMatrix is not supported for the vector source /v1/tiles/topographic/{tileMatrix}/tile.json.');
|
|
124
|
+
const converted = () => convertStyleJson(baseStyleJson, Nztm2000QuadTms, 'abc123', null);
|
|
125
|
+
assert.throws(converted, expected);
|
|
126
|
+
});
|
|
72
127
|
it('should convert relative glyphs and sprites', () => {
|
|
73
128
|
const apiKey = '0x9f9f';
|
|
74
|
-
const converted = convertStyleJson(baseStyleJson, apiKey, null);
|
|
129
|
+
const converted = convertStyleJson(baseStyleJson, GoogleTms, apiKey, null);
|
|
75
130
|
assert.equal(converted.sprite, 'https://tiles.test/v1/sprites');
|
|
76
131
|
assert.equal(converted.glyphs, 'https://tiles.test/v1/glyphs');
|
|
77
132
|
assert.equal(JSON.stringify(baseStyleJson).includes(apiKey), false);
|
|
@@ -79,16 +134,16 @@ describe('TileStyleJson', () => {
|
|
|
79
134
|
});
|
|
80
135
|
it('should convert with config', () => {
|
|
81
136
|
const apiKey = '0x9f9f';
|
|
82
|
-
const converted = convertStyleJson(baseStyleJson, apiKey, 'config.json');
|
|
137
|
+
const converted = convertStyleJson(baseStyleJson, GoogleTms, apiKey, 'config.json');
|
|
83
138
|
assert.equal(converted.sprite, 'https://tiles.test/v1/sprites?config=config.json');
|
|
84
139
|
assert.equal(converted.glyphs, 'https://tiles.test/v1/glyphs?config=config.json');
|
|
85
140
|
assert.deepEqual(converted.sources['vector'], {
|
|
86
141
|
type: 'vector',
|
|
87
|
-
url: 'https://tiles.test/v1/tiles/topographic/
|
|
142
|
+
url: 'https://tiles.test/v1/tiles/topographic/WebMercatorQuad/tile.json?api=0x9f9f&config=config.json',
|
|
88
143
|
});
|
|
89
144
|
assert.deepEqual(converted.sources['raster'], {
|
|
90
145
|
type: 'raster',
|
|
91
|
-
tiles: ['https://tiles.test/v1/tiles/aerial/
|
|
146
|
+
tiles: ['https://tiles.test/v1/tiles/aerial/WebMercatorQuad/{z}/{x}/{y}.webp?api=0x9f9f&config=config.json'],
|
|
92
147
|
});
|
|
93
148
|
});
|
|
94
149
|
});
|
|
@@ -1 +1 @@
|
|
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AAE,iDAAiD,CAAC,CAAC;QAElF,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC5C,IAAI,EAAE,QAAQ;YACd,GAAG,EAAE,iGAAiG;SACvG,CAAC,CAAC;QACH,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC5C,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,CAAC,mGAAmG,CAAC;SAC7G,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ConfigTileSetRaster, Layer, StyleJson } from '@basemaps/config';
|
|
2
|
+
import { TileMatrixSet } from '@basemaps/geo';
|
|
2
3
|
import { LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
|
|
3
4
|
/**
|
|
4
5
|
* Convert relative URLS into a full hostname url
|
|
@@ -6,19 +7,19 @@ import { LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
|
|
|
6
7
|
* @param apiKey ApiKey to append with ?api= if required
|
|
7
8
|
* @returns Updated Url or empty string if url is empty
|
|
8
9
|
*/
|
|
9
|
-
export declare function convertRelativeUrl(url?: string, apiKey?: string, config?: string | null): string;
|
|
10
|
+
export declare function convertRelativeUrl(url?: string, tileMatrix?: TileMatrixSet, apiKey?: string, config?: string | null): string;
|
|
10
11
|
/**
|
|
11
12
|
* Create a new style json that has absolute urls to the current host and API Keys where required
|
|
12
13
|
* @param style style to update
|
|
13
14
|
* @param apiKey api key to inject
|
|
14
15
|
* @returns new stylejson
|
|
15
16
|
*/
|
|
16
|
-
export declare function convertStyleJson(style: StyleJson, apiKey: string, config: string | null, layers?: Layer[]): StyleJson;
|
|
17
|
+
export declare function convertStyleJson(style: StyleJson, tileMatrix: TileMatrixSet, apiKey: string, config: string | null, layers?: Layer[]): StyleJson;
|
|
17
18
|
export interface StyleGet {
|
|
18
19
|
Params: {
|
|
19
20
|
styleName: string;
|
|
20
21
|
};
|
|
21
22
|
}
|
|
22
|
-
export declare function tileSetToStyle(req: LambdaHttpRequest<StyleGet>, tileSet: ConfigTileSetRaster, apiKey: string): Promise<LambdaHttpResponse>;
|
|
23
|
-
export declare function tileSetOutputToStyle(req: LambdaHttpRequest<StyleGet>, tileSet: ConfigTileSetRaster, apiKey: string): Promise<LambdaHttpResponse>;
|
|
23
|
+
export declare function tileSetToStyle(req: LambdaHttpRequest<StyleGet>, tileSet: ConfigTileSetRaster, tileMatrix: TileMatrixSet, apiKey: string): Promise<LambdaHttpResponse>;
|
|
24
|
+
export declare function tileSetOutputToStyle(req: LambdaHttpRequest<StyleGet>, tileSet: ConfigTileSetRaster, tileMatrix: TileMatrixSet, apiKey: string): Promise<LambdaHttpResponse>;
|
|
24
25
|
export declare function styleJsonGet(req: LambdaHttpRequest<StyleGet>): Promise<LambdaHttpResponse>;
|
|
@@ -13,9 +13,11 @@ import { Validate } from '../util/validate.js';
|
|
|
13
13
|
* @param apiKey ApiKey to append with ?api= if required
|
|
14
14
|
* @returns Updated Url or empty string if url is empty
|
|
15
15
|
*/
|
|
16
|
-
export function convertRelativeUrl(url, apiKey, config) {
|
|
16
|
+
export function convertRelativeUrl(url, tileMatrix, apiKey, config) {
|
|
17
17
|
if (url == null)
|
|
18
18
|
return '';
|
|
19
|
+
if (tileMatrix)
|
|
20
|
+
url = url.replace('{tileMatrix}', tileMatrix.identifier);
|
|
19
21
|
const host = Env.get(Env.PublicUrlBase) ?? '';
|
|
20
22
|
if (!url.startsWith('/'))
|
|
21
23
|
return url; // Not relative ignore
|
|
@@ -32,34 +34,37 @@ export function convertRelativeUrl(url, apiKey, config) {
|
|
|
32
34
|
* @param apiKey api key to inject
|
|
33
35
|
* @returns new stylejson
|
|
34
36
|
*/
|
|
35
|
-
export function convertStyleJson(style, apiKey, config, layers) {
|
|
37
|
+
export function convertStyleJson(style, tileMatrix, apiKey, config, layers) {
|
|
36
38
|
const sources = JSON.parse(JSON.stringify(style.sources));
|
|
37
39
|
for (const [key, value] of Object.entries(sources)) {
|
|
38
40
|
if (value.type === 'vector') {
|
|
39
|
-
|
|
41
|
+
if (tileMatrix !== GoogleTms)
|
|
42
|
+
throw new Error(`TileMatrix is not supported for the vector source ${value.url}.`);
|
|
43
|
+
value.url = convertRelativeUrl(value.url, tileMatrix, apiKey, config);
|
|
40
44
|
}
|
|
41
|
-
else if (value.type === 'raster' && Array.isArray(value.tiles)) {
|
|
45
|
+
else if ((value.type === 'raster' || value.type === 'raster-dem') && Array.isArray(value.tiles)) {
|
|
42
46
|
for (let i = 0; i < value.tiles.length; i++) {
|
|
43
|
-
value.tiles[i] = convertRelativeUrl(value.tiles[i], apiKey, config);
|
|
47
|
+
value.tiles[i] = convertRelativeUrl(value.tiles[i], tileMatrix, apiKey, config);
|
|
44
48
|
}
|
|
45
49
|
}
|
|
46
50
|
sources[key] = value;
|
|
47
51
|
}
|
|
48
|
-
|
|
52
|
+
const styleJson = {
|
|
49
53
|
version: 8,
|
|
50
54
|
id: style.id,
|
|
51
55
|
name: style.name,
|
|
52
56
|
sources,
|
|
53
57
|
layers: layers ? layers : style.layers,
|
|
54
|
-
metadata: style.metadata ?? {},
|
|
55
|
-
glyphs: convertRelativeUrl(style.glyphs, undefined, config),
|
|
56
|
-
sprite: convertRelativeUrl(style.sprite, undefined, config),
|
|
57
58
|
};
|
|
59
|
+
if (style.metadata)
|
|
60
|
+
styleJson.metadata = style.metadata;
|
|
61
|
+
if (style.glyphs)
|
|
62
|
+
styleJson.glyphs = convertRelativeUrl(style.glyphs, undefined, undefined, config);
|
|
63
|
+
if (style.sprite)
|
|
64
|
+
styleJson.sprite = convertRelativeUrl(style.sprite, undefined, undefined, config);
|
|
65
|
+
return styleJson;
|
|
58
66
|
}
|
|
59
|
-
export async function tileSetToStyle(req, tileSet, apiKey) {
|
|
60
|
-
const tileMatrix = TileMatrixSets.find(req.query.get('tileMatrix') ?? GoogleTms.identifier);
|
|
61
|
-
if (tileMatrix == null)
|
|
62
|
-
return new LambdaHttpResponse(400, 'Invalid tile matrix');
|
|
67
|
+
export async function tileSetToStyle(req, tileSet, tileMatrix, apiKey) {
|
|
63
68
|
const [tileFormat] = Validate.getRequestedFormats(req) ?? ['webp'];
|
|
64
69
|
if (tileFormat == null)
|
|
65
70
|
return new LambdaHttpResponse(400, 'Invalid image format');
|
|
@@ -86,10 +91,7 @@ export async function tileSetToStyle(req, tileSet, apiKey) {
|
|
|
86
91
|
req.set('bytes', data.byteLength);
|
|
87
92
|
return response;
|
|
88
93
|
}
|
|
89
|
-
export async function tileSetOutputToStyle(req, tileSet, apiKey) {
|
|
90
|
-
const tileMatrix = TileMatrixSets.find(req.query.get('tileMatrix') ?? GoogleTms.identifier);
|
|
91
|
-
if (tileMatrix == null)
|
|
92
|
-
return new LambdaHttpResponse(400, 'Invalid tile matrix');
|
|
94
|
+
export async function tileSetOutputToStyle(req, tileSet, tileMatrix, apiKey) {
|
|
93
95
|
const configLocation = ConfigLoader.extract(req);
|
|
94
96
|
const query = toQueryString({ config: configLocation, api: apiKey });
|
|
95
97
|
const styleId = `basemaps-${tileSet.name}`;
|
|
@@ -152,6 +154,9 @@ export async function styleJsonGet(req) {
|
|
|
152
154
|
const styleName = req.params.styleName;
|
|
153
155
|
const excludeLayers = req.query.getAll('exclude');
|
|
154
156
|
const excluded = new Set(excludeLayers.map((l) => l.toLowerCase()));
|
|
157
|
+
const tileMatrix = TileMatrixSets.find(req.query.get('tileMatrix') ?? GoogleTms.identifier);
|
|
158
|
+
if (tileMatrix == null)
|
|
159
|
+
return new LambdaHttpResponse(400, 'Invalid tile matrix');
|
|
155
160
|
// Get style Config from db
|
|
156
161
|
const config = await ConfigLoader.load(req);
|
|
157
162
|
const dbId = config.Style.id(styleName);
|
|
@@ -164,12 +169,12 @@ export async function styleJsonGet(req) {
|
|
|
164
169
|
if (tileSet.type !== TileSetType.Raster)
|
|
165
170
|
return NotFound();
|
|
166
171
|
if (tileSet.outputs)
|
|
167
|
-
return tileSetOutputToStyle(req, tileSet, apiKey);
|
|
172
|
+
return tileSetOutputToStyle(req, tileSet, tileMatrix, apiKey);
|
|
168
173
|
else
|
|
169
|
-
return tileSetToStyle(req, tileSet, apiKey);
|
|
174
|
+
return tileSetToStyle(req, tileSet, tileMatrix, apiKey);
|
|
170
175
|
}
|
|
171
176
|
// Prepare sources and add linz source
|
|
172
|
-
const style = convertStyleJson(styleConfig.style, apiKey, ConfigLoader.extract(req), styleConfig.style.layers.filter((f) => !excluded.has(f.id.toLowerCase())));
|
|
177
|
+
const style = convertStyleJson(styleConfig.style, tileMatrix, apiKey, ConfigLoader.extract(req), styleConfig.style.layers.filter((f) => !excluded.has(f.id.toLowerCase())));
|
|
173
178
|
const data = Buffer.from(JSON.stringify(style));
|
|
174
179
|
const cacheKey = Etag.key(data);
|
|
175
180
|
if (Etag.isNotModified(req, cacheKey))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tile.style.json.js","sourceRoot":"","sources":["../../src/routes/tile.style.json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkD,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/F,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"tile.style.json.js","sourceRoot":"","sources":["../../src/routes/tile.style.json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkD,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/F,OAAO,EAAE,SAAS,EAAiB,cAAc,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAqB,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;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
|
"url": "https://github.com/linz/basemaps.git",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"types": "./build/index.d.ts",
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@basemaps/config": "^7.
|
|
26
|
-
"@basemaps/config-loader": "^7.
|
|
27
|
-
"@basemaps/geo": "^7.
|
|
28
|
-
"@basemaps/shared": "^7.
|
|
29
|
-
"@basemaps/tiler": "^7.
|
|
30
|
-
"@basemaps/tiler-sharp": "^7.
|
|
25
|
+
"@basemaps/config": "^7.4.0",
|
|
26
|
+
"@basemaps/config-loader": "^7.4.0",
|
|
27
|
+
"@basemaps/geo": "^7.4.0",
|
|
28
|
+
"@basemaps/shared": "^7.4.0",
|
|
29
|
+
"@basemaps/tiler": "^7.4.0",
|
|
30
|
+
"@basemaps/tiler-sharp": "^7.4.0",
|
|
31
31
|
"@linzjs/geojson": "^7.1.0",
|
|
32
32
|
"@linzjs/lambda": "^4.0.0",
|
|
33
33
|
"p-limit": "^4.0.0",
|
|
@@ -49,11 +49,11 @@
|
|
|
49
49
|
"bundle": "./bundle.sh"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@basemaps/attribution": "^7.
|
|
52
|
+
"@basemaps/attribution": "^7.4.0",
|
|
53
53
|
"@chunkd/fs": "^11.2.0",
|
|
54
54
|
"@types/aws-lambda": "^8.10.75",
|
|
55
55
|
"@types/pixelmatch": "^5.0.0",
|
|
56
56
|
"pretty-json-log": "^1.0.0"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "4302f0ced0baff4b2c3240029c3b3a7bae062d7c"
|
|
59
59
|
}
|
|
@@ -2,6 +2,7 @@ import assert from 'node:assert';
|
|
|
2
2
|
import { afterEach, beforeEach, describe, it } from 'node:test';
|
|
3
3
|
|
|
4
4
|
import { StyleJson } from '@basemaps/config';
|
|
5
|
+
import { GoogleTms, Nztm2000QuadTms } from '@basemaps/geo';
|
|
5
6
|
import { Env } from '@basemaps/shared';
|
|
6
7
|
|
|
7
8
|
import { convertRelativeUrl, convertStyleJson } from '../routes/tile.style.json.js';
|
|
@@ -30,16 +31,31 @@ describe('TileStyleJson', () => {
|
|
|
30
31
|
});
|
|
31
32
|
|
|
32
33
|
it('should only convert with api keys', () => {
|
|
33
|
-
assert.equal(convertRelativeUrl('/foo', 'abc'), 'https://tiles.test/foo?api=abc');
|
|
34
|
-
assert.equal(convertRelativeUrl('/bar/baz/', 'abc'), 'https://tiles.test/bar/baz/?api=abc');
|
|
34
|
+
assert.equal(convertRelativeUrl('/foo', undefined, 'abc'), 'https://tiles.test/foo?api=abc');
|
|
35
|
+
assert.equal(convertRelativeUrl('/bar/baz/', undefined, 'abc'), 'https://tiles.test/bar/baz/?api=abc');
|
|
35
36
|
});
|
|
36
37
|
|
|
37
38
|
it('should convert with other query params', () => {
|
|
38
|
-
assert.equal(convertRelativeUrl('/foo?bar=baz', 'abc'), 'https://tiles.test/foo?bar=baz&api=abc');
|
|
39
|
+
assert.equal(convertRelativeUrl('/foo?bar=baz', undefined, 'abc'), 'https://tiles.test/foo?bar=baz&api=abc');
|
|
39
40
|
});
|
|
40
41
|
|
|
41
42
|
it('should not convert full urls', () => {
|
|
42
|
-
assert.equal(convertRelativeUrl('https://foo.com/foo?bar=baz', 'abc'), 'https://foo.com/foo?bar=baz');
|
|
43
|
+
assert.equal(convertRelativeUrl('https://foo.com/foo?bar=baz', undefined, 'abc'), 'https://foo.com/foo?bar=baz');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should update tileMatrix if exists', () => {
|
|
47
|
+
assert.equal(
|
|
48
|
+
convertRelativeUrl('/{tileMatrix}/{z}/{x}/{y}.webp', GoogleTms),
|
|
49
|
+
'https://tiles.test/WebMercatorQuad/{z}/{x}/{y}.webp',
|
|
50
|
+
);
|
|
51
|
+
assert.equal(
|
|
52
|
+
convertRelativeUrl('/{tileMatrix}/{z}/{x}/{y}.webp', Nztm2000QuadTms),
|
|
53
|
+
'https://tiles.test/NZTM2000Quad/{z}/{x}/{y}.webp',
|
|
54
|
+
);
|
|
55
|
+
assert.equal(
|
|
56
|
+
convertRelativeUrl('/WebMercatorQuad/{z}/{x}/{y}.webp'),
|
|
57
|
+
'https://tiles.test/WebMercatorQuad/{z}/{x}/{y}.webp',
|
|
58
|
+
);
|
|
43
59
|
});
|
|
44
60
|
|
|
45
61
|
const baseStyleJson: StyleJson = {
|
|
@@ -47,8 +63,9 @@ describe('TileStyleJson', () => {
|
|
|
47
63
|
id: 'style.id',
|
|
48
64
|
name: 'style.name',
|
|
49
65
|
sources: {
|
|
50
|
-
vector: { type: 'vector', url: '/v1/tiles/topographic/
|
|
51
|
-
raster: { type: 'raster', tiles: ['/v1/tiles/aerial/
|
|
66
|
+
vector: { type: 'vector', url: '/v1/tiles/topographic/{tileMatrix}/tile.json' },
|
|
67
|
+
raster: { type: 'raster', tiles: ['/v1/tiles/aerial/{tileMatrix}/{z}/{x}/{y}.webp'] },
|
|
68
|
+
terrain: { type: 'raster-dem', tiles: ['/v1/tiles/elevation/{tileMatrix}/{z}/{x}/{y}.png'] },
|
|
52
69
|
},
|
|
53
70
|
layers: [],
|
|
54
71
|
metadata: {},
|
|
@@ -58,27 +75,35 @@ describe('TileStyleJson', () => {
|
|
|
58
75
|
|
|
59
76
|
it('should not destroy the original configuration', () => {
|
|
60
77
|
const apiKey = 'abc123';
|
|
61
|
-
const converted = convertStyleJson(baseStyleJson, apiKey, null);
|
|
78
|
+
const converted = convertStyleJson(baseStyleJson, GoogleTms, apiKey, null);
|
|
62
79
|
|
|
63
80
|
assert.deepEqual(converted.sources['vector'], {
|
|
64
81
|
type: 'vector',
|
|
65
|
-
url: 'https://tiles.test/v1/tiles/topographic/
|
|
82
|
+
url: 'https://tiles.test/v1/tiles/topographic/WebMercatorQuad/tile.json?api=abc123',
|
|
66
83
|
});
|
|
67
84
|
assert.deepEqual(converted.sources['raster'], {
|
|
68
85
|
type: 'raster',
|
|
69
|
-
tiles: ['https://tiles.test/v1/tiles/aerial/
|
|
86
|
+
tiles: ['https://tiles.test/v1/tiles/aerial/WebMercatorQuad/{z}/{x}/{y}.webp?api=abc123'],
|
|
87
|
+
});
|
|
88
|
+
assert.deepEqual(converted.sources['terrain'], {
|
|
89
|
+
type: 'raster-dem',
|
|
90
|
+
tiles: ['https://tiles.test/v1/tiles/elevation/WebMercatorQuad/{z}/{x}/{y}.png?api=abc123'],
|
|
70
91
|
});
|
|
71
92
|
|
|
72
93
|
assert.equal(JSON.stringify(baseStyleJson).includes(apiKey), false);
|
|
73
94
|
|
|
74
|
-
const convertedB = convertStyleJson(baseStyleJson, '0x1234', null);
|
|
95
|
+
const convertedB = convertStyleJson(baseStyleJson, GoogleTms, '0x1234', null);
|
|
75
96
|
assert.deepEqual(convertedB.sources['vector'], {
|
|
76
97
|
type: 'vector',
|
|
77
|
-
url: 'https://tiles.test/v1/tiles/topographic/
|
|
98
|
+
url: 'https://tiles.test/v1/tiles/topographic/WebMercatorQuad/tile.json?api=0x1234',
|
|
78
99
|
});
|
|
79
100
|
assert.deepEqual(convertedB.sources['raster'], {
|
|
80
101
|
type: 'raster',
|
|
81
|
-
tiles: ['https://tiles.test/v1/tiles/aerial/
|
|
102
|
+
tiles: ['https://tiles.test/v1/tiles/aerial/WebMercatorQuad/{z}/{x}/{y}.webp?api=0x1234'],
|
|
103
|
+
});
|
|
104
|
+
assert.deepEqual(convertedB.sources['terrain'], {
|
|
105
|
+
type: 'raster-dem',
|
|
106
|
+
tiles: ['https://tiles.test/v1/tiles/elevation/WebMercatorQuad/{z}/{x}/{y}.png?api=0x1234'],
|
|
82
107
|
});
|
|
83
108
|
|
|
84
109
|
assert.equal(JSON.stringify(baseStyleJson).includes('0x1234'), false);
|
|
@@ -86,9 +111,60 @@ describe('TileStyleJson', () => {
|
|
|
86
111
|
assert.equal(JSON.stringify(baseStyleJson).includes('?api='), false);
|
|
87
112
|
});
|
|
88
113
|
|
|
114
|
+
const rasterStyleJson: StyleJson = {
|
|
115
|
+
version: 8,
|
|
116
|
+
id: 'style.id',
|
|
117
|
+
name: 'style.name',
|
|
118
|
+
sources: {
|
|
119
|
+
raster: { type: 'raster', tiles: ['/v1/tiles/aerial/{tileMatrix}/{z}/{x}/{y}.webp'] },
|
|
120
|
+
terrain: { type: 'raster-dem', tiles: ['/v1/tiles/elevation/{tileMatrix}/{z}/{x}/{y}.png'] },
|
|
121
|
+
},
|
|
122
|
+
layers: [],
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
it('should cover raster style Json without metadata, sprite and glyphs', () => {
|
|
126
|
+
const apiKey = 'abc123';
|
|
127
|
+
const converted = convertStyleJson(rasterStyleJson, GoogleTms, apiKey, null);
|
|
128
|
+
|
|
129
|
+
assert.equal(converted.metadata, null);
|
|
130
|
+
assert.equal(converted.sprite, null);
|
|
131
|
+
assert.equal(converted.sprite, null);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('should cover for raster styles for NZTM2000Quad', () => {
|
|
135
|
+
const rasterStyleJson: StyleJson = {
|
|
136
|
+
...baseStyleJson,
|
|
137
|
+
sources: {
|
|
138
|
+
raster: { type: 'raster', tiles: ['/v1/tiles/aerial/{tileMatrix}/{z}/{x}/{y}.webp'] },
|
|
139
|
+
terrain: { type: 'raster-dem', tiles: ['/v1/tiles/elevation/{tileMatrix}/{z}/{x}/{y}.png'] },
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const converted = convertStyleJson(rasterStyleJson, Nztm2000QuadTms, 'abc123', null);
|
|
144
|
+
|
|
145
|
+
assert.deepEqual(converted.sources['raster'], {
|
|
146
|
+
type: 'raster',
|
|
147
|
+
tiles: ['https://tiles.test/v1/tiles/aerial/NZTM2000Quad/{z}/{x}/{y}.webp?api=abc123'],
|
|
148
|
+
});
|
|
149
|
+
assert.deepEqual(converted.sources['terrain'], {
|
|
150
|
+
type: 'raster-dem',
|
|
151
|
+
tiles: ['https://tiles.test/v1/tiles/elevation/NZTM2000Quad/{z}/{x}/{y}.png?api=abc123'],
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('should thrown error for NZTM2000Quad with vector source', () => {
|
|
156
|
+
const expected = new Error(
|
|
157
|
+
'TileMatrix is not supported for the vector source /v1/tiles/topographic/{tileMatrix}/tile.json.',
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
const converted = (): StyleJson => convertStyleJson(baseStyleJson, Nztm2000QuadTms, 'abc123', null);
|
|
161
|
+
|
|
162
|
+
assert.throws(converted, expected);
|
|
163
|
+
});
|
|
164
|
+
|
|
89
165
|
it('should convert relative glyphs and sprites', () => {
|
|
90
166
|
const apiKey = '0x9f9f';
|
|
91
|
-
const converted = convertStyleJson(baseStyleJson, apiKey, null);
|
|
167
|
+
const converted = convertStyleJson(baseStyleJson, GoogleTms, apiKey, null);
|
|
92
168
|
assert.equal(converted.sprite, 'https://tiles.test/v1/sprites');
|
|
93
169
|
assert.equal(converted.glyphs, 'https://tiles.test/v1/glyphs');
|
|
94
170
|
|
|
@@ -98,17 +174,17 @@ describe('TileStyleJson', () => {
|
|
|
98
174
|
|
|
99
175
|
it('should convert with config', () => {
|
|
100
176
|
const apiKey = '0x9f9f';
|
|
101
|
-
const converted = convertStyleJson(baseStyleJson, apiKey, 'config.json');
|
|
177
|
+
const converted = convertStyleJson(baseStyleJson, GoogleTms, apiKey, 'config.json');
|
|
102
178
|
assert.equal(converted.sprite, 'https://tiles.test/v1/sprites?config=config.json');
|
|
103
179
|
assert.equal(converted.glyphs, 'https://tiles.test/v1/glyphs?config=config.json');
|
|
104
180
|
|
|
105
181
|
assert.deepEqual(converted.sources['vector'], {
|
|
106
182
|
type: 'vector',
|
|
107
|
-
url: 'https://tiles.test/v1/tiles/topographic/
|
|
183
|
+
url: 'https://tiles.test/v1/tiles/topographic/WebMercatorQuad/tile.json?api=0x9f9f&config=config.json',
|
|
108
184
|
});
|
|
109
185
|
assert.deepEqual(converted.sources['raster'], {
|
|
110
186
|
type: 'raster',
|
|
111
|
-
tiles: ['https://tiles.test/v1/tiles/aerial/
|
|
187
|
+
tiles: ['https://tiles.test/v1/tiles/aerial/WebMercatorQuad/{z}/{x}/{y}.webp?api=0x9f9f&config=config.json'],
|
|
112
188
|
});
|
|
113
189
|
});
|
|
114
190
|
});
|