Skip to content

Commit

Permalink
Fix invalid cast of QgsProperty as bool to store in strings
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 25, 2021
1 parent 785ad7c commit 253e017
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/core/vectortile/qgsmapboxglstyleconverter.cpp
Expand Up @@ -904,7 +904,7 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer,
QgsPropertyCollection ddLabelProperties;

double textSize = 16.0 * context.pixelSizeConversionFactor();
QString textSizeProperty;
QgsProperty textSizeProperty;
if ( jsonLayout.contains( QStringLiteral( "text-size" ) ) )
{
const QVariant jsonTextSize = jsonLayout.value( QStringLiteral( "text-size" ) );
Expand Down Expand Up @@ -932,7 +932,7 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer,
break;
}

if ( !textSizeProperty.isEmpty() )
if ( textSizeProperty )
{
ddLabelProperties.setProperty( QgsPalLayerSettings::Size, textSizeProperty );
}
Expand Down Expand Up @@ -1453,14 +1453,14 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer,
switch ( jsonTextOffset.type() )
{
case QVariant::Map:
textOffsetProperty = parseInterpolatePointByZoom( jsonTextOffset.toMap(), context, textSizeProperty.isEmpty() ? textSize : 1.0, &textOffset );
if ( textSizeProperty.isEmpty() )
textOffsetProperty = parseInterpolatePointByZoom( jsonTextOffset.toMap(), context, !textSizeProperty ? textSize : 1.0, &textOffset );
if ( !textSizeProperty )
{
ddLabelProperties.setProperty( QgsPalLayerSettings::LabelDistance, QStringLiteral( "abs(array_get(%1,1))-%2" ).arg( textOffsetProperty ).arg( textSize ) );
}
else
{
ddLabelProperties.setProperty( QgsPalLayerSettings::LabelDistance, QStringLiteral( "with_variable('text_size',%2,abs(array_get(%1,1))*@text_size-@text_size)" ).arg( textOffsetProperty ).arg( textSizeProperty ) );
ddLabelProperties.setProperty( QgsPalLayerSettings::LabelDistance, QStringLiteral( "with_variable('text_size',%2,abs(array_get(%1,1))*@text_size-@text_size)" ).arg( textOffsetProperty, textSizeProperty.asExpression() ) );
}
ddLabelProperties.setProperty( QgsPalLayerSettings::LinePlacementOptions, QStringLiteral( "if(array_get(%1,1)>0,'BL','AL')" ).arg( textOffsetProperty ) );
break;
Expand All @@ -1481,9 +1481,9 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer,
labelSettings.distUnits = context.targetUnit();
labelSettings.dist = std::abs( textOffset.y() ) - textSize;
labelSettings.lineSettings().setPlacementFlags( textOffset.y() > 0.0 ? QgsLabeling::BelowLine : QgsLabeling::AboveLine );
if ( !textSizeProperty.isEmpty() && textOffsetProperty.isEmpty() )
if ( textSizeProperty && textOffsetProperty.isEmpty() )
{
ddLabelProperties.setProperty( QgsPalLayerSettings::LabelDistance, QStringLiteral( "with_variable('text_size',%2,%1*@text_size-@text_size)" ).arg( std::abs( textOffset.y() / textSize ) ).arg( ( textSizeProperty ) ) );
ddLabelProperties.setProperty( QgsPalLayerSettings::LabelDistance, QStringLiteral( "with_variable('text_size',%2,%1*@text_size-@text_size)" ).arg( std::abs( textOffset.y() / textSize ) ).arg( textSizeProperty.asExpression() ) );
}
}
}
Expand Down

0 comments on commit 253e017

Please sign in to comment.