(match)
return root_if.dumps()
Implements the expression match
    See: https://docs.mapbox.com/mapbox-gl-js/style-spec/#expressions-match
    :param match:
    :return:
Implements the expression match
    See: https://docs.mapbox.com/mapbox-gl-js/style-spec/#expressions-match
    :param match:
    :return:
Implements the expression match See : https : // docs . mapbox . com / mapbox - gl - js / style - spec / #expressions - match : param match : : return :
def _get_match_expr(match):
    """
    Implements the expression match
    See: https://docs.mapbox.com/mapbox-gl-js/style-spec/#expressions-match
    :param match:
    :return:
    """

    assert isinstance(match, list)
    assert len(match) >= 4 and divmod(len(match), 2)[1] == 1  # the last value is the fallback
    assert match[0] in _comparision_operators

    labels = match[2:-1:2]
    all_outputs = list(map(lambda c: parse_color(c), match[3::2]))
    fallback = parse_color(match[-1])
    labels_with_output = zip(labels, all_outputs)
    op = match[0]
    attr = match[1][1]
    root_if = None
    current_if = None

    for label, output in labels_with_output:
        expr = _get_comparision_expr([op, attr, label])
        new_if = If(expr, output)
        if not root_if:
            root_if = new_if
            current_if = root_if

        if current_if != new_if:
            current_if.else_if = new_if
            current_if = new_if
    current_if.else_if = fallback

    return root_if.dumps()
def _get_match_expr ( match ) : assert isinstance ( match , list ) assert len ( match ) >= 4 and divmod ( len ( match ) , 2 ) [ 1 ] == 1 # the last value is the fallback assert match [ 0 ] in _comparision_operators labels = match [ 2 : - 1 : 2 ] all_outputs = list ( map ( lambda c : parse_color ( c ) , match [ 3 : : 2 ] ) ) fallback = parse_color ( match [ - 1 ] ) labels_with_output = zip ( labels , all_outputs ) op = match [ 0 ] attr = match [ 1 ] [ 1 ] root_if = None current_if = None for label , output in labels_with_output : expr = _get_comparision_expr ( [ op , attr , label ] ) new_if = If ( expr , output ) if not root_if : root_if = new_if current_if = root_if if current_if != new_if : current_if . else_if = new_if current_if = new_if current_if . else_if = fallback return root_if . dumps ( )