Merge branch 'master' into develop
This commit is contained in:
commit
d2a813b009
231 changed files with 7858 additions and 8096 deletions
|
@ -110,7 +110,7 @@ export class Each<X, Y> extends Conversion<X[], Y[]> {
|
|||
values[i]?.["id"] !== undefined ? values[i]?.["id"] : ""
|
||||
)
|
||||
}
|
||||
const context_ = c.enter(i - 1)
|
||||
const context_ = c.enter(i)
|
||||
const r = step.convert(values[i], context_)
|
||||
result.push(r)
|
||||
}
|
||||
|
|
|
@ -25,7 +25,14 @@ export class ConversionContext {
|
|||
if (this.path.some((p) => typeof p === "object" || p === "[object Object]")) {
|
||||
throw "ConversionMessage: got an object as path entry:" + JSON.stringify(path)
|
||||
}
|
||||
if (this.path.some((p) => typeof p === "number" && p < 0)) {
|
||||
if (!ConversionContext.reported) {
|
||||
ConversionContext.reported = true
|
||||
console.trace("ConversionContext: got a path containing a negative number")
|
||||
}
|
||||
}
|
||||
}
|
||||
private static reported = false
|
||||
|
||||
public static construct(path: (string | number)[], operation: string[]) {
|
||||
return new ConversionContext([], [...path], [...operation])
|
||||
|
@ -71,6 +78,10 @@ export class ConversionContext {
|
|||
|
||||
public enter(key: string | number | (string | number)[]) {
|
||||
if (!Array.isArray(key)) {
|
||||
if (typeof key === "number" && key < 0) {
|
||||
console.trace("Invalid key")
|
||||
throw "Invalid key: <0"
|
||||
}
|
||||
return new ConversionContext(this.messages, [...this.path, key], this.operation)
|
||||
}
|
||||
return new ConversionContext(this.messages, [...this.path, ...key], this.operation)
|
||||
|
|
|
@ -1061,10 +1061,20 @@ export class PrevalidateLayer extends DesugaringStep<LayerConfigJson> {
|
|||
"'"
|
||||
)
|
||||
}
|
||||
if (json["pointRenderings"]?.length > 0) {
|
||||
context
|
||||
.enter("pointRenderings")
|
||||
.err("Detected a 'pointRenderingS', it is written singular")
|
||||
}
|
||||
|
||||
if (!(json.pointRendering?.length > 0)) {
|
||||
context.enter("pointRendering").err("There are no pointRenderings at all...")
|
||||
}
|
||||
|
||||
if (json["mapRendering"]) {
|
||||
context.enter("mapRendering").err("This layer has a legacy 'mapRendering'")
|
||||
}
|
||||
|
||||
if (json.presets?.length > 0) {
|
||||
if (!(json.pointRendering?.length > 0)) {
|
||||
context.enter("presets").warn("A preset is defined, but there is no pointRendering")
|
||||
|
|
|
@ -22,7 +22,6 @@ import { Utils } from "../../Utils"
|
|||
import { TagsFilter } from "../../Logic/Tags/TagsFilter"
|
||||
import Table from "../../UI/Base/Table"
|
||||
import FilterConfigJson from "./Json/FilterConfigJson"
|
||||
import { And } from "../../Logic/Tags/And"
|
||||
import { Overpass } from "../../Logic/Osm/Overpass"
|
||||
import { FixedUiElement } from "../../UI/Base/FixedUiElement"
|
||||
import Svg from "../../Svg"
|
||||
|
@ -458,11 +457,6 @@ export default class LayerConfig extends WithContextLoader {
|
|||
)
|
||||
}
|
||||
|
||||
let neededTags: TagsFilter[] = Utils.NoNull([this.source?.osmTags])
|
||||
if (this.source?.osmTags["and"] !== undefined) {
|
||||
neededTags = this.source.osmTags["and"]
|
||||
}
|
||||
|
||||
const tableRows = Utils.NoNull(
|
||||
this.tagRenderings
|
||||
.map((tr) => tr.FreeformValues())
|
||||
|
@ -523,7 +517,7 @@ export default class LayerConfig extends WithContextLoader {
|
|||
try {
|
||||
overpassLink = new Link(
|
||||
"Execute on overpass",
|
||||
Overpass.AsOverpassTurboLink(<TagsFilter>new And(neededTags).optimize())
|
||||
Overpass.AsOverpassTurboLink(<TagsFilter>this.source.osmTags.optimize())
|
||||
.replaceAll("(", "%28")
|
||||
.replaceAll(")", "%29")
|
||||
)
|
||||
|
@ -540,12 +534,30 @@ export default class LayerConfig extends WithContextLoader {
|
|||
|
||||
const tagsDescription = []
|
||||
if (this.source !== null) {
|
||||
tagsDescription.push(
|
||||
new Title("Basic tags for this layer", 2),
|
||||
"Elements must have the all of following tags to be shown on this layer:",
|
||||
new List(neededTags.map((t) => t.asHumanString(true, false, {}))),
|
||||
overpassLink
|
||||
)
|
||||
tagsDescription.push(new Title("Basic tags for this layer", 2))
|
||||
|
||||
const neededTags = <TagsFilter>this.source.osmTags.optimize()
|
||||
if (neededTags["and"]) {
|
||||
const parts = neededTags["and"]
|
||||
tagsDescription.push(
|
||||
"Elements must match **all** of the following expressions:",
|
||||
parts.map((p, i) => i + ". " + p.asHumanString(true, false, {})).join("\n")
|
||||
)
|
||||
} else if (neededTags["or"]) {
|
||||
const parts = neededTags["or"]
|
||||
tagsDescription.push(
|
||||
"Elements must match **any** of the following expressions:",
|
||||
parts.map((p) => " - " + p.asHumanString(true, false, {})).join("\n")
|
||||
)
|
||||
} else {
|
||||
tagsDescription.push(
|
||||
"Elements must match the expression **" +
|
||||
neededTags.asHumanString(true, false, {}) +
|
||||
"**"
|
||||
)
|
||||
}
|
||||
|
||||
tagsDescription.push(overpassLink)
|
||||
} else {
|
||||
tagsDescription.push("This is a special layer - data is not sourced from OpenStreetMap")
|
||||
}
|
||||
|
|
|
@ -85,6 +85,12 @@ export default class PointRenderingConfig extends WithContextLoader {
|
|||
throw `At ${context}: A point rendering should define at least an marker or a label`
|
||||
}
|
||||
|
||||
if (json["markers"]) {
|
||||
throw `At ${context}.markers: detected a field 'markerS' in pointRendering. It is written as a singular case`
|
||||
}
|
||||
if (json.marker && !Array.isArray(json.marker)) {
|
||||
throw `At ${context}.marker: the marker in a pointRendering should be an array`
|
||||
}
|
||||
if (this.location.size == 0) {
|
||||
throw (
|
||||
"A pointRendering should have at least one 'location' to defined where it should be rendered. (At " +
|
||||
|
|
|
@ -746,17 +746,11 @@ export default class TagRenderingConfig {
|
|||
new Combine([
|
||||
new FixedUiElement(m.then.txt).SetClass("font-bold"),
|
||||
" corresponds with ",
|
||||
new FixedUiElement(m.if.asHumanString(false, false, {})).SetClass(
|
||||
"code"
|
||||
),
|
||||
m.if.asHumanString(true, false, {}),
|
||||
]),
|
||||
]
|
||||
if (m.hideInAnswer === true) {
|
||||
msgs.push(
|
||||
new FixedUiElement(
|
||||
"This option cannot be chosen as answer"
|
||||
).SetClass("italic")
|
||||
)
|
||||
msgs.push("_This option cannot be chosen as answer_")
|
||||
}
|
||||
if (m.ifnot !== undefined) {
|
||||
msgs.push(
|
||||
|
@ -774,7 +768,9 @@ export default class TagRenderingConfig {
|
|||
if (this.condition !== undefined && !this.condition?.matchesProperties({})) {
|
||||
condition = new Combine([
|
||||
"This tagrendering is only visible in the popup if the following condition is met:",
|
||||
new FixedUiElement(this.condition.asHumanString(false, false, {})).SetClass("code"),
|
||||
new FixedUiElement(
|
||||
(<TagsFilter>this.condition.optimize()).asHumanString(true, false, {})
|
||||
).SetClass("code"),
|
||||
])
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue