Skip to content
Permalink
Browse files

Fix line pattern fill symbol corruption with negative angles

(cherry picked from commit 0f056b5)
  • Loading branch information
nyalldawson committed Oct 12, 2018
1 parent 968948a commit 8bc8c0b838802d36c0a1b43e8779a87d85bc05ab
@@ -2630,6 +2630,9 @@ void QgsLinePatternFillSymbolLayer::applyPattern( const QgsSymbolV2RenderContext

//create image
int height, width;
lineAngle = fmod( lineAngle, 360 );
if ( lineAngle < 0 )
lineAngle += 360;
if ( qgsDoubleNear( lineAngle, 0 ) || qgsDoubleNear( lineAngle, 360 ) || qgsDoubleNear( lineAngle, 180 ) )
{
height = outputPixelDist;
@@ -2655,7 +2658,7 @@ void QgsLinePatternFillSymbolLayer::applyPattern( const QgsSymbolV2RenderContext
height = qAbs( height );
width = qAbs( width );

outputPixelDist = height * cos( lineAngle * M_PI / 180 );
outputPixelDist = qAbs( height * 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
@@ -62,6 +62,7 @@ class TestQgsLineFillSymbol : public QObject
void lineFillSymbol();
void lineFillSymbolOffset();
void lineFillLargeOffset();
void lineFillNegativeAngle();

void dataDefinedSubSymbol();

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

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

void TestQgsLineFillSymbol::dataDefinedSubSymbol()
{
mReport += "<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 8bc8c0b

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