mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-28 00:05:04 -04:00
Fix line pattern fill symbol corruption with negative angles
This commit is contained in:
parent
e277b91087
commit
0f056b500a
src/core/symbology
tests
src/core
testdata/control_images/symbol_linefill
expected_symbol_linefill_large_negoffset
expected_symbol_linefill_large_posoffset
expected_symbol_linefill_negangle
@ -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" );
|
||||
|
BIN
tests/testdata/control_images/symbol_linefill/expected_symbol_linefill_large_negoffset/expected_symbol_linefill_large_negoffset.png
vendored
Normal file
BIN
tests/testdata/control_images/symbol_linefill/expected_symbol_linefill_large_negoffset/expected_symbol_linefill_large_negoffset.png
vendored
Normal file
Binary file not shown.
After ![]() (image error) Size: 626 KiB |
BIN
tests/testdata/control_images/symbol_linefill/expected_symbol_linefill_large_posoffset/expected_symbol_linefill_large_posoffset.png
vendored
Normal file
BIN
tests/testdata/control_images/symbol_linefill/expected_symbol_linefill_large_posoffset/expected_symbol_linefill_large_posoffset.png
vendored
Normal file
Binary file not shown.
After ![]() (image error) Size: 626 KiB |
BIN
tests/testdata/control_images/symbol_linefill/expected_symbol_linefill_negangle/expected_symbol_linefill_negangle.png
vendored
Normal file
BIN
tests/testdata/control_images/symbol_linefill/expected_symbol_linefill_negangle/expected_symbol_linefill_negangle.png
vendored
Normal file
Binary file not shown.
After ![]() (image error) Size: 626 KiB |
Loading…
x
Reference in New Issue
Block a user