@basemaps/lambda-tiler 6.46.0 → 7.0.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.
Files changed (38) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +93 -1
  3. package/build/index.d.ts.map +1 -1
  4. package/build/index.js +3 -11
  5. package/build/index.js.map +1 -1
  6. package/build/util/config.loader.d.ts.map +1 -1
  7. package/build/util/config.loader.js +7 -1
  8. package/build/util/config.loader.js.map +1 -1
  9. package/package.json +11 -11
  10. package/src/index.ts +3 -12
  11. package/src/util/config.loader.ts +7 -1
  12. package/tsconfig.tsbuildinfo +1 -1
  13. package/typedoc.json +4 -0
  14. package/build/arcgis/__tests__/arcgis.style.json.test.d.ts +0 -2
  15. package/build/arcgis/__tests__/arcgis.style.json.test.d.ts.map +0 -1
  16. package/build/arcgis/__tests__/arcgis.style.json.test.js +0 -131
  17. package/build/arcgis/__tests__/arcgis.style.json.test.js.map +0 -1
  18. package/build/arcgis/__tests__/vector.tiler.server.test.d.ts +0 -2
  19. package/build/arcgis/__tests__/vector.tiler.server.test.d.ts.map +0 -1
  20. package/build/arcgis/__tests__/vector.tiler.server.test.js +0 -54
  21. package/build/arcgis/__tests__/vector.tiler.server.test.js.map +0 -1
  22. package/build/arcgis/arcgis.info.d.ts +0 -3
  23. package/build/arcgis/arcgis.info.d.ts.map +0 -1
  24. package/build/arcgis/arcgis.info.js +0 -25
  25. package/build/arcgis/arcgis.info.js.map +0 -1
  26. package/build/arcgis/arcgis.style.json.d.ts +0 -9
  27. package/build/arcgis/arcgis.style.json.d.ts.map +0 -1
  28. package/build/arcgis/arcgis.style.json.js +0 -75
  29. package/build/arcgis/arcgis.style.json.js.map +0 -1
  30. package/build/arcgis/vector.tile.server.d.ts +0 -8
  31. package/build/arcgis/vector.tile.server.d.ts.map +0 -1
  32. package/build/arcgis/vector.tile.server.js +0 -73
  33. package/build/arcgis/vector.tile.server.js.map +0 -1
  34. package/src/arcgis/__tests__/arcgis.style.json.test.ts +0 -157
  35. package/src/arcgis/__tests__/vector.tiler.server.test.ts +0 -70
  36. package/src/arcgis/arcgis.info.ts +0 -26
  37. package/src/arcgis/arcgis.style.json.ts +0 -83
  38. package/src/arcgis/vector.tile.server.ts +0 -81
