@basemaps/lambda-tiler 7.0.0 → 7.1.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 (242) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/build/__tests__/config.data.d.ts +0 -1
  3. package/build/__tests__/config.data.js +2 -6
  4. package/build/__tests__/config.data.js.map +1 -1
  5. package/build/__tests__/index.test.d.ts +0 -1
  6. package/build/__tests__/index.test.js +28 -27
  7. package/build/__tests__/index.test.js.map +1 -1
  8. package/build/__tests__/tile.style.json.test.d.ts +0 -1
  9. package/build/__tests__/tile.style.json.test.js +38 -37
  10. package/build/__tests__/tile.style.json.test.js.map +1 -1
  11. package/build/__tests__/wmts.capability.test.d.ts +0 -1
  12. package/build/__tests__/wmts.capability.test.js +111 -122
  13. package/build/__tests__/wmts.capability.test.js.map +1 -1
  14. package/build/__tests__/xyz.util.d.ts +0 -1
  15. package/build/cli/render.preview.d.ts +0 -1
  16. package/build/cli/render.preview.js +13 -9
  17. package/build/cli/render.preview.js.map +1 -1
  18. package/build/cli/render.tile.d.ts +0 -1
  19. package/build/cli/render.tile.js +25 -17
  20. package/build/cli/render.tile.js.map +1 -1
  21. package/build/index.d.ts +0 -1
  22. package/build/index.js +24 -20
  23. package/build/index.js.map +1 -1
  24. package/build/routes/__tests__/attribution.test.d.ts +0 -1
  25. package/build/routes/__tests__/attribution.test.js +38 -37
  26. package/build/routes/__tests__/attribution.test.js.map +1 -1
  27. package/build/routes/__tests__/fonts.test.d.ts +0 -1
  28. package/build/routes/__tests__/fonts.test.js +61 -63
  29. package/build/routes/__tests__/fonts.test.js.map +1 -1
  30. package/build/routes/__tests__/health.test.d.ts +0 -1
  31. package/build/routes/__tests__/health.test.js +16 -16
  32. package/build/routes/__tests__/health.test.js.map +1 -1
  33. package/build/routes/__tests__/imagery.test.d.ts +0 -1
  34. package/build/routes/__tests__/imagery.test.js +10 -9
  35. package/build/routes/__tests__/imagery.test.js.map +1 -1
  36. package/build/routes/__tests__/memory.fs.d.ts +2 -3
  37. package/build/routes/__tests__/preview.index.test.d.ts +0 -1
  38. package/build/routes/__tests__/preview.index.test.js +88 -42
  39. package/build/routes/__tests__/preview.index.test.js.map +1 -1
  40. package/build/routes/__tests__/sprites.test.d.ts +0 -1
  41. package/build/routes/__tests__/sprites.test.js +34 -34
  42. package/build/routes/__tests__/sprites.test.js.map +1 -1
  43. package/build/routes/__tests__/tile.json.test.d.ts +0 -1
  44. package/build/routes/__tests__/tile.json.test.js +45 -51
  45. package/build/routes/__tests__/tile.json.test.js.map +1 -1
  46. package/build/routes/__tests__/tile.style.json.test.d.ts +0 -1
  47. package/build/routes/__tests__/tile.style.json.test.js +49 -50
  48. package/build/routes/__tests__/tile.style.json.test.js.map +1 -1
  49. package/build/routes/__tests__/wmts.test.d.ts +0 -1
  50. package/build/routes/__tests__/wmts.test.js +27 -20
  51. package/build/routes/__tests__/wmts.test.js.map +1 -1
  52. package/build/routes/__tests__/xyz.test.d.ts +0 -1
  53. package/build/routes/__tests__/xyz.test.js +97 -49
  54. package/build/routes/__tests__/xyz.test.js.map +1 -1
  55. package/build/routes/attribution.d.ts +1 -1
  56. package/build/routes/attribution.js +4 -5
  57. package/build/routes/attribution.js.map +1 -1
  58. package/build/routes/config.d.ts +0 -1
  59. package/build/routes/config.js +1 -2
  60. package/build/routes/config.js.map +1 -1
  61. package/build/routes/fonts.d.ts +0 -1
  62. package/build/routes/fonts.js +2 -3
  63. package/build/routes/fonts.js.map +1 -1
  64. package/build/routes/health.d.ts +1 -2
  65. package/build/routes/health.js +5 -15
  66. package/build/routes/health.js.map +1 -1
  67. package/build/routes/imagery.d.ts +0 -1
  68. package/build/routes/imagery.js +1 -1
  69. package/build/routes/imagery.js.map +1 -1
  70. package/build/routes/ping.d.ts +0 -1
  71. package/build/routes/ping.js +1 -1
  72. package/build/routes/ping.js.map +1 -1
  73. package/build/routes/preview.d.ts +6 -5
  74. package/build/routes/preview.index.d.ts +0 -1
  75. package/build/routes/preview.index.js +6 -5
  76. package/build/routes/preview.index.js.map +1 -1
  77. package/build/routes/preview.js +35 -10
  78. package/build/routes/preview.js.map +1 -1
  79. package/build/routes/sprites.d.ts +0 -1
  80. package/build/routes/sprites.js +2 -4
  81. package/build/routes/sprites.js.map +1 -1
  82. package/build/routes/tile.json.d.ts +0 -1
  83. package/build/routes/tile.json.js +10 -5
  84. package/build/routes/tile.json.js.map +1 -1
  85. package/build/routes/tile.style.json.d.ts +1 -1
  86. package/build/routes/tile.style.json.js +79 -16
  87. package/build/routes/tile.style.json.js.map +1 -1
  88. package/build/routes/tile.wmts.d.ts +0 -1
  89. package/build/routes/tile.wmts.js +8 -9
  90. package/build/routes/tile.wmts.js.map +1 -1
  91. package/build/routes/tile.xyz.d.ts +0 -1
  92. package/build/routes/tile.xyz.js.map +1 -1
  93. package/build/routes/tile.xyz.raster.d.ts +7 -8
  94. package/build/routes/tile.xyz.raster.js +17 -13
  95. package/build/routes/tile.xyz.raster.js.map +1 -1
  96. package/build/routes/tile.xyz.vector.d.ts +0 -1
  97. package/build/routes/tile.xyz.vector.js +4 -3
  98. package/build/routes/tile.xyz.vector.js.map +1 -1
  99. package/build/routes/version.d.ts +0 -1
  100. package/build/routes/version.js +3 -4
  101. package/build/routes/version.js.map +1 -1
  102. package/build/util/__test__/config.loader.test.d.ts +0 -1
  103. package/build/util/__test__/config.loader.test.js +35 -34
  104. package/build/util/__test__/config.loader.test.js.map +1 -1
  105. package/build/util/__test__/filter.test.d.ts +0 -1
  106. package/build/util/__test__/filter.test.js +17 -16
  107. package/build/util/__test__/filter.test.js.map +1 -1
  108. package/build/util/__test__/validate.test.d.ts +0 -1
  109. package/build/util/__test__/validate.test.js +26 -43
  110. package/build/util/__test__/validate.test.js.map +1 -1
  111. package/build/util/assets.provider.d.ts +5 -5
  112. package/build/util/assets.provider.js +8 -8
  113. package/build/util/assets.provider.js.map +1 -1
  114. package/build/util/config.cache.d.ts +2 -2
  115. package/build/util/config.cache.js +14 -3
  116. package/build/util/config.cache.js.map +1 -1
  117. package/build/util/config.loader.d.ts +0 -1
  118. package/build/util/config.loader.js +11 -12
  119. package/build/util/config.loader.js.map +1 -1
  120. package/build/util/cotar.serve.d.ts +3 -3
  121. package/build/util/cotar.serve.js +2 -2
  122. package/build/util/cotar.serve.js.map +1 -1
  123. package/build/util/etag.d.ts +0 -1
  124. package/build/util/etag.js.map +1 -1
  125. package/build/util/filter.d.ts +0 -1
  126. package/build/util/filter.js +4 -5
  127. package/build/util/filter.js.map +1 -1
  128. package/build/util/response.d.ts +0 -1
  129. package/build/util/source.cache.d.ts +8 -9
  130. package/build/util/source.cache.js +27 -24
  131. package/build/util/source.cache.js.map +1 -1
  132. package/build/util/swapping.lru.d.ts +0 -1
  133. package/build/util/swapping.lru.js +48 -7
  134. package/build/util/swapping.lru.js.map +1 -1
  135. package/build/util/validate.d.ts +17 -5
  136. package/build/util/validate.js +51 -15
  137. package/build/util/validate.js.map +1 -1
  138. package/build/wmts.capability.d.ts +1 -2
  139. package/build/wmts.capability.js +81 -12
  140. package/build/wmts.capability.js.map +1 -1
  141. package/bundle.sh +2 -2
  142. package/package.json +16 -18
  143. package/scripts/create.deployment.package.mjs +4 -11
  144. package/src/__tests__/config.data.ts +2 -6
  145. package/src/__tests__/index.test.ts +29 -27
  146. package/src/__tests__/tile.style.json.test.ts +40 -37
  147. package/src/__tests__/wmts.capability.test.ts +139 -120
  148. package/src/cli/render.preview.ts +14 -9
  149. package/src/cli/render.tile.ts +27 -18
  150. package/src/index.ts +28 -23
  151. package/src/routes/__tests__/attribution.test.ts +40 -37
  152. package/src/routes/__tests__/fonts.test.ts +68 -64
  153. package/src/routes/__tests__/health.test.ts +18 -17
  154. package/src/routes/__tests__/imagery.test.ts +11 -9
  155. package/src/routes/__tests__/preview.index.test.ts +114 -40
  156. package/src/routes/__tests__/sprites.test.ts +39 -34
  157. package/src/routes/__tests__/tile.json.test.ts +41 -39
  158. package/src/routes/__tests__/tile.style.json.test.ts +49 -46
  159. package/src/routes/__tests__/wmts.test.ts +28 -20
  160. package/src/routes/__tests__/xyz.test.ts +134 -55
  161. package/src/routes/attribution.ts +2 -2
  162. package/src/routes/config.ts +1 -0
  163. package/src/routes/fonts.ts +3 -3
  164. package/src/routes/health.ts +7 -13
  165. package/src/routes/imagery.ts +2 -1
  166. package/src/routes/ping.ts +1 -1
  167. package/src/routes/preview.index.ts +9 -5
  168. package/src/routes/preview.ts +44 -15
  169. package/src/routes/sprites.ts +4 -5
  170. package/src/routes/tile.json.ts +9 -2
  171. package/src/routes/tile.style.json.ts +89 -13
  172. package/src/routes/tile.wmts.ts +4 -3
  173. package/src/routes/tile.xyz.raster.ts +26 -22
  174. package/src/routes/tile.xyz.ts +1 -0
  175. package/src/routes/tile.xyz.vector.ts +5 -3
  176. package/src/routes/version.ts +3 -3
  177. package/src/util/__test__/config.loader.test.ts +38 -34
  178. package/src/util/__test__/filter.test.ts +19 -16
  179. package/src/util/__test__/validate.test.ts +28 -43
  180. package/src/util/assets.provider.ts +10 -9
  181. package/src/util/config.cache.ts +4 -3
  182. package/src/util/config.loader.ts +13 -13
  183. package/src/util/cotar.serve.ts +3 -2
  184. package/src/util/source.cache.ts +15 -26
  185. package/src/util/validate.ts +61 -14
  186. package/src/wmts.capability.ts +3 -3
  187. package/tsconfig.json +1 -0
  188. package/tsconfig.tsbuildinfo +1 -1
  189. package/build/__tests__/config.data.d.ts.map +0 -1
  190. package/build/__tests__/index.test.d.ts.map +0 -1
  191. package/build/__tests__/tile.style.json.test.d.ts.map +0 -1
  192. package/build/__tests__/wmts.capability.test.d.ts.map +0 -1
  193. package/build/__tests__/xyz.util.d.ts.map +0 -1
  194. package/build/cli/render.preview.d.ts.map +0 -1
  195. package/build/cli/render.tile.d.ts.map +0 -1
  196. package/build/index.d.ts.map +0 -1
  197. package/build/routes/__tests__/attribution.test.d.ts.map +0 -1
  198. package/build/routes/__tests__/fonts.test.d.ts.map +0 -1
  199. package/build/routes/__tests__/health.test.d.ts.map +0 -1
  200. package/build/routes/__tests__/imagery.test.d.ts.map +0 -1
  201. package/build/routes/__tests__/memory.fs.d.ts.map +0 -1
  202. package/build/routes/__tests__/preview.index.test.d.ts.map +0 -1
  203. package/build/routes/__tests__/sprites.test.d.ts.map +0 -1
  204. package/build/routes/__tests__/tile.json.test.d.ts.map +0 -1
  205. package/build/routes/__tests__/tile.style.json.test.d.ts.map +0 -1
  206. package/build/routes/__tests__/wmts.test.d.ts.map +0 -1
  207. package/build/routes/__tests__/xyz.test.d.ts.map +0 -1
  208. package/build/routes/attribution.d.ts.map +0 -1
  209. package/build/routes/config.d.ts.map +0 -1
  210. package/build/routes/fonts.d.ts.map +0 -1
  211. package/build/routes/health.d.ts.map +0 -1
  212. package/build/routes/imagery.d.ts.map +0 -1
  213. package/build/routes/ping.d.ts.map +0 -1
  214. package/build/routes/preview.d.ts.map +0 -1
  215. package/build/routes/preview.index.d.ts.map +0 -1
  216. package/build/routes/sprites.d.ts.map +0 -1
  217. package/build/routes/tile.json.d.ts.map +0 -1
  218. package/build/routes/tile.style.json.d.ts.map +0 -1
  219. package/build/routes/tile.wmts.d.ts.map +0 -1
  220. package/build/routes/tile.xyz.d.ts.map +0 -1
  221. package/build/routes/tile.xyz.raster.d.ts.map +0 -1
  222. package/build/routes/tile.xyz.vector.d.ts.map +0 -1
  223. package/build/routes/version.d.ts.map +0 -1
  224. package/build/util/__test__/config.loader.test.d.ts.map +0 -1
  225. package/build/util/__test__/filter.test.d.ts.map +0 -1
  226. package/build/util/__test__/validate.test.d.ts.map +0 -1
  227. package/build/util/assets.provider.d.ts.map +0 -1
  228. package/build/util/config.cache.d.ts.map +0 -1
  229. package/build/util/config.loader.d.ts.map +0 -1
  230. package/build/util/cotar.serve.d.ts.map +0 -1
  231. package/build/util/etag.d.ts.map +0 -1
  232. package/build/util/filter.d.ts.map +0 -1
  233. package/build/util/response.d.ts.map +0 -1
  234. package/build/util/source.cache.d.ts.map +0 -1
  235. package/build/util/source.tracer.d.ts +0 -18
  236. package/build/util/source.tracer.d.ts.map +0 -1
  237. package/build/util/source.tracer.js +0 -26
  238. package/build/util/source.tracer.js.map +0 -1
  239. package/build/util/swapping.lru.d.ts.map +0 -1
  240. package/build/util/validate.d.ts.map +0 -1
  241. package/build/wmts.capability.d.ts.map +0 -1
  242. package/src/util/source.tracer.ts +0 -38
