Skip to content

Commit eaacb12

Browse files
committed
Merge pull request #1509 from ahuarte47/Issue_10767
Fix bug #10767: Simplified rendering causing boxes to appear instead
2 parents 6fcfb97 + b07660a commit eaacb12

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/core/qgsmaptopixelgeometrysimplifier.cpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry(
222222
double* ptr = ( double* )targetWkb;
223223
map2pixelTol *= map2pixelTol; //-> Use mappixelTol for 'LengthSquare' calculations.
224224

225+
bool isaUngenerizableSegment;
226+
bool hasUngenerizableSegments = false; //-> To avoid replace the simplified geometry by its BBOX when there are 'long' segments.
227+
225228
// Check whether the LinearRing is really closed.
226229
if ( isaLinearRing )
227230
{
@@ -246,22 +249,29 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry(
246249
memcpy( &x, sourceWkb, sizeof( double ) ); sourceWkb += sizeOfDoubleX;
247250
memcpy( &y, sourceWkb, sizeof( double ) ); sourceWkb += sizeOfDoubleY;
248251

252+
isaUngenerizableSegment = false;
253+
249254
if ( i == 0 ||
250255
!isGeneralizable ||
251-
calculateLengthSquared2D( x, y, lastX, lastY ) > map2pixelTol ||
256+
( isaUngenerizableSegment = ( calculateLengthSquared2D( x, y, lastX, lastY ) > map2pixelTol ) ) ||
252257
( !isaLinearRing && ( i == 1 || i >= numPoints - 2 ) ) )
253258
{
254259
memcpy( ptr, &x, sizeof( double ) ); lastX = x; ptr++;
255260
memcpy( ptr, &y, sizeof( double ) ); lastY = y; ptr++;
256261
numTargetPoints++;
262+
263+
if ( isaUngenerizableSegment && !hasUngenerizableSegments )
264+
{
265+
hasUngenerizableSegments = true;
266+
}
257267
}
258268

259269
r.combineExtentWith( x, y );
260270
}
261271
targetWkb = wkb2 + 4;
262272

263273
// Fix the topology of the geometry
264-
if ( numTargetPoints <= ( isaLinearRing ? 2 : 1 ) )
274+
if ( numTargetPoints <= ( isaLinearRing ? 2 : 1 ) && !hasUngenerizableSegments )
265275
{
266276
unsigned char* targetTempWkb = targetWkb;
267277
int targetWkbTempSize = targetWkbSize;

0 commit comments

Comments
 (0)