Skip to content

Commit 60e1a9b

Browse files
ahuarte47m-kuhn
authored andcommitted
#9686: fix simplification of no-closed polygons
1 parent fc6cd54 commit 60e1a9b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/core/qgsmaptopixelgeometrysimplifier.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,24 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry( int simplifyFlags, QGis::WkbT
207207
double* ptr = ( double* )targetWkb;
208208
map2pixelTol *= map2pixelTol; //-> Use mappixelTol for 'LengthSquare' calculations.
209209

210+
// Check whether the LinearRing is really closed.
211+
if ( isaLinearRing )
212+
{
213+
double x1, y1, x2, y2;
214+
215+
unsigned char* startWkbX = sourceWkb;
216+
unsigned char* startWkbY = startWkbX + sizeOfDoubleX;
217+
unsigned char* finalWkbX = sourceWkb + ( numPoints - 1 ) * ( sizeOfDoubleX + sizeOfDoubleY );
218+
unsigned char* finalWkbY = finalWkbX + sizeOfDoubleX;
219+
220+
memcpy( &x1, startWkbX, sizeof( double ) );
221+
memcpy( &y1, startWkbY, sizeof( double ) );
222+
memcpy( &x2, finalWkbX, sizeof( double ) );
223+
memcpy( &y2, finalWkbY, sizeof( double ) );
224+
225+
isaLinearRing = ( x1 == x2 ) && ( y1 == y2 );
226+
}
227+
210228
// Process each vertex...
211229
for ( int i = 0, numPoints_i = ( isaLinearRing ? numPoints - 1 : numPoints ); i < numPoints_i; ++i )
212230
{

0 commit comments

Comments
 (0)