Fix: allow to delete freeform values in more cases

This commit is contained in:
Pieter Vander Vennet 2024-02-13 00:22:47 +01:00
parent c2d8ff906b
commit 9b78838745
3 changed files with 13 additions and 3 deletions

View file

@ -1,6 +1,7 @@
import { TagsFilter } from "./TagsFilter"
import { TagConfigJson } from "../../Models/ThemeConfig/Json/TagConfigJson"
import { Tag } from "./Tag"
import { ExpressionSpecification } from "maplibre-gl"
export default class ComparingTag implements TagsFilter {
private readonly _key: string
@ -12,7 +13,7 @@ export default class ComparingTag implements TagsFilter {
key: string,
predicate: (value: string | undefined) => boolean,
representation: "<" | ">" | "<=" | ">=",
boundary: string
boundary: string,
) {
this._key = key
this._predicate = predicate
@ -125,4 +126,8 @@ export default class ComparingTag implements TagsFilter {
visit(f: (TagsFilter) => void) {
f(this)
}
asMapboxExpression(): ExpressionSpecification {
return [this._representation, ["get", this._key], this._boundary]
}
}

View file

@ -2,6 +2,7 @@ import { TagsFilter } from "./TagsFilter"
import { Tag } from "./Tag"
import { Utils } from "../../Utils"
import { TagConfigJson } from "../../Models/ThemeConfig/Json/TagConfigJson"
import { ExpressionSpecification } from "maplibre-gl"
/**
* The substituting-tag uses the tags of a feature a variables and replaces them.
@ -23,6 +24,10 @@ export default class SubstitutingTag implements TagsFilter {
this._invert = invert
}
asMapboxExpression(): ExpressionSpecification {
throw new Error("Method not implemented.")
}
private static substituteString(template: string, dict: Record<string, string>): string {
for (const k in dict) {
template = template.replace(new RegExp("\\{" + k + "\\}", "g"), dict[k])