Skip to content
Permalink
Browse files

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.
  • Loading branch information
Patrick Valsecchi
Patrick Valsecchi committed Jul 19, 2016
1 parent cd4bc88 commit 5ee97adc1696bc1d274b0926f3f6ece1adc76033
@@ -547,9 +547,15 @@ bool QgsMapToPixelSimplifier::simplifyPoints( QgsWkbTypes::Type wkbType, QgsCons
if ( numPoints <= ( isaLinearRing ? 6 : 3 ) )
return false;

QgsRectangle envelope = calculateBoundingBox( singleType, QgsConstWkbPtr( sourceWkbPtr ), numPoints );
sourceWkbPtr -= sizeof( int );
const QgsRectangle envelope = calculateBoundingBox( singleType, QgsConstWkbPtr( sourceWkbPtr ), numPoints );

if ( qMax( envelope.width(), envelope.height() ) / numPoints > tolerance * 2.0 )
{
//points are in average too far appart to lead to any significant simplification
return false;
}

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

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 5ee97ad

Please sign in to comment.
You can’t perform that action at this time.