forked from MapComplete/MapComplete
Themes: fix generation of automatic filters with multiAnswer, add test
This commit is contained in:
parent
6c4c880127
commit
2ec369f259
1 changed files with 11 additions and 1 deletions
|
|
@ -132,6 +132,16 @@ export class ExpandFilter extends DesugaringStep<LayerConfigJson> {
|
||||||
return filters
|
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(
|
public static buildFilterFromTagRendering(
|
||||||
tr: TagRenderingConfigJson,
|
tr: TagRenderingConfigJson,
|
||||||
context: ConversionContext
|
context: ConversionContext
|
||||||
|
|
@ -153,7 +163,7 @@ export class ExpandFilter extends DesugaringStep<LayerConfigJson> {
|
||||||
if (qtr.multiAnswer && osmTags instanceof Tag) {
|
if (qtr.multiAnswer && osmTags instanceof Tag) {
|
||||||
osmTags = new RegexTag(
|
osmTags = new RegexTag(
|
||||||
osmTags.key,
|
osmTags.key,
|
||||||
new RegExp("^(.+;)?" + osmTags.value + "(;.+)$", "is")
|
new RegExp("^(.+;)?" + osmTags.value + "(;.+)?$", "is")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (mapping.alsoShowIf) {
|
if (mapping.alsoShowIf) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue