Merge master
This commit is contained in:
commit
a11e0fc545
57 changed files with 1535 additions and 1381 deletions
|
@ -10,10 +10,12 @@ export interface DesugaringContext {
|
|||
export abstract class Conversion<TIn, TOut> {
|
||||
public readonly modifiedAttributes: string[];
|
||||
protected readonly doc: string;
|
||||
|
||||
constructor(doc: string, modifiedAttributes: string[] = []) {
|
||||
public readonly name: string
|
||||
|
||||
constructor(doc: string, modifiedAttributes: string[] = [], name?: string) {
|
||||
this.modifiedAttributes = modifiedAttributes;
|
||||
this.doc = doc + "\n\nModified attributes are\n" + modifiedAttributes.join(", ");
|
||||
this.name = name ?? this.constructor.name
|
||||
}
|
||||
|
||||
public static strict<T>(fixed: { errors: string[], warnings: string[], result?: T }): T {
|
||||
|
@ -83,7 +85,8 @@ export class OnEveryConcat<X, T> extends DesugaringStep<T> {
|
|||
private readonly step: Conversion<X, X[]>;
|
||||
|
||||
constructor(key: string, step: Conversion<X, X[]>) {
|
||||
super(`Applies ${step.constructor.name} onto every object of the list \`${key}\`. The results are concatenated and used as new list`, [key]);
|
||||
super(`Applies ${step.constructor.name} onto every object of the list \`${key}\`. The results are concatenated and used as new list`, [key],
|
||||
"OnEveryConcat("+step.name+")");
|
||||
this.step = step;
|
||||
this.key = key;
|
||||
}
|
||||
|
@ -128,7 +131,7 @@ export class Fuse<T> extends DesugaringStep<T> {
|
|||
const warnings = []
|
||||
for (let i = 0; i < this.steps.length; i++) {
|
||||
const step = this.steps[i];
|
||||
let r = step.convert(state, json, context + "(fusion " + this.constructor.name + "." + i + ")")
|
||||
let r = step.convert(state, json, "While running step " +step.name + ": " + context)
|
||||
errors.push(...r.errors)
|
||||
warnings.push(...r.warnings)
|
||||
json = r.result
|
||||
|
|
|
@ -43,7 +43,7 @@ class SubstituteLayer extends Conversion<(string | LayerConfigJson), LayerConfig
|
|||
for (const name of names) {
|
||||
const found = Utils.Clone(state.sharedLayers.get(name))
|
||||
if (found === undefined) {
|
||||
errors.push(context + ": The layer with name " + json + " was not found as a builtin layer")
|
||||
errors.push(context + ": The layer with name " + JSON.stringify(json) + " was not found as a builtin layer. Known builtin layers are "+Array.from(state.sharedLayers.keys()).join(",")+"\n For more information, see https://github.com/pietervdvn/MapComplete/blob/develop/Docs/BuiltinLayers.md" )
|
||||
continue
|
||||
}
|
||||
if (json["override"]["tagRenderings"] !== undefined && (found["tagRenderings"] ?? []).length > 0) {
|
||||
|
@ -81,6 +81,7 @@ class AddDefaultLayers extends DesugaringStep<LayoutConfigJson> {
|
|||
const errors = []
|
||||
const warnings = []
|
||||
json.layers = [...json.layers]
|
||||
const alreadyLoaded = new Set(json.layers.map(l => l["id"]))
|
||||
|
||||
if (json.id === "personal") {
|
||||
json.layers = []
|
||||
|
@ -105,6 +106,10 @@ class AddDefaultLayers extends DesugaringStep<LayoutConfigJson> {
|
|||
if (v === undefined) {
|
||||
errors.push("Default layer " + layerName + " not found")
|
||||
}
|
||||
if(alreadyLoaded.has(v.id)){
|
||||
warnings.push("Layout "+context+" already has a layer with name "+v.id+"; skipping inclusion of this builtin layer")
|
||||
continue
|
||||
}
|
||||
json.layers.push(v)
|
||||
}
|
||||
|
||||
|
@ -131,44 +136,45 @@ class AddImportLayers extends DesugaringStep<LayoutConfigJson> {
|
|||
json.layers = [...json.layers]
|
||||
|
||||
|
||||
const creator = new CreateNoteImportLayer()
|
||||
for (let i1 = 0; i1 < allLayers.length; i1++) {
|
||||
const layer = allLayers[i1];
|
||||
if (Constants.priviliged_layers.indexOf(layer.id) >= 0) {
|
||||
// Priviliged layers are skipped
|
||||
continue
|
||||
}
|
||||
|
||||
if (layer.source["geoJson"] !== undefined) {
|
||||
// Layer which don't get their data from OSM are skipped
|
||||
continue
|
||||
}
|
||||
|
||||
if (layer.title === undefined || layer.name === undefined) {
|
||||
// Anonymous layers and layers without popup are skipped
|
||||
continue
|
||||
}
|
||||
|
||||
if (layer.presets === undefined || layer.presets.length == 0) {
|
||||
// A preset is needed to be able to generate a new point
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
const importLayerResult = creator.convert(state, layer, context + ".(noteimportlayer)[" + i1 + "]")
|
||||
errors.push(...importLayerResult.errors)
|
||||
warnings.push(...importLayerResult.warnings)
|
||||
if (importLayerResult.result !== undefined) {
|
||||
warnings.push("Added an import layer to theme " + json.id + ", namely " + importLayerResult.result.id)
|
||||
json.layers.push(importLayerResult.result)
|
||||
if(json.enableNoteImports ?? true) {
|
||||
const creator = new CreateNoteImportLayer()
|
||||
for (let i1 = 0; i1 < allLayers.length; i1++) {
|
||||
const layer = allLayers[i1];
|
||||
if (Constants.priviliged_layers.indexOf(layer.id) >= 0) {
|
||||
// Priviliged layers are skipped
|
||||
continue
|
||||
}
|
||||
|
||||
if (layer.source["geoJson"] !== undefined) {
|
||||
// Layer which don't get their data from OSM are skipped
|
||||
continue
|
||||
}
|
||||
|
||||
if (layer.title === undefined || layer.name === undefined) {
|
||||
// Anonymous layers and layers without popup are skipped
|
||||
continue
|
||||
}
|
||||
|
||||
if (layer.presets === undefined || layer.presets.length == 0) {
|
||||
// A preset is needed to be able to generate a new point
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
const importLayerResult = creator.convert(state, layer, context + ".(noteimportlayer)[" + i1 + "]")
|
||||
errors.push(...importLayerResult.errors)
|
||||
warnings.push(...importLayerResult.warnings)
|
||||
if (importLayerResult.result !== undefined) {
|
||||
warnings.push("Added an import layer to theme " + json.id + ", namely " + importLayerResult.result.id)
|
||||
json.layers.push(importLayerResult.result)
|
||||
}
|
||||
} catch (e) {
|
||||
errors.push("Could not generate an import-layer for " + layer.id + " due to " + e)
|
||||
}
|
||||
} catch (e) {
|
||||
errors.push("Could not generate an import-layer for " + layer.id + " due to " + e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
errors,
|
||||
warnings,
|
||||
|
|
|
@ -249,6 +249,7 @@ export interface LayoutConfigJson {
|
|||
enableDownload?: boolean;
|
||||
enablePdfDownload?: boolean;
|
||||
enableIframePopout?: true | boolean;
|
||||
enableNoteImports?: true | boolean;
|
||||
|
||||
/**
|
||||
* Set one or more overpass URLs to use for this theme..
|
||||
|
|
|
@ -67,7 +67,7 @@ export default class LayoutConfig {
|
|||
this.credits = json.credits;
|
||||
this.version = json.version;
|
||||
this.language = Array.from(Object.keys(json.title));
|
||||
|
||||
|
||||
{
|
||||
if (typeof json.title === "string") {
|
||||
console.error("The title is not a translation, it instead is ", json.title, "("+typeof json.title+")")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue