@basemaps/lambda-tiler 6.38.0 → 6.40.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.
Files changed (126) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/build/__tests__/config.data.d.ts.map +1 -1
  3. package/build/__tests__/config.data.js +142 -1
  4. package/build/__tests__/config.data.js.map +1 -1
  5. package/build/__tests__/wmts.capability.test.js +9 -16
  6. package/build/__tests__/wmts.capability.test.js.map +1 -1
  7. package/build/__tests__/xyz.util.d.ts.map +1 -1
  8. package/build/__tests__/xyz.util.js +6 -2
  9. package/build/__tests__/xyz.util.js.map +1 -1
  10. package/build/cli/render.tile.d.ts +2 -0
  11. package/build/cli/render.tile.d.ts.map +1 -0
  12. package/build/cli/render.tile.js +33 -0
  13. package/build/cli/render.tile.js.map +1 -0
  14. package/build/routes/__tests__/attribution.test.js +63 -3
  15. package/build/routes/__tests__/attribution.test.js.map +1 -1
  16. package/build/routes/__tests__/tile.style.json.test.js +91 -43
  17. package/build/routes/__tests__/tile.style.json.test.js.map +1 -1
  18. package/build/routes/__tests__/wmts.test.js +50 -8
  19. package/build/routes/__tests__/wmts.test.js.map +1 -1
  20. package/build/routes/attribution.d.ts +12 -0
  21. package/build/routes/attribution.d.ts.map +1 -1
  22. package/build/routes/attribution.js +29 -27
  23. package/build/routes/attribution.js.map +1 -1
  24. package/build/routes/tile.json.d.ts.map +1 -1
  25. package/build/routes/tile.json.js +2 -1
  26. package/build/routes/tile.json.js.map +1 -1
  27. package/build/routes/tile.style.json.d.ts +2 -2
  28. package/build/routes/tile.style.json.d.ts.map +1 -1
  29. package/build/routes/tile.style.json.js +7 -4
  30. package/build/routes/tile.style.json.js.map +1 -1
  31. package/build/routes/tile.wmts.d.ts.map +1 -1
  32. package/build/routes/tile.wmts.js +3 -1
  33. package/build/routes/tile.wmts.js.map +1 -1
  34. package/build/routes/tile.xyz.raster.d.ts.map +1 -1
  35. package/build/routes/tile.xyz.raster.js +9 -6
  36. package/build/routes/tile.xyz.raster.js.map +1 -1
  37. package/build/util/__test__/filter.test.d.ts +2 -0
  38. package/build/util/__test__/filter.test.d.ts.map +1 -0
  39. package/build/util/__test__/filter.test.js +64 -0
  40. package/build/util/__test__/filter.test.js.map +1 -0
  41. package/build/util/config.loader.d.ts.map +1 -1
  42. package/build/util/config.loader.js +2 -3
  43. package/build/util/config.loader.js.map +1 -1
  44. package/build/util/filter.d.ts +15 -0
  45. package/build/util/filter.d.ts.map +1 -0
  46. package/build/util/filter.js +59 -0
  47. package/build/util/filter.js.map +1 -0
  48. package/build/wmts.capability.d.ts +8 -5
  49. package/build/wmts.capability.d.ts.map +1 -1
  50. package/build/wmts.capability.js +17 -15
  51. package/build/wmts.capability.js.map +1 -1
  52. package/dist/index.js +60 -60
  53. package/dist/node_modules/.package-lock.json +14 -14
  54. package/dist/node_modules/minimist/.eslintrc +25 -50
  55. package/dist/node_modules/minimist/CHANGELOG.md +87 -1
  56. package/dist/node_modules/minimist/README.md +14 -10
  57. package/dist/node_modules/minimist/example/parse.js +2 -0
  58. package/dist/node_modules/minimist/index.js +256 -242
  59. package/dist/node_modules/minimist/package.json +73 -73
  60. package/dist/node_modules/minimist/test/all_bool.js +26 -24
  61. package/dist/node_modules/minimist/test/bool.js +146 -147
  62. package/dist/node_modules/minimist/test/dash.js +33 -21
  63. package/dist/node_modules/minimist/test/default_bool.js +26 -24
  64. package/dist/node_modules/minimist/test/dotted.js +13 -11
  65. package/dist/node_modules/minimist/test/kv_short.js +26 -10
  66. package/dist/node_modules/minimist/test/long.js +28 -26
  67. package/dist/node_modules/minimist/test/num.js +30 -28
  68. package/dist/node_modules/minimist/test/parse.js +169 -157
  69. package/dist/node_modules/minimist/test/parse_modified.js +7 -5
  70. package/dist/node_modules/minimist/test/proto.js +41 -37
  71. package/dist/node_modules/minimist/test/short.js +57 -55
  72. package/dist/node_modules/minimist/test/stop_early.js +10 -8
  73. package/dist/node_modules/minimist/test/unknown.js +83 -81
  74. package/dist/node_modules/minimist/test/whitespace.js +6 -4
  75. package/dist/node_modules/node-abi/.circleci/config.yml +7 -25
  76. package/dist/node_modules/node-abi/.github/CODEOWNERS +1 -0
  77. package/dist/node_modules/node-abi/.github/workflows/update-abi.yml +5 -4
  78. package/dist/node_modules/node-abi/CONTRIBUTING.md +1 -1
  79. package/dist/node_modules/node-abi/README.md +5 -3
  80. package/dist/node_modules/node-abi/abi_registry.json +14 -0
  81. package/dist/node_modules/node-abi/package.json +5 -6
  82. package/dist/node_modules/node-addon-api/README.md +36 -12
  83. package/dist/node_modules/node-addon-api/index.js +3 -3
  84. package/dist/node_modules/node-addon-api/napi-inl.deprecated.h +121 -127
  85. package/dist/node_modules/node-addon-api/napi-inl.h +1166 -1122
  86. package/dist/node_modules/node-addon-api/napi.h +2786 -2675
  87. package/dist/node_modules/node-addon-api/package.json +42 -1
  88. package/dist/node_modules/node-addon-api/tools/check-napi.js +13 -14
  89. package/dist/node_modules/node-addon-api/tools/conversion.js +161 -169
  90. package/dist/node_modules/node-addon-api/tools/eslint-format.js +9 -1
  91. package/dist/node_modules/readable-stream/README.md +1 -1
  92. package/dist/node_modules/readable-stream/lib/_stream_duplex.js +12 -25
  93. package/dist/node_modules/readable-stream/lib/_stream_passthrough.js +2 -4
  94. package/dist/node_modules/readable-stream/lib/_stream_readable.js +176 -273
  95. package/dist/node_modules/readable-stream/lib/_stream_transform.js +26 -37
  96. package/dist/node_modules/readable-stream/lib/_stream_writable.js +118 -174
  97. package/dist/node_modules/readable-stream/lib/internal/streams/async_iterator.js +10 -37
  98. package/dist/node_modules/readable-stream/lib/internal/streams/buffer_list.js +20 -47
  99. package/dist/node_modules/readable-stream/lib/internal/streams/destroy.js +8 -17
  100. package/dist/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +1 -19
  101. package/dist/node_modules/readable-stream/lib/internal/streams/from.js +12 -24
  102. package/dist/node_modules/readable-stream/lib/internal/streams/pipeline.js +5 -16
  103. package/dist/node_modules/readable-stream/lib/internal/streams/state.js +2 -7
  104. package/dist/node_modules/readable-stream/package.json +1 -1
  105. package/dist/package-lock.json +15 -346
  106. package/dist/package.json +1 -1
  107. package/package.json +8 -8
  108. package/src/__tests__/config.data.ts +142 -1
  109. package/src/__tests__/wmts.capability.test.ts +9 -16
  110. package/src/__tests__/xyz.util.ts +6 -2
  111. package/src/cli/render.tile.ts +38 -0
  112. package/src/routes/__tests__/attribution.test.ts +65 -3
  113. package/src/routes/__tests__/tile.style.json.test.ts +100 -44
  114. package/src/routes/__tests__/wmts.test.ts +70 -9
  115. package/src/routes/attribution.ts +24 -28
  116. package/src/routes/tile.json.ts +2 -1
  117. package/src/routes/tile.style.json.ts +13 -5
  118. package/src/routes/tile.wmts.ts +3 -1
  119. package/src/routes/tile.xyz.raster.ts +10 -7
  120. package/src/util/__test__/filter.test.ts +80 -0
  121. package/src/util/config.loader.ts +1 -2
  122. package/src/util/filter.ts +60 -0
  123. package/src/wmts.capability.ts +19 -14
  124. package/tsconfig.tsbuildinfo +1 -1
  125. package/test-dump.js +0 -6
  126. package/test-imagery.js +0 -3
