@basemaps/lambda-tiler 8.11.1 → 8.13.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.
- package/CHANGELOG.md +60 -0
- package/build/__tests__/config.data.d.ts +2 -0
- package/build/__tests__/config.data.js +38 -2
- package/build/__tests__/config.data.js.map +1 -1
- package/build/__tests__/wmts.capability.test.js +29 -4
- package/build/__tests__/wmts.capability.test.js.map +1 -1
- package/build/index.js.map +1 -1
- package/build/routes/__tests__/tile.style.json.test.js +114 -39
- package/build/routes/__tests__/tile.style.json.test.js.map +1 -1
- package/build/routes/__tests__/wmts.test.js +6 -3
- package/build/routes/__tests__/wmts.test.js.map +1 -1
- package/build/routes/__tests__/xyz.test.js +1 -1
- package/build/routes/__tests__/xyz.test.js.map +1 -1
- package/build/routes/preview.js +4 -14
- package/build/routes/preview.js.map +1 -1
- package/build/routes/tile.style.json.js +75 -23
- package/build/routes/tile.style.json.js.map +1 -1
- package/build/routes/tile.xyz.raster.js +7 -12
- package/build/routes/tile.xyz.raster.js.map +1 -1
- package/build/util/validate.d.ts +13 -2
- package/build/util/validate.js +53 -35
- package/build/util/validate.js.map +1 -1
- package/build/wmts.capability.d.ts +6 -6
- package/build/wmts.capability.js +45 -22
- package/build/wmts.capability.js.map +1 -1
- package/package.json +7 -7
- package/src/__tests__/config.data.ts +40 -2
- package/src/__tests__/wmts.capability.test.ts +57 -4
- package/src/index.ts +1 -0
- package/src/routes/__tests__/tile.style.json.test.ts +154 -42
- package/src/routes/__tests__/wmts.test.ts +14 -3
- package/src/routes/__tests__/xyz.test.ts +1 -1
- package/src/routes/preview.ts +4 -16
- package/src/routes/tile.style.json.ts +84 -24
- package/src/routes/tile.xyz.raster.ts +7 -11
- package/src/util/validate.ts +60 -34
- package/src/wmts.capability.ts +57 -24
- package/tsconfig.tsbuildinfo +1 -1
package/src/wmts.capability.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ConfigImagery,
|
|
3
|
+
ConfigLayer,
|
|
4
|
+
ConfigTileSet,
|
|
5
|
+
ConfigTileSetRasterOutput,
|
|
6
|
+
standardizeLayerName,
|
|
7
|
+
TileSetType,
|
|
8
|
+
} from '@basemaps/config';
|
|
2
9
|
import { BoundingBox, Bounds, GoogleTms, ImageFormat, Projection, TileMatrixSet, WmtsProvider } from '@basemaps/geo';
|
|
3
10
|
import { toQueryString, V, VNodeElement } from '@basemaps/shared';
|
|
4
11
|
import { ImageFormatOrder } from '@basemaps/tiler';
|
|
@@ -74,7 +81,13 @@ export class WmtsBuilder {
|
|
|
74
81
|
for (const format of formats) this.formats.push(format);
|
|
75
82
|
}
|
|
76
83
|
|
|
77
|
-
getFormats(): ImageFormat[] {
|
|
84
|
+
getFormats(restrictTo?: ImageFormat[]): ImageFormat[] {
|
|
85
|
+
if (restrictTo) {
|
|
86
|
+
if (this.formats.length === 0) return restrictTo;
|
|
87
|
+
const filtered = this.formats.filter((f) => restrictTo.includes(f));
|
|
88
|
+
if (filtered.length === 0) return restrictTo;
|
|
89
|
+
return filtered;
|
|
90
|
+
}
|
|
78
91
|
if (this.formats.length) return this.formats;
|
|
79
92
|
return ImageFormatOrder;
|
|
80
93
|
}
|
|
@@ -154,17 +167,17 @@ export class WmtsBuilder {
|
|
|
154
167
|
return V('Style', { isDefault: 'true' }, [V('ows:Title', 'Default Style'), V('ows:Identifier', 'default')]);
|
|
155
168
|
}
|
|
156
169
|
|
|
157
|
-
buildResourceUrl(tileSetId: string, suffix: string): VNodeElement {
|
|
170
|
+
buildResourceUrl(tileSetId: string, suffix: string, pipeline?: string): VNodeElement {
|
|
158
171
|
return V('ResourceURL', {
|
|
159
172
|
format: 'image/' + suffix,
|
|
160
173
|
resourceType: 'tile',
|
|
161
|
-
template: this.buildTileUrl(tileSetId, suffix),
|
|
174
|
+
template: this.buildTileUrl(tileSetId, suffix, pipeline),
|
|
162
175
|
});
|
|
163
176
|
}
|
|
164
177
|
|
|
165
|
-
buildTileUrl(tileSetId: string, suffix: string): string {
|
|
178
|
+
buildTileUrl(tileSetId: string, suffix: string, pipeline?: string): string {
|
|
166
179
|
// TODO this should restrict the output formats to supported formats in pipelines
|
|
167
|
-
const query = { api: this.apiKey, config: this.config, pipeline
|
|
180
|
+
const query = { api: this.apiKey, config: this.config, pipeline };
|
|
168
181
|
|
|
169
182
|
return [
|
|
170
183
|
this.httpBase,
|
|
@@ -178,10 +191,6 @@ export class WmtsBuilder {
|
|
|
178
191
|
].join('/');
|
|
179
192
|
}
|
|
180
193
|
|
|
181
|
-
buildFormats(): VNodeElement[] {
|
|
182
|
-
return this.getFormats().map((fmt) => V('Format', 'image/' + fmt));
|
|
183
|
-
}
|
|
184
|
-
|
|
185
194
|
buildTileMatrixLink(tileSet: ConfigTileSet): VNodeElement[] {
|
|
186
195
|
const matrixSetNodes: VNodeElement[] = [];
|
|
187
196
|
for (const tms of this.tileMatrixSets.values()) {
|
|
@@ -319,7 +328,7 @@ export class WmtsCapabilities extends WmtsBuilder {
|
|
|
319
328
|
];
|
|
320
329
|
}
|
|
321
330
|
|
|
322
|
-
toLayerVNode(tileSet: ConfigTileSet): VNodeElement {
|
|
331
|
+
toLayerVNode(tileSet: ConfigTileSet): VNodeElement[] {
|
|
323
332
|
const matrixSets = this.getMatrixSets(tileSet);
|
|
324
333
|
const matrixSetList = [...matrixSets.values()];
|
|
325
334
|
const firstMatrix = matrixSetList[0];
|
|
@@ -334,19 +343,43 @@ export class WmtsCapabilities extends WmtsBuilder {
|
|
|
334
343
|
bounds.push(Bounds.fromJson(img.bounds));
|
|
335
344
|
}
|
|
336
345
|
|
|
346
|
+
const layers: VNodeElement[] = [];
|
|
347
|
+
|
|
348
|
+
const pipelines = this.getPipelines(tileSet, this.pipeline);
|
|
349
|
+
|
|
337
350
|
const layerNameId = standardizeLayerName(tileSet.name);
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
351
|
+
|
|
352
|
+
for (const pipeline of pipelines) {
|
|
353
|
+
const formats = this.getFormats(pipeline.format);
|
|
354
|
+
const layerId = pipeline.default ? layerNameId : `${layerNameId}_${pipeline.name}`;
|
|
355
|
+
const layerTitle = pipeline.default ? tileSet.title : `${tileSet.title} ${pipeline.title}`;
|
|
356
|
+
|
|
357
|
+
const layer = V('Layer', [
|
|
358
|
+
V('ows:Title', layerTitle),
|
|
359
|
+
V('ows:Abstract', tileSet.description ?? ''),
|
|
360
|
+
V('ows:Identifier', layerId),
|
|
361
|
+
this.buildKeywords(tileSet),
|
|
362
|
+
...[...matrixSets.values()].map((tms) => this.buildBoundingBoxFromImagery(tms, tileSet.layers)),
|
|
363
|
+
this.buildWgs84BoundingBox(webMercatorOrFirst, bounds),
|
|
364
|
+
this.buildStyle(),
|
|
365
|
+
...formats.map((fmt) => V('Format', 'image/' + fmt)),
|
|
366
|
+
...this.buildTileMatrixLink(tileSet),
|
|
367
|
+
...formats.map((fmt) => this.buildResourceUrl(layerNameId, fmt, pipeline.default ? undefined : pipeline.name)),
|
|
368
|
+
]);
|
|
369
|
+
layers.push(layer);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
return layers;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
getPipelines(tileSet: ConfigTileSet, pipeline?: string): ConfigTileSetRasterOutput[] {
|
|
376
|
+
if (tileSet.type !== TileSetType.Raster) return [];
|
|
377
|
+
|
|
378
|
+
if (tileSet.outputs == null) return [{ name: 'rgba', title: 'RGBA', default: true }];
|
|
379
|
+
|
|
380
|
+
if (pipeline) return tileSet.outputs.filter((f) => f.name === pipeline);
|
|
381
|
+
|
|
382
|
+
return tileSet.outputs;
|
|
350
383
|
}
|
|
351
384
|
|
|
352
385
|
toAllImageryLayersVNode(configLayers?: ConfigLayer[]): VNodeElement[] {
|
|
@@ -393,7 +426,7 @@ export class WmtsCapabilities extends WmtsBuilder {
|
|
|
393
426
|
|
|
394
427
|
// Build TileSet Layer VNodes
|
|
395
428
|
const layers: VNodeElement[] = [];
|
|
396
|
-
layers.push(this.toLayerVNode(this.tileSet));
|
|
429
|
+
layers.push(...this.toLayerVNode(this.tileSet));
|
|
397
430
|
const contents = layers.concat(this.toAllImageryLayersVNode(this.configLayers));
|
|
398
431
|
|
|
399
432
|
// Build TileMatrix Sets vNodes
|