@@ -1,3 +0,0 @@
1
- import { LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
2
- export declare function arcgisInfoGet(req: LambdaHttpRequest): Promise<LambdaHttpResponse>;
3
- //# sourceMappingURL=arcgis.info.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"arcgis.info.d.ts","sourceRoot":"","sources":["../../src/arcgis/arcgis.info.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAInF,wBAAsB,aAAa,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAoBvF"}
@@ -1,25 +0,0 @@
1
- import { Env } from '@basemaps/shared';
2
- import { HttpHeader, LambdaHttpResponse } from '@linzjs/lambda';
3
- import { Etag } from '../util/etag.js';
4
- import { NotFound, NotModified } from '../util/response.js';
5
- export async function arcgisInfoGet(req) {
6
- const host = Env.get(Env.PublicUrlBase);
7
- if (host == null)
8
- return NotFound();
9
- const info = {
10
- currentVersion: 10.1,
11
- fullVersion: '10.1',
12
- owningSystemUrl: host,
13
- };
14
- const json = JSON.stringify(info);
15
- const data = Buffer.from(json);
16
- const cacheKey = Etag.key(data);
17
- if (Etag.isNotModified(req, cacheKey))
18
- return NotModified();
19
- const response = new LambdaHttpResponse(200, 'ok');
20
- response.header(HttpHeader.CacheControl, 'public, max-age=604800, stale-while-revalidate=86400');
21
- response.buffer(data, 'application/json');
22
- req.set('bytes', data.byteLength);
23
- return response;
24
- }
25
- //# sourceMappingURL=arcgis.info.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"arcgis.info.js","sourceRoot":"","sources":["../../src/arcgis/arcgis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/lambda';
2
- interface StyleGet {
3
- Params: {
4
- tileSet: string;
5
- };
6
- }
7
- export declare function arcgisStyleJsonGet(req: LambdaHttpRequest<StyleGet>): Promise<LambdaHttpResponse>;
8
- export {};
9
- //# sourceMappingURL=arcgis.style.json.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"arcgis.style.json.d.ts","sourceRoot":"","sources":["../../src/arcgis/arcgis.style.json.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAOnF,UAAU,QAAQ;IAChB,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AA0CD,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,iBAAiB,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA2BtG"}
@@ -1,75 +0,0 @@
1
- import { TileSetType } from '@basemaps/config';
2
- import { Env, fsa } from '@basemaps/shared';
3
- import { HttpHeader, LambdaHttpResponse } from '@linzjs/lambda';
4
- import { convertRelativeUrl } from '../routes/tile.style.json.js';
5
- import { ConfigLoader } from '../util/config.loader.js';
6
- import { Etag } from '../util/etag.js';
7
- import { NotFound, NotModified } from '../util/response.js';
8
- import { Validate } from '../util/validate.js';
9
- function tileserverUrl(tileSet, apiKey) {
10
- var _a;
11
- const host = (_a = Env.get(Env.PublicUrlBase)) !== null && _a !== void 0 ? _a : '';
12
- const url = `/v1/arcgis/rest/services/${tileSet}/VectorTileServer`;
13
- const fullUrl = new URL(fsa.join(host, url));
14
- fullUrl.searchParams.set('api', apiKey);
15
- fullUrl.searchParams.set('f', 'json');
16
- return fullUrl.toString().replace(/%7B/g, '{').replace(/%7D/g, '}');
17
- }
18
- function convertStyleJson(tileSet, style, apiKey) {
19
- var _a;
20
- const sources = JSON.parse(JSON.stringify(style.sources));
21
- // Only keep the vector layer and update the source url
22
- for (const [key, value] of Object.entries(sources)) {
23
- if (value.type === 'vector') {
24
- value.url = tileserverUrl(tileSet, apiKey);
25
- sources[key] = value;
26
- }
27
- else {
28
- delete sources[key];
29
- }
30
- }
31
- // Remove all the not vector layers.
32
- const layers = [];
33
- for (const layer of style.layers) {
34
- if (layer.source != null && !sources.hasOwnProperty(layer.source))
35
- continue;
36
- layers.push(layer);
37
- }
38
- return {
39
- version: 8,
40
- id: style.id,
41
- name: style.name,
42
- sources,
43
- layers,
44
- metadata: (_a = style.metadata) !== null && _a !== void 0 ? _a : {},
45
- glyphs: convertRelativeUrl(style.glyphs),
46
- sprite: convertRelativeUrl(style.sprite),
47
- };
48
- }
49
- export async function arcgisStyleJsonGet(req) {
50
- const apiKey = Validate.apiKey(req);
51
- const config = await ConfigLoader.load(req);
52
- const tileSet = await config.TileSet.get(config.TileSet.id(req.params.tileSet));
53
- if ((tileSet === null || tileSet === void 0 ? void 0 : tileSet.type) !== TileSetType.Vector)
54
- return NotFound();
55
- const style = req.query.get('style');
56
- const styleName = style ? style : 'topographic'; // Defalut to topographic style
57
- // Get style Config from db
58
- const dbId = config.Style.id(styleName);
59
- const styleConfig = await config.Style.get(dbId);
60
- if (styleConfig == null)
61
- return NotFound();
62
- // Prepare sources and add linz source
63
- const styleJson = convertStyleJson(tileSet.name, styleConfig.style, apiKey);
64
- const data = Buffer.from(JSON.stringify(styleJson));
65
- const cacheKey = Etag.key(data);
66
- if (Etag.isNotModified(req, cacheKey))
67
- return NotModified();
68
- const response = new LambdaHttpResponse(200, 'ok');
69
- response.header(HttpHeader.ETag, cacheKey);
70
- response.header(HttpHeader.CacheControl, 'no-store');
71
- response.buffer(data, 'application/json');
72
- req.set('bytes', data.byteLength);
73
- return response;
74
- }
75
- //# sourceMappingURL=arcgis.style.json.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"arcgis.style.json.js","sourceRoot":"","sources":["../../src/arcgis/arcgis.style.json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,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AAC;IAClC,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -1,8 +0,0 @@
1
- import { LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
2
- export interface VectorTileServer {
3
- Params: {
4
- tileSet: string;
5
- };
6
- }
7
- export declare function arcgisTileServerGet(req: LambdaHttpRequest<VectorTileServer>): Promise<LambdaHttpResponse>;
8
- //# sourceMappingURL=vector.tile.server.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vector.tile.server.d.ts","sourceRoot":"","sources":["../../src/arcgis/vector.tile.server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAUnF,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAED,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA8D/G"}
@@ -1,73 +0,0 @@
1
- import { TileSetType } from '@basemaps/config';
2
- import { GoogleTms } from '@basemaps/geo';
3
- import { HttpHeader, LambdaHttpResponse } from '@linzjs/lambda';
4
- import { convertRelativeUrl } from '../routes/tile.style.json.js';
5
- import { ConfigLoader } from '../util/config.loader.js';
6
- import { NotFound } from '../util/response.js';
7
- import { Validate } from '../util/validate.js';
8
- /** Zoom level for the tilematrix which will be slice by 1 during the covertion to arcgis tileserve lods */
9
- const MaxTileMatrixZoom = 18;
10
- const MinTileMatrixZoom = 1;
11
- export async function arcgisTileServerGet(req) {
12
- const config = await ConfigLoader.load(req);
13
- const tileSet = await config.TileSet.get(config.TileSet.id(req.params.tileSet));
14
- if ((tileSet === null || tileSet === void 0 ? void 0 : tileSet.type) !== TileSetType.Vector)
15
- return NotFound();
16
- const apiKey = Validate.apiKey(req);
17
- const f = req.query.get('f');
18
- if (f !== 'json')
19
- return NotFound();
20
- const extent = {
21
- xmin: GoogleTms.extent.x,
22
- ymin: GoogleTms.extent.y,
23
- xmax: GoogleTms.extent.right,
24
- ymax: GoogleTms.extent.bottom,
25
- // TODO where is wkid from
26
- spatialReference: { wkid: 102100, latestWkid: GoogleTms.projection.code },
27
- };
28
- const vectorTileServer = {
29
- currentVersion: 10.81,
30
- name: tileSet.name,
31
- capabilities: 'TilesOnly',
32
- type: 'indexedVector',
33
- defaultStyles: '',
34
- tiles: [convertRelativeUrl(`/v1/tiles/${tileSet.name}/WebMercatorQuad/{z}/{x}/{y}.pbf`, apiKey)],
35
- exportTilesAllowed: false,
36
- maxExportTilesCount: 0,
37
- initialExtent: extent,
38
- fullExtent: extent,
39
- minScale: 0.0,
40
- maxScale: 0.0,
41
- tileInfo: {
42
- rows: 512,
43
- cols: 512,
44
- dpi: 96,
45
- format: 'pbf',
46
- origin: { x: GoogleTms.extent.x, y: GoogleTms.extent.bottom },
47
- spatialReference: { wkid: 102100, latestWkid: GoogleTms.projection.code },
48
- lods: GoogleTms.zooms.slice(MinTileMatrixZoom, MaxTileMatrixZoom).map((c, i) => {
49
- return {
50
- level: i,
51
- resolution: c.scaleDenominator * 0.28e-3,
52
- scale: c.scaleDenominator,
53
- };
54
- }),
55
- },
56
- maxzoom: 22,
57
- minLOD: 0,
58
- maxLOD: 15,
59
- resourceInfo: {
60
- styleVersion: 8,
61
- tileCompression: 'gzip',
62
- cacheInfo: { storageInfo: { packetSize: 128, storageFormat: 'compactV2' } },
63
- },
64
- };
65
- const json = JSON.stringify(vectorTileServer, null, 2);
66
- const data = Buffer.from(json);
67
- const response = new LambdaHttpResponse(200, 'ok');
68
- response.header(HttpHeader.CacheControl, 'no-store');
69
- response.buffer(data, 'application/json');
70
- req.set('bytes', data.byteLength);
71
- return response;
72
- }
73
- //# sourceMappingURL=vector.tile.server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vector.tile.server.js","sourceRoot":"","sources":["../../src/arcgis/vector.tile.server.ts"],"names":[],"mappings":"AAAA,O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EAAE;QACX,MAAM,EAAE,CAAC;QACT,MAAM,EAAE,EAAE;QACV,YAAY,EAAE;YACZ,YAAY,EAAE,CAAC;YACf,eAAe,EAAE,MAAM;YACvB,SAAS,EAAE,EAAE,WAAW,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,aAAa,EAAE,WAAW,EAAE,EAAE;SAC5E;KACF,CAAC;IAEF,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACvD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE/B,MAAM,QAAQ,GAAG,IAAI,kBAAkB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACnD,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IACrD,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;IAC1C,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAClC,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -1,157 +0,0 @@
1
- import { BaseConfig, ConfigProviderMemory, StyleJson } from '@basemaps/config';
2
- import { Env } from '@basemaps/shared';
3
- import o from 'ospec';
4
- import { createSandbox } from 'sinon';
5
- import { handler } from '../../index.js';
6
- import { ConfigLoader } from '../../util/config.loader.js';
7
- import { FakeData } from '../../__tests__/config.data.js';
8
- import { Api, mockRequest, mockUrlRequest } from '../../__tests__/xyz.util.js';
9
-
10
- o.spec('arcgis/stylejson', () => {
11
- const host = 'https://tiles.test';
12
- const sandbox = createSandbox();
13
- const config = new ConfigProviderMemory();
14
-
15
- o.before(() => {
16
- process.env[Env.PublicUrlBase] = host;
17
- });
18
-
19
- o.beforeEach(() => {
20
- sandbox.stub(ConfigLoader, 'getDefaultConfig').resolves(config);
21
- config.objects.clear();
22
- });
23
-
24
- o.afterEach(() => {
25
- sandbox.restore();
26
- });
27
-
28
- o('should not found tile set', async () => {
29
- const request = mockRequest('/v1/arcgis/rest/services/topographic/VectorTileServer/root.json', 'get', Api.header);
30
-
31
- const res = await handler.router.handle(request);
32
- o(res.status).equals(404);
33
- });
34
-
35
- o('should not found style', async () => {
36
- const request = mockRequest('/v1/arcgis/rest/services/topographic/VectorTileServer/root.json', 'get', Api.header);
37
- config.put(FakeData.tileSetVector('topographic'));
38
-
39
- const res = await handler.router.handle(request);
40
- o(res.status).equals(404);
41
- });
42
-
43
- const fakeStyle: StyleJson = {
44
- version: 8,
45
- id: 'test',
46
- name: 'topographic',
47
- sources: {
48
- basemaps_vector: {
49
- type: 'vector',
50
- url: `/vector`,
51
- },
52
- basemaps_raster: {
53
- type: 'raster',
54
- tiles: [`/raster`],
55
- },
56
- },
57
- layers: [
58
- {
59
- source: 'basemaps_vector',
60
- layout: {
61
- visibility: 'visible',
62
- },
63
- paint: {
64
- 'background-color': 'rgba(206, 229, 242, 1)',
65
- },
66
- id: 'Background-vector',
67
- type: 'background',
68
- minzoom: 0,
69
- },
70
- {
71
- source: 'basemaps_raster',
72
- layout: {
73
- visibility: 'visible',
74
- },
75
- paint: {
76
- 'background-color': 'rgba(222, 229, 132, 1)',
77
- },
78
- id: 'Background-raster',
79
- type: 'background',
80
- minzoom: 0,
81
- },
82
- ],
83
- glyphs: '/glyphs',
84
- sprite: '/sprite',
85
- metadata: { id: 'test' },
86
- };
87
-
88
- const fakeRecord = {
89
- id: 'st_topographic',
90
- name: 'topographic',
91
- style: fakeStyle,
92
- };
93
-
94
- o('should serve style json and remove the raster source and layers, then replace the vector url', async () => {
95
- const request = mockRequest('/v1/arcgis/rest/services/topographic/VectorTileServer/root.json', 'get', Api.header);
96
-
97
- config.put(FakeData.tileSetVector('topographic'));
98
- config.put(fakeRecord);
99
-
100
- const res = await handler.router.handle(request);
101
- o(res.status).equals(200);
102
- o(res.header('content-type')).equals('application/json');
103
- o(res.header('cache-control')).equals('no-store');
104
-
105
- const body = Buffer.from(res.body ?? '', 'base64').toString();
106
- fakeStyle.sources.basemaps_vector = {
107
- type: 'vector',
108
- url: `${host}/v1/arcgis/rest/services/topographic/VectorTileServer?api=${Api.key}&f=json`,
109
- };
110
- delete fakeStyle.sources.basemaps_raster;
111
- fakeStyle.layers = [fakeStyle.layers[0]];
112
-
113
- fakeStyle.sprite = `${host}/sprite`;
114
- fakeStyle.glyphs = `${host}/glyphs`;
115
-
116
- o(JSON.parse(body)).deepEquals(fakeStyle);
117
- });
118
-
119
- o('should not found for raster tileset', async () => {
120
- const request = mockRequest('/v1/arcgis/rest/services/raster/VectorTileServer/root.json', 'get', Api.header);
121
-
122
- config.put(FakeData.tileSetRaster('raster'));
123
- config.put(fakeRecord);
124
-
125
- const res = await handler.router.handle(request);
126
- o(res.status).equals(404);
127
- });
128
-
129
- o('should fine the new style with url query', async () => {
130
- const request = mockUrlRequest(
131
- '/v1/arcgis/rest/services/topographic/VectorTileServer/root.json',
132
- 'style=topolite',
133
- Api.header,
134
- );
135
-
136
- config.put({ id: 'st_topolite', name: 'topographic', style: fakeStyle } as BaseConfig);
137
- config.put(FakeData.tileSetVector('topographic'));
138
-
139
- const res = await handler.router.handle(request);
140
- o(res.status).equals(200);
141
- o(res.header('content-type')).equals('application/json');
142
- o(res.header('cache-control')).equals('no-store');
143
-
144
- const body = Buffer.from(res.body ?? '', 'base64').toString();
145
- fakeStyle.sources.basemaps_vector = {
146
- type: 'vector',
147
- url: `${host}/v1/arcgis/rest/services/topographic/VectorTileServer?api=${Api.key}&f=json`,
148
- };
149
- delete fakeStyle.sources.basemaps_raster;
150
- fakeStyle.layers = [fakeStyle.layers[0]];
151
-
152
- fakeStyle.sprite = `${host}/sprite`;
153
- fakeStyle.glyphs = `${host}/glyphs`;
154
-
155
- o(JSON.parse(body)).deepEquals(fakeStyle);
156
- });
157
- });
@@ -1,70 +0,0 @@
1
- import { ConfigProviderMemory } from '@basemaps/config';
2
- import { Env } from '@basemaps/shared';
3
- import o from 'ospec';
4
- import { createSandbox } from 'sinon';
5
- import { handler } from '../../index.js';
6
- import { ConfigLoader } from '../../util/config.loader.js';
7
- import { FakeData } from '../../__tests__/config.data.js';
8
- import { Api, mockRequest, mockUrlRequest } from '../../__tests__/xyz.util.js';
9
-
10
- o.spec('arcgis/VectorTileServer', () => {
11
- const host = 'https://tiles.test';
12
- const sandbox = createSandbox();
13
- const config = new ConfigProviderMemory();
14
-
15
- o.before(() => {
16
- process.env[Env.PublicUrlBase] = host;
17
- });
18
-
19
- o.beforeEach(() => {
20
- sandbox.stub(ConfigLoader, 'getDefaultConfig').resolves(config);
21
- config.objects.clear();
22
- });
23
-
24
- o.afterEach(() => {
25
- sandbox.restore();
26
- });
27
-
28
- o('should not found tile set', async () => {
29
- const request = mockUrlRequest('/v1/arcgis/rest/services/topographic/VectorTileServer', 'f=json', Api.header);
30
-
31
- const res = await handler.router.handle(request);
32
- o(res.status).equals(404);
33
- });
34
- o('should return the vector tile server', async () => {
35
- const request = mockUrlRequest('/v1/arcgis/rest/services/topographic/VectorTileServer', 'f=json', Api.header);
36
-
37
- config.put(FakeData.tileSetVector('topographic'));
38
-
39
- const res = await handler.router.handle(request);
40
- o(res.status).equals(200);
41
- o(res.header('content-type')).equals('application/json');
42
- o(res.header('cache-control')).equals('no-store');
43
-
44
- const body = JSON.parse(Buffer.from(res.body ?? '', 'base64').toString());
45
- o(body.tiles[0]).equals(`${host}/v1/tiles/topographic/WebMercatorQuad/{z}/{x}/{y}.pbf?api=${Api.key}`);
46
- o(body.tileInfo.lods.length).equals(17);
47
- });
48
- o('should not return with no f=json query', async () => {
49
- const request = mockRequest('/v1/arcgis/rest/services/topographic/VectorTileServer', 'get', Api.header);
50
-
51
- config.put(FakeData.tileSetVector('topographic'));
52
-
53
- const res = await handler.router.handle(request);
54
- o(res.status).equals(404);
55
- });
56
- o('should return ok for post request', async () => {
57
- const request = mockUrlRequest(
58
- '/v1/arcgis/rest/services/topographic/VectorTileServer',
59
- 'f=json',
60
- Api.header,
61
- 'POST',
62
- );
63
-
64
- config.put(FakeData.tileSetVector('topographic'));
65
-
66
- const res = await handler.router.handle(request);
67
- o(res.status).equals(200);
68
- o(res.body).deepEquals(`{"id":"${request.id}","correlationId":"${request.correlationId}","message":"ok"}`);
69
- });
70
- });
@@ -1,26 +0,0 @@
1
- import { Env } from '@basemaps/shared';
2
- import { HttpHeader, LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
3
- import { Etag } from '../util/etag.js';
4
- import { NotFound, NotModified } from '../util/response.js';
5
-
6
- export async function arcgisInfoGet(req: LambdaHttpRequest): Promise<LambdaHttpResponse> {
7
- const host = Env.get(Env.PublicUrlBase);
8
- if (host == null) return NotFound();
9
- const info = {
10
- currentVersion: 10.1,
11
- fullVersion: '10.1',
12
- owningSystemUrl: host,
13
- };
14
-
15
- const json = JSON.stringify(info);
16
- const data = Buffer.from(json);
17
-
18
- const cacheKey = Etag.key(data);
19
- if (Etag.isNotModified(req, cacheKey)) return NotModified();
20
-
21
- const response = new LambdaHttpResponse(200, 'ok');
22
- response.header(HttpHeader.CacheControl, 'public, max-age=604800, stale-while-revalidate=86400');
23
- response.buffer(data, 'application/json');
24
- req.set('bytes', data.byteLength);
25
- return response;
26
- }
@@ -1,83 +0,0 @@
1
- import { Sources, StyleJson, TileSetType } from '@basemaps/config';
2
- import { Env, fsa } from '@basemaps/shared';
3
- import { HttpHeader, LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
4
- import { convertRelativeUrl } from '../routes/tile.style.json.js';
5
- import { ConfigLoader } from '../util/config.loader.js';
6
- import { Etag } from '../util/etag.js';
7
- import { NotFound, NotModified } from '../util/response.js';
8
- import { Validate } from '../util/validate.js';
9
-
10
- interface StyleGet {
11
- Params: {
12
- tileSet: string;
13
- };
14
- }
15
-
16
- function tileserverUrl(tileSet: string, apiKey: string): string {
17
- const host = Env.get(Env.PublicUrlBase) ?? '';
18
- const url = `/v1/arcgis/rest/services/${tileSet}/VectorTileServer`;
19
- const fullUrl = new URL(fsa.join(host, url));
20
- fullUrl.searchParams.set('api', apiKey);
21
- fullUrl.searchParams.set('f', 'json');
22
- return fullUrl.toString().replace(/%7B/g, '{').replace(/%7D/g, '}');
23
- }
24
-
25
- function convertStyleJson(tileSet: string, style: StyleJson, apiKey: string): StyleJson {
26
- const sources: Sources = JSON.parse(JSON.stringify(style.sources));
27
- // Only keep the vector layer and update the source url
28
- for (const [key, value] of Object.entries(sources)) {
29
- if (value.type === 'vector') {
30
- value.url = tileserverUrl(tileSet, apiKey);
31
- sources[key] = value;
32
- } else {
33
- delete sources[key];
34
- }
35
- }
36
-
37
- // Remove all the not vector layers.
38
- const layers = [];
39
- for (const layer of style.layers) {
40
- if (layer.source != null && !sources.hasOwnProperty(layer.source)) continue;
41
- layers.push(layer);
42
- }
43
-
44
- return {
45
- version: 8,
46
- id: style.id,
47
- name: style.name,
48
- sources,
49
- layers,
50
- metadata: style.metadata ?? {},
51
- glyphs: convertRelativeUrl(style.glyphs),
52
- sprite: convertRelativeUrl(style.sprite),
53
- } as StyleJson;
54
- }
55
-
56
- export async function arcgisStyleJsonGet(req: LambdaHttpRequest<StyleGet>): Promise<LambdaHttpResponse> {
57
- const apiKey = Validate.apiKey(req);
58
- const config = await ConfigLoader.load(req);
59
- const tileSet = await config.TileSet.get(config.TileSet.id(req.params.tileSet));
60
- if (tileSet?.type !== TileSetType.Vector) return NotFound();
61
-
62
- const style = req.query.get('style');
63
- const styleName = style ? style : 'topographic'; // Defalut to topographic style
64
-
65
- // Get style Config from db
66
- const dbId = config.Style.id(styleName);
67
- const styleConfig = await config.Style.get(dbId);
68
- if (styleConfig == null) return NotFound();
69
-
70
- // Prepare sources and add linz source
71
- const styleJson = convertStyleJson(tileSet.name, styleConfig.style, apiKey);
72
- const data = Buffer.from(JSON.stringify(styleJson));
73
-
74
- const cacheKey = Etag.key(data);
75
- if (Etag.isNotModified(req, cacheKey)) return NotModified();
76
-
77
- const response = new LambdaHttpResponse(200, 'ok');
78
- response.header(HttpHeader.ETag, cacheKey);
79
- response.header(HttpHeader.CacheControl, 'no-store');
80
- response.buffer(data, 'application/json');
81
- req.set('bytes', data.byteLength);
82
- return response;
83
- }
@@ -1,81 +0,0 @@
1
- import { TileSetType } from '@basemaps/config';
2
- import { GoogleTms } from '@basemaps/geo';
3
- import { HttpHeader, LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
4
- import { convertRelativeUrl } from '../routes/tile.style.json.js';
5
- import { ConfigLoader } from '../util/config.loader.js';
6
- import { NotFound } from '../util/response.js';
7
- import { Validate } from '../util/validate.js';
8
-
9
- /** Zoom level for the tilematrix which will be slice by 1 during the covertion to arcgis tileserve lods */
10
- const MaxTileMatrixZoom = 18;
11
- const MinTileMatrixZoom = 1;
12
-
13
- export interface VectorTileServer {
14
- Params: {
15
- tileSet: string;
16
- };
17
- }
18
-
19
- export async function arcgisTileServerGet(req: LambdaHttpRequest<VectorTileServer>): Promise<LambdaHttpResponse> {
20
- const config = await ConfigLoader.load(req);
21
-
22
- const tileSet = await config.TileSet.get(config.TileSet.id(req.params.tileSet));
23
- if (tileSet?.type !== TileSetType.Vector) return NotFound();
24
- const apiKey = Validate.apiKey(req);
25
- const f = req.query.get('f');
26
- if (f !== 'json') return NotFound();
27
- const extent = {
28
- xmin: GoogleTms.extent.x,
29
- ymin: GoogleTms.extent.y,
30
- xmax: GoogleTms.extent.right,
31
- ymax: GoogleTms.extent.bottom,
32
- // TODO where is wkid from
33
- spatialReference: { wkid: 102100, latestWkid: GoogleTms.projection.code },
34
- };
35
- const vectorTileServer = {
36
- currentVersion: 10.81,
37
- name: tileSet.name,
38
- capabilities: 'TilesOnly',
39
- type: 'indexedVector',
40
- defaultStyles: '',
41
- tiles: [convertRelativeUrl(`/v1/tiles/${tileSet.name}/WebMercatorQuad/{z}/{x}/{y}.pbf`, apiKey)],
42
- exportTilesAllowed: false,
43
- maxExportTilesCount: 0,
44
- initialExtent: extent,
45
- fullExtent: extent,
46
- minScale: 0.0,
47
- maxScale: 0.0,
48
- tileInfo: {
49
- rows: 512,
50
- cols: 512,
51
- dpi: 96,
52
- format: 'pbf',
53
- origin: { x: GoogleTms.extent.x, y: GoogleTms.extent.bottom },
54
- spatialReference: { wkid: 102100, latestWkid: GoogleTms.projection.code },
55
- lods: GoogleTms.zooms.slice(MinTileMatrixZoom, MaxTileMatrixZoom).map((c, i) => {
56
- return {
57
- level: i,
58
- resolution: c.scaleDenominator * 0.28e-3,
59
- scale: c.scaleDenominator,
60
- };
61
- }),
62
- },
63
- maxzoom: 22,
64
- minLOD: 0,
65
- maxLOD: 15,
66
- resourceInfo: {
67
- styleVersion: 8,
68
- tileCompression: 'gzip',
69
- cacheInfo: { storageInfo: { packetSize: 128, storageFormat: 'compactV2' } },
70
- },
71
- };
72
-
73
- const json = JSON.stringify(vectorTileServer, null, 2);
74
- const data = Buffer.from(json);
75
-
76
- const response = new LambdaHttpResponse(200, 'ok');
77
- response.header(HttpHeader.CacheControl, 'no-store');
78
- response.buffer(data, 'application/json');
79
- req.set('bytes', data.byteLength);
80
- return response;
81
- }