@basemaps/lambda-tiler 6.24.1 → 6.26.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 (63) hide show
  1. package/CHANGELOG.md +41 -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__/xyz.test.js +51 -28
  8. package/build/__test__/xyz.util.d.ts +4 -0
  9. package/build/__test__/xyz.util.d.ts.map +1 -1
  10. package/build/__test__/xyz.util.js +8 -1
  11. package/build/cli/dump.js +2 -3
  12. package/build/import/imagery.find.d.ts +17 -0
  13. package/build/import/imagery.find.d.ts.map +1 -0
  14. package/build/import/imagery.find.js +38 -0
  15. package/build/import/make.cog.d.ts +5 -0
  16. package/build/import/make.cog.d.ts.map +1 -0
  17. package/build/import/make.cog.js +21 -0
  18. package/build/index.d.ts.map +1 -1
  19. package/build/index.js +2 -0
  20. package/build/routes/__test__/attribution.test.js +4 -0
  21. package/build/routes/__test__/health.test.js +1 -2
  22. package/build/routes/attribution.d.ts.map +1 -1
  23. package/build/routes/attribution.js +1 -0
  24. package/build/routes/health.d.ts.map +1 -1
  25. package/build/routes/health.js +3 -4
  26. package/build/routes/import.d.ts +9 -0
  27. package/build/routes/import.d.ts.map +1 -0
  28. package/build/routes/import.js +62 -0
  29. package/build/routes/tile.json.d.ts +0 -7
  30. package/build/routes/tile.json.d.ts.map +1 -1
  31. package/build/routes/tile.json.js +26 -18
  32. package/build/tile.set.cache.d.ts.map +1 -1
  33. package/build/tile.set.cache.js +7 -3
  34. package/build/tile.set.raster.d.ts +4 -2
  35. package/build/tile.set.raster.d.ts.map +1 -1
  36. package/build/tile.set.raster.js +9 -5
  37. package/build/tile.set.vector.d.ts +4 -1
  38. package/build/tile.set.vector.d.ts.map +1 -1
  39. package/build/tile.set.vector.js +9 -1
  40. package/build/wmts.capability.d.ts +4 -0
  41. package/build/wmts.capability.d.ts.map +1 -1
  42. package/build/wmts.capability.js +1 -1
  43. package/package.json +9 -8
  44. package/src/__test__/tile.cache.key.test.ts +3 -3
  45. package/src/__test__/tile.import.test.ts +140 -0
  46. package/src/__test__/tile.set.cache.test.ts +11 -0
  47. package/src/__test__/xyz.test.ts +55 -28
  48. package/src/__test__/xyz.util.ts +10 -2
  49. package/src/cli/dump.ts +2 -3
  50. package/src/import/imagery.find.ts +60 -0
  51. package/src/import/make.cog.ts +29 -0
  52. package/src/index.ts +2 -0
  53. package/src/routes/__test__/attribution.test.ts +4 -0
  54. package/src/routes/__test__/health.test.ts +1 -3
  55. package/src/routes/attribution.ts +1 -0
  56. package/src/routes/health.ts +3 -4
  57. package/src/routes/import.ts +67 -0
  58. package/src/routes/tile.json.ts +26 -27
  59. package/src/tile.set.cache.ts +6 -2
  60. package/src/tile.set.raster.ts +9 -6
  61. package/src/tile.set.vector.ts +11 -2
  62. package/src/wmts.capability.ts +1 -1
  63. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,62 @@
