Fix: build, some metatagging errors

This commit is contained in:
Pieter Vander Vennet 2023-09-22 12:42:09 +02:00
parent df7b0f84db
commit 0d529e7cca
6 changed files with 13 additions and 22 deletions

View file

@ -424,11 +424,12 @@ class LayerOverviewUtils extends Script {
]
for (const layer of themeFile.layers) {
const l = <LayerConfigJson>layer
const id = l.id.replace(/[^a-zA-Z0-9_]/g, "_")
const code = l.calculatedTags ?? []
allCode.push(
" public metaTaggging_for_" +
l.id +
id +
"(feat: Feature, helperFunctions: Record<ExtraFuncType, (feature: Feature) => Function>) {"
)
allCode.push(" const {" + ExtraFunctions.types.join(", ") + "} = helperFunctions")
@ -446,7 +447,7 @@ class LayerOverviewUtils extends Script {
" ) "
)
} else {
attributeName = attributeName.substring(0, attributeName.length - 2).trim()
attributeName = attributeName.substring(0, attributeName.length - 1).trim()
allCode.push(" feat.properties['" + attributeName + "'] = " + expression)
}
}
@ -463,6 +464,9 @@ class LayerOverviewUtils extends Script {
}
private extractJavascriptCodeForLayer(l: LayerConfigJson, targetPath?: string) {
if (!l) {
return // Probably a bootstrapping run
}
let importPath = "../../../"
if (targetPath) {
const l = targetPath.split("/")
@ -478,7 +482,7 @@ class LayerOverviewUtils extends Script {
}
const allCode = [
`import { Utils } from "${importPath}Utils"`,
`/** This code is autogenerated - do not edit. Edit ./assets/layers/${l.id}/${l.id}.json instead */`,
`/** This code is autogenerated - do not edit. Edit ./assets/layers/${l?.id}/${l?.id}.json instead */`,
"export class ThemeMetaTagging {",
" public static readonly themeName = " + JSON.stringify(l.id),
"",