Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix line pattern fill symbol corruption with negative angles
(cherry picked from commit 0f056b5)
  • Loading branch information
nyalldawson committed Oct 15, 2018
1 parent 968948a commit 8bc8c0b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/core/symbology-ng/qgsfillsymbollayerv2.cpp
Expand Up @@ -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;
Expand All @@ -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
Expand Down
12 changes: 12 additions & 0 deletions tests/src/core/testqgslinefillsymbol.cpp
Expand Up @@ -62,6 +62,7 @@ class TestQgsLineFillSymbol : public QObject
void lineFillSymbol();
void lineFillSymbolOffset();
void lineFillLargeOffset();
void lineFillNegativeAngle();

void dataDefinedSubSymbol();

Expand Down Expand Up @@ -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";
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8bc8c0b

Please sign in to comment.