Skip to content

Commit 0f056b5

Browse files
committedOct 12, 2018
Fix line pattern fill symbol corruption with negative angles
1 parent e277b91 commit 0f056b5

File tree

5 files changed

+16
-1
lines changed

5 files changed

+16
-1
lines changed
 

‎src/core/symbology/qgsfillsymbollayer.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2560,6 +2560,9 @@ void QgsLinePatternFillSymbolLayer::applyPattern( const QgsSymbolRenderContext &
25602560

25612561
//create image
25622562
int height, width;
2563+
lineAngle = std::fmod( lineAngle, 360 );
2564+
if ( lineAngle < 0 )
2565+
lineAngle += 360;
25632566
if ( qgsDoubleNear( lineAngle, 0 ) || qgsDoubleNear( lineAngle, 360 ) || qgsDoubleNear( lineAngle, 180 ) )
25642567
{
25652568
height = outputPixelDist;
@@ -2585,7 +2588,7 @@ void QgsLinePatternFillSymbolLayer::applyPattern( const QgsSymbolRenderContext &
25852588
height = std::abs( height );
25862589
width = std::abs( width );
25872590

2588-
outputPixelDist = height * std::cos( lineAngle * M_PI / 180 );
2591+
outputPixelDist = std::abs( height * std::cos( lineAngle * M_PI / 180 ) );
25892592

25902593
// Round offset to correspond to one pixel height, otherwise lines may
25912594
// be shifted on tile border if offset falls close to pixel center

‎tests/src/core/testqgslinefillsymbol.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class TestQgsLineFillSymbol : public QObject
5656
void lineFillSymbol();
5757
void lineFillSymbolOffset();
5858
void lineFillLargeOffset();
59+
void lineFillNegativeAngle();
5960

6061
void dataDefinedSubSymbol();
6162

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

169+
void TestQgsLineFillSymbol::lineFillNegativeAngle()
170+
{
171+
mLineFill->setOffset( -8 );
172+
mLineFill->setDistance( 2.2 );
173+
mLineFill->setLineAngle( -130 );
174+
QVERIFY( imageCheck( QStringLiteral( "symbol_linefill_negangle" ) ) );
175+
mLineFill->setOffset( 0 );
176+
mLineFill->setLineAngle( 45 );
177+
mLineFill->setDistance( 5 );
178+
}
179+
168180
void TestQgsLineFillSymbol::dataDefinedSubSymbol()
169181
{
170182
mReport += QLatin1String( "<h2>Line fill symbol data defined sub symbol test</h2>\n" );

0 commit comments

Comments
 (0)
Please sign in to comment.