Skip to content
Permalink
Browse files

Fix line pattern fill symbol corruption with negative angles

  • Loading branch information
nyalldawson committed Oct 12, 2018
1 parent e277b91 commit 0f056b500a5628bc76a30a4fe6de85f11cb5a9fb
@@ -2560,6 +2560,9 @@ void QgsLinePatternFillSymbolLayer::applyPattern( const QgsSymbolRenderContext &

//create image
int height, width;
lineAngle = std::fmod( lineAngle, 360 );
if ( lineAngle < 0 )
lineAngle += 360;
if ( qgsDoubleNear( lineAngle, 0 ) || qgsDoubleNear( lineAngle, 360 ) || qgsDoubleNear( lineAngle, 180 ) )
{
height = outputPixelDist;
@@ -2585,7 +2588,7 @@ void QgsLinePatternFillSymbolLayer::applyPattern( const QgsSymbolRenderContext &
height = std::abs( height );
width = std::abs( width );

outputPixelDist = height * std::cos( lineAngle * M_PI / 180 );
outputPixelDist = std::abs( height * std::cos( lineAngle * M_PI / 180 ) );

// Round offset to correspond to one pixel height, otherwise lines may
// be shifted on tile border if offset falls close to pixel center
@@ -56,6 +56,7 @@ class TestQgsLineFillSymbol : public QObject
void lineFillSymbol();
void lineFillSymbolOffset();
void lineFillLargeOffset();
void lineFillNegativeAngle();

void dataDefinedSubSymbol();

@@ -165,6 +166,17 @@ void TestQgsLineFillSymbol::lineFillLargeOffset()
mLineFill->setOffset( 0 );
}

void TestQgsLineFillSymbol::lineFillNegativeAngle()
{
mLineFill->setOffset( -8 );
mLineFill->setDistance( 2.2 );
mLineFill->setLineAngle( -130 );
QVERIFY( imageCheck( QStringLiteral( "symbol_linefill_negangle" ) ) );
mLineFill->setOffset( 0 );
mLineFill->setLineAngle( 45 );
mLineFill->setDistance( 5 );
}

void TestQgsLineFillSymbol::dataDefinedSubSymbol()
{
mReport += QLatin1String( "<h2>Line fill symbol data defined sub symbol test</h2>\n" );
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 0f056b5

Please sign in to comment.
You can’t perform that action at this time.