Formatting

This commit is contained in:
Pieter Vander Vennet 2021-07-07 18:12:07 +02:00
parent caacb6a3ef
commit 37d7040cff
2 changed files with 35 additions and 27 deletions

View file

@ -94,7 +94,7 @@ export default class LayoutConfig {
}
);
this.defaultBackgroundId = json.defaultBackgroundId;
this.layers = LayoutConfig.ExtractLayers(json, context, this.units, official);
this.layers = LayoutConfig.ExtractLayers(json, this.units, official);
// ALl the layers are constructed, let them share tags in now!
const roaming: { r, source: LayerConfig }[] = []
@ -158,7 +158,7 @@ export default class LayoutConfig {
}
private static ExtractLayers(json: LayoutConfigJson, context: string, units: Unit[], official: boolean): LayerConfig[] {
private static ExtractLayers(json: LayoutConfigJson, units: Unit[], official: boolean): LayerConfig[] {
const result: LayerConfig[] = []
json.layers.forEach((layer, i) => {
@ -168,16 +168,16 @@ export default class LayoutConfig {
let lyr = JSON.parse(JSON.stringify(AllKnownLayers.sharedLayersJson[layer]));
const newLayer = new LayerConfig(Utils.Merge(json.overrideAll, lyr), units, `${json.id}+overrideAll.layers[${i}]`, official)
result.push(newLayer)
return
return
} else {
result.push(AllKnownLayers.sharedLayers[layer])
return
return
}
} else {
throw "Unknown fixed layer " + layer;
}
}
if (layer["builtin"] === undefined) {
if (json.overrideAll !== undefined) {
layer = Utils.Merge(json.overrideAll, layer);
@ -185,7 +185,7 @@ export default class LayoutConfig {
// @ts-ignore
const newLayer = new LayerConfig(layer, units, `${json.id}.layers[${i}]`, official)
result.push(newLayer)
return
return
}
// @ts-ignore
let names = layer.builtin;
@ -194,19 +194,19 @@ export default class LayoutConfig {
}
names.forEach(name => {
const shared = AllKnownLayers.sharedLayersJson[name];
if (shared === undefined) {
throw "Unknown fixed layer " + name;
}
// @ts-ignore
let newLayer: LayerConfigJson = 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) {
newLayer = Utils.Merge(json.overrideAll, newLayer);
}
// @ts-ignore
const layerConfig = new LayerConfig(newLayer, units, `${json.id}.layers[${i}]`, official)
result.push(layerConfig)
return
})
if (shared === undefined) {
throw "Unknown fixed layer " + name;
}
// @ts-ignore
let newLayer: LayerConfigJson = 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) {
newLayer = Utils.Merge(json.overrideAll, newLayer);
}
// @ts-ignore
const layerConfig = new LayerConfig(newLayer, units, `${json.id}.layers[${i}]`, official)
result.push(layerConfig)
return
})
});

View file

@ -143,7 +143,7 @@ export interface LayoutConfigJson {
* "overrideAll": {
* "+tagRenderings": [ { ... some tagrendering ... }]
* }
*
*
* In the above scenario, `sometagrendering` will be added at the beginning of the tagrenderings of every layer
*/
overrideAll?: any;
@ -188,9 +188,13 @@ export interface LayoutConfigJson {
* *layers can also remove 'leftover'-features if the leftovers overlap with a feature in the layer itself
*
* Note that builtin layers can be reused. Either put in the name of the layer to reuse, or use {builtin: "layername", override: ...}
*
* The 'override'-object will be copied over the original values of the layer, which allows to change certain aspects of the layer
* ex: If you would like to use layer nature reserves, but only from a specific operator (eg. Natuurpunt) you would use the following in your theme:
* layer: {
*
* For example: If you would like to use layer nature reserves, but only from a specific operator (eg. Natuurpunt) you would use the following in your theme:
*
* ```
* "layer": {
* "builtin": "nature_reserve",
* "override": {"source":
* {"osmTags": {
@ -198,13 +202,17 @@ export interface LayoutConfigJson {
* }
* }
* }
* };
*It's also possible to load multiple layers at once, for example, if you would like for both drinking water and benches to start the zoomlevel at 12, you would use the following:
layer: {
* }
* ```
*
* It's also possible to load multiple layers at once, for example, if you would like for both drinking water and benches to start at the zoomlevel at 12, you would use the following:
*
* ```
* "layer": {
* "builtin": ["benches", "drinking_water"],
* "override": {"minzoom": 12}
* }
*
*```
*/
layers: (LayerConfigJson | string | { builtin: string | string[], override: any })[],
@ -262,7 +270,7 @@ export interface LayoutConfigJson {
* Also, if a freeform text field is used, an extra dropdown with applicable denominations will be given
*
*/
units?: {
/**