Add override-all option to layers
This commit is contained in:
parent
a4f8559108
commit
1a1477ca43
3 changed files with 23 additions and 8 deletions
|
@ -1,5 +1,4 @@
|
|||
import LayerConfig from "./JSON/LayerConfig";
|
||||
import {LayerConfigJson} from "./JSON/LayerConfigJson";
|
||||
import * as known_layers from "../assets/generated/known_layers_and_themes.json"
|
||||
import {Utils} from "../Utils";
|
||||
|
||||
|
@ -9,7 +8,6 @@ export default class AllKnownLayers {
|
|||
// Must be below the list...
|
||||
public static sharedLayers: Map<string, LayerConfig> = AllKnownLayers.getSharedLayers();
|
||||
public static sharedLayersJson: Map<string, any> = AllKnownLayers.getSharedLayersJson();
|
||||
private static sharedLayersListRaw: LayerConfigJson[] = known_layers.layers;
|
||||
|
||||
private static getSharedLayers(): Map<string, LayerConfig> {
|
||||
const sharedLayers = new Map<string, LayerConfig>();
|
||||
|
|
|
@ -93,8 +93,13 @@ export default class LayoutConfig {
|
|||
this.defaultBackgroundId = json.defaultBackgroundId;
|
||||
this.layers = json.layers.map((layer, i) => {
|
||||
if (typeof layer === "string") {
|
||||
if (AllKnownLayers.sharedLayers[layer] !== undefined) {
|
||||
return AllKnownLayers.sharedLayers[layer];
|
||||
if (AllKnownLayers.sharedLayersJson[layer] !== undefined) {
|
||||
if(json.overrideAll !== undefined){
|
||||
let lyr = JSON.parse(JSON.stringify( AllKnownLayers.sharedLayersJson[layer]));
|
||||
return new LayerConfig(Utils.Merge(json.overrideAll, lyr),`${this.id}+overrideAll.layers[${i}]`, official);
|
||||
}else{
|
||||
return AllKnownLayers.sharedLayers[layer]
|
||||
}
|
||||
} else {
|
||||
throw "Unkown fixed layer " + layer;
|
||||
}
|
||||
|
@ -109,12 +114,17 @@ export default class LayoutConfig {
|
|||
}
|
||||
// @ts-ignore
|
||||
layer = Utils.Merge(layer.override, JSON.parse(JSON.stringify(shared))); // We make a deep copy of the shared layer, in order to protect it from changes
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(json.overrideAll !== undefined){
|
||||
layer = Utils.Merge(json.overrideAll, layer);
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
return new LayerConfig(layer, `${this.id}.layers[${i}]`, official)
|
||||
});
|
||||
|
||||
|
||||
// ALl the layers are constructed, let them share tags in now!
|
||||
const roaming: { r, source: LayerConfig }[] = []
|
||||
for (const layer of this.layers) {
|
||||
|
@ -140,10 +150,11 @@ export default class LayoutConfig {
|
|||
);
|
||||
}
|
||||
|
||||
this.clustering = {
|
||||
const defaultClustering = {
|
||||
maxZoom: 16,
|
||||
minNeededElements: 250
|
||||
minNeededElements: 500
|
||||
};
|
||||
this.clustering = defaultClustering;
|
||||
if (json.clustering) {
|
||||
this.clustering = {
|
||||
maxZoom: json.clustering.maxZoom ?? 18,
|
||||
|
|
|
@ -114,6 +114,11 @@ export interface LayoutConfigJson {
|
|||
*/
|
||||
roamingRenderings?: (TagRenderingConfigJson | string)[],
|
||||
|
||||
/**
|
||||
* An override applied on all layers of the theme
|
||||
*/
|
||||
overrideAll?: any;
|
||||
|
||||
/**
|
||||
* The id of the default background. BY default: vanilla OSM
|
||||
*/
|
||||
|
@ -161,6 +166,7 @@ export interface LayoutConfigJson {
|
|||
|
||||
/**
|
||||
* If defined, data will be clustered.
|
||||
* Defaults to {maxZoom: 16, minNeeded: 500}
|
||||
*/
|
||||
clustering?: {
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue