@basemaps/lambda-tiler 6.31.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 +21 -0
- package/build/__tests__/config.data.d.ts +6 -1
- package/build/__tests__/config.data.d.ts.map +1 -1
- package/build/__tests__/config.data.js +33 -2
- package/build/__tests__/config.data.js.map +1 -1
- package/build/__tests__/index.test.js +3 -13
- package/build/__tests__/index.test.js.map +1 -1
- package/build/__tests__/xyz.util.d.ts +7 -9
- package/build/__tests__/xyz.util.d.ts.map +1 -1
- package/build/__tests__/xyz.util.js +14 -20
- package/build/__tests__/xyz.util.js.map +1 -1
- package/build/index.d.ts +0 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +57 -26
- package/build/index.js.map +1 -1
- package/build/routes/__tests__/attribution.test.js +350 -400
- package/build/routes/__tests__/attribution.test.js.map +1 -1
- package/build/routes/__tests__/fonts.test.js +11 -5
- package/build/routes/__tests__/fonts.test.js.map +1 -1
- package/build/routes/__tests__/health.test.js +16 -13
- package/build/routes/__tests__/health.test.js.map +1 -1
- package/build/routes/__tests__/sprites.test.js +6 -0
- package/build/routes/__tests__/sprites.test.js.map +1 -1
- 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 +5 -44
- package/build/routes/__tests__/wmts.test.js.map +1 -1
- 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 +43 -81
- package/build/routes/attribution.js.map +1 -1
- package/build/routes/fonts.d.ts +1 -1
- package/build/routes/fonts.d.ts.map +1 -1
- package/build/routes/fonts.js +30 -15
- package/build/routes/fonts.js.map +1 -1
- package/build/routes/health.d.ts +3 -3
- package/build/routes/health.d.ts.map +1 -1
- package/build/routes/health.js +15 -13
- package/build/routes/health.js.map +1 -1
- package/build/routes/imagery.d.ts.map +1 -1
- package/build/routes/imagery.js +11 -10
- package/build/routes/imagery.js.map +1 -1
- 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 +16 -10
- package/build/routes/sprites.js.map +1 -1
- 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 +18 -21
- package/build/routes/tile.json.js.map +1 -1
- 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 +10 -13
- package/build/routes/tile.style.json.js.map +1 -1
- 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 +26 -35
- package/build/routes/tile.wmts.js.map +1 -1
- 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 +21 -17
- package/build/routes/tile.xyz.js.map +1 -1
- 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/{cotar.cache.d.ts → util/cotar.serve.d.ts} +3 -8
- 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} +3 -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 +1 -1
- package/build/wmts.capability.d.ts.map +1 -1
- package/dist/index.js +62 -60
- 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 +6 -6
- package/src/__tests__/config.data.ts +41 -3
- package/src/__tests__/index.test.ts +3 -19
- package/src/__tests__/xyz.util.ts +18 -21
- package/src/index.ts +66 -29
- package/src/routes/__tests__/attribution.test.ts +356 -403
- package/src/routes/__tests__/fonts.test.ts +11 -5
- 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 +5 -55
- package/src/routes/__tests__/xyz.test.ts +119 -0
- package/src/routes/attribution.ts +53 -99
- package/src/routes/fonts.ts +29 -15
- package/src/routes/health.ts +17 -16
- package/src/routes/imagery.ts +10 -9
- package/src/routes/ping.ts +8 -0
- package/src/routes/sprites.ts +16 -10
- package/src/routes/tile.json.ts +24 -18
- package/src/routes/tile.style.json.ts +15 -12
- package/src/routes/tile.wmts.ts +30 -31
- 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 +1 -1
- 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 -21
- package/build/__tests__/route.test.js.map +0 -1
- 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 -59
- package/build/__tests__/tiff.cache.test.js.map +0 -1
- 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 -49
- package/build/__tests__/tile.cache.key.test.js.map +0 -1
- 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 -72
- package/build/__tests__/tile.set.cache.test.js.map +0 -1
- 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 -12
- package/build/__tests__/tile.set.test.js.map +0 -1
- package/build/__tests__/xyz.test.d.ts.map +0 -1
- package/build/__tests__/xyz.test.js +0 -275
- package/build/__tests__/xyz.test.js.map +0 -1
- package/build/api.key.d.ts +0 -2
- package/build/api.key.d.ts.map +0 -1
- package/build/api.key.js +0 -24
- package/build/api.key.js.map +0 -1
- package/build/cli/dump.d.ts +0 -2
- package/build/cli/dump.d.ts.map +0 -1
- package/build/cli/dump.js +0 -48
- package/build/cli/dump.js.map +0 -1
- 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 -40
- package/build/cli/tile.set.local.js.map +0 -1
- package/build/cotar.cache.d.ts.map +0 -1
- package/build/cotar.cache.js +0 -50
- package/build/cotar.cache.js.map +0 -1
- package/build/router.d.ts +0 -15
- package/build/router.d.ts.map +0 -1
- package/build/router.js +0 -50
- package/build/router.js.map +0 -1
- package/build/routes/api.d.ts +0 -4
- package/build/routes/api.d.ts.map +0 -1
- package/build/routes/api.js +0 -14
- package/build/routes/api.js.map +0 -1
- 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 -88
- package/build/routes/esri/rest.js.map +0 -1
- package/build/routes/response.d.ts +0 -4
- package/build/routes/response.d.ts.map +0 -1
- package/build/routes/response.js +0 -4
- package/build/routes/response.js.map +0 -1
- 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 -30
- package/build/routes/tile.etag.js.map +0 -1
- package/build/routes/tile.js +0 -28
- package/build/routes/tile.js.map +0 -1
- package/build/source.tracer.d.ts.map +0 -1
- package/build/source.tracer.js.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 -46
- package/build/tiff.cache.js.map +0 -1
- package/build/tile.set.cache.d.ts +0 -20
- package/build/tile.set.cache.d.ts.map +0 -1
- package/build/tile.set.cache.js +0 -72
- package/build/tile.set.cache.js.map +0 -1
- package/build/tile.set.d.ts +0 -4
- package/build/tile.set.d.ts.map +0 -1
- package/build/tile.set.js +0 -2
- package/build/tile.set.js.map +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 -189
- package/build/tile.set.raster.js.map +0 -1
- package/build/tile.set.vector.d.ts +0 -18
- package/build/tile.set.vector.d.ts.map +0 -1
- package/build/tile.set.vector.js +0 -54
- package/build/tile.set.vector.js.map +0 -1
- package/build/validate.d.ts +0 -16
- package/build/validate.d.ts.map +0 -1
- package/build/validate.js +0 -32
- package/build/validate.js.map +0 -1
- 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 -80
- package/src/__tests__/tile.set.test.ts +0 -12
- package/src/__tests__/xyz.test.ts +0 -318
- 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/cotar.cache.ts +0 -54
- package/src/router.ts +0 -58
- package/src/routes/api.ts +0 -15
- 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 -84
- package/src/tile.set.raster.ts +0 -230
- package/src/tile.set.ts +0 -4
- package/src/tile.set.vector.ts +0 -61
- package/src/validate.ts +0 -32
|
@@ -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,MAA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D;IACpD,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI;IAShD,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI;CAuB3C"}
|
package/build/tile.set.raster.js
DELETED
|
@@ -1,189 +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, _d;
|
|
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 = (_d = image.title) !== null && _d !== void 0 ? _d : `${title} ${titleizeImageryName(image.name)}`;
|
|
178
|
-
child.extentOverride = Bounds.fromJson(image.bounds);
|
|
179
|
-
if (image.category)
|
|
180
|
-
child.tileSet.category = image.category;
|
|
181
|
-
const layer = { name: image.name, minZoom: 0, maxZoom: 100 };
|
|
182
|
-
layer[this.tileMatrix.projection.code] = image.id;
|
|
183
|
-
child.tileSet.layers = [layer];
|
|
184
|
-
child.imagery = new Map();
|
|
185
|
-
child.imagery.set(image.id, image);
|
|
186
|
-
return child;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
//# sourceMappingURL=tile.set.raster.js.map
|
|
@@ -1 +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,KAAK,CAAC,MAAM,CAAC,CAAC;QAErD,IAAI,KAAK,CAAC,QAAQ;YAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAE5D,MAAM,KAAK,GAAgB,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;QAC1E,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC;QAElD,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,CAAC;QAC/B,KAAK,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;QAC1B,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QAEnC,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ConfigTileSetVector, TileSetNameComponents, TileSetType } from '@basemaps/config';
|
|
2
|
-
import { TileMatrixSet, VectorFormat } from '@basemaps/geo';
|
|
3
|
-
import { TileDataXyz } from '@basemaps/shared';
|
|
4
|
-
import { LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
|
|
5
|
-
export declare class TileSetVector {
|
|
6
|
-
type: TileSetType.Vector;
|
|
7
|
-
components: TileSetNameComponents;
|
|
8
|
-
tileMatrix: TileMatrixSet;
|
|
9
|
-
tileSet: ConfigTileSetVector;
|
|
10
|
-
constructor(name: string, tileMatrix: TileMatrixSet);
|
|
11
|
-
init(record: ConfigTileSetVector): Promise<void>;
|
|
12
|
-
/** What format does tile set use */
|
|
13
|
-
get format(): VectorFormat;
|
|
14
|
-
get id(): string;
|
|
15
|
-
get fullName(): string;
|
|
16
|
-
tile(req: LambdaHttpRequest, xyz: TileDataXyz): Promise<LambdaHttpResponse>;
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=tile.set.vector.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tile.set.vector.d.ts","sourceRoot":"","sources":["../src/tile.set.vector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAqB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC9G,OAAO,EAAa,aAAa,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAc,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAKnF,qBAAa,aAAa;IACxB,IAAI,EAAE,WAAW,CAAC,MAAM,CAAsB;IAC9C,UAAU,EAAE,qBAAqB,CAAC;IAClC,UAAU,EAAE,aAAa,CAAC;IAC1B,OAAO,EAAE,mBAAmB,CAAC;gBACjB,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa;IAK7C,IAAI,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAItD,oCAAoC;IACpC,IAAI,MAAM,IAAI,YAAY,CAEzB;IAED,IAAI,EAAE,IAAI,MAAM,CAEf;IAED,IAAI,QAAQ,IAAI,MAAM,CAErB;IAEK,IAAI,CAAC,GAAG,EAAE,iBAAiB,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAyBlF"}
|
package/build/tile.set.vector.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { TileSetNameParser, TileSetType } from '@basemaps/config';
|
|
2
|
-
import { GoogleTms, VectorFormat } from '@basemaps/geo';
|
|
3
|
-
import { HttpHeader, LambdaHttpResponse } from '@linzjs/lambda';
|
|
4
|
-
import { CotarCache } from './cotar.cache.js';
|
|
5
|
-
import { NotFound } from './routes/response.js';
|
|
6
|
-
import { TileSets } from './tile.set.cache.js';
|
|
7
|
-
export class TileSetVector {
|
|
8
|
-
constructor(name, tileMatrix) {
|
|
9
|
-
this.type = TileSetType.Vector;
|
|
10
|
-
this.components = TileSetNameParser.parse(name);
|
|
11
|
-
this.tileMatrix = tileMatrix;
|
|
12
|
-
}
|
|
13
|
-
async init(record) {
|
|
14
|
-
this.tileSet = record;
|
|
15
|
-
}
|
|
16
|
-
/** What format does tile set use */
|
|
17
|
-
get format() {
|
|
18
|
-
return VectorFormat.MapboxVectorTiles;
|
|
19
|
-
}
|
|
20
|
-
get id() {
|
|
21
|
-
return TileSets.id(this.fullName, this.tileMatrix);
|
|
22
|
-
}
|
|
23
|
-
get fullName() {
|
|
24
|
-
return TileSetNameParser.componentsToName(this.components);
|
|
25
|
-
}
|
|
26
|
-
async tile(req, xyz) {
|
|
27
|
-
if (xyz.ext !== VectorFormat.MapboxVectorTiles)
|
|
28
|
-
return NotFound;
|
|
29
|
-
if (xyz.tileMatrix.identifier !== GoogleTms.identifier)
|
|
30
|
-
return NotFound;
|
|
31
|
-
if (this.tileSet.layers.length > 1)
|
|
32
|
-
return new LambdaHttpResponse(500, 'Too many layers in tileset');
|
|
33
|
-
const [layer] = this.tileSet.layers;
|
|
34
|
-
if (layer[3857] == null)
|
|
35
|
-
return new LambdaHttpResponse(500, 'Layer url not found from tileset Config');
|
|
36
|
-
req.timer.start('cotar:load');
|
|
37
|
-
const cotar = await CotarCache.get(layer[3857]);
|
|
38
|
-
if (cotar == null)
|
|
39
|
-
return new LambdaHttpResponse(500, 'Failed to load VectorTiles');
|
|
40
|
-
req.timer.end('cotar:load');
|
|
41
|
-
// Flip Y coordinate because MBTiles files are TMS.
|
|
42
|
-
const y = (1 << xyz.z) - 1 - xyz.y;
|
|
43
|
-
req.timer.start('cotar:tile');
|
|
44
|
-
const tile = await cotar.get(`tiles/${xyz.z}/${xyz.x}/${y}.pbf.gz`);
|
|
45
|
-
if (tile == null)
|
|
46
|
-
return NotFound;
|
|
47
|
-
req.timer.end('cotar:tile');
|
|
48
|
-
const response = new LambdaHttpResponse(200, 'Ok');
|
|
49
|
-
response.buffer(Buffer.from(tile), 'application/x-protobuf');
|
|
50
|
-
response.header(HttpHeader.ContentEncoding, 'gzip');
|
|
51
|
-
return response;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=tile.set.vector.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tile.set.vector.js","sourceRoot":"","sources":["../src/tile.set.vector.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,iBAAiB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC9G,OAAO,EAAE,SAAS,EAAiB,YAAY,EAAE,MAAM,eAAe,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAqB,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,MAAM,OAAO,aAAa;IAKxB,YAAY,IAAY,EAAE,UAAyB;QAJnD,SAAI,GAAuB,WAAW,CAAC,MAAM,CAAC;QAK5C,IAAI,CAAC,UAAU,GAAG,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAChD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,MAA2B;QACpC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,oCAAoC;IACpC,IAAI,MAAM;QACR,OAAO,YAAY,CAAC,iBAAiB,CAAC;IACxC,CAAC;IAED,IAAI,EAAE;QACJ,OAAO,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,iBAAiB,CA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,IAAI,IAAI,IAAI,IAAI;YAAE,OAAO,QAAQ,CAAC;QAClC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAE5B,MAAM,QAAQ,GAAG,IAAI,kBAAkB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACnD,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,wBAAwB,CAAC,CAAC;QAC7D,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;QACpD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
|
package/build/validate.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { TileDataXyz } from '@basemaps/shared';
|
|
2
|
-
import { LambdaHttpRequest } from '@linzjs/lambda';
|
|
3
|
-
export declare const ValidateTilePath: {
|
|
4
|
-
/**
|
|
5
|
-
* Validate that the tile request is somewhat valid
|
|
6
|
-
* - Valid projection
|
|
7
|
-
* - Valid range
|
|
8
|
-
*
|
|
9
|
-
* @throws LambdaHttpResponse for tile requests that are not valid
|
|
10
|
-
*
|
|
11
|
-
* @param req request to validate
|
|
12
|
-
* @param xyzData
|
|
13
|
-
*/
|
|
14
|
-
validate(req: LambdaHttpRequest, xyzData: TileDataXyz): void;
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=validate.d.ts.map
|
package/build/validate.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAsB,MAAM,gBAAgB,CAAC;AAEvE,eAAO,MAAM,gBAAgB;IAC3B;;;;;;;;;OASG;kBACW,iBAAiB,WAAW,WAAW,GAAG,IAAI;CAiB7D,CAAC"}
|
package/build/validate.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Projection } from '@basemaps/shared';
|
|
2
|
-
import { LambdaHttpResponse } from '@linzjs/lambda';
|
|
3
|
-
export const ValidateTilePath = {
|
|
4
|
-
/**
|
|
5
|
-
* Validate that the tile request is somewhat valid
|
|
6
|
-
* - Valid projection
|
|
7
|
-
* - Valid range
|
|
8
|
-
*
|
|
9
|
-
* @throws LambdaHttpResponse for tile requests that are not valid
|
|
10
|
-
*
|
|
11
|
-
* @param req request to validate
|
|
12
|
-
* @param xyzData
|
|
13
|
-
*/
|
|
14
|
-
validate(req, xyzData) {
|
|
15
|
-
const { tileMatrix, x, y, z, ext } = xyzData;
|
|
16
|
-
req.set('xyz', { x, y, z });
|
|
17
|
-
req.set('projection', tileMatrix.projection.code);
|
|
18
|
-
req.set('tileMatrix', tileMatrix.identifier);
|
|
19
|
-
req.set('extension', ext);
|
|
20
|
-
req.set('tileSet', xyzData.name);
|
|
21
|
-
if (z > tileMatrix.maxZoom || z < 0)
|
|
22
|
-
throw new LambdaHttpResponse(404, `Zoom not found: ${z}`);
|
|
23
|
-
const zoom = tileMatrix.zooms[z];
|
|
24
|
-
if (x < 0 || x > zoom.matrixWidth)
|
|
25
|
-
throw new LambdaHttpResponse(404, `X not found: ${x}`);
|
|
26
|
-
if (y < 0 || y > zoom.matrixHeight)
|
|
27
|
-
throw new LambdaHttpResponse(404, `Y not found: ${y}`);
|
|
28
|
-
const latLon = Projection.tileCenterToLatLon(tileMatrix, xyzData);
|
|
29
|
-
req.set('location', latLon);
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
//# sourceMappingURL=validate.js.map
|
package/build/validate.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAe,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAqB,kBAAkB,EAAE,MAAM,gBAAgB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C;IAC9B,CAAC;CACF,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Router } from '../router.js';
|
|
2
|
-
import o from 'ospec';
|
|
3
|
-
import { LambdaHttpRequest } from '@linzjs/lambda';
|
|
4
|
-
|
|
5
|
-
o.spec('Router', () => {
|
|
6
|
-
function request(p: string): LambdaHttpRequest {
|
|
7
|
-
return { path: p } as any;
|
|
8
|
-
}
|
|
9
|
-
o('should decode UTF8 correctly', () => {
|
|
10
|
-
o(Router.action(request('/v1/version'))).deepEquals({ version: 'v1', name: 'version', rest: [] });
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
o('should ignore encoded paths', () => {
|
|
14
|
-
o(Router.action(request('/v1/version%2fbar'))).deepEquals({ version: 'v1', name: 'version/bar', rest: [] });
|
|
15
|
-
o(Router.action(request('/v1/tiles/%C5%8Dtorohanga%2fbar'))).deepEquals({
|
|
16
|
-
version: 'v1',
|
|
17
|
-
name: 'tiles',
|
|
18
|
-
rest: ['ōtorohanga/bar'],
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
const uri = encodeURI('/v1/🌈/🦄.tiff');
|
|
22
|
-
o(Router.action(request(uri))).deepEquals({ version: 'v1', name: '🌈', rest: ['🦄.tiff'] });
|
|
23
|
-
});
|
|
24
|
-
});
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { SourceMemory } from '@chunkd/core';
|
|
2
|
-
import { CogTiff } from '@cogeotiff/core';
|
|
3
|
-
import o from 'ospec';
|
|
4
|
-
import { TiffCache } from '../tiff.cache.js';
|
|
5
|
-
|
|
6
|
-
/** convert number to megabytes */
|
|
7
|
-
const MegaBytes = (num: number): number => num * 1024 * 1024;
|
|
8
|
-
|
|
9
|
-
o.spec('TiffCache', () => {
|
|
10
|
-
o.beforeEach(() => TiffCache.clear());
|
|
11
|
-
|
|
12
|
-
o('should cache items', () => {
|
|
13
|
-
const source = new SourceMemory('fake', Buffer.from('foo'));
|
|
14
|
-
const tiff = new CogTiff(source);
|
|
15
|
-
|
|
16
|
-
o(TiffCache.get('fake')).equals(null);
|
|
17
|
-
TiffCache.set('fake', tiff);
|
|
18
|
-
o(TiffCache.get('fake')?.source.uri).equals(tiff.source.uri);
|
|
19
|
-
|
|
20
|
-
TiffCache.check();
|
|
21
|
-
o(TiffCache.get('fake')?.source.uri).equals(tiff.source.uri);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
o('should expire cached object if size gets too large', () => {
|
|
25
|
-
const source = new SourceMemory('fake', Buffer.from('foo'));
|
|
26
|
-
const sourceB = new SourceMemory('fakeB', Buffer.from('foo'));
|
|
27
|
-
|
|
28
|
-
// Override chunk size to say there is 500 mb of items
|
|
29
|
-
source.chunkSize = MegaBytes(257);
|
|
30
|
-
sourceB.chunkSize = MegaBytes(257);
|
|
31
|
-
|
|
32
|
-
const tiff = new CogTiff(source);
|
|
33
|
-
const tiffB = new CogTiff(sourceB);
|
|
34
|
-
|
|
35
|
-
o(TiffCache.get('fake')).equals(null);
|
|
36
|
-
|
|
37
|
-
TiffCache.set('fake', tiff);
|
|
38
|
-
o(TiffCache.get('fake')?.source.uri).equals(tiff.source.uri);
|
|
39
|
-
|
|
40
|
-
TiffCache.check();
|
|
41
|
-
o(TiffCache.cacheA.get('fake')?.source.uri).equals(undefined);
|
|
42
|
-
o(TiffCache.cacheB.get('fake')?.source.uri).equals(tiff.source.uri);
|
|
43
|
-
|
|
44
|
-
// Should evict the cache
|
|
45
|
-
TiffCache.set('fakeB', tiffB);
|
|
46
|
-
TiffCache.check();
|
|
47
|
-
|
|
48
|
-
o(TiffCache.cacheA.get('fake')?.source.uri).equals(undefined);
|
|
49
|
-
o(TiffCache.cacheB.get('fake')?.source.uri).equals(undefined);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
o('should allow multiple items in the cache', () => {
|
|
53
|
-
const source = new SourceMemory('fake', Buffer.from('foo'));
|
|
54
|
-
const tiff = new CogTiff(source);
|
|
55
|
-
|
|
56
|
-
TiffCache.set('fake', tiff);
|
|
57
|
-
const oneMb = MegaBytes(1);
|
|
58
|
-
source.chunkSize = oneMb;
|
|
59
|
-
|
|
60
|
-
for (let i = 1; i < 256; i++) {
|
|
61
|
-
o(TiffCache.currentSize).equals(i * oneMb);
|
|
62
|
-
source.chunks.set(i, source.chunks.get(0)!);
|
|
63
|
-
}
|
|
64
|
-
// should not have overflown
|
|
65
|
-
TiffCache.check();
|
|
66
|
-
o(TiffCache.cacheA.size).equals(1);
|
|
67
|
-
// Overflow the cache
|
|
68
|
-
source.chunks.set(257, source.chunks.get(0)!);
|
|
69
|
-
|
|
70
|
-
TiffCache.check();
|
|
71
|
-
o(TiffCache.cacheA.size).equals(0);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { GoogleTms, Nztm2000Tms, ImageFormat } from '@basemaps/geo';
|
|
2
|
-
import { TileDataXyz, TileType } from '@basemaps/shared';
|
|
3
|
-
import { TestTiff } from '@basemaps/test';
|
|
4
|
-
import { Composition } from '@basemaps/tiler';
|
|
5
|
-
import o from 'ospec';
|
|
6
|
-
import { TileEtag } from '../routes/tile.etag.js';
|
|
7
|
-
|
|
8
|
-
o.spec('TileCacheKey', () => {
|
|
9
|
-
const oldRenderId = TileEtag.RenderId;
|
|
10
|
-
|
|
11
|
-
const xyzData: TileDataXyz = {
|
|
12
|
-
x: 0,
|
|
13
|
-
y: 0,
|
|
14
|
-
z: 0,
|
|
15
|
-
tileMatrix: GoogleTms,
|
|
16
|
-
name: 'foo',
|
|
17
|
-
ext: ImageFormat.Png,
|
|
18
|
-
type: TileType.Tile,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
o.afterEach(() => {
|
|
22
|
-
TileEtag.RenderId = oldRenderId;
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
o('should generate a cachekey', async () => {
|
|
26
|
-
const tiff = await TestTiff.Google.init();
|
|
27
|
-
const comp: Composition = {
|
|
28
|
-
tiff,
|
|
29
|
-
source: {
|
|
30
|
-
x: 0,
|
|
31
|
-
y: 0,
|
|
32
|
-
imageId: 0,
|
|
33
|
-
width: 512,
|
|
34
|
-
height: 512,
|
|
35
|
-
},
|
|
36
|
-
x: 5,
|
|
37
|
-
y: 5,
|
|
38
|
-
};
|
|
39
|
-
const firstKey = TileEtag.generate([comp], xyzData);
|
|
40
|
-
o(firstKey).equals('8eJ7XnUeEGBI2d7mfAaK5o8KbUc0+CVaIoPzqCvkoDk=');
|
|
41
|
-
|
|
42
|
-
// Different layers should generate different keys
|
|
43
|
-
o(TileEtag.generate([comp, comp], xyzData)).notEquals(firstKey);
|
|
44
|
-
|
|
45
|
-
// Different projections should generate different keys
|
|
46
|
-
xyzData.tileMatrix = Nztm2000Tms;
|
|
47
|
-
o(TileEtag.generate([comp], xyzData)).notEquals(firstKey);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
o('should change if the renderId changes', () => {
|
|
51
|
-
const keyA = TileEtag.generate([], { tileMatrix: {} } as any);
|
|
52
|
-
TileEtag.RenderId = 2;
|
|
53
|
-
const KeyB = TileEtag.generate([], { tileMatrix: {} } as any);
|
|
54
|
-
o(keyA).notEquals(KeyB);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { ConfigImagery, ConfigTileSetRaster, TileSetType } from '@basemaps/config';
|
|
2
|
-
import { GoogleTms } from '@basemaps/geo';
|
|
3
|
-
import o from 'ospec';
|
|
4
|
-
import sinon from 'sinon';
|
|
5
|
-
import { TileSets } from '../tile.set.cache.js';
|
|
6
|
-
import { TileSetRaster } from '../tile.set.raster.js';
|
|
7
|
-
const sandbox = sinon.createSandbox();
|
|
8
|
-
o.spec('TileSetCache', () => {
|
|
9
|
-
const imageOne = {
|
|
10
|
-
id: 'im_id1',
|
|
11
|
-
name: 'tasman_rural_2018-19_0-3m',
|
|
12
|
-
bounds: { x: 123, y: 456, width: 200, height: 300 },
|
|
13
|
-
files: [{ name: 'foo', x: 123, y: 456, width: 200, height: 300 }],
|
|
14
|
-
uri: 's3://foo/bar',
|
|
15
|
-
} as ConfigImagery;
|
|
16
|
-
|
|
17
|
-
const imgMap = new Map<string, ConfigImagery>();
|
|
18
|
-
imgMap.set(imageOne.id, imageOne);
|
|
19
|
-
|
|
20
|
-
o.afterEach(() => {
|
|
21
|
-
TileSets.cache.clear();
|
|
22
|
-
sandbox.restore();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
o.spec('loadTileSet', () => {
|
|
26
|
-
o('load individual set', async () => {
|
|
27
|
-
TileSets.add(new TileSetRaster('aerial@head', GoogleTms));
|
|
28
|
-
|
|
29
|
-
const parentTileSet = await TileSets.get('aerial@head', GoogleTms);
|
|
30
|
-
if (parentTileSet == null || parentTileSet.type === TileSetType.Vector) throw new Error('null parentTileSet');
|
|
31
|
-
parentTileSet.imagery = imgMap;
|
|
32
|
-
parentTileSet.tileSet = {
|
|
33
|
-
name: 'parent',
|
|
34
|
-
title: 'parent aerial title',
|
|
35
|
-
background: { r: 200, g: 50, b: 100, alpha: 0.5 },
|
|
36
|
-
} as ConfigTileSetRaster;
|
|
37
|
-
|
|
38
|
-
const subTileSet = await TileSets.get('aerial@head:tasman_rural_2018-19_0-3m', GoogleTms);
|
|
39
|
-
if (subTileSet == null || subTileSet.type === TileSetType.Vector) throw new Error('null subTileSet');
|
|
40
|
-
|
|
41
|
-
o(subTileSet.title).equals('parent aerial title Tasman rural 2018-19 0.3m');
|
|
42
|
-
o(subTileSet.fullName).equals('aerial@head:tasman_rural_2018-19_0-3m');
|
|
43
|
-
o([...subTileSet.imagery.values()]).deepEquals([imageOne]);
|
|
44
|
-
const [firstLayer] = subTileSet.tileSet.layers;
|
|
45
|
-
o(firstLayer).deepEquals({
|
|
46
|
-
name: firstLayer.name,
|
|
47
|
-
[3857]: 'im_id1',
|
|
48
|
-
minZoom: 0,
|
|
49
|
-
maxZoom: 100,
|
|
50
|
-
});
|
|
51
|
-
o(subTileSet.tileSet.background).equals(undefined);
|
|
52
|
-
|
|
53
|
-
o(parentTileSet.tileSet.background).deepEquals({ r: 200, g: 50, b: 100, alpha: 0.5 });
|
|
54
|
-
|
|
55
|
-
const noTiffs = subTileSet.getTiffsForTile({ x: 0, y: 0, z: 1 });
|
|
56
|
-
o(noTiffs).deepEquals([]);
|
|
57
|
-
|
|
58
|
-
const aTiff = subTileSet.getTiffsForTile({ x: 0, y: 0, z: 0 });
|
|
59
|
-
o(aTiff.length).equals(1);
|
|
60
|
-
o(aTiff[0].source.uri).equals('s3://foo/bar/foo.tiff');
|
|
61
|
-
|
|
62
|
-
TileSets.cache.delete(subTileSet.id);
|
|
63
|
-
delete parentTileSet.tileSet.title;
|
|
64
|
-
const subTileSetB = await TileSets.get('aerial@head:tasman_rural_2018-19_0-3m', GoogleTms);
|
|
65
|
-
if (subTileSetB == null || subTileSetB.type === TileSetType.Vector) throw new Error('null subTileSetB');
|
|
66
|
-
o(subTileSetB.title).equals('parent Tasman rural 2018-19 0.3m');
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
o('should not throw if child does not exist', async () => {
|
|
70
|
-
TileSets.add(new TileSetRaster('aerial@head', GoogleTms));
|
|
71
|
-
|
|
72
|
-
const parentTileSet = await TileSets.get('aerial@head', GoogleTms);
|
|
73
|
-
if (parentTileSet == null || parentTileSet.type === TileSetType.Vector) throw new Error('null parentTileSet');
|
|
74
|
-
parentTileSet.imagery = imgMap;
|
|
75
|
-
|
|
76
|
-
const subTileSet = await TileSets.get('aerial@head:fake', GoogleTms);
|
|
77
|
-
o(subTileSet).equals(null);
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { GoogleTms, Nztm2000Tms } from '@basemaps/geo';
|
|
2
|
-
import o from 'ospec';
|
|
3
|
-
import { TileSetRaster } from '../tile.set.raster.js';
|
|
4
|
-
|
|
5
|
-
o.spec('tile.set', () => {
|
|
6
|
-
o('extent', () => {
|
|
7
|
-
o(new TileSetRaster('google', GoogleTms).extent.toBbox()).deepEquals([
|
|
8
|
-
-20037508.3427892, -20037508.3427892, 20037508.3427892, 20037508.3427892,
|
|
9
|
-
]);
|
|
10
|
-
o(new TileSetRaster('nztm', Nztm2000Tms).extent.toBbox()).deepEquals([274000, 3087000, 3327000, 7173000]);
|
|
11
|
-
});
|
|
12
|
-
});
|