Skip to content

Commit

Permalink
#10767: No replace the simplified geometry by its BBOX when there are…
Browse files Browse the repository at this point in the history
… 'long' segments
  • Loading branch information
ahuarte47 committed Sep 23, 2014
1 parent 0f8fef1 commit b07660a
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 b07660a

Please sign in to comment.