@basemaps/lambda-tiler 6.26.0 → 6.28.1

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 (107) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/build/{__test__ → __tests__}/index.test.d.ts +0 -0
  3. package/build/{__test__ → __tests__}/index.test.d.ts.map +1 -1
  4. package/build/{__test__ → __tests__}/index.test.js +0 -0
  5. package/build/{__test__ → __tests__}/route.test.d.ts +0 -0
  6. package/build/{__test__ → __tests__}/route.test.d.ts.map +1 -1
  7. package/build/{__test__ → __tests__}/route.test.js +0 -0
  8. package/build/{__test__ → __tests__}/tiff.cache.test.d.ts +0 -0
  9. package/build/__tests__/tiff.cache.test.d.ts.map +1 -0
  10. package/build/{__test__ → __tests__}/tiff.cache.test.js +0 -0
  11. package/build/{__test__ → __tests__}/tile.cache.key.test.d.ts +0 -0
  12. package/build/__tests__/tile.cache.key.test.d.ts.map +1 -0
  13. package/build/{__test__ → __tests__}/tile.cache.key.test.js +0 -0
  14. package/build/{__test__ → __tests__}/tile.set.cache.test.d.ts +0 -0
  15. package/build/__tests__/tile.set.cache.test.d.ts.map +1 -0
  16. package/build/{__test__ → __tests__}/tile.set.cache.test.js +0 -0
  17. package/build/{__test__ → __tests__}/tile.set.test.d.ts +0 -0
  18. package/build/__tests__/tile.set.test.d.ts.map +1 -0
  19. package/build/{__test__ → __tests__}/tile.set.test.js +0 -5
  20. package/build/{__test__ → __tests__}/tile.style.json.test.d.ts +0 -0
  21. package/build/__tests__/tile.style.json.test.d.ts.map +1 -0
  22. package/build/{__test__ → __tests__}/tile.style.json.test.js +0 -0
  23. package/build/{__test__ → __tests__}/wmts.capability.test.d.ts +0 -0
  24. package/build/__tests__/wmts.capability.test.d.ts.map +1 -0
  25. package/build/{__test__ → __tests__}/wmts.capability.test.js +36 -9
  26. package/build/{__test__ → __tests__}/xyz.test.d.ts +0 -0
  27. package/build/{__test__ → __tests__}/xyz.test.d.ts.map +1 -1
  28. package/build/{__test__ → __tests__}/xyz.test.js +0 -0
  29. package/build/{__test__ → __tests__}/xyz.util.d.ts +0 -0
  30. package/build/__tests__/xyz.util.d.ts.map +1 -0
  31. package/build/{__test__ → __tests__}/xyz.util.js +0 -0
  32. package/build/index.d.ts +3 -1
  33. package/build/index.d.ts.map +1 -1
  34. package/build/index.js +2 -3
  35. package/build/routes/{__test__ → __tests__}/attribution.test.d.ts +0 -0
  36. package/build/routes/__tests__/attribution.test.d.ts.map +1 -0
  37. package/build/routes/{__test__ → __tests__}/attribution.test.js +3 -2
  38. package/build/routes/{__test__ → __tests__}/health.test.d.ts +0 -0
  39. package/build/routes/__tests__/health.test.d.ts.map +1 -0
  40. package/build/routes/{__test__ → __tests__}/health.test.js +0 -0
  41. package/build/routes/{__test__ → __tests__}/imagery.test.d.ts +0 -0
  42. package/build/routes/__tests__/imagery.test.d.ts.map +1 -0
  43. package/build/routes/{__test__ → __tests__}/imagery.test.js +0 -0
  44. package/build/routes/__tests__/wmts.test.d.ts +2 -0
  45. package/build/routes/__tests__/wmts.test.d.ts.map +1 -0
  46. package/build/routes/__tests__/wmts.test.js +31 -0
  47. package/build/routes/tile.wmts.d.ts +2 -0
  48. package/build/routes/tile.wmts.d.ts.map +1 -1
  49. package/build/routes/tile.wmts.js +23 -3
  50. package/build/tile.set.cache.js +1 -1
  51. package/build/tile.set.raster.d.ts +1 -6
  52. package/build/tile.set.raster.d.ts.map +1 -1
  53. package/build/tile.set.raster.js +12 -22
  54. package/build/tile.set.vector.d.ts.map +1 -1
  55. package/build/tile.set.vector.js +3 -1
  56. package/build/wmts.capability.d.ts +12 -6
  57. package/build/wmts.capability.d.ts.map +1 -1
  58. package/build/wmts.capability.js +12 -11
  59. package/package.json +13 -14
  60. package/scripts/create.deployment.package.mjs +3 -3
  61. package/src/{__test__ → __tests__}/index.test.ts +0 -0
  62. package/src/{__test__ → __tests__}/route.test.ts +0 -0
  63. package/src/{__test__ → __tests__}/tiff.cache.test.ts +0 -0
  64. package/src/{__test__ → __tests__}/tile.cache.key.test.ts +0 -0
  65. package/src/{__test__ → __tests__}/tile.set.cache.test.ts +0 -0
  66. package/src/{__test__ → __tests__}/tile.set.test.ts +0 -7
  67. package/src/{__test__ → __tests__}/tile.style.json.test.ts +0 -0
  68. package/src/{__test__ → __tests__}/wmts.capability.test.ts +39 -8
  69. package/src/{__test__ → __tests__}/xyz.test.ts +0 -0
  70. package/src/{__test__ → __tests__}/xyz.util.ts +0 -0
  71. package/src/index.ts +2 -3
  72. package/src/routes/{__test__ → __tests__}/attribution.test.ts +3 -2
  73. package/src/routes/{__test__ → __tests__}/health.test.ts +0 -0
  74. package/src/routes/{__test__ → __tests__}/imagery.test.ts +0 -0
  75. package/src/routes/__tests__/wmts.test.ts +40 -0
  76. package/src/routes/tile.wmts.ts +23 -3
  77. package/src/tile.set.cache.ts +1 -1
  78. package/src/tile.set.raster.ts +12 -21
  79. package/src/tile.set.vector.ts +2 -1
  80. package/src/wmts.capability.ts +21 -15
  81. package/tsconfig.tsbuildinfo +1 -1
  82. package/build/__test__/tiff.cache.test.d.ts.map +0 -1
  83. package/build/__test__/tile.cache.key.test.d.ts.map +0 -1
  84. package/build/__test__/tile.import.test.d.ts +0 -2
  85. package/build/__test__/tile.import.test.d.ts.map +0 -1
  86. package/build/__test__/tile.import.test.js +0 -115
  87. package/build/__test__/tile.set.cache.test.d.ts.map +0 -1
  88. package/build/__test__/tile.set.test.d.ts.map +0 -1
  89. package/build/__test__/tile.style.json.test.d.ts.map +0 -1
  90. package/build/__test__/wmts.capability.test.d.ts.map +0 -1
  91. package/build/__test__/xyz.util.d.ts.map +0 -1
  92. package/build/import/imagery.find.d.ts +0 -17
  93. package/build/import/imagery.find.d.ts.map +0 -1
  94. package/build/import/imagery.find.js +0 -38
  95. package/build/import/make.cog.d.ts +0 -5
  96. package/build/import/make.cog.d.ts.map +0 -1
  97. package/build/import/make.cog.js +0 -21
  98. package/build/routes/__test__/attribution.test.d.ts.map +0 -1
  99. package/build/routes/__test__/health.test.d.ts.map +0 -1
  100. package/build/routes/__test__/imagery.test.d.ts.map +0 -1
  101. package/build/routes/import.d.ts +0 -9
  102. package/build/routes/import.d.ts.map +0 -1
  103. package/build/routes/import.js +0 -62
  104. package/src/__test__/tile.import.test.ts +0 -140
  105. package/src/import/imagery.find.ts +0 -60
  106. package/src/import/make.cog.ts +0 -29
  107. package/src/routes/import.ts +0 -67
