Skip to content

Commit 42fd6a2

Browse files
ahuarte47m-kuhn
authored andcommitted
#8725-R: never simplifying the first two or last two vertices in a line
This ensure that the angles at the line start and end are the same after simplification
1 parent 2c67e51 commit 42fd6a2

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/core/qgsmaptopixelgeometrysimplifier.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry( int simplifyFlags, QGis::WkbT
203203
memcpy( &x, sourceWkb, sizeof( double ) ); sourceWkb += sizeOfDoubleX;
204204
memcpy( &y, sourceWkb, sizeof( double ) ); sourceWkb += sizeOfDoubleY;
205205

206-
if ( i == 0 || !canbeGeneralizable || QgsMapToPixelSimplifier::calculateLengthSquared2D( x, y, lastX, lastY ) > map2pixelTol )
206+
if ( i == 0 || !canbeGeneralizable || QgsMapToPixelSimplifier::calculateLengthSquared2D( x, y, lastX, lastY ) > map2pixelTol || ( !isaLinearRing && ( i == 1 || i >= numPoints - 2 ) ) )
207207
{
208208
memcpy( ptr, &x, sizeof( double ) ); lastX = x; ptr++;
209209
memcpy( ptr, &y, sizeof( double ) ); lastY = y; ptr++;

src/providers/ogr/qgsogrgeometrysimplifier.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ bool QgsOgrMapToPixelSimplifier::simplifyOgrGeometry( QGis::GeometryType geometr
113113
memcpy( &x, xsourcePtr, sizeof( double ) ); xsourcePtr += xStride;
114114
memcpy( &y, ysourcePtr, sizeof( double ) ); ysourcePtr += yStride;
115115

116-
if ( i == 0 || !canbeGeneralizable || QgsMapToPixelSimplifier::calculateLengthSquared2D( x, y, lastX, lastY ) > map2pixelTol )
116+
if ( i == 0 || !canbeGeneralizable || QgsMapToPixelSimplifier::calculateLengthSquared2D( x, y, lastX, lastY ) > map2pixelTol || ( geometryType == QGis::Line && ( i == 1 || i >= numPoints - 2 ) ) )
117117
{
118118
memcpy( xtargetPtr, &x, sizeof( double ) ); lastX = x; xtargetPtr += xStride;
119119
memcpy( ytargetPtr, &y, sizeof( double ) ); lastY = y; ytargetPtr += yStride;
@@ -140,7 +140,7 @@ bool QgsOgrMapToPixelSimplifier::simplifyOgrGeometry( OGRGeometry* geometry, boo
140140
OGRLineString* lineString = ( OGRLineString* )geometry;
141141

142142
int numPoints = lineString->getNumPoints();
143-
if (( isaLinearRing && numPoints <= 5 ) || ( !isaLinearRing && numPoints <= 2 ) ) return false;
143+
if (( isaLinearRing && numPoints <= 5 ) || ( !isaLinearRing && numPoints <= 4 ) ) return false;
144144

145145
OGREnvelope env;
146146
geometry->getEnvelope( &env );

0 commit comments

Comments
 (0)