Skip to content
Permalink
Browse files

Merge pull request #1509 from ahuarte47/Issue_10767

Fix bug #10767: Simplified rendering causing boxes to appear instead
  • Loading branch information
wonder-sk committed Sep 26, 2014
2 parents 6fcfb97 + b07660a commit eaacb125c402cf22dd66482b313bdaef73791fea
Showing with 12 additions and 2 deletions.
  1. +12 −2 src/core/qgsmaptopixelgeometrysimplifier.cpp
@@ -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 )
{
@@ -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;

0 comments on commit eaacb12

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