@@ -1,18 +1,25 @@
1
- import { ConfigProvider } from '@basemaps/config';
2
- import { Bounds, TileMatrixSet, WmtsProvider } from '@basemaps/geo';
1
+ import { Bounds, ImageFormat, TileMatrixSet, WmtsProvider } from '@basemaps/geo';
3
2
  import { VNodeElement } from '@basemaps/shared';
4
3
  import { TileSetRaster } from './tile.set.raster.js';
5
4
  /**
6
5
  * Default the tile matrix id to the projection of the TileMatrixSet
7
6
  */
8
7
  export declare function getTileMatrixId(tileMatrix: TileMatrixSet): string;
8
+ export interface WmtsCapabilitiesParams {
9
+ httpBase: string;
10
+ provider?: WmtsProvider;
11
+ layers: TileSetRaster[];
12
+ apiKey?: string;
13
+ formats?: ImageFormat[];
14
+ }
9
15
  export declare class WmtsCapabilities {
10
16
  httpBase: string;
11
- provider: WmtsProvider;
17
+ provider?: WmtsProvider;
12
18
  layers: Map<string, TileSetRaster[]>;
13
19
  apiKey?: string;
14
20
  tileMatrixSets: Map<string, TileMatrixSet>;
15
- constructor(httpBase: string, provider: WmtsProvider, layers: TileSetRaster[], apiKey?: string);
21
+ formats: ImageFormat[];
22
+ constructor(params: WmtsCapabilitiesParams);
16
23
  buildWgs84BoundingBox(layers: TileSetRaster[], tagName?: string): VNodeElement;
17
24
  buildBoundingBox(tms: TileMatrixSet, extent: Bounds): VNodeElement;
18
25
  buildProvider(): VNodeElement[];
@@ -22,7 +29,6 @@ export declare class WmtsCapabilities {
22
29
  buildStyle(): VNodeElement;
23
30
  buildTileMatrixSet(tms: TileMatrixSet): VNodeElement;
24
31
  toVNode(): VNodeElement;
25
- toString(): string;
26
- static toXml(httpBase: string, provider: ConfigProvider, tileSet: TileSetRaster[], apiKey?: string): string;
32
+ toXml(): string;
27
33
  }
28
34
  //# sourceMappingURL=wmts.capability.d.ts.map
@@ -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;AAiBrD;;GAEG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,aAAa,GAAG,MAAM,CAIjE;AAED,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,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"}
1
+ {"version":3,"file":"wmts.capability.d.ts","sourceRoot":"","sources":["../src/wmts.capability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAmB,aAAa,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClG,OAAO,EAAiB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAG/D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAiBrD;;GAEG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,aAAa,GAAG,MAAM,CAIjE;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;CACzB;AAED,qBAAa,gBAAgB;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,YAAY,CAAC;IAExB,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,EAAE,CAAC,CAAa;IAEjD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,6BAAoC;IAClD,OAAO,EAAE,WAAW,EAAE,CAAC;gBAEX,MAAM,EAAE,sBAAsB;IAoB1C,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;IAmC/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,KAAK,IAAI,MAAM;CAGhB"}
@@ -24,12 +24,13 @@ export function getTileMatrixId(tileMatrix) {
24
24
  return tileMatrix.projection.toEpsgString();
25
25
  }
26
26
  export class WmtsCapabilities {
27
- constructor(httpBase, provider, layers, apiKey) {
27
+ constructor(params) {
28
+ var _a;
28
29
  this.layers = new Map();
29
30
  this.tileMatrixSets = new Map();
30
- this.httpBase = httpBase;
31
- this.provider = provider;
32
- for (const layer of layers) {
31
+ this.httpBase = params.httpBase;
32
+ this.provider = params.provider;
33
+ for (const layer of params.layers) {
33
34
  // TODO is grouping by name the best option
34
35
  let existing = this.layers.get(layer.fullName);
35
36
  if (existing == null) {
@@ -40,7 +41,8 @@ export class WmtsCapabilities {
40
41
  existing.push(layer);
41
42
  this.tileMatrixSets.set(layer.tileMatrix.identifier, layer.tileMatrix);
42
43
  }
43
- this.apiKey = apiKey;
44
+ this.apiKey = params.apiKey;
45
+ this.formats = (_a = params.formats) !== null && _a !== void 0 ? _a : ImageFormatOrder;
44
46
  }
45
47
  buildWgs84BoundingBox(layers, tagName = 'ows:WGS84BoundingBox') {
46
48
  let bbox = wgs84Extent(layers[0]);
@@ -59,6 +61,8 @@ export class WmtsCapabilities {
59
61
  ]);
60
62
  }
61
63
  buildProvider() {
64
+ if (this.provider == null)
65
+ return [];
62
66
  const { serviceIdentification, serviceProvider } = this.provider;
63
67
  const { contact } = serviceProvider;
64
68
  return [
@@ -127,9 +131,9 @@ export class WmtsCapabilities {
127
131
  ...layers.map((layer) => this.buildBoundingBox(layer.tileMatrix, layer.extent)),
128
132
  this.buildWgs84BoundingBox(layers),
129
133
  this.buildStyle(),
130
- ...ImageFormatOrder.map((fmt) => V('Format', 'image/' + fmt)),
134
+ ...this.formats.map((fmt) => V('Format', 'image/' + fmt)),
131
135
  ...matrixSetNodes,
132
- ...ImageFormatOrder.map((fmt) => this.buildResourceUrl(firstLayer, fmt)),
136
+ ...this.formats.map((fmt) => this.buildResourceUrl(firstLayer, fmt)),
133
137
  ]);
134
138
  }
135
139
  buildStyle() {
@@ -164,10 +168,7 @@ export class WmtsCapabilities {
164
168
  layers.push(this.buildTileMatrixSet(tms));
165
169
  return V('Capabilities', CapabilitiesAttrs, [...this.buildProvider(), V('Contents', layers)]);
166
170
  }
167
- toString() {
171
+ toXml() {
168
172
  return '<?xml version="1.0"?>\n' + this.toVNode().toString();
169
173
  }
170
- static toXml(httpBase, provider, tileSet, apiKey) {
171
- return new WmtsCapabilities(httpBase, provider, tileSet, apiKey).toString();
172
- }
173
174
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basemaps/lambda-tiler",
3
- "version": "6.26.0",
3
+ "version": "6.28.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/linz/basemaps.git",
@@ -22,22 +22,21 @@
22
22
  "types": "./build/index.d.ts",
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "@basemaps/cli": "^6.26.0",
26
- "@basemaps/config": "^6.26.0",
27
- "@basemaps/geo": "^6.26.0",
25
+ "@basemaps/config": "^6.28.1",
26
+ "@basemaps/geo": "^6.28.1",
28
27
  "@basemaps/lambda": "^6.7.0",
29
- "@basemaps/shared": "^6.26.0",
30
- "@basemaps/tiler": "^6.26.0",
31
- "@basemaps/tiler-sharp": "^6.26.0",
28
+ "@basemaps/shared": "^6.28.1",
29
+ "@basemaps/tiler": "^6.28.1",
30
+ "@basemaps/tiler-sharp": "^6.28.1",
32
31
  "@chunkd/fs": "^8.1.0",
33
32
  "@cogeotiff/core": "^7.0.0",
34
33
  "@cotar/core": "^5.3.0",
35
- "@linzjs/geojson": "^6.21.1",
36
- "@linzjs/lambda": "^2.0.0",
34
+ "@linzjs/geojson": "^6.28.1",
35
+ "@linzjs/lambda": "^3.0.1",
37
36
  "p-limit": "^4.0.0",
38
37
  "path-to-regexp": "^6.1.0",
39
38
  "pixelmatch": "^5.1.0",
40
- "sharp": "^0.29.3"
39
+ "sharp": "0.29.2"
41
40
  },
42
41
  "bundle": {
43
42
  "entry": "src/index.ts",
@@ -53,12 +52,12 @@
53
52
  "bundle": "./bundle.sh"
54
53
  },
55
54
  "devDependencies": {
56
- "@basemaps/attribution": "^6.26.0",
55
+ "@basemaps/attribution": "^6.28.1",
57
56
  "@types/aws-lambda": "^8.10.75",
58
- "@types/node": "^14.11.2",
57
+ "@types/node": "^17.0.34",
59
58
  "@types/pixelmatch": "^5.0.0",
60
- "@types/sharp": "^0.29.3",
59
+ "@types/sharp": "0.29.2",
61
60
  "pretty-json-log": "^1.0.0"
62
61
  },
63
- "gitHead": "1b3a7eb8aad1e0c9bb2ca64e0dcfe13b16e08a50"
62
+ "gitHead": "f387e0365bcfc7391fd8d0665195b246c93532cf"
64
63
  }
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Create a pacakge.json for the `dist` bundle based off the parent package.json
3
+ * Create a package.json for the `dist` bundle based off the parent package.json
4
4
  *
5
5
  * This is needed as libsharp has to be "installed" into the dist node_modules so that lambda has access to sharp
6
6
  */
@@ -9,7 +9,7 @@ import * as fs from 'fs';
9
9
  const parentPackage = JSON.parse(fs.readFileSync('../package.json').toString());
10
10
 
11
11
  // Find the exact version of a package in the yarn lock
12
- function getPackageVersion(packageName) {
12
+ export function getPackageVersion(packageName) {
13
13
  const parentLock = fs.readFileSync('../../../yarn.lock').toString().split('\n');
14
14
 
15
15
  for (let i = 0; i < parentLock.length; i++) {
@@ -24,7 +24,7 @@ function getPackageVersion(packageName) {
24
24
  // the bundle is a commonjs module
25
25
  parentPackage.type = 'commonjs';
26
26
  parentPackage.main = 'index.js';
27
- parentPackage.dependencies = { sharp: getPackageVersion('sharp') };
27
+ parentPackage.dependencies = { sharp: '0.29.2' };
28
28
 
29
29
  // Clean up
30
30
  delete parentPackage.types;
File without changes
File without changes
File without changes
@@ -1,15 +1,8 @@
1
- import { ConfigImagery } from '@basemaps/config';
2
1
  import { GoogleTms, Nztm2000Tms } from '@basemaps/geo';
3
2
  import o from 'ospec';
4
3
  import { TileSetRaster } from '../tile.set.raster.js';
5
4
 
6
5
  o.spec('tile.set', () => {
7
- o('basePath', () => {
8
- const rec = { uri: 's3://test-bucket/3857/aerail/job123' } as ConfigImagery;
9
- o(TileSetRaster.basePath(rec)).equals('s3://test-bucket/3857/aerail/job123');
10
- o(TileSetRaster.basePath(rec, '31223')).equals('s3://test-bucket/3857/aerail/job123/31223.tiff');
11
- });
12
-
13
6
  o('extent', () => {
14
7
  o(new TileSetRaster('google', GoogleTms).extent.toBbox()).deepEquals([
15
8
  -20037508.3427892, -20037508.3427892, 20037508.3427892, 20037508.3427892,
@@ -1,4 +1,4 @@
1
- import { Bounds, Epsg, GoogleTms, Nztm2000QuadTms, Nztm2000Tms } from '@basemaps/geo';
1
+ import { Bounds, Epsg, GoogleTms, ImageFormat, Nztm2000QuadTms, Nztm2000Tms } from '@basemaps/geo';
2
2
  import { TileSetName, V, VNodeElement } from '@basemaps/shared';
3
3
  import { roundNumbersInString } from '@basemaps/test/build/rounding.js';
4
4
  import { createHash } from 'crypto';
@@ -21,8 +21,30 @@ o.spec('WmtsCapabilities', () => {
21
21
  const tileSet = new FakeTileSet(TileSetName.aerial, GoogleTms);
22
22
  const tileSetImagery = new FakeTileSet('01E7PJFR9AMQFJ05X9G7FQ3XMW', GoogleTms);
23
23
 
24
+ o('should output the requested formats', () => {
25
+ const wmts = new WmtsCapabilities({
26
+ httpBase: 'https://basemaps.test',
27
+ provider: Provider,
28
+ layers: [tileSet],
29
+ apiKey,
30
+ formats: [ImageFormat.Avif],
31
+ }).toVNode();
32
+
33
+ const urls = tags(wmts, 'ResourceURL');
34
+ o(urls.length).equals(1);
35
+ o(urls[0].attrs.format).equals('image/avif');
36
+ o(urls[0].attrs.template).equals(
37
+ 'https://basemaps.test/v1/tiles/aerial/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.avif?api=secret1234',
38
+ );
39
+ });
40
+
24
41
  o('should build capability xml for tileset and projection', () => {
25
- const wmts = new WmtsCapabilities('https://basemaps.test', Provider, [tileSet], apiKey);
42
+ const wmts = new WmtsCapabilities({
43
+ httpBase: 'https://basemaps.test',
44
+ provider: Provider,
45
+ layers: [tileSet],
46
+ apiKey,
47
+ });
26
48
 
27
49
  const raw = wmts.toVNode();
28
50
  const serviceId = raw.find('ows:ServiceIdentification');
@@ -102,7 +124,12 @@ o.spec('WmtsCapabilities', () => {
102
124
  compareMatrix(tileMatrices[0], '0', 1, 559082264.028717);
103
125
  compareMatrix(tileMatrices[10], '10', 1024, 545978.773465544);
104
126
 
105
- const xml = WmtsCapabilities.toXml('https://basemaps.test', Provider, [tileSet], apiKey) ?? '';
127
+ const xml = new WmtsCapabilities({
128
+ httpBase: 'https://basemaps.test',
129
+ provider: Provider,
130
+ layers: [tileSet],
131
+ apiKey,
132
+ }).toXml();
106
133
 
107
134
  o(xml).deepEquals('<?xml version="1.0"?>\n' + raw?.toString());
108
135
 
@@ -112,7 +139,11 @@ o.spec('WmtsCapabilities', () => {
112
139
  });
113
140
 
114
141
  o('should allow individual imagery sets', () => {
115
- const raw = new WmtsCapabilities('https://basemaps.test', Provider, [tileSetImagery]).toVNode();
142
+ const raw = new WmtsCapabilities({
143
+ httpBase: 'https://basemaps.test',
144
+ provider: Provider,
145
+ layers: [tileSetImagery],
146
+ }).toVNode();
116
147
 
117
148
  const tms = raw?.find('TileMatrixSet', 'ows:Identifier');
118
149
 
@@ -128,7 +159,7 @@ o.spec('WmtsCapabilities', () => {
128
159
 
129
160
  o('should support multiple projections', () => {
130
161
  const ts = [new FakeTileSet(TileSetName.aerial, Nztm2000Tms), new FakeTileSet(TileSetName.aerial, GoogleTms)];
131
- const xml = new WmtsCapabilities('basemaps.test', Provider, ts);
162
+ const xml = new WmtsCapabilities({ httpBase: 'basemaps.test', provider: Provider, layers: ts });
132
163
  const nodes = xml.toVNode();
133
164
 
134
165
  const layers = tags(nodes, 'Layer');
@@ -175,7 +206,7 @@ o.spec('WmtsCapabilities', () => {
175
206
  new FakeTileSet(TileSetName.aerial, Nztm2000Tms, 'aerial-title'),
176
207
  new FakeTileSet('01E7PJFR9AMQFJ05X9G7FQ3XMW', Nztm2000Tms, 'imagery-title'),
177
208
  ];
178
- const nodes = new WmtsCapabilities('basemaps.test', Provider, ts).toVNode();
209
+ const nodes = new WmtsCapabilities({ httpBase: 'basemaps.test', provider: Provider, layers: ts }).toVNode();
179
210
  const layers = tags(nodes, 'Layer');
180
211
  o(layers.length).equals(2);
181
212
 
@@ -199,7 +230,7 @@ o.spec('WmtsCapabilities', () => {
199
230
  'west-coast_rural_2016-17_0-3m',
200
231
  ),
201
232
  ];
202
- const nodes = new WmtsCapabilities('basemaps.test', Provider, ts).toVNode();
233
+ const nodes = new WmtsCapabilities({ httpBase: 'basemaps.test', provider: Provider, layers: ts }).toVNode();
203
234
  const layers = tags(nodes, 'Layer');
204
235
 
205
236
  o(layers.length).equals(2);
@@ -223,7 +254,7 @@ o.spec('WmtsCapabilities', () => {
223
254
  ts[1].extentOverride = new Bounds(1, 2, 2, 2);
224
255
 
225
256
  ts[2].tileSet.title = 'aerial_dunedin_urban';
226
- const nodes = new WmtsCapabilities('basemaps.test', Provider, ts).toVNode();
257
+ const nodes = new WmtsCapabilities({ httpBase: 'basemaps.test', provider: Provider, layers: ts }).toVNode();
227
258
 
228
259
  const allMatrixes = tags(nodes, 'TileMatrixSet');
229
260
 
File without changes
File without changes
package/src/index.ts CHANGED
@@ -8,7 +8,6 @@ import { createHash } from 'crypto';
8
8
  import { Imagery } from './routes/imagery.js';
9
9
  import { Esri } from './routes/esri/rest.js';
10
10
  import { St } from './source.tracer.js';
11
- import { Import } from './routes/import.js';
12
11
 
13
12
  const app = new Router();
14
13
 
@@ -18,7 +17,6 @@ app.get('version', Version);
18
17
  app.get('tiles', Tiles);
19
18
  app.get('imagery', Imagery);
20
19
  app.get('esri', Esri);
21
- app.get('import', Import);
22
20
 
23
21
  let slowTimer: NodeJS.Timer | null = null;
24
22
  export async function handleRequest(req: LambdaHttpRequest): Promise<LambdaHttpResponse> {
@@ -50,4 +48,5 @@ export async function handleRequest(req: LambdaHttpRequest): Promise<LambdaHttpR
50
48
  }
51
49
  }
52
50
 
53
- export const handler = lf.http(handleRequest, LogConfig.get());
51
+ export const handler = lf.http(LogConfig.get());
52
+ handler.router.get('*', handleRequest);
@@ -2,14 +2,14 @@ import { ConfigImagery, ConfigLayer, ConfigProvider } from '@basemaps/config';
2
2
  import { EpsgCode, GoogleTms, NamedBounds, Nztm2000QuadTms, Nztm2000Tms, Stac, TileMatrixSets } from '@basemaps/geo';
3
3
  import { HttpHeader } from '@linzjs/lambda';
4
4
  import { Config } from '@basemaps/shared';
5
- import { mockFileOperator } from '@basemaps/shared/build/file/__test__/file.operator.test.helper.js';
5
+ import { mockFileOperator } from '@basemaps/shared/build/file/__tests__/file.operator.test.helper.js';
6
6
  import { round } from '@basemaps/test/build/rounding.js';
7
7
  import o from 'ospec';
8
8
  import sinon from 'sinon';
9
9
  const sandbox = sinon.createSandbox();
10
10
  import { TileSets } from '../../tile.set.cache.js';
11
11
  import { TileSetRaster } from '../../tile.set.raster.js';
12
- import { FakeTileSet, mockRequest, Provider } from '../../__test__/xyz.util.js';
12
+ import { FakeTileSet, mockRequest, Provider } from '../../__tests__/xyz.util.js';
13
13
  import { attribution, createAttributionCollection } from '../attribution.js';
14
14
  import { TileEtag } from '../tile.etag.js';
15
15
  import { Attribution } from '@basemaps/attribution';
@@ -268,6 +268,7 @@ function makeImageRecord(id: string, name: string, x = 10): ConfigImagery {
268
268
  id,
269
269
  name,
270
270
  projection: EpsgCode.Google,
271
+ tileMatrix: 'WebMercatorQuad',
271
272
  uri: 's3://bucket/path/' + name,
272
273
  bounds: GoogleTms.tileToSourceBounds({ x, y: 10, z: 5 }),
273
274
  files: [0, 1].map((i) => {
@@ -0,0 +1,40 @@
1
+ import { ImageFormat } from '@basemaps/geo';
2
+ import { LogConfig } from '@basemaps/shared';
3
+ import { LambdaHttpRequest, LambdaUrlRequest } from '@linzjs/lambda';
4
+ import { Context } from 'aws-lambda';
5
+ import o from 'ospec';
6
+ import { getImageFormats } from '../tile.wmts.js';
7
+
8
+ o.spec('GetImageFormats', () => {
9
+ function newRequest(path: string, query: string): LambdaHttpRequest {
10
+ return new LambdaUrlRequest(
11
+ {
12
+ requestContext: { http: { method: 'GET' } },
13
+ headers: {},
14
+ rawPath: path,
15
+ rawQueryString: query,
16
+ isBase64Encoded: false,
17
+ } as any,
18
+ {} as Context,
19
+ LogConfig.get(),
20
+ );
21
+ }
22
+
23
+ o('should parse all formats', () => {
24
+ const req = newRequest('/v1/blank', 'format=png&format=jpeg');
25
+ const formats = getImageFormats(req);
26
+ o(formats).deepEquals([ImageFormat.Png, ImageFormat.Jpeg]);
27
+ });
28
+
29
+ o('should ignore bad formats', () => {
30
+ const req = newRequest('/v1/blank', 'format=fake&format=mvt');
31
+ const formats = getImageFormats(req);
32
+ o(formats).equals(undefined);
33
+ });
34
+
35
+ o('should de-dupe formats', () => {
36
+ const req = newRequest('/v1/blank', 'format=png&format=jpeg&format=png&format=jpeg&format=png&format=jpeg');
37
+ const formats = getImageFormats(req);
38
+ o(formats).deepEquals([ImageFormat.Png, ImageFormat.Jpeg]);
39
+ });
40
+ });
@@ -1,6 +1,7 @@
1
1
  import { Config, TileSetType } from '@basemaps/config';
2
- import { TileMatrixSet } from '@basemaps/geo';
2
+ import { ImageFormat, TileMatrixSet } from '@basemaps/geo';
3
3
  import { Env, TileSetName, tileWmtsFromPath } from '@basemaps/shared';
4
+ import { getImageFormat } from '@basemaps/tiler';
4
5
  import { HttpHeader, LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
5
6
  import { createHash } from 'crypto';
6
7
  import { Router } from '../router.js';
@@ -10,6 +11,20 @@ import { WmtsCapabilities } from '../wmts.capability.js';
10
11
  import { NotFound, NotModified } from './response.js';
11
12
  import { TileEtag } from './tile.etag.js';
12
13
 
14
+ export function getImageFormats(req: LambdaHttpRequest): ImageFormat[] | undefined {
15
+ const formats = req.query.getAll('format');
16
+ if (formats == null || formats.length === 0) return undefined;
17
+
18
+ const output: Set<ImageFormat> = new Set();
19
+ for (const fmt of formats) {
20
+ const parsed = getImageFormat(fmt);
21
+ if (parsed == null) continue;
22
+ output.add(parsed);
23
+ }
24
+ if (output.size === 0) return undefined;
25
+ return [...output.values()];
26
+ }
27
+
13
28
  /**
14
29
  * Serve a WMTS request
15
30
  *
@@ -29,10 +44,15 @@ export async function wmts(req: LambdaHttpRequest): Promise<LambdaHttpResponse>
29
44
 
30
45
  const providerId = Config.Provider.id('linz');
31
46
  const provider = await Config.Provider.get(providerId);
32
- if (provider == null) return NotFound;
33
47
 
34
48
  const apiKey = Router.apiKey(req);
35
- const xml = WmtsCapabilities.toXml(host, provider, tileSets, apiKey);
49
+ const xml = new WmtsCapabilities({
50
+ httpBase: host,
51
+ provider: provider ?? undefined,
52
+ layers: tileSets,
53
+ apiKey,
54
+ formats: getImageFormats(req),
55
+ }).toXml();
36
56
  if (xml == null) return NotFound;
37
57
 
38
58
  const data = Buffer.from(xml);
@@ -63,7 +63,7 @@ export class TileSetCache {
63
63
 
64
64
  // If we already have a copy and it hasn't been modified just return it
65
65
  const existing = this.tileSets.get(tileSetId);
66
- if (existing?.tileSet.updatedAt === tileSet.updatedAt) {
66
+ if (existing != null && existing?.tileSet.updatedAt === tileSet.updatedAt) {
67
67
  return existing;
68
68
  }
69
69
 
@@ -20,7 +20,7 @@ import { St } from './source.tracer.js';
20
20
  import { TiffCache } from './tiff.cache.js';
21
21
  import { TileSets } from './tile.set.cache.js';
22
22
 
23
- const LoadingQueue = pLimit(Env.getNumber(Env.TiffConcurrency, 5));
23
+ const LoadingQueue = pLimit(Env.getNumber(Env.TiffConcurrency, 25));
24
24
 
25
25
  export const TileComposer = new TileMakerSharp(256);
26
26
 
@@ -35,6 +35,11 @@ export interface TileSetResponse {
35
35
  const DefaultResizeKernel = { in: 'lanczos3', out: 'lanczos3' } as const;
36
36
  const DefaultBackground = { r: 0, g: 0, b: 0, alpha: 0 };
37
37
 
38
+ export function getTiffName(name: string): string {
39
+ if (name.endsWith('.tif') || name.endsWith('.tiff')) return name;
40
+ return `${name}.tiff`;
41
+ }
42
+
38
43
  export class TileSetRaster {
39
44
  type: TileSetType.Raster = TileSetType.Raster;
40
45
 
@@ -46,17 +51,6 @@ export class TileSetRaster {
46
51
  components: TileSetNameComponents;
47
52
  tileSet: ConfigTileSetRaster;
48
53
 
49
- /**
50
- * Return the location of a imagery `record`
51
- * @param record
52
- * @param name the COG to locate. Return just the directory if `null`
53
- */
54
- static basePath(record: ConfigImagery, name?: string): string {
55
- if (name == null) return record.uri;
56
- if (record.uri.endsWith('/')) throw new Error("Invalid uri ending with '/' " + record.uri);
57
- return `${record.uri}/${name}.tiff`;
58
- }
59
-
60
54
  constructor(name: string, tileMatrix: TileMatrixSet) {
61
55
  this.components = TileSetNameParser.parse(name);
62
56
  this.tileMatrix = tileMatrix;
@@ -122,17 +116,15 @@ export class TileSetRaster {
122
116
  req.set('layers', layers.length);
123
117
  if (TileEtag.isNotModified(req, cacheKey)) return NotModified;
124
118
 
125
- req.timer.start('tile:compose');
126
119
  const res = await TileComposer.compose({
127
120
  layers,
128
121
  format: xyz.ext,
129
122
  background: this.tileSet.background ?? DefaultBackground,
130
123
  resizeKernel: this.tileSet.resizeKernel ?? DefaultResizeKernel,
124
+ metrics: req.timer,
131
125
  });
132
- req.timer.end('tile:compose');
133
126
 
134
127
  req.set('layersUsed', res.layers);
135
- req.set('allLayersUsed', res.layers === layers.length);
136
128
  req.set('bytes', res.buffer.byteLength);
137
129
 
138
130
  const response = new LambdaHttpResponse(200, 'ok');
@@ -165,7 +157,6 @@ export class TileSetRaster {
165
157
 
166
158
  const imagery = this.imagery.get(imgId);
167
159
  if (imagery == null) {
168
- console.log('Failed', { imagery, i: this.imagery, ts: this.tileSet.layers });
169
160
  log?.warn(
170
161
  { layer: layer.name, projection: this.tileMatrix.projection.code, imgId },
171
162
  'Failed to lookup imagery',
@@ -183,18 +174,18 @@ export class TileSetRaster {
183
174
  const output: CogTiff[] = [];
184
175
  for (const c of record.files) {
185
176
  if (!tileBounds.intersects(Bounds.fromJson(c))) continue;
177
+ const tiffPath = fsa.join(record.uri, getTiffName(c.name));
186
178
 
187
- const tiffKey = `${record.id}_${c.name}`;
188
- let existing = TiffCache.get(tiffKey);
179
+ let existing = TiffCache.get(tiffPath);
189
180
  if (existing == null) {
190
- const source = fsa.source(TileSetRaster.basePath(record, c.name));
181
+ const source = fsa.source(tiffPath);
191
182
  if (source == null) {
192
- throw new Error(`Failed to create CogSource from ${TileSetRaster.basePath(record, c.name)}`);
183
+ throw new Error(`Failed to create CogSource from ${tiffPath}`);
193
184
  }
194
185
 
195
186
  St.trace(source);
196
187
  existing = new CogTiff(source);
197
- TiffCache.set(tiffKey, existing);
188
+ TiffCache.set(tiffPath, existing);
198
189
  }
199
190
 
200
191
  output.push(existing);
@@ -1,5 +1,5 @@
1
1
  import { ConfigTileSetVector, TileSetNameComponents, TileSetNameParser, TileSetType } from '@basemaps/config';
2
- import { TileMatrixSet, VectorFormat } from '@basemaps/geo';
2
+ import { GoogleTms, TileMatrixSet, VectorFormat } from '@basemaps/geo';
3
3
  import { fsa, TileDataXyz } from '@basemaps/shared';
4
4
  import { Cotar } from '@cotar/core';
5
5
  import { HttpHeader, LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
@@ -53,6 +53,7 @@ export class TileSetVector {
53
53
 
54
54
  async tile(req: LambdaHttpRequest, xyz: TileDataXyz): Promise<LambdaHttpResponse> {
55
55
  if (xyz.ext !== VectorFormat.MapboxVectorTiles) return NotFound;
56
+ if (xyz.tileMatrix.identifier !== GoogleTms.identifier) return NotFound;
56
57
  if (this.tileSet.layers.length > 1) return new LambdaHttpResponse(500, 'Too many layers in tileset');
57
58
  const [layer] = this.tileSet.layers;
58
59
  if (layer[3857] == null) return new LambdaHttpResponse(500, 'Layer url not found from tileset Config');