@basemaps/lambda-tiler 7.11.0 → 7.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/build/index.js +9 -4
- package/build/index.js.map +1 -1
- package/build/routes/__tests__/link.test.d.ts +1 -0
- package/build/routes/__tests__/link.test.js +82 -0
- package/build/routes/__tests__/link.test.js.map +1 -0
- package/build/routes/__tests__/tile.style.json.attribution.test.d.ts +1 -0
- package/build/routes/__tests__/tile.style.json.attribution.test.js +172 -0
- package/build/routes/__tests__/tile.style.json.attribution.test.js.map +1 -0
- package/build/routes/attribution.d.ts +19 -1
- package/build/routes/attribution.js +38 -3
- package/build/routes/attribution.js.map +1 -1
- package/build/routes/link.d.ts +17 -0
- package/build/routes/link.js +42 -0
- package/build/routes/link.js.map +1 -0
- package/build/routes/tile.style.json.d.ts +2 -2
- package/build/routes/tile.style.json.js +12 -4
- package/build/routes/tile.style.json.js.map +1 -1
- package/package.json +9 -9
- package/src/index.ts +10 -4
- package/src/routes/__tests__/link.test.ts +114 -0
- package/src/routes/__tests__/tile.style.json.attribution.test.ts +224 -0
- package/src/routes/attribution.ts +50 -5
- package/src/routes/link.ts +55 -0
- package/src/routes/tile.style.json.ts +15 -4
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -19,6 +19,7 @@ import { Etag } from '../util/etag.js';
|
|
|
19
19
|
import { convertStyleToNztmStyle } from '../util/nztm.style.js';
|
|
20
20
|
import { NotFound, NotModified } from '../util/response.js';
|
|
21
21
|
import { Validate } from '../util/validate.js';
|
|
22
|
+
import { createTileSetAttribution } from './attribution.js';
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Convert relative URL into a full hostname URL, converting {tileMatrix} into the provided tileMatrix
|
|
@@ -153,12 +154,13 @@ async function ensureTerrain(
|
|
|
153
154
|
* Generate a StyleJSON from a tileset
|
|
154
155
|
* @returns
|
|
155
156
|
*/
|
|
156
|
-
export function tileSetToStyle(
|
|
157
|
+
export async function tileSetToStyle(
|
|
157
158
|
req: LambdaHttpRequest<StyleGet>,
|
|
159
|
+
config: BasemapsConfigProvider,
|
|
158
160
|
tileSet: ConfigTileSetRaster,
|
|
159
161
|
tileMatrix: TileMatrixSet,
|
|
160
162
|
apiKey: string,
|
|
161
|
-
): StyleJson {
|
|
163
|
+
): Promise<StyleJson> {
|
|
162
164
|
// If the style has outputs defined it has a different process for generating the stylejson
|
|
163
165
|
if (tileSet.outputs) return tileSetOutputToStyle(req, tileSet, tileMatrix, apiKey);
|
|
164
166
|
|
|
@@ -175,12 +177,21 @@ export function tileSetToStyle(
|
|
|
175
177
|
(Env.get(Env.PublicUrlBase) ?? '') +
|
|
176
178
|
`/v1/tiles/${tileSet.name}/${tileMatrix.identifier}/{z}/{x}/{y}.${tileFormat}${query}`;
|
|
177
179
|
|
|
180
|
+
const attribution = await createTileSetAttribution(config, tileSet, tileMatrix.projection);
|
|
181
|
+
|
|
178
182
|
const styleId = `basemaps-${tileSet.name}`;
|
|
179
183
|
return {
|
|
180
184
|
id: ConfigId.prefix(ConfigPrefix.Style, tileSet.name),
|
|
181
185
|
name: tileSet.name,
|
|
182
186
|
version: 8,
|
|
183
|
-
sources: {
|
|
187
|
+
sources: {
|
|
188
|
+
[styleId]: {
|
|
189
|
+
type: 'raster',
|
|
190
|
+
tiles: [tileUrl],
|
|
191
|
+
tileSize: 256,
|
|
192
|
+
attribution,
|
|
193
|
+
},
|
|
194
|
+
},
|
|
184
195
|
layers: [{ id: styleId, type: 'raster', source: styleId }],
|
|
185
196
|
};
|
|
186
197
|
}
|
|
@@ -248,7 +259,7 @@ async function generateStyleFromTileSet(
|
|
|
248
259
|
throw new LambdaHttpResponse(400, 'Only raster tile sets can generate style JSON');
|
|
249
260
|
}
|
|
250
261
|
if (tileSet.outputs) return tileSetOutputToStyle(req, tileSet, tileMatrix, apiKey);
|
|
251
|
-
|
|
262
|
+
return tileSetToStyle(req, config, tileSet, tileMatrix, apiKey);
|
|
252
263
|
}
|
|
253
264
|
|
|
254
265
|
export interface StyleGet {
|