forked from MapComplete/MapComplete
Add overrie capabilities
This commit is contained in:
parent
66018cb421
commit
93a16944a3
7 changed files with 113 additions and 41 deletions
|
@ -4,6 +4,7 @@ import LayerConfig from "./LayerConfig";
|
|||
import {LayoutConfigJson} from "./LayoutConfigJson";
|
||||
import SharedLayers from "../SharedLayers";
|
||||
import SharedTagRenderings from "../SharedTagRenderings";
|
||||
import {Utils} from "../../Utils";
|
||||
|
||||
export default class LayoutConfig {
|
||||
public readonly id: string;
|
||||
|
@ -24,11 +25,11 @@ export default class LayoutConfig {
|
|||
public readonly roamingRenderings: TagRenderingConfig[];
|
||||
public readonly defaultBackgroundId?: string;
|
||||
public readonly layers: LayerConfig[];
|
||||
public readonly clustering?: {
|
||||
public readonly clustering?: {
|
||||
maxZoom: number,
|
||||
minNeededElements: number
|
||||
};
|
||||
|
||||
|
||||
public readonly hideFromOverview: boolean;
|
||||
public readonly enableUserBadge: boolean;
|
||||
public readonly enableShareScreen: boolean;
|
||||
|
@ -79,13 +80,28 @@ export default class LayoutConfig {
|
|||
);
|
||||
this.defaultBackgroundId = json.defaultBackgroundId;
|
||||
this.layers = json.layers.map((layer, i) => {
|
||||
if (typeof layer === "string"){
|
||||
if (typeof layer === "string") {
|
||||
if (SharedLayers.sharedLayers[layer] !== undefined) {
|
||||
return SharedLayers.sharedLayers[layer];
|
||||
} else {
|
||||
throw "Unkown fixed layer " + layer;
|
||||
}
|
||||
}
|
||||
// @ts-ignore
|
||||
if (layer.builtin !== undefined) {
|
||||
// @ts-ignore
|
||||
const name = layer.builtin;
|
||||
console.warn("Overwriting!")
|
||||
const shared = SharedLayers.sharedLayersJson[name];
|
||||
if (shared === undefined) {
|
||||
throw "Unkown fixed layer " + name;
|
||||
}
|
||||
console.log("PREMERGE", layer, shared)
|
||||
// @ts-ignore
|
||||
layer = Utils.Merge(layer.override, shared);
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
return new LayerConfig(layer, this.roamingRenderings, `${this.id}.layers[${i}]`);
|
||||
});
|
||||
|
||||
|
@ -94,14 +110,14 @@ export default class LayoutConfig {
|
|||
maxZoom: 16,
|
||||
minNeededElements: 250
|
||||
};
|
||||
if(json.clustering){
|
||||
if (json.clustering) {
|
||||
this.clustering = {
|
||||
maxZoom : json.clustering.maxZoom ?? 18,
|
||||
maxZoom: json.clustering.maxZoom ?? 18,
|
||||
minNeededElements: json.clustering.minNeededElements ?? 1
|
||||
}
|
||||
for (const layer of this.layers) {
|
||||
if(layer.wayHandling !== LayerConfig.WAYHANDLING_CENTER_ONLY){
|
||||
console.error("WARNING: In order to allow clustering, every layer must be set to CENTER_ONLY. Layer", layer.id,"does not respect this for layout",this.id);
|
||||
if (layer.wayHandling !== LayerConfig.WAYHANDLING_CENTER_ONLY) {
|
||||
console.error("WARNING: In order to allow clustering, every layer must be set to CENTER_ONLY. Layer", layer.id, "does not respect this for layout", this.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,8 +120,11 @@ 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
|
||||
*
|
||||
*/
|
||||
layers: (LayerConfigJson | string)[],
|
||||
layers: (LayerConfigJson | string | {builtin: string, override: any})[],
|
||||
|
||||
/**
|
||||
* If defined, data will be clustered.
|
||||
|
|
|
@ -46,7 +46,7 @@ export default class TagRenderingConfig {
|
|||
this.multiAnswer = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
this.render = Translations.T(json.render);
|
||||
this.question = Translations.T(json.question);
|
||||
this.condition = FromJSON.Tag(json.condition ?? {"and": []}, `${context}.condition`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue