Skip to content

Commit 5ee97ad

Browse files
author
Patrick Valsecchi
committed
Add heuristic to not simplify geometries for nothing
Tested with a release binary and Swiss OSM roads in PostGIS at several zoom levels (the higher, the less features), values in ms (average over at least 100 queries): Level | Before | After | % improvement ------------------------------------------- 7 | 37 | 36 | 2.7 6 | 41 | 38 | 7.32 5 | 48 | 46 | 4.17 4 | 70 | 64 | 8.57 3 | 114 | 109 | 4.39 Not much improvement (I'm quite dispointed, here), but not much change in the code.
1 parent cd4bc88 commit 5ee97ad

File tree

10 files changed

+8
-2
lines changed

10 files changed

+8
-2
lines changed

src/core/qgsmaptopixelgeometrysimplifier.cpp

+8-2
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)