Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vector tiles] Handle 'to-boolean' mapboxgl expressions when importing styles #59489

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading