Skip to content

Commit

Permalink
feat(config): Update the config to support sky in the style json. BM-…
Browse files Browse the repository at this point in the history
…1052 (#3314)

### Motivation

Update the config style parser and loader to include sky in the
stylejson.

### Modifications

Add sky type into stylejson

### Verification


![image](https://github.com/linz/basemaps/assets/12163920/1d75956e-ffcf-40a0-8000-cb5064762d69)

![image](https://github.com/linz/basemaps/assets/12163920/852a5d68-de74-429a-8ff3-8ef1d90fb1b4)
  • Loading branch information
Wentao-Kuang authored Jul 10, 2024
1 parent ab711d6 commit 60db515
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/config-loader/src/json/parse.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const zStyleJson = z.object({

// TODO it would be good to actually validate all the styles
layers: z.array(z.unknown()),
sky: z.unknown(),
});

export type StyleJsonConfigSchema = z.infer<typeof zStyleJson>;
21 changes: 21 additions & 0 deletions packages/config/src/config/vector.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ export interface Layer {
'source-layer'?: string;
}

/** Sky MapLibre Style Spec, all valuables support interpolate expressions, as unknown format */
export interface Sky {
/** The base color for the sky. Optional Defaults to #88C6FC */
'sky-color'?: string | unknown[];
/** The base color at the horizon. Optional Defaults to #ffffff */
'horizon-color'?: string | unknown[];
/** The base color for the fog. Requires 3D terrain. Optional Defaults to #ffffff */
'fog-color'?: string | unknown[];
/** How to blend the fog over the 3D terrain. Optional number in range [0, 1]. Defaults to 0.5 */
'fog-ground-blend'?: number | unknown[];
/** How to blend the fog color and the horizon color. Optional number in range [0, 1]. Defaults to 0.8. */
'horizon-fog-blend'?: number | unknown[];
/** How to blend the the sky color and the horizon color. Optional number in range [0, 1]. Defaults to 0.8. */
'sky-horizon-blend'?: number | unknown[];
/** How to blend the atmosphere. Optional number in range [0, 1]. Defaults to 0.8. */
'atmosphere-blend'?: number | unknown[];
}

export interface Terrain {
source: string;
exaggeration: number;
Expand Down Expand Up @@ -73,6 +91,9 @@ export interface StyleJson {
/** Layers will be drawn in the order of this array. */
layers: Layer[];

/** The map's sky configuration */
sky?: Sky;

/** OPTIONAL - A global modifier that elevates layers and markers based on a DEM data source */
terrain?: Terrain;
}
Expand Down
1 change: 1 addition & 0 deletions packages/lambda-tiler/src/routes/tile.style.json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export function convertStyleJson(
if (style.metadata) styleJson.metadata = style.metadata;
if (style.glyphs) styleJson.glyphs = convertRelativeUrl(style.glyphs, undefined, undefined, config);
if (style.sprite) styleJson.sprite = convertRelativeUrl(style.sprite, undefined, undefined, config);
if (style.sky) styleJson.sky = style.sky;

return styleJson;
}
Expand Down

0 comments on commit 60db515

Please sign in to comment.