@basemaps/lambda-tiler 6.19.0 → 6.20.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 (157) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE +2 -2
  3. package/build/__test__/tile.style.json.test.d.ts +2 -0
  4. package/build/__test__/tile.style.json.test.d.ts.map +1 -0
  5. package/build/__test__/tile.style.json.test.js +33 -0
  6. package/build/__test__/xyz.test.js +24 -23
  7. package/build/cli/dump.js +2 -2
  8. package/build/index.d.ts.map +1 -1
  9. package/build/index.js +2 -0
  10. package/build/routes/esri/rest.d.ts +10 -0
  11. package/build/routes/esri/rest.d.ts.map +1 -0
  12. package/build/routes/esri/rest.js +87 -0
  13. package/build/routes/imagery.d.ts +2 -0
  14. package/build/routes/imagery.d.ts.map +1 -1
  15. package/build/routes/imagery.js +3 -1
  16. package/build/routes/response.d.ts +4 -0
  17. package/build/routes/response.d.ts.map +1 -0
  18. package/build/routes/response.js +3 -0
  19. package/build/routes/tile.d.ts +0 -20
  20. package/build/routes/tile.d.ts.map +1 -1
  21. package/build/routes/tile.js +11 -161
  22. package/build/routes/tile.json.d.ts +10 -0
  23. package/build/routes/tile.json.d.ts.map +1 -0
  24. package/build/routes/tile.json.js +31 -0
  25. package/build/routes/tile.style.json.d.ts +10 -0
  26. package/build/routes/tile.style.json.d.ts.map +1 -0
  27. package/build/routes/tile.style.json.js +74 -0
  28. package/build/routes/tile.wmts.d.ts +9 -0
  29. package/build/routes/tile.wmts.d.ts.map +1 -0
  30. package/build/routes/tile.wmts.js +57 -0
  31. package/build/routes/tile.xyz.d.ts +13 -0
  32. package/build/routes/tile.xyz.d.ts.map +1 -0
  33. package/build/routes/tile.xyz.js +28 -0
  34. package/build/tile.set.raster.d.ts +2 -0
  35. package/build/tile.set.raster.d.ts.map +1 -1
  36. package/build/tile.set.raster.js +3 -1
  37. package/build/tile.set.vector.js +1 -1
  38. package/dist/index.js +10545 -9583
  39. package/dist/node_modules/color/README.md +7 -7
  40. package/dist/node_modules/color/index.js +173 -158
  41. package/dist/node_modules/color/package.json +18 -16
  42. package/dist/node_modules/color-convert/conversions.js +281 -310
  43. package/dist/node_modules/color-convert/index.js +27 -24
  44. package/dist/node_modules/color-convert/package.json +16 -14
  45. package/dist/node_modules/color-convert/route.js +22 -22
  46. package/dist/node_modules/color-name/package.json +17 -14
  47. package/dist/node_modules/color-string/package.json +5 -5
  48. package/dist/node_modules/decompress-response/index.d.ts +14 -21
  49. package/dist/node_modules/decompress-response/index.js +34 -16
  50. package/dist/node_modules/decompress-response/license +1 -1
  51. package/dist/node_modules/decompress-response/package.json +23 -17
  52. package/dist/node_modules/decompress-response/readme.md +2 -6
  53. package/dist/node_modules/detect-libc/package.json +0 -1
  54. package/dist/node_modules/mimic-response/index.d.ts +2 -2
  55. package/dist/node_modules/mimic-response/index.js +41 -2
  56. package/dist/node_modules/mimic-response/package.json +17 -17
  57. package/dist/node_modules/mimic-response/readme.md +22 -1
  58. package/dist/node_modules/node-abi/.circleci/config.yml +63 -0
  59. package/dist/node_modules/node-abi/.releaserc.json +9 -0
  60. package/dist/node_modules/node-abi/abi_registry.json +39 -4
  61. package/dist/node_modules/node-abi/index.js +5 -2
  62. package/dist/node_modules/node-abi/package.json +17 -16
  63. package/dist/node_modules/node-abi/test/index.js +7 -15
  64. package/dist/node_modules/node-addon-api/README.md +2 -2
  65. package/dist/node_modules/node-addon-api/except.gypi +20 -11
  66. package/dist/node_modules/node-addon-api/napi-inl.h +734 -196
  67. package/dist/node_modules/node-addon-api/napi.h +420 -164
  68. package/dist/node_modules/node-addon-api/noexcept.gypi +21 -11
  69. package/dist/node_modules/node-addon-api/package.json +43 -14
  70. package/dist/node_modules/node-addon-api/tools/clang-format.js +18 -17
  71. package/dist/node_modules/node-addon-api/tools/eslint-format.js +71 -0
  72. package/dist/node_modules/prebuild-install/CHANGELOG.md +24 -7
  73. package/dist/node_modules/prebuild-install/README.md +24 -4
  74. package/dist/node_modules/prebuild-install/asset.js +10 -10
  75. package/dist/node_modules/prebuild-install/bin.js +13 -13
  76. package/dist/node_modules/prebuild-install/download.js +22 -22
  77. package/dist/node_modules/prebuild-install/log.js +4 -4
  78. package/dist/node_modules/prebuild-install/node_modules/detect-libc/LICENSE +201 -0
  79. package/dist/node_modules/prebuild-install/node_modules/detect-libc/README.md +160 -0
  80. package/dist/node_modules/prebuild-install/node_modules/detect-libc/index.d.ts +11 -0
  81. package/dist/node_modules/prebuild-install/node_modules/detect-libc/lib/detect-libc.js +178 -0
  82. package/dist/node_modules/prebuild-install/node_modules/detect-libc/lib/process.js +16 -0
  83. package/dist/node_modules/prebuild-install/node_modules/detect-libc/package.json +71 -0
  84. package/dist/node_modules/prebuild-install/package.json +18 -19
  85. package/dist/node_modules/prebuild-install/proxy.js +10 -10
  86. package/dist/node_modules/prebuild-install/rc.js +12 -12
  87. package/dist/node_modules/prebuild-install/util.js +14 -14
  88. package/dist/node_modules/semver/package.json +1 -0
  89. package/dist/node_modules/sharp/README.md +2 -2
  90. package/dist/node_modules/sharp/binding.gyp +12 -9
  91. package/dist/node_modules/sharp/build/Release/sharp-linux-x64.node +0 -0
  92. package/dist/node_modules/sharp/install/dll-copy.js +6 -6
  93. package/dist/node_modules/sharp/install/libvips.js +4 -8
  94. package/dist/node_modules/sharp/lib/channel.js +11 -7
  95. package/dist/node_modules/sharp/lib/colour.js +42 -1
  96. package/dist/node_modules/sharp/lib/constructor.js +18 -31
  97. package/dist/node_modules/sharp/lib/input.js +45 -3
  98. package/dist/node_modules/sharp/lib/is.js +19 -5
  99. package/dist/node_modules/sharp/lib/libvips.js +4 -19
  100. package/dist/node_modules/sharp/lib/operation.js +28 -5
  101. package/dist/node_modules/sharp/lib/output.js +147 -16
  102. package/dist/node_modules/sharp/lib/sharp.js +31 -0
  103. package/dist/node_modules/sharp/lib/utility.js +3 -2
  104. package/dist/node_modules/sharp/package.json +32 -23
  105. package/dist/node_modules/sharp/src/common.cc +67 -11
  106. package/dist/node_modules/sharp/src/common.h +25 -5
  107. package/dist/node_modules/sharp/src/libvips/cplusplus/VConnection.cpp +0 -26
  108. package/dist/node_modules/sharp/src/libvips/cplusplus/VImage.cpp +54 -16
  109. package/dist/node_modules/sharp/src/libvips/cplusplus/VInterpolate.cpp +0 -13
  110. package/dist/node_modules/sharp/src/libvips/cplusplus/vips-operators.cpp +185 -1
  111. package/dist/node_modules/sharp/src/metadata.cc +14 -0
  112. package/dist/node_modules/sharp/src/metadata.h +1 -0
  113. package/dist/node_modules/sharp/src/operations.cc +29 -3
  114. package/dist/node_modules/sharp/src/operations.h +13 -2
  115. package/dist/node_modules/sharp/src/pipeline.cc +103 -35
  116. package/dist/node_modules/sharp/src/pipeline.h +23 -3
  117. package/dist/node_modules/sharp/src/utilities.cc +1 -1
  118. package/dist/node_modules/sharp/vendor/{8.10.6 → 8.11.3/linux-x64}/THIRD-PARTY-NOTICES.md +2 -3
  119. package/dist/node_modules/sharp/vendor/{8.10.6 → 8.11.3/linux-x64}/lib/libvips-cpp.so.42 +0 -0
  120. package/dist/node_modules/sharp/vendor/{8.10.6 → 8.11.3/linux-x64}/platform.json +0 -0
  121. package/dist/node_modules/sharp/vendor/8.11.3/linux-x64/versions.json +30 -0
  122. package/dist/node_modules/simple-get/.github/dependabot.yml +15 -0
  123. package/dist/node_modules/simple-get/.github/workflows/ci.yml +23 -0
  124. package/dist/node_modules/simple-get/README.md +17 -3
  125. package/dist/node_modules/simple-get/index.js +9 -0
  126. package/dist/node_modules/simple-get/package.json +27 -13
  127. package/dist/package-lock.json +51 -51
  128. package/dist/package.json +9 -9
  129. package/package.json +10 -10
  130. package/src/__test__/tile.style.json.test.ts +40 -0
  131. package/src/__test__/xyz.test.ts +32 -30
  132. package/src/cli/dump.ts +2 -2
  133. package/src/index.ts +2 -0
  134. package/src/routes/esri/rest.ts +90 -0
  135. package/src/routes/imagery.ts +3 -1
  136. package/src/routes/response.ts +4 -0
  137. package/src/routes/tile.json.ts +44 -0
  138. package/src/routes/tile.style.json.ts +77 -0
  139. package/src/routes/tile.ts +11 -183
  140. package/src/routes/tile.wmts.ts +59 -0
  141. package/src/routes/tile.xyz.ts +30 -0
  142. package/src/tile.set.raster.ts +4 -1
  143. package/src/tile.set.vector.ts +1 -1
  144. package/tsconfig.tsbuildinfo +1 -1
  145. package/dist/node_modules/color-name/.eslintrc.json +0 -43
  146. package/dist/node_modules/color-name/test.js +0 -7
  147. package/dist/node_modules/node-abi/.travis.yml +0 -17
  148. package/dist/node_modules/node-abi/node_modules/semver/CHANGELOG.md +0 -39
  149. package/dist/node_modules/node-abi/node_modules/semver/LICENSE +0 -15
  150. package/dist/node_modules/node-abi/node_modules/semver/README.md +0 -412
  151. package/dist/node_modules/node-abi/node_modules/semver/bin/semver +0 -160
  152. package/dist/node_modules/node-abi/node_modules/semver/package.json +0 -60
  153. package/dist/node_modules/node-abi/node_modules/semver/range.bnf +0 -16
  154. package/dist/node_modules/node-abi/node_modules/semver/semver.js +0 -1483
  155. package/dist/node_modules/node-addon-api/CHANGELOG.md +0 -722
  156. package/dist/node_modules/sharp/build/Release/sharp.node +0 -0
  157. package/dist/node_modules/sharp/vendor/8.10.6/versions.json +0 -31
package/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [6.20.0](https://github.com/linz/basemaps/compare/v6.19.0...v6.20.0) (2022-02-01)
7
+
8
+
9
+ ### Features
10
+
11
+ * **lambda-tiler:** allow relative sprites and glyphs ([#2071](https://github.com/linz/basemaps/issues/2071)) ([a283157](https://github.com/linz/basemaps/commit/a283157f6b11fd9f6168edd19e9d5624f52d0325))
12
+ * **lambda-tiler:** wip esri vectortileserver interface for vector tiles ([#2041](https://github.com/linz/basemaps/issues/2041)) ([0549d68](https://github.com/linz/basemaps/commit/0549d688ae44c20bd8dce0281988c7ba258fdacb))
13
+
14
+
15
+
16
+
17
+
6
18
  # [6.19.0](https://github.com/linz/basemaps/compare/v6.18.1...v6.19.0) (2021-12-20)
7
19
 
8
20
 
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
- Basemaps MIT Licence
1
+ MIT License
2
2
 
3
- Crown copyright (c) 2020, Land Information New Zealand on behalf of the New Zealand Government.
3
+ Crown copyright (c), Toitū Te Whenua Land Information New Zealand on behalf of the New Zealand Government.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tile.style.json.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tile.style.json.test.d.ts","sourceRoot":"","sources":["../../src/__test__/tile.style.json.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,33 @@
1
+ import { Env } from '@basemaps/shared';
2
+ import o from 'ospec';
3
+ import { convertRelativeUrl } from '../routes/tile.style.json.js';
4
+ o.spec('TileStyleJson', () => {
5
+ const host = 'https://tiles.test';
6
+ let originalHost;
7
+ o.beforeEach(() => {
8
+ originalHost = process.env[Env.PublicUrlBase];
9
+ process.env[Env.PublicUrlBase] = host;
10
+ });
11
+ o.afterEach(() => {
12
+ process.env[Env.PublicUrlBase] = originalHost;
13
+ });
14
+ o('should not convert empty urls', () => {
15
+ o(convertRelativeUrl()).equals('');
16
+ o(convertRelativeUrl('')).equals('');
17
+ o(convertRelativeUrl(undefined)).equals('');
18
+ });
19
+ o('should only convert relative urls', () => {
20
+ o(convertRelativeUrl('/foo')).equals('https://tiles.test/foo');
21
+ o(convertRelativeUrl('/bar/baz/')).equals('https://tiles.test/bar/baz/');
22
+ });
23
+ o('should only convert with api keys', () => {
24
+ o(convertRelativeUrl('/foo', 'abc')).equals('https://tiles.test/foo?api=abc');
25
+ o(convertRelativeUrl('/bar/baz/', 'abc')).equals('https://tiles.test/bar/baz/?api=abc');
26
+ });
27
+ o('should convert with other query params', () => {
28
+ o(convertRelativeUrl('/foo?bar=baz', 'abc')).equals('https://tiles.test/foo?bar=baz&api=abc');
29
+ });
30
+ o('should not convert full urls', () => {
31
+ o(convertRelativeUrl('https://foo.com/foo?bar=baz', 'abc')).equals('https://foo.com/foo?bar=baz');
32
+ });
33
+ });
@@ -2,16 +2,18 @@ import { TileMatrixSets } from '@basemaps/geo';
2
2
  import { Config, Env, LogConfig, VNodeParser } from '@basemaps/shared';
3
3
  import { round } from '@basemaps/test/build/rounding.js';
4
4
  import o from 'ospec';
5
+ import sinon from 'sinon';
5
6
  import { handleRequest } from '../index.js';
6
- import { TileComposer } from '../routes/tile.js';
7
7
  import { TileEtag } from '../routes/tile.etag.js';
8
8
  import { TileSets } from '../tile.set.cache.js';
9
+ import { TileComposer } from '../tile.set.raster.js';
9
10
  import { FakeTileSet, mockRequest, Provider } from './xyz.util.js';
10
- import sinon from 'sinon';
11
11
  const sandbox = sinon.createSandbox();
12
12
  const TileSetNames = ['aerial', 'aerial@head', 'aerial@beta', '01E7PJFR9AMQFJ05X9G7FQ3XMW'];
13
13
  /* eslint-disable @typescript-eslint/explicit-function-return-type */
14
14
  o.spec('LambdaXyz', () => {
15
+ const host = 'https://tiles.test';
16
+ const origPublicUrlBase = process.env[Env.PublicUrlBase];
15
17
  /** Generate mock ALBEvent */
16
18
  let rasterMock = o.spy();
17
19
  const generateMock = o.spy(() => 'foo');
@@ -21,6 +23,7 @@ o.spec('LambdaXyz', () => {
21
23
  const apiKey = 'd01f7w7rnhdzg0p7fyrc9v9ard1';
22
24
  const apiKeyHeader = { 'x-linz-api-key': 'd01f7w7rnhdzg0p7fyrc9v9ard1' };
23
25
  o.beforeEach(() => {
26
+ process.env[Env.PublicUrlBase] = host;
24
27
  LogConfig.disable();
25
28
  // tileMock = o.spy(() => tileMockData) as any;
26
29
  rasterMock = o.spy(() => {
@@ -45,6 +48,7 @@ o.spec('LambdaXyz', () => {
45
48
  TileSets.cache.clear();
46
49
  TileComposer.compose = origCompose;
47
50
  TileEtag.generate = origTileEtag;
51
+ process.env[Env.PublicUrlBase] = origPublicUrlBase;
48
52
  sandbox.restore();
49
53
  });
50
54
  o('should export handler', async () => {
@@ -115,11 +119,8 @@ o.spec('LambdaXyz', () => {
115
119
  }
116
120
  });
117
121
  o.spec('WMTSCapabilities', () => {
118
- const origPublicUrlBase = process.env[Env.PublicUrlBase];
119
- o.after(() => {
120
- process.env[Env.PublicUrlBase] = origPublicUrlBase;
121
- });
122
122
  o('should 304 if a xml is not modified', async () => {
123
+ delete process.env[Env.PublicUrlBase];
123
124
  o.timeout(1000);
124
125
  const key = 'NuirTK8fozzCJV1iG1FznmdHhKvk6WaWuDhhEA1d40c=';
125
126
  const request = mockRequest('/v1/tiles/WMTSCapabilities.xml', 'get', {
@@ -137,8 +138,6 @@ o.spec('LambdaXyz', () => {
137
138
  });
138
139
  o('should serve WMTSCapabilities for tile_set', async () => {
139
140
  var _a;
140
- console.log('\n\nTestStart');
141
- process.env[Env.PublicUrlBase] = 'https://tiles.test';
142
141
  const request = mockRequest('/v1/tiles/aerial@beta/WMTSCapabilities.xml', 'get', apiKeyHeader);
143
142
  const res = await handleRequest(request);
144
143
  o(res.status).equals(200);
@@ -153,12 +152,9 @@ o.spec('LambdaXyz', () => {
153
152
  });
154
153
  });
155
154
  o.spec('tileJson', () => {
156
- const origPublicUrlBase = process.env[Env.PublicUrlBase];
157
- o.after(() => {
158
- process.env[Env.PublicUrlBase] = origPublicUrlBase;
159
- });
160
155
  o('should 304 if a json is not modified', async () => {
161
- const key = 'XecTdbcdjCyzB1MHOOQbrOkD2TTJ0ORh4JuXqhxXEE0=';
156
+ // delete process.env[Env.PublicUrlBase];
157
+ const key = 'BBfQpNXA3Q90jlFrLSOZhxbvfOh7OpN1OEE+BylpbHw=';
162
158
  const request = mockRequest('/v1/tiles/tile.json', 'get', { 'if-none-match': key, ...apiKeyHeader });
163
159
  const res = await handleRequest(request);
164
160
  if (res.status === 200) {
@@ -169,9 +165,19 @@ o.spec('LambdaXyz', () => {
169
165
  o(rasterMock.calls.length).equals(0);
170
166
  o(request.logContext['cache']).deepEquals({ key, match: key, hit: true });
171
167
  });
168
+ o('should 200 if a invalid etag is given', async () => {
169
+ var _a;
170
+ const key = 'ABCXecTdbcdjCyzB1MHOOQbrOkD2TTJ0ORh4JuXqhxXEE0=';
171
+ const request = mockRequest('/v1/tiles/tile.json', 'get', { 'if-none-match': key, ...apiKeyHeader });
172
+ const res = await handleRequest(request);
173
+ o(res.status).equals(200);
174
+ o(res.header('etag')).equals('BBfQpNXA3Q90jlFrLSOZhxbvfOh7OpN1OEE+BylpbHw=');
175
+ const out = JSON.parse(Buffer.from((_a = res.body) !== null && _a !== void 0 ? _a : '', 'base64').toString());
176
+ o(out.tiles[0].startsWith('https://tiles.test/v1/tiles/tile.json/undefined/{z}/{x}/{y}.pbf?api=')).equals(true);
177
+ o(request.logContext['cache']).deepEquals(undefined);
178
+ });
172
179
  o('should serve tile json for tile_set', async () => {
173
180
  var _a;
174
- process.env[Env.PublicUrlBase] = 'https://tiles.test';
175
181
  const request = mockRequest('/v1/tiles/topographic/Google/tile.json', 'get', apiKeyHeader);
176
182
  const res = await handleRequest(request);
177
183
  o(res.status).equals(200);
@@ -188,12 +194,7 @@ o.spec('LambdaXyz', () => {
188
194
  });
189
195
  });
190
196
  o.spec('styleJson', () => {
191
- const origPublicUrlBase = process.env[Env.PublicUrlBase];
192
- o.after(() => {
193
- process.env[Env.PublicUrlBase] = origPublicUrlBase;
194
- });
195
197
  o('should not found style json', async () => {
196
- process.env[Env.PublicUrlBase] = 'https://tiles.test';
197
198
  const request = mockRequest('/v1/tiles/topographic/Google/style/topographic.json', 'get', apiKeyHeader);
198
199
  sandbox.stub(Config.Style, 'get').resolves(null);
199
200
  const res = await handleRequest(request);
@@ -201,8 +202,6 @@ o.spec('LambdaXyz', () => {
201
202
  });
202
203
  o('should serve style json', async () => {
203
204
  var _a;
204
- const host = 'https://tiles.test';
205
- process.env[Env.PublicUrlBase] = host;
206
205
  const request = mockRequest('/v1/tiles/topographic/Google/style/topographic.json', 'get', apiKeyHeader);
207
206
  const fakeStyle = {
208
207
  version: 8,
@@ -243,8 +242,8 @@ o.spec('LambdaXyz', () => {
243
242
  minzoom: 0,
244
243
  },
245
244
  ],
246
- glyphs: 'glyphs',
247
- sprite: 'sprite',
245
+ glyphs: '/glyphs',
246
+ sprite: '/sprite',
248
247
  metadata: { id: 'test' },
249
248
  };
250
249
  const fakeRecord = {
@@ -270,6 +269,8 @@ o.spec('LambdaXyz', () => {
270
269
  type: 'raster',
271
270
  tiles: [`${host}/raster/{z}/{x}/{y}.webp?api=${apiKey}`],
272
271
  };
272
+ fakeStyle.sprite = `${host}/sprite`;
273
+ fakeStyle.glyphs = `${host}/glyphs`;
273
274
  o(JSON.parse(body)).deepEquals(fakeStyle);
274
275
  });
275
276
  });
package/build/cli/dump.js CHANGED
@@ -3,7 +3,7 @@ import { LogConfig } from '@basemaps/shared';
3
3
  import { ImageFormat } from '@basemaps/tiler';
4
4
  import { LambdaAlbRequest } from '@linzjs/lambda';
5
5
  import { promises as fs } from 'fs';
6
- import { TileRoute } from '../routes/tile.js';
6
+ import { tileXyz } from '../routes/tile.xyz.js';
7
7
  import { TileSets } from '../tile.set.cache.js';
8
8
  import { TileSetLocal } from './tile.set.local.js';
9
9
  const xyz = { x: 0, y: 0, z: 0 };
@@ -36,7 +36,7 @@ async function main() {
36
36
  httpMethod: 'get',
37
37
  path: `/v1/tiles/${tileSet.fullName}/${tileMatrix.identifier}/${xyz.z}/${xyz.x}/${xyz.y}.${ext}`,
38
38
  }, {}, logger);
39
- const tileData = await TileRoute.tile(ctx);
39
+ const tileData = await tileXyz(ctx);
40
40
  const headers = {};
41
41
  for (const [key, value] of tileData.headers)
42
42
  headers[key] = value;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAkB3E,wBAAsB,aAAa,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAkBvF;AAED,eAAO,MAAM,OAAO,2LAA0C,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAoB3E,wBAAsB,aAAa,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAkBvF;AAED,eAAO,MAAM,OAAO,2LAA0C,CAAC"}
package/build/index.js CHANGED
@@ -6,12 +6,14 @@ import { Tiles } from './routes/tile.js';
6
6
  import { Router } from './router.js';
7
7
  import { createHash } from 'crypto';
8
8
  import { Imagery } from './routes/imagery.js';
9
+ import { Esri } from './routes/esri/rest.js';
9
10
  const app = new Router();
10
11
  app.get('ping', Ping);
11
12
  app.get('health', Health);
12
13
  app.get('version', Version);
13
14
  app.get('tiles', Tiles);
14
15
  app.get('imagery', Imagery);
16
+ app.get('esri', Esri);
15
17
  let slowTimer = null;
16
18
  export async function handleRequest(req) {
17
19
  // Warn if a request takes more than 10 seconds to process
@@ -0,0 +1,10 @@
1
+ import { TileMatrixSet } from '@basemaps/geo';
2
+ import { LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
3
+ export declare function vectorTileServer(req: LambdaHttpRequest, layerId: string, tms: TileMatrixSet): Promise<LambdaHttpResponse>;
4
+ /**
5
+ * /v1/esri/services/:layerId/VectorTileServer
6
+ *
7
+ * @example http://localhost:5000/v1/esri/services/topographic/VectorTileServer
8
+ */
9
+ export declare function Esri(req: LambdaHttpRequest): Promise<LambdaHttpResponse>;
10
+ //# sourceMappingURL=rest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rest.d.ts","sourceRoot":"","sources":["../../../src/routes/esri/rest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,aAAa,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAKvE,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,iBAAiB,EACtB,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,aAAa,GACjB,OAAO,CAAC,kBAAkB,CAAC,CAiD7B;AAED;;;;GAIG;AACH,wBAAsB,IAAI,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAsB9E"}
@@ -0,0 +1,87 @@
1
+ import { GoogleTms } from '@basemaps/geo';
2
+ import { tileXyzFromPath } from '@basemaps/shared';
3
+ import { LambdaHttpResponse } from '@linzjs/lambda';
4
+ import { Router } from '../../router.js';
5
+ import { TileSets } from '../../tile.set.cache.js';
6
+ import { NotFound } from '../response.js';
7
+ export async function vectorTileServer(req, layerId, tms) {
8
+ if (tms.identifier !== GoogleTms.identifier)
9
+ return NotFound;
10
+ const extent = {
11
+ xmin: tms.extent.x,
12
+ ymin: tms.extent.y,
13
+ xmax: tms.extent.right,
14
+ ymax: tms.extent.bottom,
15
+ // TODO where is wkid from
16
+ spatialReference: { wkid: 102100, latestWkid: tms.projection.code },
17
+ };
18
+ const res = new LambdaHttpResponse(200, 'ok');
19
+ res.json({
20
+ currentVersion: 10.4,
21
+ name: layerId,
22
+ capabilities: 'TilesOnly',
23
+ type: 'indexedVector',
24
+ tileMap: 'tilemap',
25
+ defaultStyles: 'resources/styles',
26
+ tiles: ['tiles/{z}/{x}/{y}.pbf'],
27
+ exportTilesAllowed: false,
28
+ maxExportTilesCount: 0,
29
+ initialExtent: extent,
30
+ fullExtent: extent,
31
+ minScale: tms.zooms[0].scaleDenominator,
32
+ maxScale: tms.zooms[tms.zooms.length - 1].scaleDenominator,
33
+ tileInfo: {
34
+ // TODO are all the pbf 256x256?
35
+ rows: 256,
36
+ cols: 256,
37
+ dpi: 96,
38
+ format: 'pbf',
39
+ origin: { x: tms.extent.x, y: tms.extent.bottom },
40
+ spatialReference: { wkid: 102100, latestWkid: tms.projection.code },
41
+ lods: tms.zooms.map((c, i) => {
42
+ return {
43
+ level: i,
44
+ scale: c.scaleDenominator,
45
+ resolution: c.scaleDenominator * 0.28e-3,
46
+ };
47
+ }),
48
+ },
49
+ resourceInfo: {
50
+ styleVersion: 8,
51
+ tileCompression: 'gzip',
52
+ cacheInfo: { storageInfo: { packetSize: 128, storageFormat: 'compactV2' } },
53
+ },
54
+ });
55
+ return res;
56
+ }
57
+ /**
58
+ * /v1/esri/services/:layerId/VectorTileServer
59
+ *
60
+ * @example http://localhost:5000/v1/esri/services/topographic/VectorTileServer
61
+ */
62
+ export async function Esri(req) {
63
+ const { rest } = Router.action(req);
64
+ if (rest[0] !== 'services')
65
+ return NotFound;
66
+ const layerId = rest[1];
67
+ if (layerId == null)
68
+ return NotFound;
69
+ const serviceId = rest[2];
70
+ if (serviceId !== 'VectorTileServer')
71
+ return NotFound;
72
+ if (rest.length === 3)
73
+ return vectorTileServer(req, layerId, GoogleTms);
74
+ if (rest[rest.length - 1].endsWith('.pbf')) {
75
+ const generatedPath = [layerId, GoogleTms.identifier, ...rest.slice(rest.length - 3)];
76
+ const xyz = tileXyzFromPath(generatedPath);
77
+ if (xyz == null)
78
+ return NotFound;
79
+ req.timer.start('tileset:load');
80
+ const tileSet = await TileSets.get(xyz.name, xyz.tileMatrix);
81
+ req.timer.end('tileset:load');
82
+ if (tileSet == null)
83
+ return NotFound;
84
+ return await tileSet.tile(req, xyz);
85
+ }
86
+ return new LambdaHttpResponse(200, 'ok');
87
+ }
@@ -1,6 +1,8 @@
1
1
  import { LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
2
2
  /**
3
3
  * Get metadata around the imagery such as the source bounding box or the bounding box of the COGS
4
+ *
5
+ * @example
4
6
  * - /v1/imagery/:imageryId/source.geojson
5
7
  * - /v1/imagery/:imageryId/covering.geojson
6
8
  */
@@ -1 +1 @@
1
- {"version":3,"file":"imagery.d.ts","sourceRoot":"","sources":["../../src/routes/imagery.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAgBnF;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA0BjF"}
1
+ {"version":3,"file":"imagery.d.ts","sourceRoot":"","sources":["../../src/routes/imagery.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAgBnF;;;;;;GAMG;AACH,wBAAsB,OAAO,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA0BjF"}
@@ -5,8 +5,8 @@ import { createHash } from 'crypto';
5
5
  import { promisify } from 'util';
6
6
  import { gzip } from 'zlib';
7
7
  import { Router } from '../router.js';
8
+ import { NotModified } from './response.js';
8
9
  import { TileEtag } from './tile.etag.js';
9
- import { NotModified } from './tile.js';
10
10
  const gzipP = promisify(gzip);
11
11
  function isAllowedFile(f) {
12
12
  if (f.endsWith('.geojson'))
@@ -17,6 +17,8 @@ function isAllowedFile(f) {
17
17
  }
18
18
  /**
19
19
  * Get metadata around the imagery such as the source bounding box or the bounding box of the COGS
20
+ *
21
+ * @example
20
22
  * - /v1/imagery/:imageryId/source.geojson
21
23
  * - /v1/imagery/:imageryId/covering.geojson
22
24
  */
@@ -0,0 +1,4 @@
1
+ import { LambdaHttpResponse } from '@linzjs/lambda';
2
+ export declare const NotFound: LambdaHttpResponse;
3
+ export declare const NotModified: LambdaHttpResponse;
4
+ //# sourceMappingURL=response.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/routes/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,eAAO,MAAM,QAAQ,oBAA2C,CAAC;AACjE,eAAO,MAAM,WAAW,oBAA8C,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { LambdaHttpResponse } from '@linzjs/lambda';
2
+ export const NotFound = new LambdaHttpResponse(404, 'Not Found');
3
+ export const NotModified = new LambdaHttpResponse(304, 'Not modified');
@@ -1,23 +1,3 @@
1
- import { TileMatrixSet } from '@basemaps/geo';
2
1
  import { LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
3
- import { TileMakerSharp } from '@basemaps/tiler-sharp';
4
- import { TileSetRaster } from '../tile.set.raster.js';
5
- export declare const TileComposer: TileMakerSharp;
6
- export declare const NotFound: LambdaHttpResponse;
7
- export declare const NotModified: LambdaHttpResponse;
8
- export interface TileJson {
9
- tiles: string[];
10
- minzoom: number;
11
- maxzoom: number;
12
- format: string;
13
- tilejson: string;
14
- }
15
- export declare const TileRoute: {
16
- tile(req: LambdaHttpRequest): Promise<LambdaHttpResponse>;
17
- wmtsLoadTileSets(name: string, tileMatrix: TileMatrixSet | null): Promise<TileSetRaster[]>;
18
- wmts(req: LambdaHttpRequest): Promise<LambdaHttpResponse>;
19
- tileJson(req: LambdaHttpRequest): Promise<LambdaHttpResponse>;
20
- styleJson(req: LambdaHttpRequest, fileName: string): Promise<LambdaHttpResponse>;
21
- };
22
2
  export declare function Tiles(req: LambdaHttpRequest): Promise<LambdaHttpResponse>;
23
3
  //# sourceMappingURL=tile.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tile.d.ts","sourceRoot":"","sources":["../../src/routes/tile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAc,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEnF,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAIvD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAStD,eAAO,MAAM,YAAY,gBAA0B,CAAC;AAEpD,eAAO,MAAM,QAAQ,oBAA2C,CAAC;AACjE,eAAO,MAAM,WAAW,oBAA8C,CAAC;AAEvE,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,eAAO,MAAM,SAAS;cACJ,iBAAiB,GAAG,QAAQ,kBAAkB,CAAC;2BAelC,MAAM,cAAc,aAAa,GAAG,IAAI,GAAG,QAAQ,aAAa,EAAE,CAAC;cAUhF,iBAAiB,GAAG,QAAQ,kBAAkB,CAAC;kBAiC3C,iBAAiB,GAAG,QAAQ,kBAAkB,CAAC;mBA8B9C,iBAAiB,YAAY,MAAM,GAAG,QAAQ,kBAAkB,CAAC;CA8DvF,CAAC;AACF,wBAAsB,KAAK,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAY/E"}
1
+ {"version":3,"file":"tile.d.ts","sourceRoot":"","sources":["../../src/routes/tile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAUvE,wBAAsB,KAAK,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAY/E"}
@@ -1,162 +1,12 @@
1
- import { HttpHeader, LambdaHttpResponse } from '@linzjs/lambda';
2
- import { Config, Env, setNameAndProjection, TileSetName, tileWmtsFromPath, tileXyzFromPath } from '@basemaps/shared';
3
- import { TileMakerSharp } from '@basemaps/tiler-sharp';
4
- import { createHash } from 'crypto';
1
+ import { LambdaHttpResponse } from '@linzjs/lambda';
5
2
  import { isValidApiKey } from '../api.key.js';
6
- import { TileSets } from '../tile.set.cache.js';
7
- import { WmtsCapabilities } from '../wmts.capability.js';
8
- import { attribution } from './attribution.js';
9
- import { TileEtag } from './tile.etag.js';
10
3
  import { Router } from '../router.js';
11
- import { ValidateTilePath } from '../validate.js';
12
- import { URL } from 'url';
13
- import { fsa } from '@chunkd/fs';
14
- export const TileComposer = new TileMakerSharp(256);
15
- export const NotFound = new LambdaHttpResponse(404, 'Not Found');
16
- export const NotModified = new LambdaHttpResponse(304, 'Not modified');
17
- export const TileRoute = {
18
- async tile(req) {
19
- const action = Router.action(req);
20
- const xyzData = tileXyzFromPath(action.rest);
21
- if (xyzData == null)
22
- return NotFound;
23
- ValidateTilePath.validate(req, xyzData);
24
- req.timer.start('tileset:load');
25
- const tileSet = await TileSets.get(xyzData.name, xyzData.tileMatrix);
26
- req.timer.end('tileset:load');
27
- if (tileSet == null)
28
- return NotFound;
29
- const res = await tileSet.tile(req, xyzData);
30
- return res;
31
- },
32
- async wmtsLoadTileSets(name, tileMatrix) {
33
- if (tileMatrix != null) {
34
- const ts = await TileSets.get(name, tileMatrix);
35
- if (ts == null || ts.isVector())
36
- return [];
37
- return [ts];
38
- }
39
- if (name === '')
40
- name = TileSetName.aerial;
41
- return (await TileSets.getAll(name, tileMatrix)).filter((f) => f.type === 'raster');
42
- },
43
- async wmts(req) {
44
- var _a;
45
- const action = Router.action(req);
46
- const wmtsData = tileWmtsFromPath(action.rest);
47
- if (wmtsData == null)
48
- return NotFound;
49
- setNameAndProjection(req, wmtsData);
50
- const host = (_a = Env.get(Env.PublicUrlBase)) !== null && _a !== void 0 ? _a : '';
51
- req.timer.start('tileset:load');
52
- const tileSets = await TileRoute.wmtsLoadTileSets(wmtsData.name, wmtsData.tileMatrix);
53
- req.timer.end('tileset:load');
54
- if (tileSets.length === 0)
55
- return NotFound;
56
- const providerId = Config.Provider.id('linz');
57
- const provider = await Config.Provider.get(providerId);
58
- if (provider == null)
59
- return NotFound;
60
- const apiKey = Router.apiKey(req);
61
- const xml = WmtsCapabilities.toXml(host, provider, tileSets, apiKey);
62
- if (xml == null)
63
- return NotFound;
64
- const data = Buffer.from(xml);
65
- const cacheKey = createHash('sha256').update(data).digest('base64');
66
- if (TileEtag.isNotModified(req, cacheKey))
67
- return NotModified;
68
- const response = new LambdaHttpResponse(200, 'ok');
69
- response.header(HttpHeader.ETag, cacheKey);
70
- response.header(HttpHeader.CacheControl, 'max-age=0');
71
- response.buffer(data, 'text/xml');
72
- req.set('bytes', data.byteLength);
73
- return response;
74
- },
75
- async tileJson(req) {
76
- var _a;
77
- const { version, rest, name } = Router.action(req);
78
- const apiKey = Router.apiKey(req);
79
- const host = (_a = Env.get(Env.PublicUrlBase)) !== null && _a !== void 0 ? _a : '';
80
- const tileUrl = `${host}/${version}/${name}/${rest[0]}/${rest[1]}/{z}/{x}/{y}.pbf?api=${apiKey}`;
81
- const tileJson = {
82
- tiles: [tileUrl],
83
- minzoom: 0,
84
- maxzoom: 15,
85
- format: 'pbf',
86
- tilejson: '2.0.0',
87
- };
88
- const json = JSON.stringify(tileJson);
89
- const data = Buffer.from(json);
90
- const cacheKey = createHash('sha256').update(data).digest('base64');
91
- if (TileEtag.isNotModified(req, cacheKey))
92
- return NotModified;
93
- const response = new LambdaHttpResponse(200, 'ok');
94
- response.header(HttpHeader.ETag, cacheKey);
95
- response.header(HttpHeader.CacheControl, 'max-age=120');
96
- response.buffer(data, 'application/json');
97
- req.set('bytes', data.byteLength);
98
- return response;
99
- },
100
- async styleJson(req, fileName) {
101
- var _a;
102
- const apiKey = Router.apiKey(req);
103
- if (apiKey == null)
104
- return new LambdaHttpResponse(400, 'Invalid API Key.');
105
- const styleName = fileName.split('.json')[0];
106
- const host = (_a = Env.get(Env.PublicUrlBase)) !== null && _a !== void 0 ? _a : '';
107
- // Get style Config from db
108
- const dbId = Config.Style.id(styleName);
109
- const styleConfig = await Config.Style.get(dbId);
110
- if (styleConfig == null)
111
- return NotFound;
112
- // Prepare sources and add linz source
113
- const style = styleConfig.style;
114
- const sources = {};
115
- for (const [key, value] of Object.entries(style.sources)) {
116
- if (value.type === 'vector') {
117
- if (value.url.startsWith('/')) {
118
- const url = new URL(fsa.join(host, value.url));
119
- url.searchParams.set('api', apiKey);
120
- value.url = url.toString().replace(/%7B/g, '{').replace(/%7D/g, '}');
121
- }
122
- }
123
- else if (value.type === 'raster' && Array.isArray(value.tiles)) {
124
- for (let i = 0; i < value.tiles.length; i++) {
125
- const tile = value.tiles[i];
126
- if (tile.startsWith('/')) {
127
- const url = new URL(fsa.join(host, tile));
128
- url.searchParams.set('api', apiKey);
129
- value.tiles[i] = url.toString().replace(/%7B/g, '{').replace(/%7D/g, '}');
130
- }
131
- }
132
- }
133
- sources[key] = value;
134
- }
135
- // prepare Style.json
136
- const styleJson = {
137
- /** Style.json version 8 */
138
- version: 8,
139
- id: style.id,
140
- name: style.name,
141
- sources,
142
- layers: style.layers,
143
- metadata: style.metadata || {},
144
- glyphs: style.glyphs || '',
145
- sprite: style.sprite || '',
146
- };
147
- const json = JSON.stringify(styleJson);
148
- const data = Buffer.from(json);
149
- const cacheKey = createHash('sha256').update(data).digest('base64');
150
- if (TileEtag.isNotModified(req, cacheKey))
151
- return NotModified;
152
- const response = new LambdaHttpResponse(200, 'ok');
153
- response.header(HttpHeader.ETag, cacheKey);
154
- response.header(HttpHeader.CacheControl, 'no-store');
155
- response.buffer(data, 'application/json');
156
- req.set('bytes', data.byteLength);
157
- return response;
158
- },
159
- };
4
+ import { attribution } from './attribution.js';
5
+ import { NotFound } from './response.js';
6
+ import { tileJson } from './tile.json.js';
7
+ import { styleJson } from './tile.style.json.js';
8
+ import { wmts } from './tile.wmts.js';
9
+ import { tileXyz } from './tile.xyz.js';
160
10
  export async function Tiles(req) {
161
11
  const { rest } = Router.action(req);
162
12
  if (rest.length < 1)
@@ -168,10 +18,10 @@ export async function Tiles(req) {
168
18
  if (fileName === 'attribution.json')
169
19
  return attribution(req);
170
20
  if (fileName === 'wmtscapabilities.xml')
171
- return TileRoute.wmts(req);
21
+ return wmts(req);
172
22
  if (fileName === 'tile.json')
173
- return TileRoute.tileJson(req);
23
+ return tileJson(req);
174
24
  if (fileName.endsWith('json') && rest[rest.length - 2] === 'style')
175
- return TileRoute.styleJson(req, fileName);
176
- return TileRoute.tile(req);
25
+ return styleJson(req, fileName);
26
+ return tileXyz(req);
177
27
  }
@@ -0,0 +1,10 @@
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
+ export declare function tileJson(req: LambdaHttpRequest): Promise<LambdaHttpResponse>;
10
+ //# sourceMappingURL=tile.json.d.ts.map
@@ -0,0 +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"}