@@ -78,7 +78,148 @@ export const Imagery3857: ConfigImagery = {
78
78
  width: 51977.179234057665,
79
79
  height: 30574.81131407339,
80
80
  },
81
- files: [],
81
+ files: [
82
+ {
83
+ x: 19461478.89763212,
84
+ y: -4591419.415033963,
85
+ width: 305.7481131407044,
86
+ height: 305.7481131407044,
87
+ name: '17-129188-80552',
88
+ },
89
+ {
90
+ x: 19502754.89290612,
91
+ y: -4603343.591446448,
92
+ width: 305.7481131407044,
93
+ height: 305.7481131407044,
94
+ name: '17-129323-80591',
95
+ },
96
+ {
97
+ x: 19504283.633471873,
98
+ y: -4608847.057483015,
99
+ width: 611.4962262814096,
100
+ height: 611.4962262814096,
101
+ name: '16-64664-40304',
102
+ },
103
+ {
104
+ x: 19509175.60328212,
105
+ y: -4605178.080125325,
106
+ width: 611.4962262814096,
107
+ height: 611.4962262814096,
108
+ name: '16-64672-40298',
109
+ },
110
+ {
111
+ x: 19509175.60328212,
112
+ y: -4604566.583899044,
113
+ width: 611.4962262814096,
114
+ height: 611.4962262814096,
115
+ name: '16-64672-40297',
116
+ },
117
+ {
118
+ x: 19459032.912726905,
119
+ y: -4582552.719752827,
120
+ width: 1222.9924525628148,
121
+ height: 1222.9924525628148,
122
+ name: '15-32295-20130',
123
+ },
124
+ {
125
+ x: 19460255.905179467,
126
+ y: -4592336.659373329,
127
+ width: 1222.9924525628148,
128
+ height: 1222.9924525628148,
129
+ name: '15-32296-20138',
130
+ },
131
+ {
132
+ x: 19501837.648566607,
133
+ y: -4609458.55370921,
134
+ width: 1222.9924525628148,
135
+ height: 1222.9924525628148,
136
+ name: '15-32330-20152',
137
+ },
138
+ {
139
+ x: 19503060.64101917,
140
+ y: -4609458.55370921,
141
+ width: 1222.9924525628148,
142
+ height: 1222.9924525628148,
143
+ name: '15-32331-20152',
144
+ },
145
+ {
146
+ x: 19503060.64101917,
147
+ y: -4603343.591446393,
148
+ width: 1222.9924525628148,
149
+ height: 1222.9924525628148,
150
+ name: '15-32331-20147',
151
+ },
152
+ {
153
+ x: 19457809.920274343,
154
+ y: -4593559.651825892,
155
+ width: 2445.9849051256297,
156
+ height: 2445.9849051256297,
157
+ name: '14-16147-10069',
158
+ },
159
+ {
160
+ x: 19457809.920274343,
161
+ y: -4591113.666920764,
162
+ width: 2445.9849051256297,
163
+ height: 2445.9849051256297,
164
+ name: '14-16147-10068',
165
+ },
166
+ {
167
+ x: 19457809.920274343,
168
+ y: -4588667.682015641,
169
+ width: 2445.9849051256297,
170
+ height: 2445.9849051256297,
171
+ name: '14-16147-10067',
172
+ },
173
+ {
174
+ x: 19457809.920274343,
175
+ y: -4581329.727300262,
176
+ width: 2445.9849051256297,
177
+ height: 2445.9849051256297,
178
+ name: '14-16147-10064',
179
+ },
180
+ {
181
+ x: 19460255.905179467,
182
+ y: -4591113.666920764,
183
+ width: 2445.9849051256297,
184
+ height: 2445.9849051256297,
185
+ name: '14-16148-10068',
186
+ },
187
+ {
188
+ x: 19460255.905179586,
189
+ y: -4588667.682015713,
190
+ width: 4891.969810251274,
191
+ height: 4891.969810251274,
192
+ name: '13-8074-5033',
193
+ },
194
+ {
195
+ x: 19460255.905179586,
196
+ y: -4583775.712205462,
197
+ width: 4891.969810251274,
198
+ height: 4891.969810251274,
199
+ name: '13-8074-5032',
200
+ },
201
+ {
202
+ x: 19499391.663661595,
203
+ y: -4608235.561256718,
204
+ width: 4891.969810251274,
205
+ height: 4891.969810251274,
206
+ name: '13-8082-5037',
207
+ },
208
+ {
209
+ x: 19504283.63347185,
210
+ y: -4608235.561256718,
211
+ width: 4891.969810251274,
212
+ height: 4891.969810251274,
213
+ name: '13-8083-5037',
214
+ },
215
+ {
216
+ x: 19504283.63347185,
217
+ y: -4603343.591446467,
218
+ width: 4891.969810251274,
219
+ height: 4891.969810251274,
220
+ name: '13-8083-5036',
221
+ },
222
+ ],
82
223
  };
