diff --git a/src/core/vectortile/qgsmapboxglstyleconverter.cpp b/src/core/vectortile/qgsmapboxglstyleconverter.cpp index 2f269e1907f..35a960d3ec0 100644 --- a/src/core/vectortile/qgsmapboxglstyleconverter.cpp +++ b/src/core/vectortile/qgsmapboxglstyleconverter.cpp @@ -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" ); diff --git a/tests/src/python/test_qgsmapboxglconverter.py b/tests/src/python/test_qgsmapboxglconverter.py index e5082049f68..92c784fdd74 100644 --- a/tests/src/python/test_qgsmapboxglconverter.py +++ b/tests/src/python/test_qgsmapboxglconverter.py @@ -529,6 +529,9 @@ class TestQgsMapBoxGlStyleConverter(QgisTestCase): 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")''')