Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/config/src/config/vector.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ export interface Terrain {
exaggeration: number;
}

/**
* https://maplibre.org/maplibre-style-spec/projection/
*
* `type` is either one of MapLibre's built in projections ("mercator" | "globe")
* or the name of a projection registered with `maplibregl.addProjection()`, eg "EPSG:2193"
*/
export interface Projection {
type: string;
}

export type Source = SourceVector | SourceRaster | SourceRasterDem;

export type Sources = Record<string, Source>;
Expand Down Expand Up @@ -107,6 +117,9 @@ export interface StyleJson {

/** OPTIONAL - A global modifier that elevates layers and markers based on a DEM data source */
terrain?: Terrain;

/** OPTIONAL - The projection the tiles are served in, if not the default "mercator" */
projection?: Projection;
}

export interface ConfigVectorStyle extends ConfigBase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,5 +582,6 @@ describe('/v1/styles', () => {
],
},
});
assert.deepEqual(style.projection, { type: 'EPSG:2193' });
});
});
5 changes: 4 additions & 1 deletion packages/lambda-tiler/src/routes/tile.style.json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,10 @@ export async function styleJsonGet(req: LambdaHttpRequest<StyleGet>): Promise<La
// convert sources to full URLS and convert style between projections
setStyleUrls(targetStyle, tileMatrix, apiKey, ConfigLoader.extract(req));

if (tileMatrix.identifier === Nztm2000QuadTms.identifier) convertStyleToNztmStyle(targetStyle, false);
if (tileMatrix.identifier === Nztm2000QuadTms.identifier) {
convertStyleToNztmStyle(targetStyle, false);
targetStyle.projection = { type: tileMatrix.projection.toEpsgString() };
}

// filter out any excluded layers
if (excluded.size > 0) targetStyle.layers = targetStyle.layers.filter((f) => !excluded.has(f.id.toLowerCase()));
Expand Down
Loading