Skip to content

Commit

Permalink
Convert line-offset property
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 9, 2020
1 parent 0fc1a73 commit 2a439c6
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/core/vectortile/qgsmapboxglstyleconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,33 @@ bool QgsMapBoxGlStyleConverter::parseLineLayer( const QVariantMap &jsonLayer, Qg
}
}

double lineOffset = 0.0;
if ( jsonPaint.contains( QStringLiteral( "line-offset" ) ) )
{
const QVariant jsonLineOffset = jsonPaint.value( QStringLiteral( "line-offset" ) );
switch ( jsonLineOffset.type() )
{
case QVariant::Int:
case QVariant::Double:
lineOffset = -jsonLineOffset.toDouble() * context.pixelSizeConversionFactor();
break;

case QVariant::Map:
lineWidth = -1;
ddProperties.setProperty( QgsSymbolLayer::PropertyOffset, parseInterpolateByZoom( jsonLineOffset.toMap(), context, context.pixelSizeConversionFactor() * -1, &lineOffset ) );
break;

case QVariant::List:
case QVariant::StringList:
ddProperties.setProperty( QgsSymbolLayer::PropertyOffset, parseInterpolateListByZoom( jsonLineOffset.toList(), PropertyType::Numeric, context, context.pixelSizeConversionFactor() * -1, 255, nullptr, &lineOffset ) );
break;

default:
context.pushWarning( QObject::tr( "Skipping non-implemented line-offset expression" ) );
break;
}
}

double lineOpacity = -1.0;
if ( jsonPaint.contains( QStringLiteral( "line-opacity" ) ) )
{
Expand Down Expand Up @@ -563,6 +590,8 @@ bool QgsMapBoxGlStyleConverter::parseLineLayer( const QVariantMap &jsonLayer, Qg
lineSymbol->setPenCapStyle( penCapStyle );
lineSymbol->setPenJoinStyle( penJoinStyle );
lineSymbol->setDataDefinedProperties( ddProperties );
lineSymbol->setOffset( lineOffset );
lineSymbol->setOffsetUnit( context.targetUnit() );

if ( lineOpacity != -1 )
{
Expand Down

0 comments on commit 2a439c6

Please sign in to comment.