@basemaps/lambda-tiler 6.24.0 → 6.25.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 (69) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/build/__test__/tile.cache.key.test.js +2 -3
  3. package/build/__test__/tile.import.test.d.ts +2 -0
  4. package/build/__test__/tile.import.test.d.ts.map +1 -0
  5. package/build/__test__/tile.import.test.js +115 -0
  6. package/build/__test__/tile.set.cache.test.js +9 -0
  7. package/build/__test__/tile.style.json.test.js +47 -1
  8. package/build/__test__/xyz.test.js +55 -28
  9. package/build/__test__/xyz.util.d.ts +4 -0
  10. package/build/__test__/xyz.util.d.ts.map +1 -1
  11. package/build/__test__/xyz.util.js +8 -1
  12. package/build/cli/dump.js +2 -3
  13. package/build/import/imagery.find.d.ts +17 -0
  14. package/build/import/imagery.find.d.ts.map +1 -0
  15. package/build/import/imagery.find.js +38 -0
  16. package/build/import/make.cog.d.ts +5 -0
  17. package/build/import/make.cog.d.ts.map +1 -0
  18. package/build/import/make.cog.js +21 -0
  19. package/build/index.d.ts.map +1 -1
  20. package/build/index.js +2 -0
  21. package/build/routes/__test__/attribution.test.js +4 -0
  22. package/build/routes/__test__/health.test.js +1 -2
  23. package/build/routes/attribution.d.ts.map +1 -1
  24. package/build/routes/attribution.js +1 -0
  25. package/build/routes/health.d.ts.map +1 -1
  26. package/build/routes/health.js +3 -4
  27. package/build/routes/import.d.ts +9 -0
  28. package/build/routes/import.d.ts.map +1 -0
  29. package/build/routes/import.js +61 -0
  30. package/build/routes/tile.json.d.ts +0 -7
  31. package/build/routes/tile.json.d.ts.map +1 -1
  32. package/build/routes/tile.json.js +26 -18
  33. package/build/routes/tile.style.json.d.ts +8 -0
  34. package/build/routes/tile.style.json.d.ts.map +1 -1
  35. package/build/routes/tile.style.json.js +26 -20
  36. package/build/tile.set.cache.d.ts.map +1 -1
  37. package/build/tile.set.cache.js +7 -3
  38. package/build/tile.set.raster.d.ts +4 -2
  39. package/build/tile.set.raster.d.ts.map +1 -1
  40. package/build/tile.set.raster.js +9 -5
  41. package/build/tile.set.vector.d.ts +4 -1
  42. package/build/tile.set.vector.d.ts.map +1 -1
  43. package/build/tile.set.vector.js +9 -1
  44. package/build/wmts.capability.d.ts +4 -0
  45. package/build/wmts.capability.d.ts.map +1 -1
  46. package/build/wmts.capability.js +1 -1
  47. package/package.json +9 -8
  48. package/src/__test__/tile.cache.key.test.ts +3 -3
  49. package/src/__test__/tile.import.test.ts +140 -0
  50. package/src/__test__/tile.set.cache.test.ts +11 -0
  51. package/src/__test__/tile.style.json.test.ts +56 -1
  52. package/src/__test__/xyz.test.ts +59 -28
  53. package/src/__test__/xyz.util.ts +10 -2
  54. package/src/cli/dump.ts +2 -3
  55. package/src/import/imagery.find.ts +60 -0
  56. package/src/import/make.cog.ts +29 -0
  57. package/src/index.ts +2 -0
  58. package/src/routes/__test__/attribution.test.ts +4 -0
  59. package/src/routes/__test__/health.test.ts +1 -3
  60. package/src/routes/attribution.ts +1 -0
  61. package/src/routes/health.ts +3 -4
  62. package/src/routes/import.ts +66 -0
  63. package/src/routes/tile.json.ts +26 -27
  64. package/src/routes/tile.style.json.ts +25 -21
  65. package/src/tile.set.cache.ts +6 -2
  66. package/src/tile.set.raster.ts +9 -6
  67. package/src/tile.set.vector.ts +11 -2
  68. package/src/wmts.capability.ts +1 -1
  69. package/tsconfig.tsbuildinfo +1 -1
