Skip to content

Commit 40b70a3

Browse files
authored
Merge pull request #3326 from pvalsecc/perf
Add heuristic to not simplify geometries for nothing
2 parents cd4bc88 + 5ee97ad commit 40b70a3

File tree

10 files changed

+8
-2
lines changed

10 files changed

+8
-2
lines changed

src/core/qgsmaptopixelgeometrysimplifier.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,9 +547,15 @@ bool QgsMapToPixelSimplifier::simplifyPoints( QgsWkbTypes::Type wkbType, QgsCons
547547
if ( numPoints <= ( isaLinearRing ? 6 : 3 ) )
548548
return false;
549549

550-
QgsRectangle envelope = calculateBoundingBox( singleType, QgsConstWkbPtr( sourceWkbPtr ), numPoints );
551-
sourceWkbPtr -= sizeof( int );
550+
const QgsRectangle envelope = calculateBoundingBox( singleType, QgsConstWkbPtr( sourceWkbPtr ), numPoints );
551+
552+
if ( qMax( envelope.width(), envelope.height() ) / numPoints > tolerance * 2.0 )
553+
{
554+
//points are in average too far appart to lead to any significant simplification
555+
return false;
556+
}
552557

558+
sourceWkbPtr -= sizeof( int );
553559
int targetWkbSize = 5 + sizeof( int ) + numPoints * ( 2 * sizeof( double ) );
554560
unsigned char* targetWkb = new unsigned char[ targetWkbSize ];
555561

Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)