Skip to content

Commit f60c370

Browse files
authored
GE-883 add support for concat expression (#169)
1 parent e35c1e0 commit f60c370

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

gl2qgis/gl2qgis.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from qgis.PyQt.Qt import QPointF, QSize, QFont, QFontDatabase, QColor, QImage, QRegularExpression
2121
from qgis.core import *
2222
from .. import utils
23+
from itertools import repeat
2324

2425

2526
class PropertyType(enum.Enum):
@@ -1134,6 +1135,12 @@ def parse_discrete(json_list: list, context: QgsMapBoxGlStyleConversionContext):
11341135
return case_str
11351136

11361137

1138+
def parse_concat(json_list: list, context: QgsMapBoxGlStyleConversionContext):
1139+
concat_items = list(map(parse_expression, json_list[1:], repeat(context)))
1140+
concat_str = f"concat({','.join(concat_items)})"
1141+
return concat_str
1142+
1143+
11371144
def parse_array_stops(stops: list, multiplier: (int, float)):
11381145
if len(stops) < 2:
11391146
return
@@ -1375,6 +1382,9 @@ def parse_join_style(style: str):
13751382

13761383
def parse_expression(json_expr, context):
13771384
""" Parses expression into QGIS expression string """
1385+
if isinstance(json_expr, str):
1386+
return QgsExpression.quotedValue(json_expr)
1387+
13781388
op = json_expr[0]
13791389

13801390
if op in ('all', "any", "none"):
@@ -1455,6 +1465,8 @@ def parse_expression(json_expr, context):
14551465
elif op == "literal":
14561466
field_name, field_is_expression = process_label_field(json_expr[1])
14571467
return field_name
1468+
elif op == "concat":
1469+
return parse_concat(json_expr, context)
14581470
else:
14591471
context.pushWarning(f"{context.layerId()}: Skipping unsupported expression.")
14601472
return

0 commit comments

Comments
 (0)