Themes: automatically derive source from presets if no source is given

This commit is contained in:
Pieter Vander Vennet 2024-08-16 02:09:54 +02:00
parent 662b5d0735
commit 06897588be
6 changed files with 243 additions and 184 deletions

View file

@ -81,15 +81,16 @@ class ParseLayer extends Conversion<
}
const fixed = this._prepareLayer.convert(parsed, context.inOperation("PrepareLayer"))
if (!fixed.source) {
context.enter("source").err("No source is configured")
if (!fixed.source && fixed.presets?.length < 1) {
context.enter("source").err("No source is configured. (Tags might be automatically derived if presets are given)")
return undefined
}
if (
fixed.source &&
typeof fixed.source !== "string" &&
fixed.source["osmTags"] &&
fixed.source["osmTags"]["and"] === undefined
fixed.source?.["osmTags"] &&
fixed.source?.["osmTags"]["and"] === undefined
) {
fixed.source["osmTags"] = { and: [fixed.source["osmTags"]] }
}