Skip to content

Commit

Permalink
Merge pull request #1509 from ahuarte47/Issue_10767
Browse files Browse the repository at this point in the history
Fix bug #10767: Simplified rendering causing boxes to appear instead
  • Loading branch information
wonder-sk committed Sep 26, 2014
2 parents 6fcfb97 + b07660a commit eaacb12
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/core/qgsmaptopixelgeometrysimplifier.cpp
Expand Up @@ -222,6 +222,9 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry(
double* ptr = ( double* )targetWkb;
map2pixelTol *= map2pixelTol; //-> Use mappixelTol for 'LengthSquare' calculations.

bool isaUngenerizableSegment;
bool hasUngenerizableSegments = false; //-> To avoid replace the simplified geometry by its BBOX when there are 'long' segments.

// Check whether the LinearRing is really closed.
if ( isaLinearRing )
{
Expand All @@ -246,22 +249,29 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry(
memcpy( &x, sourceWkb, sizeof( double ) ); sourceWkb += sizeOfDoubleX;
memcpy( &y, sourceWkb, sizeof( double ) ); sourceWkb += sizeOfDoubleY;

isaUngenerizableSegment = false;

if ( i == 0 ||
!isGeneralizable ||
calculateLengthSquared2D( x, y, lastX, lastY ) > map2pixelTol ||
( isaUngenerizableSegment = ( calculateLengthSquared2D( x, y, lastX, lastY ) > map2pixelTol ) ) ||
( !isaLinearRing && ( i == 1 || i >= numPoints - 2 ) ) )
{
memcpy( ptr, &x, sizeof( double ) ); lastX = x; ptr++;
memcpy( ptr, &y, sizeof( double ) ); lastY = y; ptr++;
numTargetPoints++;

if ( isaUngenerizableSegment && !hasUngenerizableSegments )
{
hasUngenerizableSegments = true;
}
}

r.combineExtentWith( x, y );
}
targetWkb = wkb2 + 4;

// Fix the topology of the geometry
if ( numTargetPoints <= ( isaLinearRing ? 2 : 1 ) )
if ( numTargetPoints <= ( isaLinearRing ? 2 : 1 ) && !hasUngenerizableSegments )
{
unsigned char* targetTempWkb = targetWkb;
int targetWkbTempSize = targetWkbSize;
Expand Down

0 comments on commit eaacb12

Please sign in to comment.