diff --git a/mapcss/mapcss_lib.py b/mapcss/mapcss_lib.py index f7c4aaf98..95bfc29e2 100644 --- a/mapcss/mapcss_lib.py +++ b/mapcss/mapcss_lib.py @@ -434,6 +434,12 @@ def trim(string): if string is not None: return str_value(string.strip()) +#trim_list(list_name) +# remove leading and trailing whitespace from a list of strings, will remove entries that are empty afterwards [since r15591] +def trim_list(l): + if l is not None and isinstance(l, list): + return list(filter(None, map(lambda s: s.strip(), l))) + #JOSM_search("...") # true, if JOSM search applies to the object def JOSM_search(string): @@ -630,7 +636,7 @@ def to_double(string): #uniq_list() # returns a list of strings that only have unique values from a list of strings [since r15353] def uniq_list(l): - return set(l) + return list(set(l)) # siunit_length(str) # convert length units to meter (fault tolerant, ignoring white space) diff --git a/plugins/tests/test_mapcss_parsing_evaluation.validator.mapcss b/plugins/tests/test_mapcss_parsing_evaluation.validator.mapcss index 5eb9fdffd..0db14dd73 100644 --- a/plugins/tests/test_mapcss_parsing_evaluation.validator.mapcss +++ b/plugins/tests/test_mapcss_parsing_evaluation.validator.mapcss @@ -639,3 +639,12 @@ node[x][inside("FR")][outside("FX")] { -osmoseAssertMatchWithContext:list("node x=1", "inside=FR-GF"); -osmoseAssertNoMatchWithContext:list("node x=1", "inside=FR-02"); } + + +node[x][join_list("-", trim_list(split(";", tag("x")))) = "a-b-c"] { + throwWarning: "test"; + assertMatch: "node x=a;b;c"; + assertMatch: "node x=;a;;b;;c;"; + assertMatch: "node x=\"a; b; ; c\""; + assertNoMatch: "node x=a;b;0;c"; +}