@@ -1,14 +1,22 @@
1
- import { ImageFormat, LatLon, Projection, TileMatrixSet, TileMatrixSets, VectorFormat } from '@basemaps/geo';
1
+ import { ConfigTileSetRaster, ConfigTileSetRasterOutput } from '@basemaps/config';
2
+ import { ImageFormat, LatLon, Projection, TileMatrixSet, TileMatrixSets } from '@basemaps/geo';
2
3
  import { Const, isValidApiKey, truncateApiKey } from '@basemaps/shared';
3
4
  import { getImageFormat } from '@basemaps/tiler';
4
5
  import { LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
5
- import { TileXyzGet } from '../routes/tile.xyz';
6
+
7
+ import { TileXyzGet } from '../routes/tile.xyz.js';
6
8
 
7
9
  export interface TileXyz {
10
+ /** Tile XYZ location */
8
11
  tile: { x: number; y: number; z: number };
12
+ /** Name of the tile set to use */
9
13
  tileSet: string;
14
+ /** TileMatrix that is requested */
10
15
  tileMatrix: TileMatrixSet;
11
- tileType: VectorFormat | ImageFormat;
16
+ /** Output tile format */
17
+ tileType: string;
18
+ /** Optional processing pipeline to use */
19
+ pipeline?: string | null;
12
20
  }
13
21
 
14
22
  export interface TileMatrixRequest {
@@ -18,6 +26,7 @@ export interface TileMatrixRequest {
18
26
  export const Validate = {
19
27
  /**
20
28
  * Validate that the api key exists and is valid
29
+ *
21
30
  * @throws if api key is not valid
22
31
  */
23
32
  apiKey(req: LambdaHttpRequest): string {
@@ -49,13 +58,6 @@ export const Validate = {
49
58
  return [...output.values()];
50
59
  },
51
60
 
52
- getTileFormat(tileType: string): ImageFormat | VectorFormat | null {
53
- const ext = getImageFormat(tileType);
54
- if (ext) return ext;
55
- if (tileType === VectorFormat.MapboxVectorTiles) return VectorFormat.MapboxVectorTiles;
56
- return null;
57
- },
58
-
59
61
  /** Validate that a lat and lon are between -90/90 and -180/180 */
60
62
  getLocation(lonIn: string, latIn: string): LatLon | null {
61
63
  const lat = parseFloat(latIn);
@@ -89,9 +91,9 @@ export const Validate = {
89
91
  req.set('tileMatrix', tileMatrix.identifier);
90
92
  req.set('projection', tileMatrix.projection.code);
91
93
 
92
- const tileType = Validate.getTileFormat(req.params.tileType);
93
- if (tileType == null) throw new LambdaHttpResponse(404, 'Tile extension not found');
94
- req.set('extension', tileType);
94
+ if (req.params.tileType == null) throw new LambdaHttpResponse(404, 'Tile extension not found');
95
+
96
+ req.set('extension', req.params.tileType);
95
97
 
96
98
  if (isNaN(z) || z > tileMatrix.maxZoom || z < 0) throw new LambdaHttpResponse(404, `Zoom not found: ${z}`);
97
99
 
@@ -99,7 +101,16 @@ export const Validate = {
99
101
  if (isNaN(x) || x < 0 || x > zoom.matrixWidth) throw new LambdaHttpResponse(404, `X not found: ${x}`);
100
102
  if (isNaN(y) || y < 0 || y > zoom.matrixHeight) throw new LambdaHttpResponse(404, `Y not found: ${y}`);
101
103
 
102
- const xyzData = { tile: { x, y, z }, tileSet: req.params.tileSet, tileMatrix, tileType };
104
+ const pipeline = req.query.get('pipeline');
105
+ if (pipeline) req.set('pipeline', pipeline);
106
+
107
+ const xyzData = {
108
+ tile: { x, y, z },
109
+ tileSet: req.params.tileSet,
110
+ tileMatrix,
111
+ tileType: req.params.tileType,
112
+ pipeline: req.query.get('pipeline'),
113
+ };
103
114
  req.set('xyz', xyzData.tile);
104
115
 
105
116
  const latLon = Projection.tileCenterToLatLon(tileMatrix, xyzData.tile);
@@ -107,4 +118,40 @@ export const Validate = {
107
118
 
108
119
  return xyzData;
109
120
  },
121
+
122
+ /**
123
+ * Lookup the raster configuration pipeline for a output tile type
124
+ *
125
+ * Defaults to standard image format output if no outputs are defined on the tileset
126
+ */
127
+ pipeline(tileSet: ConfigTileSetRaster, tileType: string, pipeline?: string | null): ConfigTileSetRasterOutput | null {
128
+ if (pipeline != null && pipeline !== 'rgba') {
129
+ if (tileSet.outputs == null) throw new LambdaHttpResponse(404, 'TileSet has no pipelines');
130
+ const output = tileSet.outputs.find((f) => f.name === pipeline);
131
+ if (output == null) throw new LambdaHttpResponse(404, `TileSet has no pipeline named "${pipeline}"`);
132
+
133
+ const validFormats = output.format ?? ['webp', 'png', 'jpeg', 'avif'];
134
+ if (!validFormats.includes(tileType as ImageFormat)) {
135
+ throw new LambdaHttpResponse(400, `TileSet pipeline "${pipeline}" cannot be output as ${tileType}`);
136
+ }
137
+ return output;
138
+ }
139
+ // If the tileset has pipelines defined the user MUST specify which one
140
+ if (tileSet.outputs) {
141
+ throw new LambdaHttpResponse(404, 'TileSet needs pipeline: ' + tileSet.outputs.map((f) => f.name));
142
+ }
143
+
144
+ // Generate a default RGBA configuration
145
+ const img = getImageFormat(tileType ?? 'webp');
146
+ if (img == null) return null;
147
+ return {
148
+ title: `RGBA ${tileType}`,
149
+ name: 'rgba',
150
+ output: {
151
+ type: [img],
152
+ lossless: img === 'png' ? true : false,
153
+ background: tileSet.background,
154
+ },
155
+ } as ConfigTileSetRasterOutput;
156
+ },
110
157
  };
@@ -1,8 +1,7 @@
1
1
  import { ConfigImagery, ConfigLayer, ConfigTileSet, standardizeLayerName } from '@basemaps/config';
2
- import { Bounds, GoogleTms, ImageFormat, Projection, TileMatrixSet, WmtsProvider } from '@basemaps/geo';
2
+ import { BoundingBox, Bounds, GoogleTms, ImageFormat, Projection, TileMatrixSet, WmtsProvider } from '@basemaps/geo';
3
3
  import { toQueryString, V, VNodeElement } from '@basemaps/shared';
4
4
  import { ImageFormatOrder } from '@basemaps/tiler';
5
- import { BoundingBox } from '@cogeotiff/core';
6
5
  import { BBox } from '@linzjs/geojson';
7
6
 
8
7
  const CapabilitiesAttrs = {
@@ -245,7 +244,7 @@ export class WmtsCapabilities extends WmtsBuilder {
245
244
  minZoom = 0;
246
245
  maxZoom = 32;
247
246
  /** Wmts tileSet layer and imagery layers information */
248
- tileSet: ConfigTileSet;
247
+ tileSet?: ConfigTileSet;
249
248
  configLayers?: ConfigLayer[];
250
249
 
251
250
  /** Wmts Provider information */
@@ -370,6 +369,7 @@ export class WmtsCapabilities extends WmtsBuilder {
370
369
  }
371
370
 
372
371
  toVNode(): VNodeElement {
372
+ if (this.tileSet == null) throw new Error('No Tileset provided');
373
373
  // Prepare provider vNode if exists
374
374
  const provider = this.toProviderVNode(this.provider);
375
375
 
package/tsconfig.json CHANGED
@@ -7,6 +7,7 @@
7
7
  "include": ["src/**/*"],
8
8
  "references": [
9
9
  { "path": "../config" },
10
+ { "path": "../config-loader/" },
10
11
  { "path": "../shared" },
11
12
  { "path": "../geo" },
12
13
  { "path": "../tiler" },