@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.
@@ -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: { [styleId]: { type: 'raster', tiles: [tileUrl], tileSize: 256 } },
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
- else return tileSetToStyle(req, tileSet, tileMatrix, apiKey);
262
+ return tileSetToStyle(req, config, tileSet, tileMatrix, apiKey);
252
263
  }
253
264
 
254
265
  export interface StyleGet {