Navigation Menu

Skip to content

Commit

Permalink
Fix line pattern fill symbol corruption with negative angles
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 12, 2018
1 parent e277b91 commit 0f056b5
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/qgsfillsymbollayer.cpp
Expand Up @@ -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;
Expand All @@ -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
Expand Down
12 changes: 12 additions & 0 deletions tests/src/core/testqgslinefillsymbol.cpp
Expand Up @@ -56,6 +56,7 @@ class TestQgsLineFillSymbol : public QObject
void lineFillSymbol();
void lineFillSymbolOffset();
void lineFillLargeOffset();
void lineFillNegativeAngle();

void dataDefinedSubSymbol();

Expand Down Expand Up @@ -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" );
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 0f056b5

Please sign in to comment.