@basemaps/lambda-tiler 6.30.0 → 6.32.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 +46 -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__/wmts.capability.test.js +88 -6
- package/build/__tests__/wmts.capability.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 +49 -91
- 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/build/wmts.capability.js +24 -8
- package/build/wmts.capability.js.map +1 -1
- package/dist/index.js +78 -76
- 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 +41 -3
- package/src/__tests__/index.test.ts +3 -19
- package/src/__tests__/wmts.capability.test.ts +109 -6
- 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 +59 -111
- 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 +30 -13
- 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
package/dist/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basemaps/lambda-tiler",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.32.1",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@basemaps/lambda-tiler",
|
|
9
|
-
"version": "6.
|
|
9
|
+
"version": "6.32.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"sharp": "0.30.7"
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basemaps/lambda-tiler",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.32.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/linz/basemaps.git",
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"types": "./build/index.d.ts",
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@basemaps/config": "^6.
|
|
26
|
-
"@basemaps/geo": "^6.
|
|
25
|
+
"@basemaps/config": "^6.32.1",
|
|
26
|
+
"@basemaps/geo": "^6.32.1",
|
|
27
27
|
"@basemaps/lambda": "^6.7.0",
|
|
28
|
-
"@basemaps/shared": "^6.
|
|
29
|
-
"@basemaps/tiler": "^6.
|
|
30
|
-
"@basemaps/tiler-sharp": "^6.
|
|
28
|
+
"@basemaps/shared": "^6.32.1",
|
|
29
|
+
"@basemaps/tiler": "^6.32.1",
|
|
30
|
+
"@basemaps/tiler-sharp": "^6.32.1",
|
|
31
31
|
"@chunkd/fs": "^8.4.0",
|
|
32
32
|
"@cogeotiff/core": "^7.0.0",
|
|
33
33
|
"@cotar/core": "^5.4.0",
|
|
34
|
-
"@linzjs/geojson": "^6.
|
|
35
|
-
"@linzjs/lambda": "^3.2.
|
|
34
|
+
"@linzjs/geojson": "^6.32.1",
|
|
35
|
+
"@linzjs/lambda": "^3.2.1",
|
|
36
36
|
"p-limit": "^4.0.0",
|
|
37
37
|
"path-to-regexp": "^6.1.0",
|
|
38
38
|
"pixelmatch": "^5.1.0",
|
|
@@ -52,12 +52,12 @@
|
|
|
52
52
|
"bundle": "./bundle.sh"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@basemaps/attribution": "^6.
|
|
55
|
+
"@basemaps/attribution": "^6.32.1",
|
|
56
56
|
"@types/aws-lambda": "^8.10.75",
|
|
57
57
|
"@types/node": "^17.0.34",
|
|
58
58
|
"@types/pixelmatch": "^5.0.0",
|
|
59
59
|
"@types/sharp": "^0.30.3",
|
|
60
60
|
"pretty-json-log": "^1.0.0"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "4544a7d98667c5274142f1bb6bf61f02e4e5f618"
|
|
63
63
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ImageFormat } from '@basemaps/geo';
|
|
1
|
+
import { ConfigImagery, ConfigProvider, ConfigTileSetRaster, ConfigTileSetVector, TileSetType } from '@basemaps/config';
|
|
2
|
+
import { ImageFormat, VectorFormat } from '@basemaps/geo';
|
|
3
3
|
|
|
4
4
|
export const TileSetAerial: ConfigTileSetRaster = {
|
|
5
5
|
id: 'ts_aerial',
|
|
@@ -19,6 +19,24 @@ export const TileSetAerial: ConfigTileSetRaster = {
|
|
|
19
19
|
},
|
|
20
20
|
],
|
|
21
21
|
};
|
|
22
|
+
export const TileSetVector: ConfigTileSetVector = {
|
|
23
|
+
id: 'ts_topographic',
|
|
24
|
+
type: TileSetType.Vector,
|
|
25
|
+
name: 'topotgrpahic',
|
|
26
|
+
description: 'topotgrpahic__description',
|
|
27
|
+
title: 'topotgrpahic Imagery',
|
|
28
|
+
category: 'Basemap',
|
|
29
|
+
format: VectorFormat.MapboxVectorTiles,
|
|
30
|
+
layers: [
|
|
31
|
+
{
|
|
32
|
+
3857: 's3://linz-basemaps/01G7WQMGHB7V946M0YWJJBZ6DW/topopgraphic.tar.co',
|
|
33
|
+
title: 'Vector tiles',
|
|
34
|
+
category: 'Vector Tiles',
|
|
35
|
+
name: 'Vector tiles',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
};
|
|
39
|
+
|
|
22
40
|
export const Imagery2193: ConfigImagery = {
|
|
23
41
|
id: 'im_01FYWKAJ86W9P7RWM1VB62KD0H',
|
|
24
42
|
name: 'ōtorohanga_urban_2021_0-1m_RGB',
|
|
@@ -54,7 +72,7 @@ export const Imagery3857: ConfigImagery = {
|
|
|
54
72
|
|
|
55
73
|
export const Provider: ConfigProvider = {
|
|
56
74
|
name: 'main',
|
|
57
|
-
id: '
|
|
75
|
+
id: 'pv_linz',
|
|
58
76
|
updatedAt: Date.now(),
|
|
59
77
|
version: 1,
|
|
60
78
|
serviceIdentification: {
|
|
@@ -80,3 +98,23 @@ export const Provider: ConfigProvider = {
|
|
|
80
98
|
site: 'https://example.provider.com',
|
|
81
99
|
},
|
|
82
100
|
};
|
|
101
|
+
|
|
102
|
+
export class FakeData {
|
|
103
|
+
static tileSetRaster(name: string): ConfigTileSetRaster {
|
|
104
|
+
const tileSet = JSON.parse(JSON.stringify(TileSetAerial));
|
|
105
|
+
|
|
106
|
+
tileSet.name = name;
|
|
107
|
+
tileSet.id = `ts_${name}`;
|
|
108
|
+
|
|
109
|
+
return tileSet;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
static tileSetVector(name: string): ConfigTileSetVector {
|
|
113
|
+
const tileSet = JSON.parse(JSON.stringify(TileSetVector));
|
|
114
|
+
|
|
115
|
+
tileSet.name = name;
|
|
116
|
+
tileSet.id = `ts_${name}`;
|
|
117
|
+
|
|
118
|
+
return tileSet;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -1,24 +1,8 @@
|
|
|
1
|
-
import { LogConfig } from '@basemaps/shared';
|
|
2
|
-
import { LambdaAlbRequest, LambdaHttpRequest } from '@linzjs/lambda';
|
|
3
|
-
import { Context } from 'aws-lambda';
|
|
4
1
|
import o from 'ospec';
|
|
5
2
|
import { handler } from '../index.js';
|
|
3
|
+
import { mockRequest } from './xyz.util.js';
|
|
6
4
|
|
|
7
5
|
o.spec('LambdaXyz index', () => {
|
|
8
|
-
function req(path: string, method = 'get'): LambdaHttpRequest {
|
|
9
|
-
return new LambdaAlbRequest(
|
|
10
|
-
{
|
|
11
|
-
requestContext: null as any,
|
|
12
|
-
httpMethod: method.toUpperCase(),
|
|
13
|
-
path,
|
|
14
|
-
body: null,
|
|
15
|
-
isBase64Encoded: false,
|
|
16
|
-
},
|
|
17
|
-
{} as Context,
|
|
18
|
-
LogConfig.get(),
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
6
|
o('should export handler', async () => {
|
|
23
7
|
const foo = await import('../index.js');
|
|
24
8
|
o(typeof foo.handler).equals('function');
|
|
@@ -36,7 +20,7 @@ o.spec('LambdaXyz index', () => {
|
|
|
36
20
|
process.env.GIT_VERSION = '1.2.3';
|
|
37
21
|
process.env.GIT_HASH = 'abc456';
|
|
38
22
|
|
|
39
|
-
const response = await handler.router.handle(
|
|
23
|
+
const response = await handler.router.handle(mockRequest('/v1/version'));
|
|
40
24
|
|
|
41
25
|
o(response.status).equals(200);
|
|
42
26
|
o(response.statusDescription).equals('ok');
|
|
@@ -49,7 +33,7 @@ o.spec('LambdaXyz index', () => {
|
|
|
49
33
|
});
|
|
50
34
|
|
|
51
35
|
o('should respond to /ping', async () => {
|
|
52
|
-
const res = await handler.router.handle(
|
|
36
|
+
const res = await handler.router.handle(mockRequest('/v1/ping'));
|
|
53
37
|
o(res.status).equals(200);
|
|
54
38
|
o(res.statusDescription).equals('ok');
|
|
55
39
|
o(res.header('cache-control')).equals('no-store');
|
|
@@ -316,22 +316,19 @@ o.spec('WmtsCapabilities', () => {
|
|
|
316
316
|
const boundingBoxes = tags(layer, 'ows:BoundingBox');
|
|
317
317
|
o(boundingBoxes.length).equals(2);
|
|
318
318
|
o(boundingBoxes[0].attrs.crs).equals('urn:ogc:def:crs:EPSG::3857');
|
|
319
|
-
o(boundingBoxes[0].children.map((c) =>
|
|
319
|
+
o(boundingBoxes[0].children.map((c) => c.textContent)).deepEquals([
|
|
320
320
|
'19457809.9203 -4609458.5537',
|
|
321
321
|
'19509787.0995 -4578883.7424',
|
|
322
322
|
]);
|
|
323
323
|
o(boundingBoxes[1].attrs.crs).equals('urn:ogc:def:crs:EPSG::2193');
|
|
324
|
-
o(boundingBoxes[1].children.map((c) =>
|
|
324
|
+
o(boundingBoxes[1].children.map((c) => c.textContent)).deepEquals([
|
|
325
325
|
'5766358.9964 1757351.3045',
|
|
326
326
|
'5793264.8304 1798321.5516',
|
|
327
327
|
]);
|
|
328
328
|
|
|
329
329
|
const wgs84 = layer.find('ows:WGS84BoundingBox');
|
|
330
330
|
o(wgs84?.attrs.crs).equals('urn:ogc:def:crs:OGC:2:84');
|
|
331
|
-
o(wgs84?.children.map((c) =>
|
|
332
|
-
'174.7925 -38.2123',
|
|
333
|
-
'175.2594 -37.9962',
|
|
334
|
-
]);
|
|
331
|
+
o(wgs84?.children.map((c) => c.textContent)).deepEquals(['174.79248 -38.212288', '175.259399 -37.996163']);
|
|
335
332
|
});
|
|
336
333
|
|
|
337
334
|
o('should only output imagery if exists', () => {
|
|
@@ -363,4 +360,110 @@ o.spec('WmtsCapabilities', () => {
|
|
|
363
360
|
const layersB = tags(rawB, 'Layer');
|
|
364
361
|
o(layersB.length).equals(1);
|
|
365
362
|
});
|
|
363
|
+
|
|
364
|
+
o('should cover the entire WebMercatorBounds', () => {
|
|
365
|
+
const halfSize = GoogleTms.extent.width / 2;
|
|
366
|
+
// Create two fake imagery sets one covers tile z1 x0 y0 another covers tile z1 x1 y1
|
|
367
|
+
// so the entire bounding box should be tile z0 x0 y0 or the full extent
|
|
368
|
+
const imagery = new Map();
|
|
369
|
+
const imageTopLeft = { ...Imagery3857, id: 'im_top_left', name: 'top_left' };
|
|
370
|
+
imageTopLeft.bounds = { x: -halfSize, y: 0, width: halfSize, height: halfSize };
|
|
371
|
+
imagery.set(imageTopLeft.id, imageTopLeft);
|
|
372
|
+
|
|
373
|
+
const imageBottomRight = { ...Imagery3857, id: 'im_bottom_right', name: 'bottom_right' };
|
|
374
|
+
imageBottomRight.bounds = { x: 0, y: -halfSize, width: halfSize, height: halfSize };
|
|
375
|
+
imagery.set(imageBottomRight.id, imageBottomRight);
|
|
376
|
+
|
|
377
|
+
const tileSet = { ...TileSetAerial };
|
|
378
|
+
tileSet.layers = [
|
|
379
|
+
{ 3857: imageTopLeft.id, name: 'a_top_left' },
|
|
380
|
+
{ 3857: imageBottomRight.id, name: 'b_bottom_right' },
|
|
381
|
+
];
|
|
382
|
+
|
|
383
|
+
const raw = new WmtsCapabilities({
|
|
384
|
+
httpBase: 'https://basemaps.test',
|
|
385
|
+
provider: Provider,
|
|
386
|
+
tileMatrix: [GoogleTms],
|
|
387
|
+
tileSet,
|
|
388
|
+
imagery,
|
|
389
|
+
formats: [ImageFormat.Png],
|
|
390
|
+
isIndividualLayers: true,
|
|
391
|
+
}).toVNode();
|
|
392
|
+
|
|
393
|
+
const boundingBox = tags(raw, 'ows:WGS84BoundingBox').map((c) =>
|
|
394
|
+
c
|
|
395
|
+
.toString()
|
|
396
|
+
.split('\n')
|
|
397
|
+
.map((c) => c.trim()),
|
|
398
|
+
);
|
|
399
|
+
o(boundingBox[0][1]).deepEquals('<ows:LowerCorner>-180 -85.051129</ows:LowerCorner>');
|
|
400
|
+
o(boundingBox[0][2]).equals('<ows:UpperCorner>180 85.051129</ows:UpperCorner>');
|
|
401
|
+
|
|
402
|
+
o(boundingBox[1][1]).deepEquals('<ows:LowerCorner>-180 0</ows:LowerCorner>');
|
|
403
|
+
o(boundingBox[1][2]).equals('<ows:UpperCorner>0 85.051129</ows:UpperCorner>');
|
|
404
|
+
|
|
405
|
+
o(boundingBox[2][1]).deepEquals('<ows:LowerCorner>0 -85.051129</ows:LowerCorner>');
|
|
406
|
+
o(boundingBox[2][2]).equals('<ows:UpperCorner>180 0</ows:UpperCorner>');
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
o('should work when crossing anti meridian', () => {
|
|
410
|
+
const halfSize = GoogleTms.extent.width / 2;
|
|
411
|
+
|
|
412
|
+
const imagery = new Map();
|
|
413
|
+
// This image covers z1 x1.5 y1 to z1 x0.5 y1
|
|
414
|
+
// which cross the AM and covers half the width of two tiles
|
|
415
|
+
const imageBottomRight = { ...Imagery3857, id: 'im_bottom_right', name: 'bottom_right' };
|
|
416
|
+
imageBottomRight.bounds = { x: halfSize / 2, y: -halfSize, width: halfSize, height: halfSize };
|
|
417
|
+
imagery.set(imageBottomRight.id, imageBottomRight);
|
|
418
|
+
|
|
419
|
+
const tileSet = { ...TileSetAerial };
|
|
420
|
+
tileSet.layers = [{ 3857: imageBottomRight.id, name: 'b_bottom_right' }];
|
|
421
|
+
|
|
422
|
+
const raw = new WmtsCapabilities({
|
|
423
|
+
httpBase: 'https://basemaps.test',
|
|
424
|
+
provider: Provider,
|
|
425
|
+
tileMatrix: [GoogleTms],
|
|
426
|
+
tileSet,
|
|
427
|
+
imagery,
|
|
428
|
+
formats: [ImageFormat.Png],
|
|
429
|
+
isIndividualLayers: true,
|
|
430
|
+
}).toVNode();
|
|
431
|
+
|
|
432
|
+
const boundingBox = tags(raw, 'ows:WGS84BoundingBox').map((c) =>
|
|
433
|
+
roundNumbersInString(c.toString(), 4)
|
|
434
|
+
.split('\n')
|
|
435
|
+
.map((c) => c.trim()),
|
|
436
|
+
);
|
|
437
|
+
o(boundingBox[0][1]).deepEquals('<ows:LowerCorner>-180 -85.0511</ows:LowerCorner>');
|
|
438
|
+
o(boundingBox[0][2]).equals('<ows:UpperCorner>180 0</ows:UpperCorner>');
|
|
439
|
+
|
|
440
|
+
o(boundingBox[1][1]).deepEquals('<ows:LowerCorner>-180 -85.0511</ows:LowerCorner>');
|
|
441
|
+
o(boundingBox[1][2]).equals('<ows:UpperCorner>180 0</ows:UpperCorner>');
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
o('should work with NZTM2000Quad', () => {
|
|
445
|
+
const wmts = new WmtsCapabilities({ tileMatrix: [] } as any);
|
|
446
|
+
|
|
447
|
+
// Full NZTM200Quad coverage
|
|
448
|
+
const bbox = wmts.buildWgs84BoundingBox(Nztm2000QuadTms, []);
|
|
449
|
+
o(bbox.children[0].textContent).equals('-180 -49.929855');
|
|
450
|
+
o(bbox.children[1].textContent).equals('180 2.938603');
|
|
451
|
+
|
|
452
|
+
// Full NZTM200Quad coverage at z1
|
|
453
|
+
const bboxB = wmts.buildWgs84BoundingBox(Nztm2000QuadTms, [
|
|
454
|
+
Nztm2000QuadTms.tileToSourceBounds({ z: 1, x: 0, y: 0 }),
|
|
455
|
+
Nztm2000QuadTms.tileToSourceBounds({ z: 1, x: 1, y: 1 }),
|
|
456
|
+
]);
|
|
457
|
+
o(bboxB.children[0].textContent).equals('-180 -49.929855');
|
|
458
|
+
o(bboxB.children[1].textContent).equals('180 2.938603');
|
|
459
|
+
|
|
460
|
+
// Full NZTM200Quad coverage at z5
|
|
461
|
+
const tileCount = Nztm2000QuadTms.zooms[5].matrixWidth;
|
|
462
|
+
const bboxC = wmts.buildWgs84BoundingBox(Nztm2000QuadTms, [
|
|
463
|
+
Nztm2000QuadTms.tileToSourceBounds({ z: 5, x: 0, y: 0 }),
|
|
464
|
+
Nztm2000QuadTms.tileToSourceBounds({ z: 5, x: tileCount - 1, y: tileCount - 1 }),
|
|
465
|
+
]);
|
|
466
|
+
o(bboxC.children[0].textContent).equals('-180 -49.929855');
|
|
467
|
+
o(bboxC.children[1].textContent).equals('180 2.938603');
|
|
468
|
+
});
|
|
366
469
|
});
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import { TileMatrixSet } from '@basemaps/geo';
|
|
2
1
|
import { LogConfig } from '@basemaps/shared';
|
|
3
|
-
import { LambdaAlbRequest, LambdaHttpRequest } from '@linzjs/lambda';
|
|
2
|
+
import { LambdaAlbRequest, LambdaHttpRequest, LambdaUrlRequest } from '@linzjs/lambda';
|
|
4
3
|
import { Context } from 'aws-lambda';
|
|
5
|
-
import { TileSetRaster } from '../tile.set.raster.js';
|
|
6
|
-
import { TileSetVector } from '../tile.set.vector.js';
|
|
7
4
|
|
|
8
5
|
export function mockRequest(path: string, method = 'get', headers: Record<string, string> = {}): LambdaHttpRequest {
|
|
9
6
|
return new LambdaAlbRequest(
|
|
10
7
|
{
|
|
11
8
|
requestContext: null as any,
|
|
12
9
|
httpMethod: method.toUpperCase(),
|
|
13
|
-
path,
|
|
10
|
+
path: encodeURI(path),
|
|
14
11
|
headers,
|
|
15
12
|
body: null,
|
|
16
13
|
isBase64Encoded: false,
|
|
@@ -20,21 +17,21 @@ export function mockRequest(path: string, method = 'get', headers: Record<string
|
|
|
20
17
|
);
|
|
21
18
|
}
|
|
22
19
|
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
} as any
|
|
32
|
-
|
|
20
|
+
export function mockUrlRequest(path: string, query = '', headers: Record<string, unknown> = {}): LambdaHttpRequest {
|
|
21
|
+
return new LambdaUrlRequest(
|
|
22
|
+
{
|
|
23
|
+
requestContext: { http: { method: 'GET' } },
|
|
24
|
+
headers,
|
|
25
|
+
rawPath: encodeURI(path),
|
|
26
|
+
rawQueryString: query,
|
|
27
|
+
isBase64Encoded: false,
|
|
28
|
+
} as any,
|
|
29
|
+
{} as Context,
|
|
30
|
+
LogConfig.get(),
|
|
31
|
+
);
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
export
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
}
|
|
34
|
+
export const Api = {
|
|
35
|
+
key: 'd01f7w7rnhdzg0p7fyrc9v9ard1',
|
|
36
|
+
header: { 'x-linz-api-key': 'd01f7w7rnhdzg0p7fyrc9v9ard1' },
|
|
37
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,56 +1,93 @@
|
|
|
1
1
|
import { LogConfig } from '@basemaps/shared';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Router } from './router.js';
|
|
5
|
-
import { Ping, Version } from './routes/api.js';
|
|
2
|
+
import { LambdaHttpResponse, LambdaUrlRequest, lf } from '@linzjs/lambda';
|
|
3
|
+
import { tileAttributionGet } from './routes/attribution.js';
|
|
6
4
|
import { fontGet, fontList } from './routes/fonts.js';
|
|
7
|
-
import {
|
|
5
|
+
import { healthGet } from './routes/health.js';
|
|
8
6
|
import { imageryGet } from './routes/imagery.js';
|
|
7
|
+
import { pingGet } from './routes/ping.js';
|
|
9
8
|
import { spriteGet } from './routes/sprites.js';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const apiKey = Router.apiKey(req);
|
|
19
|
-
if (apiKey != null) {
|
|
20
|
-
const apiKeyHash = createHash('sha256').update(apiKey).digest('base64');
|
|
21
|
-
req.set('api', apiKeyHash);
|
|
22
|
-
}
|
|
23
|
-
return await app.handle(req);
|
|
24
|
-
}
|
|
9
|
+
import { tileJsonGet } from './routes/tile.json.js';
|
|
10
|
+
import { styleJsonGet } from './routes/tile.style.json.js';
|
|
11
|
+
import { wmtsCapabilitiesGet } from './routes/tile.wmts.js';
|
|
12
|
+
import { tileXyzGet } from './routes/tile.xyz.js';
|
|
13
|
+
import { versionGet } from './routes/version.js';
|
|
14
|
+
import { NotFound } from './util/response.js';
|
|
15
|
+
import { CoSources } from './util/source.cache.js';
|
|
16
|
+
import { St } from './util/source.tracer.js';
|
|
25
17
|
|
|
26
18
|
export const handler = lf.http(LogConfig.get());
|
|
27
19
|
|
|
28
20
|
handler.router.hook('request', (req) => {
|
|
29
21
|
req.set('name', 'LambdaTiler');
|
|
22
|
+
|
|
30
23
|
// Reset the request tracing before every request
|
|
31
24
|
St.reset();
|
|
32
25
|
});
|
|
33
26
|
|
|
34
|
-
handler.router.hook('response', (req) => {
|
|
27
|
+
handler.router.hook('response', (req, res) => {
|
|
35
28
|
if (St.requests.length > 0) {
|
|
36
29
|
// TODO this could be relaxed to every say 5% of requests if logging gets too verbose.
|
|
37
30
|
req.set('requests', St.requests.slice(0, 100)); // limit to 100 requests (some tiles need 100s of requests)
|
|
38
31
|
req.set('requestCount', St.requests.length);
|
|
39
32
|
}
|
|
33
|
+
// Log the source cache hit/miss ratio
|
|
34
|
+
req.set('sources', {
|
|
35
|
+
hits: CoSources.cache.hits,
|
|
36
|
+
misses: CoSources.cache.misses,
|
|
37
|
+
size: CoSources.cache.currentSize,
|
|
38
|
+
resets: CoSources.cache.resets,
|
|
39
|
+
cacheA: CoSources.cache.cacheA.size,
|
|
40
|
+
cacheB: CoSources.cache.cacheB.size,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// FunctionURLs automatically inject CORS responses for us
|
|
44
|
+
if (!(req instanceof LambdaUrlRequest) && req.headers.has('origin')) {
|
|
45
|
+
res.header('access-control-allow-origin', '*');
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// CORS is handled by function url hook so just return ok if the route exists
|
|
50
|
+
handler.router.options('*', (req) => {
|
|
51
|
+
const route = handler.router.router.find('GET', req.path);
|
|
52
|
+
if (route == null) return NotFound();
|
|
53
|
+
return LambdaHttpResponse.ok();
|
|
40
54
|
});
|
|
55
|
+
|
|
41
56
|
// TODO some internal health checks hit these routes, we should change them all to point at /v1/
|
|
42
|
-
handler.router.get('/ping',
|
|
43
|
-
handler.router.get('/health',
|
|
44
|
-
handler.router.get('/version',
|
|
57
|
+
handler.router.get('/ping', pingGet);
|
|
58
|
+
handler.router.get('/health', healthGet);
|
|
59
|
+
handler.router.get('/version', versionGet);
|
|
45
60
|
|
|
46
|
-
handler.router.get('/v1/ping',
|
|
47
|
-
handler.router.get('/v1/health',
|
|
48
|
-
handler.router.get('/v1/version',
|
|
61
|
+
handler.router.get('/v1/ping', pingGet);
|
|
62
|
+
handler.router.get('/v1/health', healthGet);
|
|
63
|
+
handler.router.get('/v1/version', versionGet);
|
|
49
64
|
|
|
65
|
+
// Image Metadata
|
|
50
66
|
handler.router.get('/v1/imagery/:imageryId/:fileName', imageryGet);
|
|
67
|
+
|
|
68
|
+
// Sprites
|
|
51
69
|
handler.router.get('/v1/sprites/:spriteName', spriteGet);
|
|
70
|
+
|
|
71
|
+
// Fonts
|
|
52
72
|
handler.router.get('/v1/fonts.json', fontList);
|
|
53
73
|
handler.router.get('/v1/fonts/:fontStack/:range.pbf', fontGet);
|
|
54
74
|
|
|
55
|
-
//
|
|
56
|
-
handler.router.get('
|
|
75
|
+
// StyleJSON
|
|
76
|
+
handler.router.get('/v1/styles/:styleName.json', styleJsonGet);
|
|
77
|
+
/** @deprecated 2022-07-22 all styles should be being served from /v1/styles/:styleName.json */
|
|
78
|
+
handler.router.get('/v1/tiles/:tileSet/:tileMatrix/style/:styleName.json', styleJsonGet);
|
|
79
|
+
|
|
80
|
+
// TileJSON
|
|
81
|
+
handler.router.get('/v1/tiles/:tileSet/:tileMatrix/tile.json', tileJsonGet);
|
|
82
|
+
|
|
83
|
+
// Tiles
|
|
84
|
+
handler.router.get('/v1/tiles/:tileSet/:tileMatrix/:z/:x/:y.:tileType', tileXyzGet);
|
|
85
|
+
|
|
86
|
+
// Attribution
|
|
87
|
+
handler.router.get('/v1/tiles/:tileSet/:tileMatrix/attribution.json', tileAttributionGet);
|
|
88
|
+
handler.router.get('/v1/attribution/:tileSet/:tileMatrix/summary.json', tileAttributionGet);
|
|
89
|
+
|
|
90
|
+
// WMTS Capabilities
|
|
91
|
+
handler.router.get('/v1/tiles/:tileSet/:tileMatrix/WMTSCapabilities.xml', wmtsCapabilitiesGet);
|
|
92
|
+
handler.router.get('/v1/tiles/:tileSet/WMTSCapabilities.xml', wmtsCapabilitiesGet);
|
|
93
|
+
handler.router.get('/v1/tiles/WMTSCapabilities.xml', wmtsCapabilitiesGet);
|