1
+ import { HttpHeader, LambdaHttpResponse } from '@linzjs/lambda';
2
+ import { Config, 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 { CogJobFactory } from '@basemaps/cli';
8
+ /**
9
+ * Trigger import imagery job by this endpoint
10
+ *
11
+ * @example
12
+ * - /v1/import?path=s3://linz-imagery-staging/2022-03/wellington_rural_2022_delivery_1
13
+ */
14
+ export async function Import(req) {
15
+ const path = req.query.get('path');
16
+ const projection = req.query.get('p');
17
+ // Parse projection as target, default to process both NZTM2000Quad
18
+ let targetTms = Nztm2000Tms;
19
+ if (projection != null) {
20
+ const tileMatrix = TileMatrixSets.find(projection);
21
+ if (tileMatrix == null)
22
+ return new LambdaHttpResponse(404, 'Target projection Not found');
23
+ targetTms = tileMatrix;
24
+ }
25
+ // Find the imagery from s3
26
+ if (path == null || !path.startsWith('s3://'))
27
+ return new LambdaHttpResponse(400, `Invalid s3 path: ${path}`);
28
+ const role = await RoleRegister.findRole(path);
29
+ if (role == null)
30
+ return new LambdaHttpResponse(403, 'Unable to Access the s3 bucket');
31
+ const files = await findImagery(path);
32
+ if (files.length === 0)
33
+ return new LambdaHttpResponse(404, 'Imagery Not Found');
34
+ // Prepare Cog jobs
35
+ const ctx = await getJobCreationContext(path, targetTms, role, files);
36
+ const id = createHash('sha256').update(JSON.stringify(ctx)).digest('base64');
37
+ const jobId = Config.ProcessingJob.id(id);
38
+ let jobConfig = await Config.ProcessingJob.get(jobId);
39
+ if (jobConfig == null) {
40
+ // Add id back to JobCreationContext
41
+ ctx.outputLocation.path = fsa.join(ctx.outputLocation.path, id);
42
+ // Insert Processing job config
43
+ jobConfig = {
44
+ id: jobId,
45
+ name: path,
46
+ status: 'processing',
47
+ };
48
+ if (Config.ProcessingJob.isWriteable())
49
+ await Config.ProcessingJob.put(jobConfig);
50
+ else
51
+ return new LambdaHttpResponse(403, 'Unable to insert the Processing Job config');
52
+ // Start processing job
53
+ await CogJobFactory.create(ctx);
54
+ }
55
+ const json = JSON.stringify(jobConfig);
56
+ const data = Buffer.from(json);
57
+ const response = new LambdaHttpResponse(200, 'ok');
58
+ response.header(HttpHeader.CacheControl, 'no-store');
59
+ response.buffer(data, 'application/json');
60
+ req.set('bytes', data.byteLength);
61
+ return response;
62
+ }
@@ -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], 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 +1 @@
1
- {"version":3,"file":"tile.set.cache.d.ts","sourceRoot":"","sources":["../src/tile.set.cache.ts"],"names":[],"mappings":"AACA,OAAO,EA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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,OAAO,EAAE,OAAO,EAAE,SAAS,SAA8B,GAAG,IAAI;IAMpE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAY/D,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,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,EA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AE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACpC,cAAc,EAAE,MAAM,CAAC;IAEvB,UAAU,EAAE,qBAAqB,CAAC;IAClC,OAAO,EAAE,mBAAmB,CAAC;IAE7B;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM;gBAMjD,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa;IAMnD,IAAI,EAAE,IAAI,MAAM,CAEf;IAED,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,uCAAuC;IACvC,IAAI,MAAM,IAAI,WAAW,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,UAAU;IACd,KAAK,qCAA4C;IAEjD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;CAUxC;AAED,eAAO,MAAM,MAAM,YAAmB,CAAC;AAEvC,qBAAa,aAAa;IACxB,IAAI,EAAE,WAAW,CAAC,MAAM,CAAsB;IAC9C,UAAU,EAAE,qBAAqB,CAAC;IAClC,UAAU,EAAE,aAAa,CAAC;IAC1B,OAAO,EAAE,mBAAmB,CAAC;gBACjB,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa;IAKnD,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
+ {"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,YAAY,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAO,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAc,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAKnF,cAAM,UAAU;IACd,KAAK,qCAA4C;IAEjD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;CAUxC;AAED,eAAO,MAAM,MAAM,YAAmB,CAAC;AAEvC,qBAAa,aAAa;IACxB,IAAI,EAAE,WAAW,CAAC,MAAM,CAAsB;IAC9C,UAAU,EAAE,qBAAqB,CAAC;IAClC,UAAU,EAAE,aAAa,CAAC;IAC1B,OAAO,EAAE,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":"","sources":["../src/wmts.capability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAmB,aAAa,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAiB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAG/D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AA0BrD,qBAAa,gBAAgB;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,YAAY,CAAC;IAEvB,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,EAAE,CAAC,CAAa;IAEjD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,6BAAoC;gBAEtC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM;IAmB9F,qBAAqB,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE,OAAO,SAAyB,GAAG,YAAY;IAe9F,gBAAgB,CAAC,GAAG,EAAE,aAAa,E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AE,EAAE,MAAM,CAAC,EAAE,MAAM;IAmB9F,qBAAqB,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE,OAAO,SAAyB,GAAG,YAAY;IAe9F,gBAAgB,CAAC,GAAG,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,GAAG,YAAY;IAQlE,aAAa,IAAI,YAAY,EAAE;IAkC/B,YAAY,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM;IAc5D,gBAAgB,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,GAAG,YAAY;IAQtE,UAAU,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,YAAY;IAuBjD,UAAU,IAAI,YAAY;IAI1B,kBAAkB,CAAC,GAAG,EAAE,aAAa,GAAG,YAAY;IAoBpD,OAAO,IAAI,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.1",
3
+ "version": "6.26.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.26.0",
26
+ "@basemaps/config": "^6.26.0",
27
+ "@basemaps/geo": "^6.26.0",
27
28
  "@basemaps/lambda": "^6.7.0",
28
- "@basemaps/shared": "^6.24.1",
29
- "@basemaps/tiler": "^6.23.0",
30
- "@basemaps/tiler-sharp": "^6.23.0",
29
+ "@basemaps/shared": "^6.26.0",
30
+ "@basemaps/tiler": "^6.26.0",
31
+ "@basemaps/tiler-sharp": "^6.26.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.26.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": "034afcc7087bbe9041098d54e1529d757a70bb29"
63
+ "gitHead": "1b3a7eb8aad1e0c9bb2ca64e0dcfe13b16e08a50"
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":400,"message":"Invalid s3 path: s3::testbucket/"}');
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":403,"message":"Unable to Access the s3 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
+ });
@@ -74,6 +74,17 @@ o.spec('TileSetCache', () => {
74
74
  if (subTileSetB == null || subTileSetB.type === TileSetType.Vector) throw new Error('null subTileSetB');
75
75
  o(subTileSetB.title).equals('parent Tasman rural 2018-19 0.3m');
76
76
  });
77
+
78
+ o('should not throw if child does not exist', async () => {
79
+ TileSets.add(new TileSetRaster('aerial@head', GoogleTms));
80
+
81
+ const parentTileSet = await TileSets.get('aerial@head', GoogleTms);
82
+ if (parentTileSet == null || parentTileSet.type === TileSetType.Vector) throw new Error('null parentTileSet');
83
+ parentTileSet.imagery = imgMap;
84
+
85
+ const subTileSet = await TileSets.get('aerial@head:fake', GoogleTms);
86
+ o(subTileSet).equals(null);
87
+ });
77
88
  });
78
89
 
79
90
  o.spec('loadTileSets', () => {