83
224
 
84
225
  export const Provider: ConfigProvider = {
@@ -30,7 +30,6 @@ o.spec('WmtsCapabilities', () => {
30
30
  imagery: allImagery,
31
31
  apiKey,
32
32
  formats: [ImageFormat.Avif],
33
- isIndividualLayers: false,
34
33
  }).toVNode();
35
34
 
36
35
  const urls = tags(wmts, 'ResourceURL');
@@ -51,7 +50,6 @@ o.spec('WmtsCapabilities', () => {
51
50
  apiKey,
52
51
  config: 's3://linz-basemaps/config.json',
53
52
  formats: [ImageFormat.Avif],
54
- isIndividualLayers: false,
55
53
  }).toVNode();
56
54
 
57
55
  const urls = tags(wmts, 'ResourceURL');
@@ -71,7 +69,6 @@ o.spec('WmtsCapabilities', () => {
71
69
  imagery: allImagery,
72
70
  apiKey,
73
71
  formats: [ImageFormat.Avif],
74
- isIndividualLayers: false,
75
72
  }).toXml();
76
73
 
77
74
  o(xml.split('\n')[0]).deepEquals('<?xml version="1.0" encoding="utf-8"?>');
@@ -90,7 +87,6 @@ o.spec('WmtsCapabilities', () => {
90
87
  imagery: allImagery,
91
88
  apiKey,
92
89
  formats: [ImageFormat.Avif],
93
- isIndividualLayers: false,
94
90
  }).toVNode();
95
91
 
96
92
  const urls = tags(wmts, 'ResourceURL');
@@ -142,7 +138,7 @@ o.spec('WmtsCapabilities', () => {
142
138
  tileSet,
143
139
  imagery,
144
140
  apiKey,
145
- isIndividualLayers: true,
141
+ layers: tileSet.layers,
146
142
  }).toVNode();
147
143
 
148
144
  const layers = tags(wmts, 'Layer').map((c) => c.find('ows:Title')?.textContent);
@@ -161,7 +157,6 @@ o.spec('WmtsCapabilities', () => {
161
157
  tileSet: TileSetAerial,
162
158
  imagery,
163
159
  apiKey,
164
- isIndividualLayers: false,
165
160
  });
166
161
 
167
162
  const raw = wmts.toVNode();
@@ -213,7 +208,6 @@ o.spec('WmtsCapabilities', () => {
213
208
  tileSet: TileSetAerial,
214
209
  imagery: allImagery,
215
210
  apiKey,
216
- isIndividualLayers: false,
217
211
  }).toVNode();
218
212
  const layer = raw.find('Contents', 'Layer');
219
213
 
@@ -260,7 +254,7 @@ o.spec('WmtsCapabilities', () => {
260
254
  tileSet: TileSetAerial,
261
255
  imagery: imagery,
262
256
  formats: [ImageFormat.Png],
263
- isIndividualLayers: true,
257
+ layers: TileSetAerial.layers,
264
258
  }).toVNode();
265
259
 
266
260
  const tms = raw?.find('TileMatrixSet', 'ows:Identifier');
@@ -299,7 +293,6 @@ o.spec('WmtsCapabilities', () => {
299
293
  tileSet: TileSetAerial,
300
294
  imagery: imagery,
301
295
  formats: [ImageFormat.Png],
302
- isIndividualLayers: false,
303
296
  }).toVNode();
304
297
 
305
298
  const layers = tags(raw, 'Layer');
@@ -361,7 +354,7 @@ o.spec('WmtsCapabilities', () => {
361
354
  tileSet: TileSetAerial,
362
355
  imagery: imagery,
363
356
  formats: [ImageFormat.Png],
364
- isIndividualLayers: true,
357
+ layers: TileSetAerial.layers,
365
358
  }).toVNode();
366
359
 
367
360
  const layers = tags(raw, 'Layer');
@@ -375,7 +368,7 @@ o.spec('WmtsCapabilities', () => {
375
368
  tileSet: TileSetAerial,
376
369
  imagery: imagery,
377
370
  formats: [ImageFormat.Png],
378
- isIndividualLayers: true,
371
+ layers: TileSetAerial.layers,
379
372
  }).toVNode();
380
373
 
381
374
  const layersB = tags(rawB, 'Layer');
@@ -397,8 +390,8 @@ o.spec('WmtsCapabilities', () => {
397
390
 
398
391
  const tileSet = { ...TileSetAerial };
399
392
  tileSet.layers = [
400
- { 3857: imageTopLeft.id, name: 'a_top_left' },
401
- { 3857: imageBottomRight.id, name: 'b_bottom_right' },
393
+ { 3857: imageTopLeft.id, name: 'a_top_left', title: 'A Top Left' },
394
+ { 3857: imageBottomRight.id, name: 'b_bottom_right', title: 'B Bottom Right' },
402
395
  ];
403
396
 
404
397
  const raw = new WmtsCapabilities({
@@ -408,7 +401,7 @@ o.spec('WmtsCapabilities', () => {
408
401
  tileSet,
409
402
  imagery,
410
403
  formats: [ImageFormat.Png],
411
- isIndividualLayers: true,
404
+ layers: tileSet.layers,
412
405
  }).toVNode();
413
406
 
414
407
  const boundingBox = tags(raw, 'ows:WGS84BoundingBox').map((c) =>
@@ -438,7 +431,7 @@ o.spec('WmtsCapabilities', () => {
438
431
  imagery.set(imageBottomRight.id, imageBottomRight);
439
432
 
440
433
  const tileSet = { ...TileSetAerial };
441
- tileSet.layers = [{ 3857: imageBottomRight.id, name: 'b_bottom_right' }];
434
+ tileSet.layers = [{ 3857: imageBottomRight.id, name: 'b_bottom_right', title: 'B Bottom Right' }];
442
435
 
443
436
  const raw = new WmtsCapabilities({
444
437
  httpBase: 'https://basemaps.test',
@@ -447,7 +440,7 @@ o.spec('WmtsCapabilities', () => {
447
440
  tileSet,
448
441
  imagery,
449
442
  formats: [ImageFormat.Png],
450
- isIndividualLayers: true,
443
+ layers: tileSet.layers,
451
444
  }).toVNode();
452
445
 
453
446
  const boundingBox = tags(raw, 'ows:WGS84BoundingBox').map((c) =>
@@ -3,6 +3,8 @@ import { LambdaAlbRequest, LambdaHttpRequest, LambdaUrlRequest } from '@linzjs/l
3
3
  import { Context } from 'aws-lambda';
4
4
 
5
5
  export function mockRequest(path: string, method = 'get', headers: Record<string, string> = {}): LambdaHttpRequest {
6
+ const log = LogConfig.get();
7
+ log.level = 'silent';
6
8
  return new LambdaAlbRequest(
7
9
  {
8
10
  requestContext: null as any,
@@ -13,7 +15,7 @@ export function mockRequest(path: string, method = 'get', headers: Record<string
13
15
  isBase64Encoded: false,
14
16
  },
15
17
  {} as Context,
16
- LogConfig.get(),
18
+ log,
17
19
  );
18
20
  }
19
21
 
@@ -23,6 +25,8 @@ export function mockUrlRequest(
23
25
  headers: Record<string, unknown> = {},
24
26
  method?: string,
25
27
  ): LambdaHttpRequest {
28
+ const log = LogConfig.get();
29
+ log.level = 'silent';
26
30
  return new LambdaUrlRequest(
27
31
  {
28
32
  requestContext: { http: { method: method ? method.toUpperCase() : 'GET' } },
@@ -32,7 +36,7 @@ export function mockUrlRequest(
32
36
  isBase64Encoded: false,
33
37
  } as any,
34
38
  {} as Context,
35
- LogConfig.get(),
39
+ log,
36
40
  );
37
41
  }
38
42
 
@@ -0,0 +1,38 @@
1
+ import { ConfigProviderMemory } from '@basemaps/config';
2
+ import { initConfigFromPaths } from '@basemaps/config/build/json/tiff.config.js';
3
+ import { ImageFormat, Nztm2000QuadTms } from '@basemaps/geo';
4
+ import { LogConfig, setDefaultConfig } from '@basemaps/shared';
5
+ import { fsa } from '@chunkd/fs';
6
+ import { LambdaHttpRequest, LambdaUrlRequest, UrlEvent } from '@linzjs/lambda';
7
+ import { Context } from 'aws-lambda';
8
+ import { TileXyzRaster } from '../routes/tile.xyz.raster.js';
9
+
10
+ const target = `/home/blacha/tmp/basemaps`;
11
+ const tile = { z: 18, x: 126359, y: 137603 };
12
+ const tileMatrix = Nztm2000QuadTms;
13
+
14
+ async function main(): Promise<void> {
15
+ const log = LogConfig.get();
16
+ const provider = new ConfigProviderMemory();
17
+ setDefaultConfig(provider);
18
+ const { tileSet, imagery } = await initConfigFromPaths(provider, [target]);
19
+
20
+ if (tileSet.layers.length === 0) throw new Error('No imagery found in path: ' + target);
21
+ log.info({ tileSet: tileSet.name, layers: tileSet.layers.length }, 'TileSet:Loaded');
22
+ for (const im of imagery) {
23
+ log.info({ imagery: im.uri, title: im.title, tileMatrix: im.tileMatrix, files: im.files.length }, 'Imagery:Loaded');
24
+ }
25
+ const request = new LambdaUrlRequest({ headers: {} } as UrlEvent, {} as Context, log) as LambdaHttpRequest;
26
+
27
+ const res = await TileXyzRaster.tile(request, tileSet, {
28
+ tile,
29
+ tileMatrix,
30
+ tileSet: tileSet.id,
31
+ tileType: ImageFormat.Png,
32
+ });
33
+
34
+ await fsa.write(`./${tile.z}_${tile.x}_${tile.y}.png`, Buffer.from(res.body, 'base64'));
35
+ log.info({ path: `./${tile.z}_${tile.x}_${tile.y}.png` }, 'Tile:Write');
36
+ }
37
+
38
+ main();
@@ -1,7 +1,8 @@
1
1
  import { Attribution } from '@basemaps/attribution';
2
2
  import { ConfigProviderMemory } from '@basemaps/config';
3
- import { Nztm2000QuadTms } from '@basemaps/geo';
4
- import { LogConfig } from '@basemaps/shared';
3
+ import { GoogleTms, Nztm2000QuadTms } from '@basemaps/geo';
4
+ import { LogConfig, Projection } from '@basemaps/shared';
5
+ import { BBox } from '@linzjs/geojson';
5
6
  import { HttpHeader } from '@linzjs/lambda';
6
7
  import o from 'ospec';
7
8
  import sinon from 'sinon';
@@ -9,6 +10,7 @@ import { handler } from '../../index.js';
9
10
  import { ConfigLoader } from '../../util/config.loader.js';
10
11
  import { FakeData, Imagery2193, Imagery3857, Provider, TileSetAerial } from '../../__tests__/config.data.js';
11
12
  import { mockUrlRequest } from '../../__tests__/xyz.util.js';
13
+ import { createCoordinates } from '../attribution.js';
12
14
 
13
15
  // const ExpectedJson = {
14
16
  // id: 'aerial_WebMercatorQuad',
@@ -332,7 +334,7 @@ o.spec('/v1/attribution', () => {
332
334
  });
333
335
 
334
336
  o.spec('ImageryRules', () => {
335
- const fakeLayer = { [2193]: Imagery2193.id, name: 'image', minZoom: 9, maxZoom: 16 };
337
+ const fakeLayer = { [2193]: Imagery2193.id, name: 'image', minZoom: 9, maxZoom: 16, title: 'Image' };
336
338
  const ts = FakeData.tileSetRaster('fake');
337
339
 
338
340
  o.beforeEach(() => {
@@ -387,4 +389,64 @@ o.spec('/v1/attribution', () => {
387
389
  o(output.collections[0].summaries['linz:zoom']).deepEquals({ min: 0, max: Nztm2000QuadTms.maxZoom });
388
390
  });
389
391
  });
392
+
393
+ o('should create valid coordinates', async () => {
394
+ //bbox: BBox, files: NamedBounds[], proj: Projection
395
+ const bbox = [174.79248047, -38.21228805, 175.25939941, -37.99616268] as BBox;
396
+ const proj = Projection.get(GoogleTms);
397
+ const coordinates = createCoordinates(bbox, Imagery3857.files, proj);
398
+ console.log(JSON.stringify(coordinates));
399
+ o(coordinates).deepEquals([
400
+ [
401
+ [
402
+ [174.79247149, -38.09998972],
403
+ [174.81446211, -38.09998972],
404
+ [174.81446211, -38.09134368],
405
+ [174.82544844, -38.09134368],
406
+ [174.82544844, -38.08485848],
407
+ [174.82819502, -38.08485848],
408
+ [174.82819502, -38.08269662],
409
+ [174.83643476, -38.08269662],
410
+ [174.83643476, -38.06539942],
411
+ [174.85840742, -38.06539942],
412
+ [174.85840742, -37.9961556],
413
+ [174.81446211, -37.9961556],
414
+ [174.81446211, -37.9961556],
415
+ [174.79247149, -37.9961556],
416
+ [174.79247149, -38.01348331],
417
+ [174.80345781, -38.01348331],
418
+ [174.80345781, -38.02213855],
419
+ [174.81444414, -38.02213855],
420
+ [174.81444414, -38.04808399],
421
+ [174.79247149, -38.04808399],
422
+ [174.79247149, -38.09998972],
423
+ ],
424
+ ],
425
+ [
426
+ [
427
+ [175.16600664, -38.20366238],
428
+ [175.1879793, -38.20366238],
429
+ [175.1879793, -38.21229511],
430
+ [175.20996992, -38.21229511],
431
+ [175.20996992, -38.20797887],
432
+ [175.21546308, -38.20797887],
433
+ [175.21546308, -38.20366238],
434
+ [175.25391523, -38.20366238],
435
+ [175.25391523, -38.18207606],
436
+ [175.2594084, -38.18207606],
437
+ [175.2594084, -38.17342562],
438
+ [175.25391523, -38.17342562],
439
+ [175.25391523, -38.13454951],
440
+ [175.20995195, -38.13454951],
441
+ [175.20995195, -38.16046922],
442
+ [175.19896563, -38.16046922],
443
+ [175.19896563, -38.16694771],
444
+ [175.19621904, -38.16694771],
445
+ [175.19621904, -38.16910707],
446
+ [175.16600664, -38.16910707],
447
+ [175.16600664, -38.20366238],
448
+ ],
449
+ ],
450
+ ]);
451
+ });
390
452
  });
@@ -28,60 +28,115 @@ o.spec('/v1/styles', () => {
28
28
  o(res.status).equals(404);
29
29
  });
30
30
 
31
- o('should serve style json', async () => {
32
- const request = mockRequest('/v1/tiles/topographic/Google/style/topographic.json', 'get', Api.header);
33
-
34
- const fakeStyle: StyleJson = {
35
- version: 8,
36
- id: 'test',
37
- name: 'topographic',
38
- sources: {
39
- basemaps_vector: {
40
- type: 'vector',
41
- url: `/vector`,
42
- },
43
- basemaps_raster: {
44
- type: 'raster',
45
- tiles: [`/raster`],
31
+ const fakeStyle: StyleJson = {
32
+ version: 8,
33
+ id: 'test',
34
+ name: 'topographic',
35
+ sources: {
36
+ basemaps_vector: {
37
+ type: 'vector',
38
+ url: `/vector`,
39
+ },
40
+ basemaps_raster: {
41
+ type: 'raster',
42
+ tiles: [`/raster`],
43
+ },
44
+ basemaps_raster_encode: {
45
+ type: 'raster',
46
+ tiles: [`/raster/{z}/{x}/{y}.webp`], // Shouldn't encode the {}
47
+ },
48
+ test_vector: {
49
+ type: 'vector',
50
+ url: 'vector.url.co.nz',
51
+ },
52
+ test_raster: {
53
+ type: 'raster',
54
+ tiles: ['raster.url.co.nz'],
55
+ },
56
+ },
57
+ layers: [
58
+ {
59
+ layout: {
60
+ visibility: 'visible',
46
61
  },
47
- basemaps_raster_encode: {
48
- type: 'raster',
49
- tiles: [`/raster/{z}/{x}/{y}.webp`], // Shouldn't encode the {}
62
+ paint: {
63
+ 'background-color': 'rgba(206, 229, 242, 1)',
50
64
  },
51
- test_vector: {
52
- type: 'vector',
53
- url: 'vector.url.co.nz',
65
+ id: 'Background1',
66
+ type: 'background',
67
+ minzoom: 0,
68
+ },
69
+ {
70
+ layout: {
71
+ visibility: 'visible',
54
72
  },
55
- test_raster: {
56
- type: 'raster',
57
- tiles: ['raster.url.co.nz'],
73
+ paint: {
74
+ 'background-color': 'rgba(206, 229, 242, 1)',
58
75
  },
76
+ id: 'Background2',
77
+ type: 'background',
78
+ minzoom: 0,
59
79
  },
60
- layers: [
61
- {
62
- layout: {
63
- visibility: 'visible',
64
- },
65
- paint: {
66
- 'background-color': 'rgba(206, 229, 242, 1)',
67
- },
68
- id: 'Background',
69
- type: 'background',
70
- minzoom: 0,
80
+ {
81
+ layout: {
82
+ visibility: 'visible',
71
83
  },
72
- ],
73
- glyphs: '/glyphs',
74
- sprite: '/sprite',
75
- metadata: { id: 'test' },
76
- };
84
+ paint: {
85
+ 'background-color': 'rgba(206, 229, 242, 1)',
86
+ },
87
+ id: 'Background3',
88
+ type: 'background',
89
+ minzoom: 0,
90
+ },
91
+ ],
92
+ glyphs: '/glyphs',
93
+ sprite: '/sprite',
94
+ metadata: { id: 'test' },
95
+ };
96
+
97
+ const fakeRecord = {
98
+ id: 'st_topographic',
99
+ name: 'topographic',
100
+ style: fakeStyle,
101
+ };
102
+
103
+ o('should serve style json', async () => {
104
+ config.put(fakeRecord);
77
105
 
78
- const fakeRecord = {
79
- id: 'st_topographic',
80
- name: 'topographic',
81
- style: fakeStyle,
106
+ const request = mockRequest('/v1/tiles/topographic/Google/style/topographic.json', 'get', Api.header);
107
+
108
+ const res = await handler.router.handle(request);
109
+ o(res.status).equals(200);
110
+ o(res.header('content-type')).equals('application/json');
111
+ o(res.header('cache-control')).equals('no-store');
112
+
113
+ const body = Buffer.from(res.body ?? '', 'base64').toString();
114
+ fakeStyle.sources.basemaps_vector = {
115
+ type: 'vector',
116
+ url: `${host}/vector?api=${Api.key}`,
117
+ };
118
+ fakeStyle.sources.basemaps_raster = {
119
+ type: 'raster',
120
+ tiles: [`${host}/raster?api=${Api.key}`],
82
121
  };
122
+ fakeStyle.sources.basemaps_raster_encode = {
123
+ type: 'raster',
124
+ tiles: [`${host}/raster/{z}/{x}/{y}.webp?api=${Api.key}`],
125
+ };
126
+
127
+ fakeStyle.sprite = `${host}/sprite`;
128
+ fakeStyle.glyphs = `${host}/glyphs`;
129
+
130
+ o(JSON.parse(body)).deepEquals(fakeStyle);
131
+ });
83
132
 
133
+ o('should serve style json with excluded layers', async () => {
84
134
  config.put(fakeRecord);
135
+ const request = mockUrlRequest(
136
+ '/v1/tiles/topographic/Google/style/topographic.json',
137
+ '?exclude=background1&exclude=BACKGROUND2',
138
+ Api.header,
139
+ );
85
140
 
86
141
  const res = await handler.router.handle(request);
87
142
  o(res.status).equals(200);
@@ -104,6 +159,7 @@ o.spec('/v1/styles', () => {
104
159
 
105
160
  fakeStyle.sprite = `${host}/sprite`;
106
161
  fakeStyle.glyphs = `${host}/glyphs`;
162
+ fakeStyle.layers = [fakeStyle.layers[2]];
107
163
 
108
164
  o(JSON.parse(body)).deepEquals(fakeStyle);
109
165
  });