Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config): Update the config to support sky in the style json. BM-1052 #3314

Merged
merged 2 commits into from
Jul 10, 2024
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
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
Loading