WIP: add oneway arrows to _all_ lines

This commit is contained in:
Pieter Vander Vennet 2024-02-03 17:27:41 +01:00
parent d48b8aff92
commit 43f9afc3ba
7 changed files with 213 additions and 190 deletions

View file

@ -30,62 +30,4 @@ export default class LineRenderingConfig extends WithContextLoader {
this.offset = this.tr("offset", "0")
}
public GenerateLeafletStyle(tags: {}): {
fillColor?: string
color: string
lineCap: string
offset: number
weight: number
dashArray: string
fill?: boolean
} {
function rendernum(tr: TagRenderingConfig, deflt: number) {
const str = Number(render(tr, "" + deflt))
const n = Number(str)
if (isNaN(n)) {
return deflt
}
return n
}
function render(tr: TagRenderingConfig, deflt?: string) {
if (tags === undefined) {
return deflt
}
if (tr === undefined) {
return deflt
}
const str = tr?.GetRenderValue(tags)?.txt ?? deflt
if (str === "") {
return deflt
}
return Utils.SubstituteKeys(str, tags)?.replace(/{.*}/g, "")
}
const dashArray = render(this.dashArray)
let color = render(this.color, "#00f")
if (color.startsWith("--")) {
color = getComputedStyle(document.body).getPropertyValue("--catch-detail-color")
}
const style = {
color,
dashArray,
weight: rendernum(this.width, 5),
lineCap: render(this.lineCap),
offset: rendernum(this.offset, 0),
}
const fillStr = render(this.fill, undefined)
if (fillStr !== undefined && fillStr !== "") {
style["fill"] = fillStr === "yes" || fillStr === "true"
}
const fillColorStr = render(this.fillColor, undefined)
if (fillColorStr !== undefined) {
style["fillColor"] = fillColorStr
}
return style
}
}