Skip to content

Commit 697ebff

Browse files
committed
Merge pull request #1616 from ahuarte47/Issue_11243
Fix #11243: Data corruption with feature simplification
2 parents 42d915e + 20b0d12 commit 697ebff

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/core/qgsvectorlayerrenderer.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ bool QgsVectorLayerRenderer::render()
135135
if ( mSimplifyGeometry )
136136
{
137137
double map2pixelTol = mSimplifyMethod.threshold();
138+
bool validTransform = true;
138139

139140
const QgsMapToPixel& mtp = mContext.mapToPixel();
140141
map2pixelTol *= mtp.mapUnitsPerPixel();
@@ -174,18 +175,28 @@ bool QgsVectorLayerRenderer::render()
174175
catch ( QgsCsException &cse )
175176
{
176177
QgsMessageLog::logMessage( QObject::tr( "Simplify transform error caught: %1" ).arg( cse.what() ), QObject::tr( "CRS" ) );
178+
validTransform = false;
177179
}
178180
}
179181

180-
QgsSimplifyMethod simplifyMethod;
181-
simplifyMethod.setMethodType( QgsSimplifyMethod::OptimizeForRendering );
182-
simplifyMethod.setTolerance( map2pixelTol );
183-
simplifyMethod.setForceLocalOptimization( mSimplifyMethod.forceLocalOptimization() );
182+
if ( validTransform )
183+
{
184+
QgsSimplifyMethod simplifyMethod;
185+
simplifyMethod.setMethodType( QgsSimplifyMethod::OptimizeForRendering );
186+
simplifyMethod.setTolerance( map2pixelTol );
187+
simplifyMethod.setForceLocalOptimization( mSimplifyMethod.forceLocalOptimization() );
184188

185-
featureRequest.setSimplifyMethod( simplifyMethod );
189+
featureRequest.setSimplifyMethod( simplifyMethod );
186190

187-
QgsVectorSimplifyMethod vectorMethod = mSimplifyMethod;
188-
mContext.setVectorSimplifyMethod( vectorMethod );
191+
QgsVectorSimplifyMethod vectorMethod = mSimplifyMethod;
192+
mContext.setVectorSimplifyMethod( vectorMethod );
193+
}
194+
else
195+
{
196+
QgsVectorSimplifyMethod vectorMethod;
197+
vectorMethod.setSimplifyHints( QgsVectorSimplifyMethod::NoSimplification );
198+
mContext.setVectorSimplifyMethod( vectorMethod );
199+
}
189200
}
190201
else
191202
{

0 commit comments

Comments
 (0)