Skip to content

Commit

Permalink
[vector tiles] Handle 'to-boolean' mapboxgl expressions when importin…
Browse files Browse the repository at this point in the history
…g styles
  • Loading branch information
nirvn committed Nov 19, 2024
1 parent c343232 commit c567e20
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/vectortile/qgsmapboxglstyleconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3428,6 +3428,10 @@ QString QgsMapBoxGlStyleConverter::parseExpression( const QVariantList &expressi
{
return QStringLiteral( "to_string(%1)" ).arg( parseExpression( expression.value( 1 ).toList(), context ) );
}
else if ( op == QLatin1String( "to-boolean" ) )
{
return QStringLiteral( "to_bool(%1)" ).arg( parseExpression( expression.value( 1 ).toList(), context ) );
}
else if ( op == QLatin1String( "case" ) )
{
QString caseString = QStringLiteral( "CASE" );
Expand Down
3 changes: 3 additions & 0 deletions tests/src/python/test_qgsmapboxglconverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,9 @@ def testParseExpression(self):
conversion_context),
'''"name"''')

self.assertEqual(QgsMapBoxGlStyleConverter.parseExpression(["to-boolean", ["get", "name"]],
conversion_context),
'''to_bool("name")''')
self.assertEqual(QgsMapBoxGlStyleConverter.parseExpression(["to-string", ["get", "name"]],
conversion_context),
'''to_string("name")''')
Expand Down

0 comments on commit c567e20

Please sign in to comment.