Themes: fix generation of automatic filters with multiAnswer, add test

This commit is contained in:
Pieter Vander Vennet 2025-01-31 15:16:42 +01:00
parent 6c4c880127
commit 2ec369f259

View file

@ -132,6 +132,16 @@ export class ExpandFilter extends DesugaringStep<LayerConfigJson> {
return filters
}
/**
*
* import FilterConfig from "../FilterConfig"
*
* // A multi-answer tagRendering should match any subkey
* const tr = {id: "test", multiAnswer: true, mappings:[{if: "x=a", then: "A"}, {if: "x=b", then:"B"}]}
* const filter = ExpandFilter.buildFilterFromTagRendering(tr, ConversionContext.test("ExpandFilter"))
* const f = new FilterConfig(filter, "test")
* f.options[1].osmTags.matchesProperties({x:"a;b"}) // => true
*/
public static buildFilterFromTagRendering(
tr: TagRenderingConfigJson,
context: ConversionContext
@ -153,7 +163,7 @@ export class ExpandFilter extends DesugaringStep<LayerConfigJson> {
if (qtr.multiAnswer && osmTags instanceof Tag) {
osmTags = new RegexTag(
osmTags.key,
new RegExp("^(.+;)?" + osmTags.value + "(;.+)$", "is")
new RegExp("^(.+;)?" + osmTags.value + "(;.+)?$", "is")
)
}
if (mapping.alsoShowIf) {