@basemaps/lambda-tiler 7.0.0 → 7.1.1
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 +40 -0
- package/build/__tests__/config.data.d.ts +0 -1
- package/build/__tests__/config.data.js +2 -6
- package/build/__tests__/config.data.js.map +1 -1
- package/build/__tests__/index.test.d.ts +0 -1
- package/build/__tests__/index.test.js +28 -27
- package/build/__tests__/index.test.js.map +1 -1
- package/build/__tests__/tile.style.json.test.d.ts +0 -1
- package/build/__tests__/tile.style.json.test.js +38 -37
- package/build/__tests__/tile.style.json.test.js.map +1 -1
- package/build/__tests__/wmts.capability.test.d.ts +0 -1
- package/build/__tests__/wmts.capability.test.js +111 -122
- package/build/__tests__/wmts.capability.test.js.map +1 -1
- package/build/__tests__/xyz.util.d.ts +0 -1
- package/build/cli/render.preview.d.ts +0 -1
- package/build/cli/render.preview.js +13 -9
- package/build/cli/render.preview.js.map +1 -1
- package/build/cli/render.tile.d.ts +0 -1
- package/build/cli/render.tile.js +25 -17
- package/build/cli/render.tile.js.map +1 -1
- package/build/index.d.ts +0 -1
- package/build/index.js +24 -20
- package/build/index.js.map +1 -1
- package/build/routes/__tests__/attribution.test.d.ts +0 -1
- package/build/routes/__tests__/attribution.test.js +38 -37
- package/build/routes/__tests__/attribution.test.js.map +1 -1
- package/build/routes/__tests__/fonts.test.d.ts +0 -1
- package/build/routes/__tests__/fonts.test.js +61 -63
- package/build/routes/__tests__/fonts.test.js.map +1 -1
- package/build/routes/__tests__/health.test.d.ts +0 -1
- package/build/routes/__tests__/health.test.js +16 -16
- package/build/routes/__tests__/health.test.js.map +1 -1
- package/build/routes/__tests__/imagery.test.d.ts +0 -1
- package/build/routes/__tests__/imagery.test.js +10 -9
- package/build/routes/__tests__/imagery.test.js.map +1 -1
- package/build/routes/__tests__/memory.fs.d.ts +2 -3
- package/build/routes/__tests__/preview.index.test.d.ts +0 -1
- package/build/routes/__tests__/preview.index.test.js +88 -42
- package/build/routes/__tests__/preview.index.test.js.map +1 -1
- package/build/routes/__tests__/sprites.test.d.ts +0 -1
- package/build/routes/__tests__/sprites.test.js +34 -34
- package/build/routes/__tests__/sprites.test.js.map +1 -1
- package/build/routes/__tests__/tile.json.test.d.ts +0 -1
- package/build/routes/__tests__/tile.json.test.js +45 -51
- package/build/routes/__tests__/tile.json.test.js.map +1 -1
- package/build/routes/__tests__/tile.style.json.test.d.ts +0 -1
- package/build/routes/__tests__/tile.style.json.test.js +49 -50
- package/build/routes/__tests__/tile.style.json.test.js.map +1 -1
- package/build/routes/__tests__/wmts.test.d.ts +0 -1
- package/build/routes/__tests__/wmts.test.js +27 -20
- package/build/routes/__tests__/wmts.test.js.map +1 -1
- package/build/routes/__tests__/xyz.test.d.ts +0 -1
- package/build/routes/__tests__/xyz.test.js +97 -49
- package/build/routes/__tests__/xyz.test.js.map +1 -1
- package/build/routes/attribution.d.ts +1 -1
- package/build/routes/attribution.js +4 -5
- package/build/routes/attribution.js.map +1 -1
- package/build/routes/config.d.ts +0 -1
- package/build/routes/config.js +1 -2
- package/build/routes/config.js.map +1 -1
- package/build/routes/fonts.d.ts +0 -1
- package/build/routes/fonts.js +2 -3
- package/build/routes/fonts.js.map +1 -1
- package/build/routes/health.d.ts +1 -2
- package/build/routes/health.js +5 -15
- package/build/routes/health.js.map +1 -1
- package/build/routes/imagery.d.ts +0 -1
- package/build/routes/imagery.js +1 -1
- package/build/routes/imagery.js.map +1 -1
- package/build/routes/ping.d.ts +0 -1
- package/build/routes/ping.js +1 -1
- package/build/routes/ping.js.map +1 -1
- package/build/routes/preview.d.ts +6 -5
- package/build/routes/preview.index.d.ts +0 -1
- package/build/routes/preview.index.js +6 -5
- package/build/routes/preview.index.js.map +1 -1
- package/build/routes/preview.js +35 -10
- package/build/routes/preview.js.map +1 -1
- package/build/routes/sprites.d.ts +0 -1
- package/build/routes/sprites.js +2 -4
- package/build/routes/sprites.js.map +1 -1
- package/build/routes/tile.json.d.ts +0 -1
- package/build/routes/tile.json.js +10 -5
- package/build/routes/tile.json.js.map +1 -1
- package/build/routes/tile.style.json.d.ts +1 -1
- package/build/routes/tile.style.json.js +79 -16
- package/build/routes/tile.style.json.js.map +1 -1
- package/build/routes/tile.wmts.d.ts +0 -1
- package/build/routes/tile.wmts.js +8 -9
- package/build/routes/tile.wmts.js.map +1 -1
- package/build/routes/tile.xyz.d.ts +0 -1
- package/build/routes/tile.xyz.js.map +1 -1
- package/build/routes/tile.xyz.raster.d.ts +7 -8
- package/build/routes/tile.xyz.raster.js +22 -15
- package/build/routes/tile.xyz.raster.js.map +1 -1
- package/build/routes/tile.xyz.vector.d.ts +0 -1
- package/build/routes/tile.xyz.vector.js +4 -3
- package/build/routes/tile.xyz.vector.js.map +1 -1
- package/build/routes/version.d.ts +0 -1
- package/build/routes/version.js +3 -4
- package/build/routes/version.js.map +1 -1
- package/build/util/__test__/config.loader.test.d.ts +0 -1
- package/build/util/__test__/config.loader.test.js +35 -34
- package/build/util/__test__/config.loader.test.js.map +1 -1
- package/build/util/__test__/filter.test.d.ts +0 -1
- package/build/util/__test__/filter.test.js +17 -16
- package/build/util/__test__/filter.test.js.map +1 -1
- package/build/util/__test__/validate.test.d.ts +0 -1
- package/build/util/__test__/validate.test.js +26 -43
- package/build/util/__test__/validate.test.js.map +1 -1
- package/build/util/assets.provider.d.ts +5 -5
- package/build/util/assets.provider.js +8 -8
- package/build/util/assets.provider.js.map +1 -1
- package/build/util/config.cache.d.ts +2 -2
- package/build/util/config.cache.js +14 -3
- package/build/util/config.cache.js.map +1 -1
- package/build/util/config.loader.d.ts +0 -1
- package/build/util/config.loader.js +11 -12
- package/build/util/config.loader.js.map +1 -1
- package/build/util/cotar.serve.d.ts +3 -3
- package/build/util/cotar.serve.js +2 -2
- package/build/util/cotar.serve.js.map +1 -1
- package/build/util/etag.d.ts +0 -1
- package/build/util/etag.js.map +1 -1
- package/build/util/filter.d.ts +0 -1
- package/build/util/filter.js +4 -5
- package/build/util/filter.js.map +1 -1
- package/build/util/response.d.ts +0 -1
- package/build/util/source.cache.d.ts +8 -9
- package/build/util/source.cache.js +27 -24
- package/build/util/source.cache.js.map +1 -1
- package/build/util/swapping.lru.d.ts +0 -1
- package/build/util/swapping.lru.js +48 -7
- package/build/util/swapping.lru.js.map +1 -1
- package/build/util/validate.d.ts +17 -5
- package/build/util/validate.js +51 -15
- package/build/util/validate.js.map +1 -1
- package/build/wmts.capability.d.ts +1 -2
- package/build/wmts.capability.js +81 -12
- package/build/wmts.capability.js.map +1 -1
- package/bundle.sh +2 -2
- package/package.json +16 -18
- package/scripts/create.deployment.package.mjs +4 -11
- package/src/__tests__/config.data.ts +2 -6
- package/src/__tests__/index.test.ts +29 -27
- package/src/__tests__/tile.style.json.test.ts +40 -37
- package/src/__tests__/wmts.capability.test.ts +139 -120
- package/src/cli/render.preview.ts +14 -9
- package/src/cli/render.tile.ts +27 -18
- package/src/index.ts +28 -23
- package/src/routes/__tests__/attribution.test.ts +40 -37
- package/src/routes/__tests__/fonts.test.ts +68 -64
- package/src/routes/__tests__/health.test.ts +18 -17
- package/src/routes/__tests__/imagery.test.ts +11 -9
- package/src/routes/__tests__/preview.index.test.ts +114 -40
- package/src/routes/__tests__/sprites.test.ts +39 -34
- package/src/routes/__tests__/tile.json.test.ts +41 -39
- package/src/routes/__tests__/tile.style.json.test.ts +49 -46
- package/src/routes/__tests__/wmts.test.ts +28 -20
- package/src/routes/__tests__/xyz.test.ts +134 -55
- package/src/routes/attribution.ts +2 -2
- package/src/routes/config.ts +1 -0
- package/src/routes/fonts.ts +3 -3
- package/src/routes/health.ts +7 -13
- package/src/routes/imagery.ts +2 -1
- package/src/routes/ping.ts +1 -1
- package/src/routes/preview.index.ts +9 -5
- package/src/routes/preview.ts +44 -15
- package/src/routes/sprites.ts +4 -5
- package/src/routes/tile.json.ts +9 -2
- package/src/routes/tile.style.json.ts +89 -13
- package/src/routes/tile.wmts.ts +4 -3
- package/src/routes/tile.xyz.raster.ts +30 -23
- package/src/routes/tile.xyz.ts +1 -0
- package/src/routes/tile.xyz.vector.ts +5 -3
- package/src/routes/version.ts +3 -3
- package/src/util/__test__/config.loader.test.ts +38 -34
- package/src/util/__test__/filter.test.ts +19 -16
- package/src/util/__test__/validate.test.ts +28 -43
- package/src/util/assets.provider.ts +10 -9
- package/src/util/config.cache.ts +4 -3
- package/src/util/config.loader.ts +13 -13
- package/src/util/cotar.serve.ts +3 -2
- package/src/util/source.cache.ts +15 -26
- package/src/util/validate.ts +61 -14
- package/src/wmts.capability.ts +3 -3
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/__tests__/config.data.d.ts.map +0 -1
- package/build/__tests__/index.test.d.ts.map +0 -1
- package/build/__tests__/tile.style.json.test.d.ts.map +0 -1
- package/build/__tests__/wmts.capability.test.d.ts.map +0 -1
- package/build/__tests__/xyz.util.d.ts.map +0 -1
- package/build/cli/render.preview.d.ts.map +0 -1
- package/build/cli/render.tile.d.ts.map +0 -1
- package/build/index.d.ts.map +0 -1
- package/build/routes/__tests__/attribution.test.d.ts.map +0 -1
- package/build/routes/__tests__/fonts.test.d.ts.map +0 -1
- package/build/routes/__tests__/health.test.d.ts.map +0 -1
- package/build/routes/__tests__/imagery.test.d.ts.map +0 -1
- package/build/routes/__tests__/memory.fs.d.ts.map +0 -1
- package/build/routes/__tests__/preview.index.test.d.ts.map +0 -1
- package/build/routes/__tests__/sprites.test.d.ts.map +0 -1
- package/build/routes/__tests__/tile.json.test.d.ts.map +0 -1
- package/build/routes/__tests__/tile.style.json.test.d.ts.map +0 -1
- package/build/routes/__tests__/wmts.test.d.ts.map +0 -1
- package/build/routes/__tests__/xyz.test.d.ts.map +0 -1
- package/build/routes/attribution.d.ts.map +0 -1
- package/build/routes/config.d.ts.map +0 -1
- package/build/routes/fonts.d.ts.map +0 -1
- package/build/routes/health.d.ts.map +0 -1
- package/build/routes/imagery.d.ts.map +0 -1
- package/build/routes/ping.d.ts.map +0 -1
- package/build/routes/preview.d.ts.map +0 -1
- package/build/routes/preview.index.d.ts.map +0 -1
- package/build/routes/sprites.d.ts.map +0 -1
- package/build/routes/tile.json.d.ts.map +0 -1
- package/build/routes/tile.style.json.d.ts.map +0 -1
- package/build/routes/tile.wmts.d.ts.map +0 -1
- package/build/routes/tile.xyz.d.ts.map +0 -1
- package/build/routes/tile.xyz.raster.d.ts.map +0 -1
- package/build/routes/tile.xyz.vector.d.ts.map +0 -1
- package/build/routes/version.d.ts.map +0 -1
- package/build/util/__test__/config.loader.test.d.ts.map +0 -1
- package/build/util/__test__/filter.test.d.ts.map +0 -1
- package/build/util/__test__/validate.test.d.ts.map +0 -1
- package/build/util/assets.provider.d.ts.map +0 -1
- package/build/util/config.cache.d.ts.map +0 -1
- package/build/util/config.loader.d.ts.map +0 -1
- package/build/util/cotar.serve.d.ts.map +0 -1
- package/build/util/etag.d.ts.map +0 -1
- package/build/util/filter.d.ts.map +0 -1
- package/build/util/response.d.ts.map +0 -1
- package/build/util/source.cache.d.ts.map +0 -1
- package/build/util/source.tracer.d.ts +0 -18
- package/build/util/source.tracer.d.ts.map +0 -1
- package/build/util/source.tracer.js +0 -26
- package/build/util/source.tracer.js.map +0 -1
- package/build/util/swapping.lru.d.ts.map +0 -1
- package/build/util/validate.d.ts.map +0 -1
- package/build/wmts.capability.d.ts.map +0 -1
- package/src/util/source.tracer.ts +0 -38
package/src/cli/render.tile.ts
CHANGED
|
@@ -1,34 +1,38 @@
|
|
|
1
1
|
import { ConfigProviderMemory } from '@basemaps/config';
|
|
2
|
-
import { initConfigFromUrls } from '@basemaps/config
|
|
3
|
-
import {
|
|
4
|
-
import { LogConfig, setDefaultConfig } from '@basemaps/shared';
|
|
5
|
-
import { fsa } from '@chunkd/fs';
|
|
2
|
+
import { initConfigFromUrls } from '@basemaps/config-loader';
|
|
3
|
+
import { Tile, TileMatrixSet, TileMatrixSets } from '@basemaps/geo';
|
|
4
|
+
import { fsa, LogConfig, setDefaultConfig } from '@basemaps/shared';
|
|
6
5
|
import { LambdaHttpRequest, LambdaUrlRequest, UrlEvent } from '@linzjs/lambda';
|
|
7
6
|
import { Context } from 'aws-lambda';
|
|
8
|
-
import {
|
|
9
|
-
import { TileXyzRaster } from '../routes/tile.xyz.raster.js';
|
|
7
|
+
import { extname } from 'path';
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
const tile = fromPath('/18/117833/146174.webp');
|
|
9
|
+
import { TileXyzRaster } from '../routes/tile.xyz.raster.js';
|
|
13
10
|
|
|
14
|
-
|
|
11
|
+
// Render configuration
|
|
12
|
+
const source = fsa.toUrl(`/home/blacha/data/elevation/christchurch_2020-2021/`);
|
|
13
|
+
const tile = fromPath('/14/7898/8615.webp');
|
|
14
|
+
const pipeline: string | null = 'color-ramp';
|
|
15
15
|
let tileMatrix: TileMatrixSet | null = null;
|
|
16
16
|
|
|
17
|
-
/** Convert a tile path /:z/:x/:y.png into a tile */
|
|
18
|
-
function fromPath(s: string): Tile {
|
|
17
|
+
/** Convert a tile path /:z/:x/:y.png into a tile & extension */
|
|
18
|
+
function fromPath(s: string): Tile & { extension: string } {
|
|
19
|
+
const ext = extname(s).slice(1);
|
|
19
20
|
const parts = s.split('.')[0].split('/').map(Number);
|
|
20
21
|
if (s.startsWith('/')) parts.shift();
|
|
21
22
|
if (parts.length !== 3) throw new Error(`Invalid tile path ${s}`);
|
|
22
|
-
return { z: parts[0], x: parts[1], y: parts[2] };
|
|
23
|
+
return { z: parts[0], x: parts[1], y: parts[2], extension: ext };
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
async function main(): Promise<void> {
|
|
26
27
|
const log = LogConfig.get();
|
|
28
|
+
log.level = 'trace';
|
|
27
29
|
const provider = new ConfigProviderMemory();
|
|
28
30
|
setDefaultConfig(provider);
|
|
29
|
-
const {
|
|
31
|
+
const { imagery, tileSets } = await initConfigFromUrls(provider, [source]);
|
|
32
|
+
|
|
33
|
+
const tileSet = tileSets.find((f) => f.layers.length > 0);
|
|
30
34
|
|
|
31
|
-
if (tileSet.layers.length === 0) throw new Error('No imagery found in path: ' +
|
|
35
|
+
if (tileSet == null || tileSet.layers.length === 0) throw new Error('No imagery found in path: ' + source);
|
|
32
36
|
log.info({ tileSet: tileSet.name, layers: tileSet.layers.length }, 'TileSet:Loaded');
|
|
33
37
|
|
|
34
38
|
for (const im of imagery) {
|
|
@@ -47,11 +51,16 @@ async function main(): Promise<void> {
|
|
|
47
51
|
tile,
|
|
48
52
|
tileMatrix,
|
|
49
53
|
tileSet: tileSet.id,
|
|
50
|
-
tileType:
|
|
54
|
+
tileType: tile.extension,
|
|
55
|
+
pipeline,
|
|
51
56
|
});
|
|
57
|
+
const pipelineName = pipeline ? `-${pipeline}` : '';
|
|
52
58
|
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
const fileName = `./render/${tile.z}_${tile.x}_${tile.y}${pipelineName}.${tile.extension}`;
|
|
60
|
+
await fsa.write(fsa.toUrl(fileName), Buffer.from(res.body, 'base64'));
|
|
61
|
+
log.info({ path: fileName, ...request.timer.metrics }, 'Tile:Write');
|
|
55
62
|
}
|
|
56
63
|
|
|
57
|
-
main()
|
|
64
|
+
main().catch((e) => {
|
|
65
|
+
LogConfig.get().fatal({ err: e }, 'Cli:Failed');
|
|
66
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { LogConfig } from '@basemaps/shared';
|
|
2
|
-
import { LambdaHttpResponse, lf } from '@linzjs/lambda';
|
|
1
|
+
import { FsaCache, FsaLog, LogConfig } from '@basemaps/shared';
|
|
2
|
+
import { LambdaHttpRequest, LambdaHttpResponse, lf } from '@linzjs/lambda';
|
|
3
|
+
|
|
3
4
|
import { tileAttributionGet } from './routes/attribution.js';
|
|
4
5
|
import { configImageryGet, configTileSetGet } from './routes/config.js';
|
|
5
6
|
import { fontGet, fontList } from './routes/fonts.js';
|
|
@@ -15,38 +16,40 @@ import { wmtsCapabilitiesGet } from './routes/tile.wmts.js';
|
|
|
15
16
|
import { tileXyzGet } from './routes/tile.xyz.js';
|
|
16
17
|
import { versionGet } from './routes/version.js';
|
|
17
18
|
import { NotFound } from './util/response.js';
|
|
18
|
-
import { CoSources } from './util/source.cache.js';
|
|
19
|
-
import { St } from './util/source.tracer.js';
|
|
20
19
|
|
|
21
20
|
export const handler = lf.http(LogConfig.get());
|
|
22
21
|
|
|
23
22
|
/** If the request takes too long, respond with a 408 timeout when there is approx 1 second remaining */
|
|
24
23
|
handler.router.timeoutEarlyMs = 1_000;
|
|
25
24
|
|
|
25
|
+
function randomTrace(req: LambdaHttpRequest): void {
|
|
26
|
+
// If the env is set to trace level always trace requests
|
|
27
|
+
if (process.env['TRACE']) {
|
|
28
|
+
req.log.level = 'trace';
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Set the logging level based off a percent
|
|
33
|
+
const rand = Math.random();
|
|
34
|
+
// 1% trace
|
|
35
|
+
if (rand < 0.01) req.log.level = 'trace';
|
|
36
|
+
// 5% debug
|
|
37
|
+
else if (rand < 0.04) req.log.level = 'debug';
|
|
38
|
+
// everything else info
|
|
39
|
+
else req.log.level = 'info';
|
|
40
|
+
}
|
|
41
|
+
|
|
26
42
|
handler.router.hook('request', (req) => {
|
|
27
|
-
|
|
43
|
+
FsaLog.reset();
|
|
28
44
|
|
|
29
|
-
|
|
30
|
-
|
|
45
|
+
randomTrace(req);
|
|
46
|
+
|
|
47
|
+
req.set('name', 'LambdaTiler');
|
|
31
48
|
});
|
|
32
49
|
|
|
33
50
|
handler.router.hook('response', (req, res) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
req.set('requests', St.requests.slice(0, 100)); // limit to 100 requests (some tiles need 100s of requests)
|
|
37
|
-
req.set('requestCount', St.requests.length);
|
|
38
|
-
}
|
|
39
|
-
// Log the source cache hit/miss ratio
|
|
40
|
-
req.set('sources', {
|
|
41
|
-
hits: CoSources.cache.hits,
|
|
42
|
-
misses: CoSources.cache.misses,
|
|
43
|
-
size: CoSources.cache.currentSize,
|
|
44
|
-
resets: CoSources.cache.resets,
|
|
45
|
-
clears: CoSources.cache.clears,
|
|
46
|
-
cacheA: CoSources.cache.cacheA.size,
|
|
47
|
-
cacheB: CoSources.cache.cacheB.size,
|
|
48
|
-
});
|
|
49
|
-
|
|
51
|
+
req.set('requestCount', FsaLog.requests.length);
|
|
52
|
+
req.set('cacheSize', FsaCache.size);
|
|
50
53
|
// Force access-control-allow-origin to everything
|
|
51
54
|
res.header('access-control-allow-origin', '*');
|
|
52
55
|
});
|
|
@@ -94,6 +97,8 @@ handler.router.get('/v1/tiles/:tileSet/:tileMatrix/:z/:x/:y.:tileType', tileXyzG
|
|
|
94
97
|
|
|
95
98
|
// Preview
|
|
96
99
|
handler.router.get('/v1/preview/:tileSet/:tileMatrix/:z/:lon/:lat', tilePreviewGet);
|
|
100
|
+
handler.router.get('/v1/preview/:tileSet/:tileMatrix/:z/:lon/:lat/:outputType', tilePreviewGet);
|
|
101
|
+
|
|
97
102
|
handler.router.get('/v1/@:location', previewIndexGet);
|
|
98
103
|
handler.router.get('/@:location', previewIndexGet);
|
|
99
104
|
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import { afterEach, beforeEach, describe, it } from 'node:test';
|
|
3
|
+
|
|
1
4
|
import { Attribution } from '@basemaps/attribution';
|
|
2
5
|
import { ConfigProviderMemory } from '@basemaps/config';
|
|
3
6
|
import { GoogleTms, Nztm2000QuadTms, Projection } from '@basemaps/geo';
|
|
4
7
|
import { LogConfig } from '@basemaps/shared';
|
|
5
8
|
import { BBox } from '@linzjs/geojson';
|
|
6
9
|
import { HttpHeader } from '@linzjs/lambda';
|
|
7
|
-
import o from 'ospec';
|
|
8
10
|
import sinon from 'sinon';
|
|
9
|
-
|
|
10
|
-
import { ConfigLoader } from '../../util/config.loader.js';
|
|
11
|
+
|
|
11
12
|
import { FakeData, Imagery2193, Imagery3857, Provider, TileSetAerial } from '../../__tests__/config.data.js';
|
|
12
13
|
import { mockUrlRequest } from '../../__tests__/xyz.util.js';
|
|
14
|
+
import { handler } from '../../index.js';
|
|
15
|
+
import { ConfigLoader } from '../../util/config.loader.js';
|
|
13
16
|
import { createCoordinates } from '../attribution.js';
|
|
14
17
|
|
|
15
18
|
// const ExpectedJson = {
|
|
@@ -280,11 +283,11 @@ import { createCoordinates } from '../attribution.js';
|
|
|
280
283
|
// updatedAt: Date.now(),
|
|
281
284
|
// };
|
|
282
285
|
// }
|
|
283
|
-
|
|
286
|
+
describe('/v1/attribution', () => {
|
|
284
287
|
const config = new ConfigProviderMemory();
|
|
285
288
|
const sandbox = sinon.createSandbox();
|
|
286
289
|
|
|
287
|
-
|
|
290
|
+
beforeEach(() => {
|
|
288
291
|
LogConfig.get().level = 'silent';
|
|
289
292
|
sandbox.stub(ConfigLoader, 'getDefaultConfig').resolves(config);
|
|
290
293
|
|
|
@@ -296,107 +299,107 @@ o.spec('/v1/attribution', () => {
|
|
|
296
299
|
config.put(Provider);
|
|
297
300
|
});
|
|
298
301
|
|
|
299
|
-
|
|
302
|
+
afterEach(() => {
|
|
300
303
|
sandbox.restore();
|
|
301
304
|
});
|
|
302
305
|
|
|
303
|
-
|
|
306
|
+
it('should notFound', async () => {
|
|
304
307
|
const request = mockUrlRequest(`/v1/attribution/aerial/1234/summary.json`);
|
|
305
308
|
const res = await handler.router.handle(request);
|
|
306
309
|
|
|
307
|
-
|
|
310
|
+
assert.equal(res.status, 404);
|
|
308
311
|
});
|
|
309
312
|
|
|
310
|
-
|
|
313
|
+
it('should 304 with etag match', async () => {
|
|
311
314
|
const request = mockUrlRequest(`/v1/attribution/aerial/EPSG:3857/summary.json`, 'get', {
|
|
312
|
-
[HttpHeader.IfNoneMatch]: '
|
|
315
|
+
[HttpHeader.IfNoneMatch]: 'AFV7dcchHkfyFvmmyXwpkxuAPb5BuVXLkLzzYgeB3mFy',
|
|
313
316
|
});
|
|
314
317
|
|
|
315
318
|
const res = await handler.router.handle(request);
|
|
316
319
|
|
|
317
|
-
if (res.status === 200)
|
|
320
|
+
if (res.status === 200) assert.equal(res.header('etag'), 'AFV7dcchHkfyFvmmyXwpkxuAPb5BuVXLkLzzYgeB3mFy');
|
|
318
321
|
|
|
319
322
|
console.log(res.header('etag'));
|
|
320
|
-
|
|
323
|
+
assert.equal(res.status, 304);
|
|
321
324
|
});
|
|
322
325
|
|
|
323
|
-
|
|
326
|
+
it('should parse attribution', async () => {
|
|
324
327
|
const request = mockUrlRequest(`/v1/attribution/aerial/EPSG:3857/summary.json`);
|
|
325
328
|
const res = await handler.router.handle(request);
|
|
326
|
-
|
|
329
|
+
assert.equal(res.status, 200);
|
|
327
330
|
|
|
328
331
|
const json = JSON.parse(res.body);
|
|
329
332
|
|
|
330
333
|
const attr = Attribution.fromStac(json);
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
+
assert.equal(attr.attributions.length, 1);
|
|
335
|
+
assert.equal(attr.attributions[0].minZoom, 0);
|
|
336
|
+
assert.equal(attr.attributions[0].maxZoom, 32);
|
|
334
337
|
});
|
|
335
338
|
|
|
336
|
-
|
|
339
|
+
describe('ImageryRules', () => {
|
|
337
340
|
const fakeLayer = { [2193]: Imagery2193.id, name: 'image', minZoom: 9, maxZoom: 16, title: 'Image' };
|
|
338
341
|
const ts = FakeData.tileSetRaster('fake');
|
|
339
342
|
|
|
340
|
-
|
|
343
|
+
beforeEach(() => {
|
|
341
344
|
ts.layers = [fakeLayer];
|
|
342
345
|
config.put(Imagery2193);
|
|
343
346
|
config.put(ts);
|
|
344
347
|
});
|
|
345
348
|
|
|
346
|
-
|
|
349
|
+
it('should generate for NZTM', async () => {
|
|
347
350
|
const req = mockUrlRequest('/v1/tiles/fake/NZTM2000/attribution.json', '');
|
|
348
351
|
const res = await handler.router.handle(req);
|
|
349
|
-
|
|
352
|
+
assert.equal(res.status, 200);
|
|
350
353
|
|
|
351
354
|
const output = JSON.parse(res.body);
|
|
352
|
-
|
|
353
|
-
|
|
355
|
+
assert.equal(output.title, ts.title);
|
|
356
|
+
assert.deepEqual(output.collections[0].summaries['linz:zoom'], { min: 5, max: 11 });
|
|
354
357
|
});
|
|
355
358
|
|
|
356
|
-
|
|
359
|
+
it('should generate with correct zooms for NZTM2000Quad', async () => {
|
|
357
360
|
const req = mockUrlRequest('/v1/tiles/fake/NZTM2000Quad/attribution.json', '');
|
|
358
361
|
const res = await handler.router.handle(req);
|
|
359
|
-
|
|
362
|
+
assert.equal(res.status, 200);
|
|
360
363
|
|
|
361
364
|
const output = JSON.parse(res.body);
|
|
362
|
-
|
|
363
|
-
|
|
365
|
+
assert.equal(output.title, ts.title);
|
|
366
|
+
assert.deepEqual(output.collections[0].summaries['linz:zoom'], { min: 7, max: 14 });
|
|
364
367
|
});
|
|
365
368
|
|
|
366
|
-
|
|
369
|
+
it('should generate with correct zooms for gebco NZTM2000Quad', async () => {
|
|
367
370
|
const fakeGebco = { ...fakeLayer, minZoom: 0, maxZoom: 15 };
|
|
368
371
|
ts.layers = [fakeGebco];
|
|
369
372
|
|
|
370
373
|
const req = mockUrlRequest('/v1/tiles/fake/NZTM2000Quad/attribution.json', '');
|
|
371
374
|
const res = await handler.router.handle(req);
|
|
372
|
-
|
|
375
|
+
assert.equal(res.status, 200);
|
|
373
376
|
|
|
374
377
|
const output = JSON.parse(res.body);
|
|
375
|
-
|
|
376
|
-
|
|
378
|
+
assert.equal(output.title, ts.title);
|
|
379
|
+
assert.deepEqual(output.collections[0].summaries['linz:zoom'], { min: 0, max: 13 });
|
|
377
380
|
});
|
|
378
381
|
|
|
379
|
-
|
|
382
|
+
it('should generate with correct zooms for nz sentinel NZTM2000Quad', async () => {
|
|
380
383
|
const fakeGebco = { ...fakeLayer, minZoom: 0, maxZoom: 32 };
|
|
381
384
|
ts.layers = [fakeGebco];
|
|
382
385
|
|
|
383
386
|
const req = mockUrlRequest('/v1/tiles/fake/NZTM2000Quad/attribution.json', '');
|
|
384
387
|
const res = await handler.router.handle(req);
|
|
385
|
-
|
|
388
|
+
assert.equal(res.status, 200);
|
|
386
389
|
|
|
387
390
|
const output = JSON.parse(res.body);
|
|
388
|
-
|
|
389
|
-
|
|
391
|
+
assert.equal(output.title, ts.title);
|
|
392
|
+
assert.deepEqual(output.collections[0].summaries['linz:zoom'], { min: 0, max: Nztm2000QuadTms.maxZoom });
|
|
390
393
|
});
|
|
391
394
|
});
|
|
392
395
|
|
|
393
|
-
|
|
396
|
+
it('should create valid coordinates', async () => {
|
|
394
397
|
//bbox: BBox, files: NamedBounds[], proj: Projection
|
|
395
398
|
const bbox = [174.79248047, -38.21228805, 175.25939941, -37.99616268] as BBox;
|
|
396
399
|
const proj = Projection.get(GoogleTms);
|
|
397
400
|
const coordinates = createCoordinates(bbox, Imagery3857.files, proj);
|
|
398
401
|
console.log(JSON.stringify(coordinates));
|
|
399
|
-
|
|
402
|
+
assert.deepEqual(coordinates, [
|
|
400
403
|
[
|
|
401
404
|
[
|
|
402
405
|
[174.79247149, -38.09998972],
|
|
@@ -1,108 +1,112 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import { afterEach, beforeEach, describe, it } from 'node:test';
|
|
3
|
+
|
|
4
|
+
import { base58, BaseConfig, ConfigProviderMemory } from '@basemaps/config';
|
|
5
|
+
import { setDefaultConfig } from '@basemaps/shared';
|
|
6
|
+
import { fsa, FsMemory } from '@chunkd/fs';
|
|
7
|
+
|
|
8
|
+
import { Api, mockRequest, mockUrlRequest } from '../../__tests__/xyz.util.js';
|
|
6
9
|
import { handler } from '../../index.js';
|
|
7
10
|
import { CachedConfig } from '../../util/config.cache.js';
|
|
8
|
-
import { ConfigLoader } from '../../util/config.loader.js';
|
|
9
11
|
import { CoSources } from '../../util/source.cache.js';
|
|
10
|
-
import { Api, mockRequest, mockUrlRequest } from '../../__tests__/xyz.util.js';
|
|
11
12
|
import { fontList } from '../fonts.js';
|
|
12
|
-
import { FsMemory } from '@chunkd/source-memory';
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
describe('/v1/fonts', () => {
|
|
15
15
|
const memory = new FsMemory();
|
|
16
|
-
const sandbox = createSandbox();
|
|
17
16
|
const config = new ConfigProviderMemory();
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
config.objects.clear();
|
|
20
20
|
fsa.register('memory://', memory);
|
|
21
|
+
config.assets = 'memory://assets/';
|
|
22
|
+
setDefaultConfig(config);
|
|
21
23
|
});
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
config.assets = 'memory://';
|
|
25
|
-
sandbox.stub(ConfigLoader, 'getDefaultConfig').resolves(config);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
o.afterEach(() => {
|
|
29
|
-
sandbox.restore();
|
|
25
|
+
afterEach(() => {
|
|
30
26
|
CachedConfig.cache.clear();
|
|
31
27
|
CoSources.cache.clear();
|
|
32
28
|
memory.files.clear();
|
|
33
29
|
});
|
|
34
30
|
|
|
35
|
-
|
|
31
|
+
it('should return 404 if no font found', async () => {
|
|
36
32
|
const res = await fontList(mockRequest('/v1/fonts.json'));
|
|
37
|
-
|
|
33
|
+
assert.equal(res.status, 404);
|
|
38
34
|
});
|
|
39
35
|
|
|
40
|
-
|
|
41
|
-
await fsa.write(
|
|
36
|
+
it('should return a list of fonts found', async () => {
|
|
37
|
+
await fsa.write(
|
|
38
|
+
new URL('memory://assets/fonts/fonts.json'),
|
|
39
|
+
Buffer.from(JSON.stringify(['Roboto Black', 'Roboto Thin'])),
|
|
40
|
+
);
|
|
42
41
|
const res = await fontList(mockRequest('/v1/fonts.json'));
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
assert.equal(res.status, 200);
|
|
43
|
+
assert.equal(res.header('content-type'), 'application/json');
|
|
44
|
+
assert.equal(res.header('content-encoding'), undefined);
|
|
45
|
+
assert.equal(res._body?.toString(), JSON.stringify(['Roboto Black', 'Roboto Thin']));
|
|
47
46
|
});
|
|
48
47
|
|
|
49
|
-
|
|
50
|
-
await fsa.write('memory://fonts/Roboto Thin/0-255.pbf', Buffer.from(''));
|
|
48
|
+
it('should get the correct font', async () => {
|
|
49
|
+
await fsa.write(new URL('memory://assets/fonts/Roboto Thin/0-255.pbf'), Buffer.from(''));
|
|
51
50
|
const res255 = await handler.router.handle(mockRequest('/v1/fonts/Roboto Thin/0-255.pbf'));
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
assert.equal(res255.status, 200);
|
|
52
|
+
assert.equal(res255.header('content-type'), 'application/x-protobuf');
|
|
53
|
+
assert.equal(res255.header('content-encoding'), undefined);
|
|
54
|
+
assert.notEqual(res255.header('etag'), undefined);
|
|
55
|
+
assert.equal(res255.header('cache-control'), 'public, max-age=604800, stale-while-revalidate=86400');
|
|
57
56
|
|
|
58
57
|
const res404 = await handler.router.handle(mockRequest('/v1/fonts/Roboto Thin/256-512.pbf'));
|
|
59
|
-
|
|
58
|
+
assert.equal(res404.status, 404);
|
|
60
59
|
});
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
await fsa.write('memory://fonts/🦄 🌈/0-255.pbf', Buffer.from(''));
|
|
61
|
+
it('should get the correct utf8 font', async () => {
|
|
62
|
+
await fsa.write(new URL('memory://assets/fonts/🦄 🌈/0-255.pbf'), Buffer.from(''));
|
|
64
63
|
const res255 = await handler.router.handle(mockRequest('/v1/fonts/🦄 🌈/0-255.pbf'));
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
assert.equal(res255.status, 200);
|
|
65
|
+
assert.equal(res255.header('content-type'), 'application/x-protobuf');
|
|
66
|
+
assert.equal(res255.header('content-encoding'), undefined);
|
|
67
|
+
assert.notEqual(res255.header('etag'), undefined);
|
|
68
|
+
assert.equal(res255.header('cache-control'), 'public, max-age=604800, stale-while-revalidate=86400');
|
|
70
69
|
});
|
|
71
70
|
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
it('should return 404 if no asset location set', async () => {
|
|
72
|
+
config.assets = undefined;
|
|
74
73
|
const res = await fontList(mockRequest('/v1/fonts.json'));
|
|
75
|
-
|
|
74
|
+
assert.equal(res.status, 404);
|
|
76
75
|
});
|
|
77
76
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
it('should get the correct utf8 font with default assets', async () => {
|
|
78
|
+
config.assets = undefined;
|
|
79
|
+
config.objects.set('cb_latest', {
|
|
80
|
+
id: 'cb_latest',
|
|
81
|
+
name: 'latest',
|
|
82
|
+
path: 'latest',
|
|
83
|
+
hash: 'hash',
|
|
84
|
+
assets: 'memory://new-location/',
|
|
85
|
+
} as BaseConfig);
|
|
86
|
+
|
|
87
|
+
await fsa.write(new URL('memory://new-location/fonts/Roboto Thin/0-255.pbf'), Buffer.from(''));
|
|
84
88
|
const res255 = await handler.router.handle(mockRequest('/v1/fonts/Roboto Thin/0-255.pbf'));
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
assert.equal(res255.status, 200, res255.statusDescription);
|
|
90
|
+
assert.equal(res255.header('content-type'), 'application/x-protobuf');
|
|
91
|
+
assert.equal(res255.header('content-encoding'), undefined);
|
|
92
|
+
assert.notEqual(res255.header('etag'), undefined);
|
|
93
|
+
assert.equal(res255.header('cache-control'), 'public, max-age=604800, stale-while-revalidate=86400');
|
|
90
94
|
});
|
|
91
95
|
|
|
92
|
-
|
|
96
|
+
it('should get the correct utf8 font with config assets', async () => {
|
|
93
97
|
const cfgBundle = new ConfigProviderMemory();
|
|
94
|
-
cfgBundle.assets = 'memory://config/assets';
|
|
95
|
-
await fsa.write('memory://linz-basemaps/bar.json', JSON.stringify(cfgBundle.toJson()));
|
|
96
|
-
await fsa.write('memory://config/assets/fonts/🦄 🌈/0-255.pbf', Buffer.from(''));
|
|
98
|
+
cfgBundle.assets = 'memory://config/assets/';
|
|
99
|
+
await fsa.write(new URL('memory://linz-basemaps/bar.json'), JSON.stringify(cfgBundle.toJson()));
|
|
100
|
+
await fsa.write(new URL('memory://config/assets/fonts/🦄 🌈/0-255.pbf'), Buffer.from(''));
|
|
97
101
|
|
|
98
102
|
const configLocation = base58.encode(Buffer.from('memory://linz-basemaps/bar.json'));
|
|
99
103
|
const res255 = await handler.router.handle(
|
|
100
104
|
mockUrlRequest('/v1/fonts/🦄 🌈/0-255.pbf', `?config=${configLocation}`, Api.header),
|
|
101
105
|
);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
assert.equal(res255.status, 200);
|
|
107
|
+
assert.equal(res255.header('content-type'), 'application/x-protobuf');
|
|
108
|
+
assert.equal(res255.header('content-encoding'), undefined);
|
|
109
|
+
assert.notEqual(res255.header('etag'), undefined);
|
|
110
|
+
assert.equal(res255.header('cache-control'), 'public, max-age=604800, stale-while-revalidate=86400');
|
|
107
111
|
});
|
|
108
112
|
});
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import { afterEach, before, beforeEach, describe, it } from 'node:test';
|
|
3
|
+
|
|
1
4
|
import { ConfigProviderMemory } from '@basemaps/config';
|
|
2
5
|
import { LogConfig } from '@basemaps/shared';
|
|
3
6
|
import { LambdaAlbRequest, LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
|
|
4
7
|
import { Context } from 'aws-lambda';
|
|
5
|
-
import o from 'ospec';
|
|
6
8
|
import sinon from 'sinon';
|
|
7
|
-
import { ConfigLoader } from '../../util/config.loader.js';
|
|
8
|
-
import { FakeData } from '../../__tests__/config.data.js';
|
|
9
9
|
|
|
10
|
+
import { FakeData } from '../../__tests__/config.data.js';
|
|
11
|
+
import { ConfigLoader } from '../../util/config.loader.js';
|
|
10
12
|
import { getTestBuffer, healthGet, TestTiles } from '../health.js';
|
|
11
13
|
import { TileXyzRaster } from '../tile.xyz.raster.js';
|
|
12
14
|
|
|
@@ -22,24 +24,23 @@ const ctx: LambdaHttpRequest = new LambdaAlbRequest(
|
|
|
22
24
|
LogConfig.get(),
|
|
23
25
|
);
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
o.specTimeout(1000);
|
|
27
|
+
describe('/v1/health', async () => {
|
|
27
28
|
const sandbox = sinon.createSandbox();
|
|
28
29
|
const config = new ConfigProviderMemory();
|
|
29
30
|
|
|
30
31
|
const fakeTileSet = FakeData.tileSetRaster('health');
|
|
31
|
-
|
|
32
|
+
beforeEach(() => {
|
|
32
33
|
config.objects.clear();
|
|
33
34
|
sandbox.stub(ConfigLoader, 'getDefaultConfig').resolves(config);
|
|
34
35
|
config.put(fakeTileSet);
|
|
35
36
|
});
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
afterEach(() => {
|
|
38
39
|
config.objects.clear();
|
|
39
40
|
sandbox.restore();
|
|
40
41
|
});
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
it('Should return bad response', async () => {
|
|
43
44
|
// Given ... a bad get tile response
|
|
44
45
|
const BadResponse = new LambdaHttpResponse(500, 'Can not get Tile Set.');
|
|
45
46
|
sandbox.stub(TileXyzRaster, 'tile').resolves(BadResponse);
|
|
@@ -48,14 +49,14 @@ o.spec('/v1/health', async () => {
|
|
|
48
49
|
const res = await healthGet(ctx);
|
|
49
50
|
|
|
50
51
|
// Then ...
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
assert.equal(res.status, 500);
|
|
53
|
+
assert.equal(res.statusDescription, 'Can not get Tile Set.');
|
|
53
54
|
});
|
|
54
55
|
|
|
55
56
|
const Response1 = new LambdaHttpResponse(200, 'ok');
|
|
56
57
|
const Response2 = new LambdaHttpResponse(200, 'ok');
|
|
57
58
|
|
|
58
|
-
|
|
59
|
+
before(async () => {
|
|
59
60
|
const testTileFile1 = await getTestBuffer(TestTiles[0]);
|
|
60
61
|
Response1.buffer(testTileFile1);
|
|
61
62
|
const testTileFile2 = await getTestBuffer(TestTiles[1]);
|
|
@@ -63,7 +64,7 @@ o.spec('/v1/health', async () => {
|
|
|
63
64
|
});
|
|
64
65
|
// Prepare mock test tile response based on the static test tiles
|
|
65
66
|
|
|
66
|
-
|
|
67
|
+
it('Should give a 200 response', async () => {
|
|
67
68
|
// Given ... a series good get tile response
|
|
68
69
|
const callback = sandbox.stub(TileXyzRaster, 'tile');
|
|
69
70
|
callback.onCall(0).resolves(Response1);
|
|
@@ -73,11 +74,11 @@ o.spec('/v1/health', async () => {
|
|
|
73
74
|
const res = await healthGet(ctx);
|
|
74
75
|
|
|
75
76
|
// Then ...
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
assert.equal(res.status, 200);
|
|
78
|
+
assert.equal(res.statusDescription, 'ok');
|
|
78
79
|
});
|
|
79
80
|
|
|
80
|
-
|
|
81
|
+
it('Should return mis-match tile response', async () => {
|
|
81
82
|
// Given ... a bad get tile response for second get tile
|
|
82
83
|
const callback = sandbox.stub(TileXyzRaster, 'tile');
|
|
83
84
|
callback.onCall(0).resolves(Response1);
|
|
@@ -87,7 +88,7 @@ o.spec('/v1/health', async () => {
|
|
|
87
88
|
const res = await healthGet(ctx);
|
|
88
89
|
|
|
89
90
|
// Then ...
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
assert.equal(res.status, 500);
|
|
92
|
+
assert.equal(res.statusDescription, 'TileSet does not match.');
|
|
92
93
|
});
|
|
93
94
|
});
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import { describe, it } from 'node:test';
|
|
3
|
+
|
|
2
4
|
import { isAllowedFile } from '../imagery.js';
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
describe('ImageryRoute', () => {
|
|
7
|
+
it('should allow geojson and json files only', () => {
|
|
8
|
+
assert.equal(isAllowedFile('foo.geojson'), true);
|
|
9
|
+
assert.equal(isAllowedFile('foo.json'), true);
|
|
10
|
+
assert.equal(isAllowedFile('foo.tiff'), false);
|
|
11
|
+
assert.equal(isAllowedFile('foo'), false);
|
|
12
|
+
assert.equal(isAllowedFile(''), false);
|
|
13
|
+
assert.equal(isAllowedFile(null as any), false);
|
|
12
14
|
});
|
|
13
15
|
});
|