@@ -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.PNG, x: 252, y: 156, z: 8 },
13
- { type: TileType.Tile, name: 'health', tileMatrix: Nztm2000QuadTms, ext: ImageFormat.PNG, x: 30, y: 33, z: 6 },
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) {
@@ -0,0 +1,9 @@
1
+ import { LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
2
+ /**
3
+ * Trigger import imagery job by this endpoint
4
+ *
5
+ * @example
6
+ * - /v1/import?path=s3://linz-imagery-staging/2022-03/wellington_rural_2022_delivery_1
7
+ */
8
+ export declare function Import(req: LambdaHttpRequest): Promise<LambdaHttpResponse>;
9
+ //# sourceMappingURL=import.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../src/routes/import.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AASnF;;;;;GAKG;AACH,wBAAsB,MAAM,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAkDhF"}
@@ -0,0 +1,61 @@
1
+ import { HttpHeader, LambdaHttpResponse } from '@linzjs/lambda';
2
+ import { Config, Const, fsa } from '@basemaps/shared';
3
+ import { createHash } from 'crypto';
4
+ import { findImagery, RoleRegister } from '../import/imagery.find.js';
5
+ import { Nztm2000Tms, TileMatrixSets } from '@basemaps/geo';
6
+ import { getJobCreationContext } from '../import/make.cog.js';
7
+ import { ConfigProviderDynamo } from '@basemaps/config';
8
+ import { CogJobFactory } from '@basemaps/cli';
9
+ /**
10
+ * Trigger import imagery job by this endpoint
11
+ *
12
+ * @example
13
+ * - /v1/import?path=s3://linz-imagery-staging/2022-03/wellington_rural_2022_delivery_1
14
+ */
15
+ export async function Import(req) {
16
+ const path = req.query.get('path');
17
+ const projection = req.query.get('p');
18
+ // Parse projection as target, default to process both NZTM2000Quad
19
+ let targetTms = Nztm2000Tms;
20
+ if (projection != null) {
21
+ const tileMatrix = TileMatrixSets.find(projection);
22
+ if (tileMatrix == null)
23
+ return new LambdaHttpResponse(404, 'Target projection Not found');
24
+ targetTms = tileMatrix;
25
+ }
26
+ // Find the imagery from s3
27
+ if (path == null || !path.startsWith('s3://'))
28
+ return new LambdaHttpResponse(500, 'Invalid s3 path');
29
+ const role = await RoleRegister.findRole(path);
30
+ if (role == null)
31
+ return new LambdaHttpResponse(500, 'Unable to Access the bucket');
32
+ const files = await findImagery(path);
33
+ if (files.length === 0)
34
+ return new LambdaHttpResponse(404, 'Imagery Not Found');
35
+ // Prepare Cog jobs
36
+ const ctx = await getJobCreationContext(path, targetTms, role, files);
37
+ const id = createHash('sha256').update(JSON.stringify(ctx)).digest('base64');
38
+ const jobId = Config.ProcessingJob.id(id);
39
+ let jobConfig = await Config.ProcessingJob.get(jobId);
40
+ if (jobConfig == null) {
41
+ // Add id back to JobCreationContext
42
+ ctx.override.id = id;
43
+ ctx.outputLocation.path = fsa.join(ctx.outputLocation.path, id);
44
+ // Start processing job
45
+ await CogJobFactory.create(ctx);
46
+ jobConfig = {
47
+ id: jobId,
48
+ name: path,
49
+ status: 'processing',
50
+ };
51
+ const config = new ConfigProviderDynamo(Const.TileMetadata.TableName);
52
+ await config.ProcessingJob.put(jobConfig);
53
+ }
54
+ const json = JSON.stringify(jobConfig);
55
+ const data = Buffer.from(json);
56
+ const response = new LambdaHttpResponse(200, 'ok');
57
+ response.header(HttpHeader.CacheControl, 'no-store');
58
+ response.buffer(data, 'application/json');
59
+ req.set('bytes', data.byteLength);
60
+ return response;
61
+ }
@@ -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":"AACA,OAAO,EAAc,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAMnF,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,QAAQ,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA4BlF"}
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 { Env } from '@basemaps/shared';
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 { NotModified } from './response.js';
6
- import { TileEtag } from './tile.etag.js';
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 = `${host}/${version}/${name}/${rest[0]}/${rest[1]}/{z}/{x}/{y}.pbf?api=${apiKey}`;
13
- const tileJson = {
14
- tiles: [tileUrl],
15
- minzoom: 0,
16
- maxzoom: 15,
17
- format: 'pbf',
18
- tilejson: '2.0.0',
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], vector_layers: [], 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.ETag, cacheKey);
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,3 +1,4 @@
1
+ import { StyleJson } from '@basemaps/config';
1
2
  import { LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
2
3
  /**
3
4
  * Convert relative URLS into a full hostname url
@@ -6,5 +7,12 @@ import { LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
6
7
  * @returns Updated Url or empty string if url is empty
7
8
  */
8
9
  export declare function convertRelativeUrl(url?: string, apiKey?: string): string;
10
+ /**
11
+ * Create a new style json that has absolute urls to the current host and API Keys where required
12
+ * @param style style to update
13
+ * @param apiKey api key to inject
14
+ * @returns new stylejson
15
+ */
16
+ export declare function convertStyleJson(style: StyleJson, apiKey: string): StyleJson;
9
17
  export declare function styleJson(req: LambdaHttpRequest, fileName: string): Promise<LambdaHttpResponse>;
10
18
  //# sourceMappingURL=tile.style.json.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tile.style.json.d.ts","sourceRoot":"","sources":["../../src/routes/tile.style.json.ts"],"names":[],"mappings":"AAGA,OAAO,EAAc,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAOnF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAOxE;AAED,wBAAsB,SAAS,CAAC,GAAG,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAmDrG"}
1
+ {"version":3,"file":"tile.style.json.d.ts","sourceRoot":"","sources":["../../src/routes/tile.style.json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGtD,OAAO,EAAc,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAOnF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAOxE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CAuB5E;AAED,wBAAsB,SAAS,CAAC,GAAG,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAwBrG"}
@@ -24,20 +24,16 @@ export function convertRelativeUrl(url, apiKey) {
24
24
  fullUrl.searchParams.set('api', apiKey);
25
25
  return fullUrl.toString().replace(/%7B/g, '{').replace(/%7D/g, '}');
26
26
  }
27
- export async function styleJson(req, fileName) {
28
- const apiKey = Router.apiKey(req);
29
- if (apiKey == null)
30
- return new LambdaHttpResponse(400, 'Invalid API Key.');
31
- const styleName = fileName.split('.json')[0];
32
- // Get style Config from db
33
- const dbId = Config.Style.id(styleName);
34
- const styleConfig = await Config.Style.get(dbId);
35
- if (styleConfig == null)
36
- return NotFound;
37
- // Prepare sources and add linz source
38
- const style = styleConfig.style;
39
- const sources = {};
40
- for (const [key, value] of Object.entries(style.sources)) {
27
+ /**
28
+ * Create a new style json that has absolute urls to the current host and API Keys where required
29
+ * @param style style to update
30
+ * @param apiKey api key to inject
31
+ * @returns new stylejson
32
+ */
33
+ export function convertStyleJson(style, apiKey) {
34
+ var _a;
35
+ const sources = JSON.parse(JSON.stringify(style.sources));
36
+ for (const [key, value] of Object.entries(sources)) {
41
37
  if (value.type === 'vector') {
42
38
  value.url = convertRelativeUrl(value.url, apiKey);
43
39
  }
@@ -48,20 +44,30 @@ export async function styleJson(req, fileName) {
48
44
  }
49
45
  sources[key] = value;
50
46
  }
51
- // prepare Style.json
52
- const styleJson = {
53
- /** Style.json version 8 */
47
+ return {
54
48
  version: 8,
55
49
  id: style.id,
56
50
  name: style.name,
57
51
  sources,
58
52
  layers: style.layers,
59
- metadata: style.metadata || {},
53
+ metadata: (_a = style.metadata) !== null && _a !== void 0 ? _a : {},
60
54
  glyphs: convertRelativeUrl(style.glyphs),
61
55
  sprite: convertRelativeUrl(style.sprite),
62
56
  };
63
- const json = JSON.stringify(styleJson);
64
- const data = Buffer.from(json);
57
+ }
58
+ export async function styleJson(req, fileName) {
59
+ const apiKey = Router.apiKey(req);
60
+ if (apiKey == null)
61
+ return new LambdaHttpResponse(400, 'Invalid API Key.');
62
+ const styleName = fileName.split('.json')[0];
63
+ // Get style Config from db
64
+ const dbId = Config.Style.id(styleName);
65
+ const styleConfig = await Config.Style.get(dbId);
66
+ if (styleConfig == null)
67
+ return NotFound;
68
+ // Prepare sources and add linz source
69
+ const style = convertStyleJson(styleConfig.style, apiKey);
70
+ const data = Buffer.from(JSON.stringify(style));
65
71
  const cacheKey = createHash('sha256').update(data).digest('base64');
66
72
  if (TileEtag.isNotModified(req, cacheKey))
67
73
  return NotModified;
@@ -1 +1 @@
1
- {"version":3,"file":"tile.set.cache.d.ts","sourceRoot":"","sources":["../src/tile.set.cache.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAkB,MAAM,eAAe,CAAC;AAE9D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAIxC,qBAAa,YAAY;IACvB,sCAAsC;IACtC,SAAS,SAAU;IAEnB,+BAA+B;IAC/B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;KAAE,CAAC,CAAa;IACjF,kCAAkC;IAClC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAa;IAE3C,EAAE,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM;IAC5B,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,GAAG,MAAM;IAUnD,GAAG,CAAC,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UAAU,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAqC7E,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,aAAa,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CA0BlF;AAED,eAAO,MAAM,QAAQ,cAAqB,CAAC"}
@@ -64,7 +64,7 @@ export class TileSetCache {
64
64
  return ts;
65
65
  }
66
66
  const ts = new TileSetVector(name, tileMatrix);
67
- ts.tileSet = tileSet;
67
+ await ts.init(tileSet);
68
68
  this.tileSets.set(tileSetId, ts);
69
69
  return ts;
70
70
  }
@@ -86,8 +86,12 @@ export class TileSetCache {
86
86
  parent.components.name = nameComp.name;
87
87
  }
88
88
  else if (parent.imagery != null && parent.imagery.size > 1) {
89
- for (const imageId of parent.imagery.keys())
90
- tileSets.push(parent.child(imageId));
89
+ for (const imageId of parent.imagery.keys()) {
90
+ const childImg = parent.child(imageId);
91
+ if (childImg == null)
92
+ continue;
93
+ tileSets.push(childImg);
94
+ }
91
95
  }
92
96
  }
93
97
  return tileSets.sort((a, b) => a.title.localeCompare(b.title));
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { ConfigImagery, ConfigTileSetRaster, TileSetNameComponents, TileSetType } from '@basemaps/config';
3
- import { Bounds, Tile, TileMatrixSet } from '@basemaps/geo';
3
+ import { Bounds, ImageFormat, Tile, TileMatrixSet } from '@basemaps/geo';
4
4
  import { LogType, TileDataXyz } from '@basemaps/shared';
5
5
  import { Tiler } from '@basemaps/tiler';
6
6
  import { TileMakerSharp } from '@basemaps/tiler-sharp';
@@ -35,6 +35,8 @@ export declare class TileSetRaster {
35
35
  get title(): string;
36
36
  get description(): string;
37
37
  get extent(): Bounds;
38
+ /** Preferred default imagery format */
39
+ get format(): ImageFormat;
38
40
  init(record: ConfigTileSetRaster): Promise<void>;
39
41
  initTiffs(tile: Tile, log: LogType): Promise<CogTiff[]>;
40
42
  tile(req: LambdaHttpRequest, xyz: TileDataXyz): Promise<LambdaHttpResponse>;
@@ -47,6 +49,6 @@ export declare class TileSetRaster {
47
49
  private getCogsForTile;
48
50
  /** Look up imagery by imageryId or by image name */
49
51
  findImagery(imgId: string): ConfigImagery | null;
50
- child(imgId: string): TileSetRaster;
52
+ child(imgId: string): TileSetRaster | null;
51
53
  }
52
54
  //# sourceMappingURL=tile.set.raster.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tile.set.raster.d.ts","sourceRoot":"","sources":["../src/tile.set.raster.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EAEb,mBAAmB,EACnB,qBAAqB,EAErB,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAQ,IAAI,EAAE,aAAa,EAAkB,MAAM,eAAe,CAAC;AAClF,OAAO,EAAoB,OAAO,EAAE,WAAW,EAAqC,MAAM,kBAAkB,CAAC;AAC7G,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAc,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAU1C,eAAO,MAAM,YAAY,gBAA0B,CAAC;AAEpD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAKD,qBAAa,aAAa;IACxB,IAAI,EAAE,WAAW,CAAC,MAAM,CAAsB;IAE9C,UAAU,EAAE,aAAa,CAAC;IAC1B,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,GAAG,CAAC,MAA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CAExB;IAEK,IAAI,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAKhD,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAmBhD,IAAI,CAAC,GAAG,EAAE,iBAAiB,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA8BxF;;;;OAIG;IACI,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,OAAO,EAAE;IAgC5D,OAAO,CAAC,cAAc;IAwBtB,oDAAoD;IACpD,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI;IAShD,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI;CAqB3C"}
@@ -1,6 +1,6 @@
1
1
  import { TileSetNameParser, TileSetType, } from '@basemaps/config';
2
- import { Bounds, Epsg, TileMatrixSet, TileMatrixSets } from '@basemaps/geo';
3
- import { Config, Env, fsa, titleizeImageryName, VectorFormat } from '@basemaps/shared';
2
+ import { Bounds, Epsg, ImageFormat, TileMatrixSet, TileMatrixSets, VectorFormat } from '@basemaps/geo';
3
+ import { Config, Env, fsa, titleizeImageryName } from '@basemaps/shared';
4
4
  import { Tiler } from '@basemaps/tiler';
5
5
  import { TileMakerSharp } from '@basemaps/tiler-sharp';
6
6
  import { CogTiff } from '@cogeotiff/core';
@@ -52,6 +52,11 @@ export class TileSetRaster {
52
52
  var _a;
53
53
  return (_a = this.extentOverride) !== null && _a !== void 0 ? _a : this.tileMatrix.extent;
54
54
  }
55
+ /** Preferred default imagery format */
56
+ get format() {
57
+ var _a;
58
+ return (_a = this.tileSet.format) !== null && _a !== void 0 ? _a : ImageFormat.Webp;
59
+ }
55
60
  async init(record) {
56
61
  this.tileSet = record;
57
62
  this.imagery = await Config.getAllImagery(this.tileSet.layers, this.tileMatrix.projection);
@@ -171,9 +176,8 @@ export class TileSetRaster {
171
176
  child(imgId) {
172
177
  var _a, _b, _c;
173
178
  const image = this.findImagery(imgId);
174
- if (image == null) {
175
- throw new Error('Failed to create child tile set ' + this.fullName + ' Missing imagery ' + imgId);
176
- }
179
+ if (image == null)
180
+ return null;
177
181
  const childName = TileSetNameParser.componentsToName({ ...this.components, layer: image.name });
178
182
  const child = new TileSetRaster(childName, this.tileMatrix);
179
183
  // use parent data as prototype for child;
@@ -1,5 +1,5 @@
1
1
  import { ConfigTileSetVector, TileSetNameComponents, TileSetType } from '@basemaps/config';
2
- import { TileMatrixSet } from '@basemaps/geo';
2
+ import { TileMatrixSet, VectorFormat } from '@basemaps/geo';
3
3
  import { TileDataXyz } from '@basemaps/shared';
4
4
  import { Cotar } from '@cotar/core';
5
5
  import { LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
@@ -14,6 +14,9 @@ export declare class TileSetVector {
14
14
  tileMatrix: TileMatrixSet;
15
15
  tileSet: ConfigTileSetVector;
16
16
  constructor(name: string, tileMatrix: TileMatrixSet);
17
+ init(record: ConfigTileSetVector): Promise<void>;
18
+ /** What format does tile set use */
19
+ get format(): VectorFormat;
17
20
  get id(): string;
18
21
  get fullName(): string;
19
22
  tile(req: LambdaHttpRequest, xyz: TileDataXyz): Promise<LambdaHttpResponse>;
@@ -1 +1 @@
1
- {"version":3,"file":"tile.set.vector.d.ts","sourceRoot":"","sources":["../src/tile.set.vector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAqB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC9G,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAO,WAAW,EAAgB,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAc,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAKnF,cAAM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AE,mBAAmB,CAAC;gBACjB,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa;IAK7C,IAAI,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAItD,oCAAoC;IACpC,IAAI,MAAM,IAAI,YAAY,CAEzB;IAED,IAAI,EAAE,IAAI,MAAM,CAEf;IAED,IAAI,QAAQ,IAAI,MAAM,CAErB;IAEK,IAAI,CAAC,GAAG,EAAE,iBAAiB,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAwBlF"}
@@ -1,5 +1,6 @@
1
1
  import { TileSetNameParser, TileSetType } from '@basemaps/config';
2
- import { fsa, VectorFormat } from '@basemaps/shared';
2
+ import { VectorFormat } from '@basemaps/geo';
3
+ import { fsa } from '@basemaps/shared';
3
4
  import { Cotar } from '@cotar/core';
4
5
  import { HttpHeader, LambdaHttpResponse } from '@linzjs/lambda';
5
6
  import { NotFound } from './routes/response.js';
@@ -27,6 +28,13 @@ export class TileSetVector {
27
28
  this.components = TileSetNameParser.parse(name);
28
29
  this.tileMatrix = tileMatrix;
29
30
  }
31
+ async init(record) {
32
+ this.tileSet = record;
33
+ }
34
+ /** What format does tile set use */
35
+ get format() {
36
+ return VectorFormat.MapboxVectorTiles;
37
+ }
30
38
  get id() {
31
39
  return TileSets.id(this.fullName, this.tileMatrix);
32
40
  }
@@ -2,6 +2,10 @@ import { ConfigProvider } from '@basemaps/config';
2
2
  import { Bounds, TileMatrixSet, WmtsProvider } from '@basemaps/geo';
3
3
  import { VNodeElement } from '@basemaps/shared';
4
4
  import { TileSetRaster } from './tile.set.raster.js';
5
+ /**
6
+ * Default the tile matrix id to the projection of the TileMatrixSet
7
+ */
8
+ export declare function getTileMatrixId(tileMatrix: TileMatrixSet): string;
5
9
  export declare class WmtsCapabilities {
6
10
  httpBase: string;
7
11
  provider: WmtsProvider;
@@ -1 +1 @@
1
- {"version":3,"file":"wmts.capability.d.ts","sourceRoot":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,YAAY;IAUvB,QAAQ,IAAI,MAAM;IAIlB,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM;CAG5G"}
@@ -17,7 +17,7 @@ function wgs84Extent(layer) {
17
17
  /**
18
18
  * Default the tile matrix id to the projection of the TileMatrixSet
19
19
  */
20
- function getTileMatrixId(tileMatrix) {
20
+ export function getTileMatrixId(tileMatrix) {
21
21
  // TODO this should really change everything to identifier
22
22
  if (tileMatrix.identifier === Nztm2000QuadTms.identifier)
23
23
  return Nztm2000QuadTms.identifier;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basemaps/lambda-tiler",
3
- "version": "6.24.0",
3
+ "version": "6.25.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/linz/basemaps.git",
@@ -22,12 +22,13 @@
22
22
  "types": "./build/index.d.ts",
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "@basemaps/config": "^6.21.1",
26
- "@basemaps/geo": "^6.21.1",
25
+ "@basemaps/cli": "^6.25.0",
26
+ "@basemaps/config": "^6.25.0",
27
+ "@basemaps/geo": "^6.25.0",
27
28
  "@basemaps/lambda": "^6.7.0",
28
- "@basemaps/shared": "^6.23.0",
29
- "@basemaps/tiler": "^6.23.0",
30
- "@basemaps/tiler-sharp": "^6.23.0",
29
+ "@basemaps/shared": "^6.25.0",
30
+ "@basemaps/tiler": "^6.25.0",
31
+ "@basemaps/tiler-sharp": "^6.25.0",
31
32
  "@chunkd/fs": "^8.1.0",
32
33
  "@cogeotiff/core": "^7.0.0",
33
34
  "@cotar/core": "^5.3.0",
@@ -52,12 +53,12 @@
52
53
  "bundle": "./bundle.sh"
53
54
  },
54
55
  "devDependencies": {
55
- "@basemaps/attribution": "^6.22.0",
56
+ "@basemaps/attribution": "^6.25.0",
56
57
  "@types/aws-lambda": "^8.10.75",
57
58
  "@types/node": "^14.11.2",
58
59
  "@types/pixelmatch": "^5.0.0",
59
60
  "@types/sharp": "^0.29.3",
60
61
  "pretty-json-log": "^1.0.0"
61
62
  },
62
- "gitHead": "8cfdb4b9821ae3e35e1fd56a551ed489817422a9"
63
+ "gitHead": "7ef26df6d42b79298035033fb6434d086fa642f8"
63
64
  }
@@ -1,7 +1,7 @@
1
- import { GoogleTms, Nztm2000Tms } from '@basemaps/geo';
1
+ import { GoogleTms, Nztm2000Tms, ImageFormat } from '@basemaps/geo';
2
2
  import { TileDataXyz, TileType } from '@basemaps/shared';
3
3
  import { TestTiff } from '@basemaps/test';
4
- import { Composition, ImageFormat } from '@basemaps/tiler';
4
+ import { Composition } from '@basemaps/tiler';
5
5
  import o from 'ospec';
6
6
  import { TileEtag } from '../routes/tile.etag.js';
7
7
 
@@ -14,7 +14,7 @@ o.spec('TileCacheKey', () => {
14
14
  z: 0,
15
15
  tileMatrix: GoogleTms,
16
16
  name: 'foo',
17
- ext: ImageFormat.PNG,
17
+ ext: ImageFormat.Png,
18
18
  type: TileType.Tile,
19
19
  };
20
20
 
@@ -0,0 +1,140 @@
1
+ import { JobCreationContext } from '@basemaps/cli/build/cog/cog.stac.job';
2
+ import { Nztm2000Tms } from '@basemaps/geo';
3
+ import { Config, Env, fsa, LogConfig } from '@basemaps/shared';
4
+ import o from 'ospec';
5
+ import { createHash } from 'crypto';
6
+ import sinon from 'sinon';
7
+ import { LambdaAlbRequest, LambdaHttpRequest } from '@linzjs/lambda';
8
+ import { Context } from 'aws-lambda';
9
+ import { Import } from '../routes/import.js';
10
+ import { RoleConfig } from '../import/imagery.find.js';
11
+ import { CogJobFactory } from '@basemaps/cli';
12
+ import { ConfigProcessingJob } from '@basemaps/config';
13
+
14
+ o.spec('Import', () => {
15
+ const sandbox = sinon.createSandbox();
16
+ const outputBucket = 'testOutputBucket';
17
+ const configBucket = 'testConfigBucket';
18
+ const origConfigBucket = process.env[Env.AwsRoleConfigBucket];
19
+ const origOutputBucket = process.env[Env.ImportImageryBucket];
20
+ o.beforeEach(() => {
21
+ process.env[Env.AwsRoleConfigBucket] = configBucket;
22
+ process.env[Env.ImportImageryBucket] = outputBucket;
23
+ });
24
+
25
+ o.afterEach(() => {
26
+ process.env[Env.AwsRoleConfigBucket] = origConfigBucket;
27
+ process.env[Env.ImportImageryBucket] = origOutputBucket;
28
+ sandbox.restore();
29
+ });
30
+
31
+ const tileMatrix = Nztm2000Tms;
32
+ const bucket = 'testSourceBucket';
33
+ const path = `s3://${bucket}/imagery/`;
34
+ const role: RoleConfig = {
35
+ bucket,
36
+ accountId: '123456',
37
+ roleArn: 'arn:aws:iam::123456:role/read-role',
38
+ };
39
+
40
+ const files = [`${path}/1.tiff`, `${path}/2.tiff`];
41
+ async function* listFiles(): AsyncGenerator<string, any, unknown> {
42
+ for (const key in files) yield files[key];
43
+ }
44
+
45
+ const ctx: JobCreationContext = {
46
+ override: {
47
+ projection: tileMatrix.projection,
48
+ resampling: {
49
+ warp: 'bilinear',
50
+ overview: 'lanczos',
51
+ },
52
+ },
53
+ outputLocation: { type: 's3' as const, path: `s3://${outputBucket}` },
54
+ sourceLocation: { type: 's3', path: path, ...role, files: files },
55
+ batch: true,
56
+ tileMatrix,
57
+ oneCogCovering: false,
58
+ };
59
+
60
+ const id = createHash('sha256').update(JSON.stringify(ctx)).digest('base64');
61
+ const jobId = Config.ProcessingJob.id(id);
62
+
63
+ function getRequest(path: string, projection: string): LambdaHttpRequest {
64
+ return new LambdaAlbRequest(
65
+ {
66
+ requestContext: null as any,
67
+ httpMethod: 'get',
68
+ path: '/v1/tiles/import',
69
+ body: null,
70
+ isBase64Encoded: false,
71
+ queryStringParameters: { path: path, p: projection },
72
+ },
73
+ {} as Context,
74
+ LogConfig.get(),
75
+ );
76
+ }
77
+
78
+ o('should return projection not found', async () => {
79
+ // Given ... wrong projection
80
+ const req = getRequest(path, '0000');
81
+
82
+ // When ... Then ...
83
+ const res = await Import(req);
84
+ o(res.body).equals('{"status":404,"message":"Target projection Not found"}');
85
+ });
86
+
87
+ o('should return Invalid s3 location', async () => {
88
+ // Given... wrong s3 path
89
+ const req = getRequest('s3::testbucket/', '2193');
90
+
91
+ // When ...Then ...
92
+ const res = await Import(req);
93
+ o(res.body).equals('{"status":500,"message":"Invalid s3 path"}');
94
+ });
95
+
96
+ o('should return Unable to access bucket', async () => {
97
+ // Given... different bucket have no access role
98
+ sandbox.stub(fsa, 'readJson').resolves({ buckets: [role] });
99
+ const req = getRequest(`s3://wrong-bucket/imagery/`, '2193');
100
+
101
+ // When ...Then ...
102
+ const res = await Import(req);
103
+ o(res.body).equals('{"status":500,"message":"Unable to Access the bucket"}');
104
+ });
105
+
106
+ o('should return Imagery not found', async () => {
107
+ // Given... none imagery find from bucket
108
+ sandbox.stub(fsa, 'readJson').resolves({ buckets: [role] });
109
+ sandbox.stub(fsa, 'list').callsFake(async function* () {
110
+ yield `${path}1.json`;
111
+ });
112
+
113
+ const req = getRequest(path, '2193');
114
+
115
+ // When ...Then ...
116
+ const res = await Import(req);
117
+ o(res.body).equals('{"status":404,"message":"Imagery Not Found"}');
118
+ });
119
+
120
+ o('should return 200 with existing import', async () => {
121
+ // Given... different bucket have no access role
122
+ sandbox.stub(fsa, 'readJson').resolves({ buckets: [role] });
123
+ sandbox.stub(fsa, 'list').callsFake(listFiles);
124
+ sandbox.stub(CogJobFactory, 'create').resolves(undefined);
125
+
126
+ const jobConfig = {
127
+ id: jobId,
128
+ name: path,
129
+ status: 'complete',
130
+ } as ConfigProcessingJob;
131
+ sandbox.stub(Config.ProcessingJob, 'get').resolves(jobConfig);
132
+ const req = getRequest(path, '2193');
133
+
134
+ // When ...Then ...
135
+ const res = await Import(req);
136
+ o(res.status).equals(200);
137
+ const body = Buffer.from(res.body ?? '', 'base64').toString();
138
+ o(JSON.parse(body)).deepEquals(jobConfig);
139
+ });
140
+ });