@basemaps/lambda-tiler 6.29.0 → 6.32.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 +63 -0
- package/build/__tests__/config.data.d.ts +11 -0
- package/build/__tests__/config.data.d.ts.map +1 -0
- package/build/__tests__/config.data.js +112 -0
- package/build/__tests__/config.data.js.map +1 -0
- package/build/__tests__/index.test.js +5 -14
- package/build/__tests__/index.test.js.map +1 -0
- package/build/__tests__/tile.style.json.test.js +1 -0
- package/build/__tests__/tile.style.json.test.js.map +1 -0
- package/build/__tests__/wmts.capability.test.d.ts +1 -1
- package/build/__tests__/wmts.capability.test.d.ts.map +1 -1
- package/build/__tests__/wmts.capability.test.js +286 -125
- package/build/__tests__/wmts.capability.test.js.map +1 -0
- package/build/__tests__/xyz.util.d.ts +7 -11
- package/build/__tests__/xyz.util.d.ts.map +1 -1
- package/build/__tests__/xyz.util.js +14 -42
- package/build/__tests__/xyz.util.js.map +1 -0
- package/build/index.d.ts +0 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +68 -41
- package/build/index.js.map +1 -0
- package/build/routes/__tests__/attribution.test.js +351 -399
- package/build/routes/__tests__/attribution.test.js.map +1 -0
- package/build/routes/__tests__/fonts.test.js +17 -3
- package/build/routes/__tests__/fonts.test.js.map +1 -0
- package/build/routes/__tests__/health.test.js +17 -13
- package/build/routes/__tests__/health.test.js.map +1 -0
- package/build/routes/__tests__/imagery.test.js +1 -0
- package/build/routes/__tests__/imagery.test.js.map +1 -0
- package/build/routes/__tests__/memory.fs.js +1 -0
- package/build/routes/__tests__/memory.fs.js.map +1 -0
- package/build/routes/__tests__/sprites.test.js +7 -0
- package/build/routes/__tests__/sprites.test.js.map +1 -0
- package/build/routes/__tests__/tile.json.test.d.ts +2 -0
- package/build/routes/__tests__/tile.json.test.d.ts.map +1 -0
- package/build/routes/__tests__/tile.json.test.js +124 -0
- package/build/routes/__tests__/tile.json.test.js.map +1 -0
- package/build/routes/__tests__/tile.style.json.test.d.ts +2 -0
- package/build/routes/__tests__/tile.style.json.test.d.ts.map +1 -0
- package/build/routes/__tests__/tile.style.json.test.js +95 -0
- package/build/routes/__tests__/tile.style.json.test.js.map +1 -0
- package/build/routes/__tests__/wmts.test.js +37 -27
- package/build/routes/__tests__/wmts.test.js.map +1 -0
- package/build/{__tests__ → routes/__tests__}/xyz.test.d.ts +0 -0
- package/build/routes/__tests__/xyz.test.d.ts.map +1 -0
- package/build/routes/__tests__/xyz.test.js +99 -0
- package/build/routes/__tests__/xyz.test.js.map +1 -0
- package/build/routes/attribution.d.ts +7 -5
- package/build/routes/attribution.d.ts.map +1 -1
- package/build/routes/attribution.js +50 -91
- package/build/routes/attribution.js.map +1 -0
- package/build/routes/fonts.d.ts +1 -1
- package/build/routes/fonts.d.ts.map +1 -1
- package/build/routes/fonts.js +33 -10
- package/build/routes/fonts.js.map +1 -0
- package/build/routes/health.d.ts +3 -3
- package/build/routes/health.d.ts.map +1 -1
- package/build/routes/health.js +16 -13
- package/build/routes/health.js.map +1 -0
- package/build/routes/imagery.d.ts +8 -1
- package/build/routes/imagery.d.ts.map +1 -1
- package/build/routes/imagery.js +17 -17
- package/build/routes/imagery.js.map +1 -0
- package/build/routes/ping.d.ts +3 -0
- package/build/routes/ping.d.ts.map +1 -0
- package/build/routes/ping.js +7 -0
- package/build/routes/ping.js.map +1 -0
- package/build/routes/sprites.d.ts.map +1 -1
- package/build/routes/sprites.js +22 -22
- package/build/routes/sprites.js.map +1 -0
- package/build/routes/tile.json.d.ts +7 -1
- package/build/routes/tile.json.d.ts.map +1 -1
- package/build/routes/tile.json.js +19 -22
- package/build/routes/tile.json.js.map +1 -0
- package/build/routes/tile.style.json.d.ts +6 -1
- package/build/routes/tile.style.json.d.ts.map +1 -1
- package/build/routes/tile.style.json.js +11 -13
- package/build/routes/tile.style.json.js.map +1 -0
- package/build/routes/tile.wmts.d.ts +9 -3
- package/build/routes/tile.wmts.d.ts.map +1 -1
- package/build/routes/tile.wmts.js +37 -50
- package/build/routes/tile.wmts.js.map +1 -0
- package/build/routes/tile.xyz.d.ts +14 -4
- package/build/routes/tile.xyz.d.ts.map +1 -1
- package/build/routes/tile.xyz.js +22 -17
- package/build/routes/tile.xyz.js.map +1 -0
- package/build/routes/tile.xyz.raster.d.ts +11 -0
- package/build/routes/tile.xyz.raster.d.ts.map +1 -0
- package/build/routes/tile.xyz.raster.js +90 -0
- package/build/routes/tile.xyz.raster.js.map +1 -0
- package/build/routes/tile.xyz.vector.d.ts +8 -0
- package/build/routes/tile.xyz.vector.d.ts.map +1 -0
- package/build/routes/tile.xyz.vector.js +46 -0
- package/build/routes/tile.xyz.vector.js.map +1 -0
- package/build/routes/version.d.ts +3 -0
- package/build/routes/version.d.ts.map +1 -0
- package/build/routes/version.js +9 -0
- package/build/routes/version.js.map +1 -0
- package/build/util/__test__/validate.test.d.ts +2 -0
- package/build/util/__test__/validate.test.d.ts.map +1 -0
- package/build/util/__test__/validate.test.js +66 -0
- package/build/util/__test__/validate.test.js.map +1 -0
- package/build/util/cotar.serve.d.ts +20 -0
- package/build/util/cotar.serve.d.ts.map +1 -0
- package/build/util/cotar.serve.js +41 -0
- package/build/util/cotar.serve.js.map +1 -0
- package/build/util/etag.d.ts +6 -0
- package/build/util/etag.d.ts.map +1 -0
- package/build/util/etag.js +20 -0
- package/build/util/etag.js.map +1 -0
- package/build/util/response.d.ts +4 -0
- package/build/util/response.d.ts.map +1 -0
- package/build/util/response.js +4 -0
- package/build/util/response.js.map +1 -0
- package/build/util/source.cache.d.ts +28 -0
- package/build/util/source.cache.d.ts.map +1 -0
- package/build/util/source.cache.js +53 -0
- package/build/util/source.cache.js.map +1 -0
- package/build/{source.tracer.d.ts → util/source.tracer.d.ts} +1 -0
- package/build/util/source.tracer.d.ts.map +1 -0
- package/build/{source.tracer.js → util/source.tracer.js} +4 -0
- package/build/util/source.tracer.js.map +1 -0
- package/build/util/swapping.lru.d.ts +21 -0
- package/build/util/swapping.lru.d.ts.map +1 -0
- package/build/util/swapping.lru.js +56 -0
- package/build/util/swapping.lru.js.map +1 -0
- package/build/util/validate.d.ts +46 -0
- package/build/util/validate.d.ts.map +1 -0
- package/build/util/validate.js +107 -0
- package/build/util/validate.js.map +1 -0
- package/build/wmts.capability.d.ts +27 -13
- package/build/wmts.capability.d.ts.map +1 -1
- package/build/wmts.capability.js +156 -55
- package/build/wmts.capability.js.map +1 -0
- package/dist/index.js +89 -73
- package/dist/node_modules/.package-lock.json +1 -1
- package/dist/package-lock.json +2 -2
- package/dist/package.json +1 -1
- package/package.json +10 -10
- package/src/__tests__/config.data.ts +120 -0
- package/src/__tests__/index.test.ts +4 -20
- package/src/__tests__/wmts.capability.test.ts +312 -139
- package/src/__tests__/xyz.util.ts +17 -45
- package/src/index.ts +75 -41
- package/src/routes/__tests__/attribution.test.ts +356 -403
- package/src/routes/__tests__/fonts.test.ts +18 -3
- package/src/routes/__tests__/health.test.ts +17 -13
- package/src/routes/__tests__/sprites.test.ts +6 -1
- package/src/routes/__tests__/tile.json.test.ts +145 -0
- package/src/routes/__tests__/tile.style.json.test.ts +105 -0
- package/src/routes/__tests__/wmts.test.ts +44 -34
- package/src/routes/__tests__/xyz.test.ts +119 -0
- package/src/routes/attribution.ts +59 -111
- package/src/routes/fonts.ts +32 -10
- package/src/routes/health.ts +17 -16
- package/src/routes/imagery.ts +18 -15
- package/src/routes/ping.ts +8 -0
- package/src/routes/sprites.ts +20 -22
- package/src/routes/tile.json.ts +24 -19
- package/src/routes/tile.style.json.ts +15 -12
- package/src/routes/tile.wmts.ts +41 -44
- package/src/routes/tile.xyz.raster.ts +106 -0
- package/src/routes/tile.xyz.ts +31 -16
- package/src/routes/tile.xyz.vector.ts +47 -0
- package/src/routes/version.ts +8 -0
- package/src/util/__test__/validate.test.ts +74 -0
- package/src/util/cotar.serve.ts +46 -0
- package/src/util/etag.ts +20 -0
- package/src/util/response.ts +4 -0
- package/src/util/source.cache.ts +71 -0
- package/src/{source.tracer.ts → util/source.tracer.ts} +4 -0
- package/src/util/swapping.lru.ts +63 -0
- package/src/util/validate.ts +126 -0
- package/src/wmts.capability.ts +170 -68
- package/tsconfig.tsbuildinfo +1 -1
- package/build/__tests__/route.test.d.ts +0 -2
- package/build/__tests__/route.test.d.ts.map +0 -1
- package/build/__tests__/route.test.js +0 -20
- package/build/__tests__/tiff.cache.test.d.ts +0 -2
- package/build/__tests__/tiff.cache.test.d.ts.map +0 -1
- package/build/__tests__/tiff.cache.test.js +0 -58
- package/build/__tests__/tile.cache.key.test.d.ts +0 -2
- package/build/__tests__/tile.cache.key.test.d.ts.map +0 -1
- package/build/__tests__/tile.cache.key.test.js +0 -48
- package/build/__tests__/tile.set.cache.test.d.ts +0 -2
- package/build/__tests__/tile.set.cache.test.d.ts.map +0 -1
- package/build/__tests__/tile.set.cache.test.js +0 -123
- package/build/__tests__/tile.set.test.d.ts +0 -2
- package/build/__tests__/tile.set.test.d.ts.map +0 -1
- package/build/__tests__/tile.set.test.js +0 -11
- package/build/__tests__/xyz.test.d.ts.map +0 -1
- package/build/__tests__/xyz.test.js +0 -306
- package/build/api.key.d.ts +0 -2
- package/build/api.key.d.ts.map +0 -1
- package/build/api.key.js +0 -23
- package/build/cli/dump.d.ts +0 -2
- package/build/cli/dump.d.ts.map +0 -1
- package/build/cli/dump.js +0 -47
- package/build/cli/tile.set.local.d.ts +0 -12
- package/build/cli/tile.set.local.d.ts.map +0 -1
- package/build/cli/tile.set.local.js +0 -39
- package/build/router.d.ts +0 -15
- package/build/router.d.ts.map +0 -1
- package/build/router.js +0 -49
- package/build/routes/api.d.ts +0 -5
- package/build/routes/api.d.ts.map +0 -1
- package/build/routes/api.js +0 -16
- package/build/routes/esri/rest.d.ts +0 -10
- package/build/routes/esri/rest.d.ts.map +0 -1
- package/build/routes/esri/rest.js +0 -87
- package/build/routes/response.d.ts +0 -4
- package/build/routes/response.d.ts.map +0 -1
- package/build/routes/response.js +0 -3
- package/build/routes/tile.d.ts +0 -3
- package/build/routes/tile.d.ts.map +0 -1
- package/build/routes/tile.etag.d.ts +0 -11
- package/build/routes/tile.etag.d.ts.map +0 -1
- package/build/routes/tile.etag.js +0 -29
- package/build/routes/tile.js +0 -27
- package/build/source.tracer.d.ts.map +0 -1
- package/build/tiff.cache.d.ts +0 -17
- package/build/tiff.cache.d.ts.map +0 -1
- package/build/tiff.cache.js +0 -45
- package/build/tile.set.cache.d.ts +0 -21
- package/build/tile.set.cache.d.ts.map +0 -1
- package/build/tile.set.cache.js +0 -100
- package/build/tile.set.d.ts +0 -4
- package/build/tile.set.d.ts.map +0 -1
- package/build/tile.set.js +0 -1
- package/build/tile.set.raster.d.ts +0 -49
- package/build/tile.set.raster.d.ts.map +0 -1
- package/build/tile.set.raster.js +0 -186
- package/build/tile.set.vector.d.ts +0 -25
- package/build/tile.set.vector.d.ts.map +0 -1
- package/build/tile.set.vector.js +0 -71
- package/build/validate.d.ts +0 -16
- package/build/validate.d.ts.map +0 -1
- package/build/validate.js +0 -31
- package/src/__tests__/route.test.ts +0 -24
- package/src/__tests__/tiff.cache.test.ts +0 -73
- package/src/__tests__/tile.cache.key.test.ts +0 -56
- package/src/__tests__/tile.set.cache.test.ts +0 -146
- package/src/__tests__/tile.set.test.ts +0 -12
- package/src/__tests__/xyz.test.ts +0 -362
- package/src/api.key.ts +0 -23
- package/src/cli/dump.ts +0 -61
- package/src/cli/tile.set.local.ts +0 -51
- package/src/router.ts +0 -58
- package/src/routes/api.ts +0 -19
- package/src/routes/esri/rest.ts +0 -90
- package/src/routes/response.ts +0 -4
- package/src/routes/tile.etag.ts +0 -36
- package/src/routes/tile.ts +0 -23
- package/src/tiff.cache.ts +0 -51
- package/src/tile.set.cache.ts +0 -111
- package/src/tile.set.raster.ts +0 -228
- package/src/tile.set.ts +0 -4
- package/src/tile.set.vector.ts +0 -79
- package/src/validate.ts +0 -32
|
@@ -1,87 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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"}
|
package/build/routes/response.js
DELETED
package/build/routes/tile.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,11 +0,0 @@
|
|
|
1
|
-
import { Composition } from '@basemaps/tiler';
|
|
2
|
-
import { TileDataXyz } from '@basemaps/shared';
|
|
3
|
-
import { LambdaHttpRequest } from '@linzjs/lambda';
|
|
4
|
-
export declare const TileEtag: {
|
|
5
|
-
RenderId: number;
|
|
6
|
-
key(object: Record<string, unknown>): string;
|
|
7
|
-
/** Generate a unique ETag for this tile */
|
|
8
|
-
generate(compositions: Composition[], xyzData: TileDataXyz): string;
|
|
9
|
-
isNotModified(req: LambdaHttpRequest, cacheKey: string): boolean;
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=tile.etag.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tile.etag.d.ts","sourceRoot":"","sources":["../../src/routes/tile.etag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAc,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAG/D,eAAO,MAAM,QAAQ;;gBAIP,OAAO,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM;IAI5C,2CAA2C;2BACpB,WAAW,EAAE,WAAW,WAAW,GAAG,MAAM;uBAUhD,iBAAiB,YAAY,MAAM,GAAG,OAAO;CAUjE,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { createHash } from 'crypto';
|
|
2
|
-
import { HttpHeader } from '@linzjs/lambda';
|
|
3
|
-
import { basename } from 'path';
|
|
4
|
-
export const TileEtag = {
|
|
5
|
-
// To force a full cache invalidation change this number
|
|
6
|
-
RenderId: 1,
|
|
7
|
-
key(object) {
|
|
8
|
-
return createHash('sha256').update(JSON.stringify(object)).digest('base64');
|
|
9
|
-
},
|
|
10
|
-
/** Generate a unique ETag for this tile */
|
|
11
|
-
generate(compositions, xyzData) {
|
|
12
|
-
// We cannot serialize the CogTiff inside of composition so replace it with the source name
|
|
13
|
-
const layers = compositions.map((c) => {
|
|
14
|
-
return { ...c, tiff: basename(c.tiff.source.uri) };
|
|
15
|
-
});
|
|
16
|
-
const xyz = { ...xyzData, tileMatrix: xyzData.tileMatrix.identifier };
|
|
17
|
-
return TileEtag.key({ xyz, layers, RenderId: TileEtag.RenderId });
|
|
18
|
-
},
|
|
19
|
-
isNotModified(req, cacheKey) {
|
|
20
|
-
// If the user has supplied a IfNoneMatch Header and it contains the full sha256 sum for our
|
|
21
|
-
// etag this tile has not been modified.
|
|
22
|
-
const ifNoneMatch = req.header(HttpHeader.IfNoneMatch);
|
|
23
|
-
if (ifNoneMatch != null && ifNoneMatch.indexOf(cacheKey) > -1) {
|
|
24
|
-
req.set('cache', { key: cacheKey, hit: true, match: ifNoneMatch });
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
return false;
|
|
28
|
-
},
|
|
29
|
-
};
|
package/build/routes/tile.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { LambdaHttpResponse } from '@linzjs/lambda';
|
|
2
|
-
import { isValidApiKey } from '../api.key.js';
|
|
3
|
-
import { Router } from '../router.js';
|
|
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';
|
|
10
|
-
export async function Tiles(req) {
|
|
11
|
-
const { rest } = Router.action(req);
|
|
12
|
-
if (rest.length < 1)
|
|
13
|
-
return NotFound;
|
|
14
|
-
const apiKey = Router.apiKey(req);
|
|
15
|
-
if (!isValidApiKey(apiKey))
|
|
16
|
-
return new LambdaHttpResponse(400, 'Invalid API Key');
|
|
17
|
-
const fileName = rest[rest.length - 1].toLowerCase();
|
|
18
|
-
if (fileName === 'attribution.json')
|
|
19
|
-
return attribution(req);
|
|
20
|
-
if (fileName === 'wmtscapabilities.xml')
|
|
21
|
-
return wmts(req);
|
|
22
|
-
if (fileName === 'tile.json')
|
|
23
|
-
return tileJson(req);
|
|
24
|
-
if (fileName.endsWith('json') && rest[rest.length - 2] === 'style')
|
|
25
|
-
return styleJson(req, fileName);
|
|
26
|
-
return tileXyz(req);
|
|
27
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"source.tracer.d.ts","sourceRoot":"","sources":["../src/source.tracer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,UAAU,aAAa;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,YAAY;IACvB,QAAQ,EAAE,aAAa,EAAE,CAAM;IAE/B,+BAA+B;IAC/B,KAAK,IAAI,IAAI;IAIb,6EAA6E;IAC7E,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;CAajC;AAED,eAAO,MAAM,EAAE,cAAqB,CAAC"}
|
package/build/tiff.cache.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { CogTiff } from '@cogeotiff/core';
|
|
2
|
-
/** Limit the caching of tiffs */
|
|
3
|
-
export declare class TiffCache {
|
|
4
|
-
static cacheA: Map<string, CogTiff>;
|
|
5
|
-
static cacheB: Map<string, CogTiff>;
|
|
6
|
-
/** 256 MB Cache */
|
|
7
|
-
static MaxCacheSizeBytes: number;
|
|
8
|
-
static get(id: string): CogTiff | null;
|
|
9
|
-
/** Reset the cache */
|
|
10
|
-
static clear(): void;
|
|
11
|
-
static set(id: string, tiff: CogTiff): void;
|
|
12
|
-
/** Validate the size of the cache has not exploded */
|
|
13
|
-
static check(): void;
|
|
14
|
-
/** Calculate the total number of bytes used by this tiff cache */
|
|
15
|
-
static get currentSize(): number;
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=tiff.cache.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tiff.cache.d.ts","sourceRoot":"","sources":["../src/tiff.cache.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,iCAAiC;AACjC,qBAAa,SAAS;IACpB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAa;IAChD,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAa;IAEhD,mBAAmB;IACnB,MAAM,CAAC,iBAAiB,SAAqB;IAE7C,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI;IAYtC,sBAAsB;IACtB,MAAM,CAAC,KAAK,IAAI,IAAI;IAKpB,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI;IAK3C,sDAAsD;IACtD,MAAM,CAAC,KAAK,IAAI,IAAI;IAOpB,kEAAkE;IAClE,MAAM,KAAK,WAAW,IAAI,MAAM,CAM/B;CACF"}
|
package/build/tiff.cache.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/** Limit the caching of tiffs */
|
|
2
|
-
export class TiffCache {
|
|
3
|
-
static get(id) {
|
|
4
|
-
const cacheA = TiffCache.cacheA.get(id);
|
|
5
|
-
if (cacheA)
|
|
6
|
-
return cacheA;
|
|
7
|
-
const cacheB = TiffCache.cacheB.get(id);
|
|
8
|
-
if (cacheB == null)
|
|
9
|
-
return null;
|
|
10
|
-
// If a object is still useful move it into the main cache
|
|
11
|
-
TiffCache.cacheA.set(id, cacheB);
|
|
12
|
-
TiffCache.cacheB.delete(id);
|
|
13
|
-
return cacheB;
|
|
14
|
-
}
|
|
15
|
-
/** Reset the cache */
|
|
16
|
-
static clear() {
|
|
17
|
-
this.cacheA.clear();
|
|
18
|
-
this.cacheB.clear();
|
|
19
|
-
}
|
|
20
|
-
static set(id, tiff) {
|
|
21
|
-
TiffCache.cacheA.set(id, tiff);
|
|
22
|
-
TiffCache.check();
|
|
23
|
-
}
|
|
24
|
-
/** Validate the size of the cache has not exploded */
|
|
25
|
-
static check() {
|
|
26
|
-
if (TiffCache.MaxCacheSizeBytes <= 0)
|
|
27
|
-
return;
|
|
28
|
-
if (TiffCache.currentSize <= TiffCache.MaxCacheSizeBytes)
|
|
29
|
-
return;
|
|
30
|
-
TiffCache.cacheB = TiffCache.cacheA;
|
|
31
|
-
TiffCache.cacheA = new Map();
|
|
32
|
-
}
|
|
33
|
-
/** Calculate the total number of bytes used by this tiff cache */
|
|
34
|
-
static get currentSize() {
|
|
35
|
-
let size = 0;
|
|
36
|
-
for (const value of TiffCache.cacheA.values()) {
|
|
37
|
-
size += value.source.chunkSize * value.source.chunks.size;
|
|
38
|
-
}
|
|
39
|
-
return size;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
TiffCache.cacheA = new Map();
|
|
43
|
-
TiffCache.cacheB = new Map();
|
|
44
|
-
/** 256 MB Cache */
|
|
45
|
-
TiffCache.MaxCacheSizeBytes = 256 * 1024 * 1024;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { TileMatrixSet } from '@basemaps/geo';
|
|
2
|
-
import { TileSet } from './tile.set.js';
|
|
3
|
-
export declare class TileSetCache {
|
|
4
|
-
/** Duration to cache tile sets for */
|
|
5
|
-
CacheTime: number;
|
|
6
|
-
/** Cache the fetch requests */
|
|
7
|
-
cache: Map<string, {
|
|
8
|
-
time: number;
|
|
9
|
-
value: Promise<TileSet | null>;
|
|
10
|
-
}>;
|
|
11
|
-
/** Cache initialized tile sets */
|
|
12
|
-
tileSets: Map<string, TileSet>;
|
|
13
|
-
id(tileSet: TileSet): string;
|
|
14
|
-
id(name: string, tileMatrix: TileMatrixSet): string;
|
|
15
|
-
add(tileSet: TileSet, expiresAt?: number): void;
|
|
16
|
-
get(name: string, tileMatrix: TileMatrixSet): Promise<TileSet | null>;
|
|
17
|
-
loadTileSet(name: string, tileMatrix: TileMatrixSet): Promise<TileSet | null>;
|
|
18
|
-
getAll(name: string, tileMatrix?: TileMatrixSet | null): Promise<TileSet[]>;
|
|
19
|
-
}
|
|
20
|
-
export declare const TileSets: TileSetCache;
|
|
21
|
-
//# sourceMappingURL=tile.set.cache.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tile.set.cache.d.ts","sourceRoot":"","sources":["../src/tile.set.cache.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAkB,MAAM,eAAe,CAAC;AAE9D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAIxC,qBAAa,YAAY;IACvB,sCAAsC;IACtC,SAAS,SAAU;IAEnB,+BAA+B;IAC/B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;KAAE,CAAC,CAAa;IACjF,kCAAkC;IAClC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAa;IAE3C,EAAE,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM;IAC5B,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,GAAG,MAAM;IAUnD,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,SAA8B,GAAG,IAAI;IAMpE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAY/D,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAqC7E,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,aAAa,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CA0BlF;AAED,eAAO,MAAM,QAAQ,cAAqB,CAAC"}
|
package/build/tile.set.cache.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { TileSetNameParser, TileSetType } from '@basemaps/config';
|
|
2
|
-
import { TileMatrixSets } from '@basemaps/geo';
|
|
3
|
-
import { Config } from '@basemaps/shared';
|
|
4
|
-
import { TileSetRaster } from './tile.set.raster.js';
|
|
5
|
-
import { TileSetVector } from './tile.set.vector.js';
|
|
6
|
-
export class TileSetCache {
|
|
7
|
-
constructor() {
|
|
8
|
-
/** Duration to cache tile sets for */
|
|
9
|
-
this.CacheTime = 30000;
|
|
10
|
-
/** Cache the fetch requests */
|
|
11
|
-
this.cache = new Map();
|
|
12
|
-
/** Cache initialized tile sets */
|
|
13
|
-
this.tileSets = new Map();
|
|
14
|
-
}
|
|
15
|
-
id(name, tileMatrix) {
|
|
16
|
-
if (typeof name === 'string') {
|
|
17
|
-
const nameComp = TileSetNameParser.parse(name);
|
|
18
|
-
return `${TileSetNameParser.componentsToName(nameComp)}_${tileMatrix === null || tileMatrix === void 0 ? void 0 : tileMatrix.identifier}`;
|
|
19
|
-
}
|
|
20
|
-
return `${name.fullName}_${name.tileMatrix.identifier}`;
|
|
21
|
-
}
|
|
22
|
-
add(tileSet, expiresAt = Date.now() + this.CacheTime) {
|
|
23
|
-
const id = this.id(tileSet);
|
|
24
|
-
if (this.cache.has(id))
|
|
25
|
-
throw new Error('Trying to add duplicate tile set:' + id);
|
|
26
|
-
this.cache.set(id, { time: expiresAt, value: Promise.resolve(tileSet) });
|
|
27
|
-
}
|
|
28
|
-
get(name, tileMatrix) {
|
|
29
|
-
const tsId = this.id(name, tileMatrix);
|
|
30
|
-
let existing = this.cache.get(tsId);
|
|
31
|
-
// Validate the data is current every ~30 seconds
|
|
32
|
-
if (existing == null || Date.now() - existing.time > 0) {
|
|
33
|
-
const value = this.loadTileSet(name, tileMatrix);
|
|
34
|
-
existing = { time: Date.now(), value };
|
|
35
|
-
this.cache.set(tsId, existing);
|
|
36
|
-
}
|
|
37
|
-
return existing.value;
|
|
38
|
-
}
|
|
39
|
-
async loadTileSet(name, tileMatrix) {
|
|
40
|
-
const nameComp = TileSetNameParser.parse(name);
|
|
41
|
-
const tileSetId = this.id(name, tileMatrix);
|
|
42
|
-
if (nameComp.layer != null) {
|
|
43
|
-
const parentName = TileSetNameParser.componentsToName({ ...nameComp, layer: undefined });
|
|
44
|
-
const parent = await this.get(parentName, tileMatrix);
|
|
45
|
-
if (parent == null || parent.type === TileSetType.Vector)
|
|
46
|
-
return null;
|
|
47
|
-
return parent.child(nameComp.layer);
|
|
48
|
-
}
|
|
49
|
-
const dbId = Config.TileSet.id(name);
|
|
50
|
-
const tileSet = await Config.TileSet.get(dbId);
|
|
51
|
-
if (tileSet == null) {
|
|
52
|
-
this.cache.delete(tileSetId);
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
// If we already have a copy and it hasn't been modified just return it
|
|
56
|
-
const existing = this.tileSets.get(tileSetId);
|
|
57
|
-
if (existing != null && (existing === null || existing === void 0 ? void 0 : existing.tileSet.updatedAt) === tileSet.updatedAt) {
|
|
58
|
-
return existing;
|
|
59
|
-
}
|
|
60
|
-
if (Config.isTileSetRaster(tileSet)) {
|
|
61
|
-
const ts = new TileSetRaster(name, tileMatrix);
|
|
62
|
-
await ts.init(tileSet);
|
|
63
|
-
this.tileSets.set(tileSetId, ts);
|
|
64
|
-
return ts;
|
|
65
|
-
}
|
|
66
|
-
const ts = new TileSetVector(name, tileMatrix);
|
|
67
|
-
await ts.init(tileSet);
|
|
68
|
-
this.tileSets.set(tileSetId, ts);
|
|
69
|
-
return ts;
|
|
70
|
-
}
|
|
71
|
-
async getAll(name, tileMatrix) {
|
|
72
|
-
const nameComp = TileSetNameParser.parse(name);
|
|
73
|
-
const tileMatrices = tileMatrix == null ? Array.from(TileMatrixSets.Defaults.values()) : [tileMatrix];
|
|
74
|
-
const promises = [];
|
|
75
|
-
for (const tileMatrix of tileMatrices)
|
|
76
|
-
promises.push(this.get(name, tileMatrix));
|
|
77
|
-
const tileMatrixSets = await Promise.all(promises);
|
|
78
|
-
const tileSets = [];
|
|
79
|
-
for (const parent of tileMatrixSets) {
|
|
80
|
-
if (parent == null)
|
|
81
|
-
continue;
|
|
82
|
-
if (parent.type === TileSetType.Vector)
|
|
83
|
-
continue;
|
|
84
|
-
tileSets.push(parent);
|
|
85
|
-
if (nameComp.layer != null) {
|
|
86
|
-
parent.components.name = nameComp.name;
|
|
87
|
-
}
|
|
88
|
-
else if (parent.imagery != null && parent.imagery.size > 1) {
|
|
89
|
-
for (const imageId of parent.imagery.keys()) {
|
|
90
|
-
const childImg = parent.child(imageId);
|
|
91
|
-
if (childImg == null)
|
|
92
|
-
continue;
|
|
93
|
-
tileSets.push(childImg);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return tileSets.sort((a, b) => a.title.localeCompare(b.title));
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
export const TileSets = new TileSetCache();
|
package/build/tile.set.d.ts
DELETED
package/build/tile.set.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tile.set.d.ts","sourceRoot":"","sources":["../src/tile.set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,oBAAY,OAAO,GAAG,aAAa,GAAG,aAAa,CAAC"}
|
package/build/tile.set.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { ConfigImagery, ConfigTileSetRaster, TileSetNameComponents, TileSetType } from '@basemaps/config';
|
|
3
|
-
import { Bounds, ImageFormat, Tile, TileMatrixSet } from '@basemaps/geo';
|
|
4
|
-
import { LogType, TileDataXyz } from '@basemaps/shared';
|
|
5
|
-
import { Tiler } from '@basemaps/tiler';
|
|
6
|
-
import { TileMakerSharp } from '@basemaps/tiler-sharp';
|
|
7
|
-
import { CogTiff } from '@cogeotiff/core';
|
|
8
|
-
import { LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
|
|
9
|
-
import { Metrics } from '@linzjs/metrics';
|
|
10
|
-
export declare const TileComposer: TileMakerSharp;
|
|
11
|
-
export interface TileSetResponse {
|
|
12
|
-
buffer: Buffer;
|
|
13
|
-
metrics: Metrics;
|
|
14
|
-
layersUsed: number;
|
|
15
|
-
layersTotal: number;
|
|
16
|
-
contentType: string;
|
|
17
|
-
}
|
|
18
|
-
export declare function getTiffName(name: string): string;
|
|
19
|
-
export declare class TileSetRaster {
|
|
20
|
-
type: TileSetType.Raster;
|
|
21
|
-
tileMatrix: TileMatrixSet;
|
|
22
|
-
tiler: Tiler;
|
|
23
|
-
imagery: Map<string, ConfigImagery>;
|
|
24
|
-
extentOverride: Bounds;
|
|
25
|
-
components: TileSetNameComponents;
|
|
26
|
-
tileSet: ConfigTileSetRaster;
|
|
27
|
-
constructor(name: string, tileMatrix: TileMatrixSet);
|
|
28
|
-
get id(): string;
|
|
29
|
-
get fullName(): string;
|
|
30
|
-
get title(): string;
|
|
31
|
-
get description(): string;
|
|
32
|
-
get extent(): Bounds;
|
|
33
|
-
/** Preferred default imagery format */
|
|
34
|
-
get format(): ImageFormat;
|
|
35
|
-
init(record: ConfigTileSetRaster): Promise<void>;
|
|
36
|
-
initTiffs(tile: Tile, log: LogType): Promise<CogTiff[]>;
|
|
37
|
-
tile(req: LambdaHttpRequest, xyz: TileDataXyz): Promise<LambdaHttpResponse>;
|
|
38
|
-
/**
|
|
39
|
-
* Get a list of tiffs in the rendering order that is needed to render the tile
|
|
40
|
-
* @param tms tile matrix set to describe the tiling scheme
|
|
41
|
-
* @param tile tile to render
|
|
42
|
-
*/
|
|
43
|
-
getTiffsForTile(tile: Tile, log?: LogType): CogTiff[];
|
|
44
|
-
private getCogsForTile;
|
|
45
|
-
/** Look up imagery by imageryId or by image name */
|
|
46
|
-
findImagery(imgId: string): ConfigImagery | null;
|
|
47
|
-
child(imgId: string): TileSetRaster | null;
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=tile.set.raster.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tile.set.raster.d.ts","sourceRoot":"","sources":["../src/tile.set.raster.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EAEb,mBAAmB,EACnB,qBAAqB,EAErB,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAQ,WAAW,EAAE,IAAI,EAAE,aAAa,EAAgC,MAAM,eAAe,CAAC;AAC7G,OAAO,EAAoB,OAAO,EAAE,WAAW,EAAuB,MAAM,kBAAkB,CAAC;AAC/F,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAc,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAU1C,eAAO,MAAM,YAAY,gBAA0B,CAAC;AAEpD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAKD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGhD;AAED,qBAAa,aAAa;IACxB,IAAI,EAAE,WAAW,CAAC,MAAM,CAAsB;IAE9C,UAAU,EAAE,aAAa,CAAC;IAC1B,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACpC,cAAc,EAAE,MAAM,CAAC;IAEvB,UAAU,EAAE,qBAAqB,CAAC;IAClC,OAAO,EAAE,mBAAmB,CAAC;gBAEjB,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa;IAMnD,IAAI,EAAE,IAAI,MAAM,CAEf;IAED,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,uCAAuC;IACvC,IAAI,MAAM,IAAI,WAAW,CAExB;IAEK,IAAI,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAKhD,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAmBhD,IAAI,CAAC,GAAG,EAAE,iBAAiB,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA4BxF;;;;OAIG;IACI,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,OAAO,EAAE;IA+B5D,OAAO,CAAC,cAAc;IAwBtB,oDAAoD;IACpD,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI;IAShD,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI;CAqB3C"}
|
package/build/tile.set.raster.js
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { TileSetNameParser, TileSetType, } from '@basemaps/config';
|
|
2
|
-
import { Bounds, Epsg, ImageFormat, TileMatrixSet, TileMatrixSets, VectorFormat } from '@basemaps/geo';
|
|
3
|
-
import { Config, Env, fsa, titleizeImageryName } from '@basemaps/shared';
|
|
4
|
-
import { Tiler } from '@basemaps/tiler';
|
|
5
|
-
import { TileMakerSharp } from '@basemaps/tiler-sharp';
|
|
6
|
-
import { CogTiff } from '@cogeotiff/core';
|
|
7
|
-
import { HttpHeader, LambdaHttpResponse } from '@linzjs/lambda';
|
|
8
|
-
import pLimit from 'p-limit';
|
|
9
|
-
import { NotFound, NotModified } from './routes/response.js';
|
|
10
|
-
import { TileEtag } from './routes/tile.etag.js';
|
|
11
|
-
import { St } from './source.tracer.js';
|
|
12
|
-
import { TiffCache } from './tiff.cache.js';
|
|
13
|
-
import { TileSets } from './tile.set.cache.js';
|
|
14
|
-
const LoadingQueue = pLimit(Env.getNumber(Env.TiffConcurrency, 25));
|
|
15
|
-
export const TileComposer = new TileMakerSharp(256);
|
|
16
|
-
const DefaultResizeKernel = { in: 'lanczos3', out: 'lanczos3' };
|
|
17
|
-
const DefaultBackground = { r: 0, g: 0, b: 0, alpha: 0 };
|
|
18
|
-
export function getTiffName(name) {
|
|
19
|
-
if (name.endsWith('.tif') || name.endsWith('.tiff'))
|
|
20
|
-
return name;
|
|
21
|
-
return `${name}.tiff`;
|
|
22
|
-
}
|
|
23
|
-
export class TileSetRaster {
|
|
24
|
-
constructor(name, tileMatrix) {
|
|
25
|
-
this.type = TileSetType.Raster;
|
|
26
|
-
this.components = TileSetNameParser.parse(name);
|
|
27
|
-
this.tileMatrix = tileMatrix;
|
|
28
|
-
this.tiler = new Tiler(this.tileMatrix);
|
|
29
|
-
}
|
|
30
|
-
get id() {
|
|
31
|
-
return TileSets.id(this.fullName, this.tileMatrix);
|
|
32
|
-
}
|
|
33
|
-
get fullName() {
|
|
34
|
-
return TileSetNameParser.componentsToName(this.components);
|
|
35
|
-
}
|
|
36
|
-
get title() {
|
|
37
|
-
var _a, _b;
|
|
38
|
-
return (_b = (_a = this.tileSet) === null || _a === void 0 ? void 0 : _a.title) !== null && _b !== void 0 ? _b : this.components.name;
|
|
39
|
-
}
|
|
40
|
-
get description() {
|
|
41
|
-
var _a, _b;
|
|
42
|
-
return (_b = (_a = this.tileSet) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : '';
|
|
43
|
-
}
|
|
44
|
-
get extent() {
|
|
45
|
-
var _a;
|
|
46
|
-
return (_a = this.extentOverride) !== null && _a !== void 0 ? _a : this.tileMatrix.extent;
|
|
47
|
-
}
|
|
48
|
-
/** Preferred default imagery format */
|
|
49
|
-
get format() {
|
|
50
|
-
var _a;
|
|
51
|
-
return (_a = this.tileSet.format) !== null && _a !== void 0 ? _a : ImageFormat.Webp;
|
|
52
|
-
}
|
|
53
|
-
async init(record) {
|
|
54
|
-
this.tileSet = record;
|
|
55
|
-
this.imagery = await Config.getAllImagery(this.tileSet.layers, this.tileMatrix.projection);
|
|
56
|
-
}
|
|
57
|
-
async initTiffs(tile, log) {
|
|
58
|
-
const tiffs = this.getTiffsForTile(tile, log);
|
|
59
|
-
let failed = false;
|
|
60
|
-
// Remove any tiffs that failed to load
|
|
61
|
-
const promises = tiffs.map((c) => {
|
|
62
|
-
return LoadingQueue(async () => {
|
|
63
|
-
try {
|
|
64
|
-
await c.init();
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
log.warn({ error, tiff: c.source.uri }, 'TiffLoadFailed');
|
|
68
|
-
failed = true;
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
await Promise.all(promises);
|
|
73
|
-
if (failed)
|
|
74
|
-
return tiffs.filter((f) => f.images.length > 0);
|
|
75
|
-
return tiffs;
|
|
76
|
-
}
|
|
77
|
-
async tile(req, xyz) {
|
|
78
|
-
var _a, _b;
|
|
79
|
-
if (xyz.ext === VectorFormat.MapboxVectorTiles)
|
|
80
|
-
return NotFound;
|
|
81
|
-
const tiffs = await this.initTiffs(xyz, req.log);
|
|
82
|
-
const layers = await this.tiler.tile(tiffs, xyz.x, xyz.y, xyz.z);
|
|
83
|
-
// Generate a unique hash given the full URI, the layers used and a renderId
|
|
84
|
-
const cacheKey = TileEtag.generate(layers, xyz);
|
|
85
|
-
req.set('layers', layers.length);
|
|
86
|
-
if (TileEtag.isNotModified(req, cacheKey))
|
|
87
|
-
return NotModified;
|
|
88
|
-
const res = await TileComposer.compose({
|
|
89
|
-
layers,
|
|
90
|
-
format: xyz.ext,
|
|
91
|
-
background: (_a = this.tileSet.background) !== null && _a !== void 0 ? _a : DefaultBackground,
|
|
92
|
-
resizeKernel: (_b = this.tileSet.resizeKernel) !== null && _b !== void 0 ? _b : DefaultResizeKernel,
|
|
93
|
-
metrics: req.timer,
|
|
94
|
-
});
|
|
95
|
-
req.set('layersUsed', res.layers);
|
|
96
|
-
req.set('bytes', res.buffer.byteLength);
|
|
97
|
-
const response = new LambdaHttpResponse(200, 'ok');
|
|
98
|
-
response.header(HttpHeader.ETag, cacheKey);
|
|
99
|
-
response.header(HttpHeader.CacheControl, 'public, max-age=604800');
|
|
100
|
-
response.buffer(res.buffer, 'image/' + xyz.ext);
|
|
101
|
-
return response;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Get a list of tiffs in the rendering order that is needed to render the tile
|
|
105
|
-
* @param tms tile matrix set to describe the tiling scheme
|
|
106
|
-
* @param tile tile to render
|
|
107
|
-
*/
|
|
108
|
-
getTiffsForTile(tile, log) {
|
|
109
|
-
const output = [];
|
|
110
|
-
const tileBounds = this.tileMatrix.tileToSourceBounds(tile);
|
|
111
|
-
// All zoom level config is stored as Google zoom levels
|
|
112
|
-
const filterZoom = TileMatrixSet.convertZoomLevel(tile.z, this.tileMatrix, TileMatrixSets.get(Epsg.Google));
|
|
113
|
-
for (const layer of this.tileSet.layers) {
|
|
114
|
-
if (layer.maxZoom != null && filterZoom > layer.maxZoom)
|
|
115
|
-
continue;
|
|
116
|
-
if (layer.minZoom != null && filterZoom < layer.minZoom)
|
|
117
|
-
continue;
|
|
118
|
-
const imgId = layer[this.tileMatrix.projection.code];
|
|
119
|
-
if (imgId == null) {
|
|
120
|
-
log === null || log === void 0 ? void 0 : log.warn({ layer: layer.name, projection: this.tileMatrix.projection.code }, 'Failed to lookup imagery');
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
const imagery = this.imagery.get(imgId);
|
|
124
|
-
if (imagery == null) {
|
|
125
|
-
log === null || log === void 0 ? void 0 : log.warn({ layer: layer.name, projection: this.tileMatrix.projection.code, imgId }, 'Failed to lookup imagery');
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
if (!tileBounds.intersects(Bounds.fromJson(imagery.bounds)))
|
|
129
|
-
continue;
|
|
130
|
-
for (const tiff of this.getCogsForTile(imagery, tileBounds))
|
|
131
|
-
output.push(tiff);
|
|
132
|
-
}
|
|
133
|
-
return output;
|
|
134
|
-
}
|
|
135
|
-
getCogsForTile(record, tileBounds) {
|
|
136
|
-
const output = [];
|
|
137
|
-
for (const c of record.files) {
|
|
138
|
-
if (!tileBounds.intersects(Bounds.fromJson(c)))
|
|
139
|
-
continue;
|
|
140
|
-
const tiffPath = fsa.join(record.uri, getTiffName(c.name));
|
|
141
|
-
let existing = TiffCache.get(tiffPath);
|
|
142
|
-
if (existing == null) {
|
|
143
|
-
const source = fsa.source(tiffPath);
|
|
144
|
-
if (source == null) {
|
|
145
|
-
throw new Error(`Failed to create CogSource from ${tiffPath}`);
|
|
146
|
-
}
|
|
147
|
-
St.trace(source);
|
|
148
|
-
existing = new CogTiff(source);
|
|
149
|
-
TiffCache.set(tiffPath, existing);
|
|
150
|
-
}
|
|
151
|
-
output.push(existing);
|
|
152
|
-
}
|
|
153
|
-
return output;
|
|
154
|
-
}
|
|
155
|
-
/** Look up imagery by imageryId or by image name */
|
|
156
|
-
findImagery(imgId) {
|
|
157
|
-
const existing = this.imagery.get(imgId);
|
|
158
|
-
if (existing != null)
|
|
159
|
-
return existing;
|
|
160
|
-
for (const img of this.imagery.values()) {
|
|
161
|
-
if (img.name === imgId)
|
|
162
|
-
return img;
|
|
163
|
-
}
|
|
164
|
-
return null;
|
|
165
|
-
}
|
|
166
|
-
child(imgId) {
|
|
167
|
-
var _a, _b, _c;
|
|
168
|
-
const image = this.findImagery(imgId);
|
|
169
|
-
if (image == null)
|
|
170
|
-
return null;
|
|
171
|
-
const childName = TileSetNameParser.componentsToName({ ...this.components, layer: image.name });
|
|
172
|
-
const child = new TileSetRaster(childName, this.tileMatrix);
|
|
173
|
-
// use parent data as prototype for child;
|
|
174
|
-
child.tileSet = { ...this.tileSet };
|
|
175
|
-
child.tileSet.background = undefined;
|
|
176
|
-
const title = (_b = (_a = this.tileSet) === null || _a === void 0 ? void 0 : _a.title) !== null && _b !== void 0 ? _b : (_c = this.tileSet) === null || _c === void 0 ? void 0 : _c.name;
|
|
177
|
-
child.tileSet.title = `${title} ${titleizeImageryName(image.name)}`;
|
|
178
|
-
child.extentOverride = Bounds.fromJson(image.bounds);
|
|
179
|
-
const layer = { name: image.name, minZoom: 0, maxZoom: 100 };
|
|
180
|
-
layer[this.tileMatrix.projection.code] = image.id;
|
|
181
|
-
child.tileSet.layers = [layer];
|
|
182
|
-
child.imagery = new Map();
|
|
183
|
-
child.imagery.set(image.id, image);
|
|
184
|
-
return child;
|
|
185
|
-
}
|
|
186
|
-
}
|