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

[Backport release-3_40] fix(QgsMapBoxGlStyleConverter): also handle text-rotate from property field #60283

Merged
merged 1 commit into from
Jan 28, 2025
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
13 changes: 13 additions & 0 deletions src/core/vectortile/qgsmapboxglstyleconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1713,6 +1713,19 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer,
break;
}

case QMetaType::Type::QVariantMap:
{
QVariantMap rotateMap = jsonTextRotate.toMap();
if ( rotateMap.contains( QStringLiteral( "property" ) ) && rotateMap[QStringLiteral( "type" )].toString() == QStringLiteral( "identity" ) )
{
const QgsProperty property = QgsProperty::fromExpression( rotateMap[QStringLiteral( "property" )].toString() );
ddLabelProperties.setProperty( QgsPalLayerSettings::Property::LabelRotation, property );
}
else
context.pushWarning( QObject::tr( "%1: Skipping unsupported text-rotate map content (%2)" ).arg( context.layerId(), QString( QJsonDocument::fromVariant( rotateMap ).toJson() ) ) );
break;
}

default:
context.pushWarning( QObject::tr( "%1: Skipping unsupported text-rotate type (%2)" ).arg( context.layerId(), QMetaType::typeName( static_cast<QMetaType::Type>( jsonTextRotate.userType() ) ) ) );
break;
Expand Down
27 changes: 27 additions & 0 deletions tests/src/python/test_qgsmapboxglconverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2203,6 +2203,33 @@ def testLabelRotation(self):
'"direction"',
)

context = QgsMapBoxGlStyleConversionContext()
style = {
"layout": {
"visibility": "visible",
"text-field": "{substance}",
"text-rotate": {
"property": "label_angle1",
"default": 0,
"type": "identity",
},
},
"paint": {
"text-color": "rgba(47, 47, 47, 1)",
},
"type": "symbol",
}
rendererStyle, has_renderer, labeling_style, has_labeling = (
QgsMapBoxGlStyleConverter.parseSymbolLayer(style, context)
)
self.assertTrue(has_labeling)
ls = labeling_style.labelSettings()
ddp = ls.dataDefinedProperties()
self.assertEqual(
ddp.property(QgsPalLayerSettings.Property.LabelRotation).asExpression(),
"label_angle1",
)

def test_parse_visibility(self):
context = QgsMapBoxGlStyleConversionContext()
style = {
Expand Down
Loading