Skip to content

Commit 697e704

Browse files
authoredNov 23, 2018
Merge pull request #8530 from elpaso/bugfix-20591-dissolve-show-error
[processing] Show error when dissolve fails
2 parents 0e5718d + eb05f0a commit 697e704

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed
 

‎src/analysis/processing/qgsalgorithmdissolve.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,27 @@ QgsDissolveAlgorithm *QgsDissolveAlgorithm::createInstance() const
212212

213213
QVariantMap QgsDissolveAlgorithm::processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
214214
{
215-
return processCollection( parameters, context, feedback, []( const QVector< QgsGeometry > &parts )->QgsGeometry
215+
return processCollection( parameters, context, feedback, [ & ]( const QVector< QgsGeometry > &parts )->QgsGeometry
216216
{
217-
return QgsGeometry::unaryUnion( parts );
217+
QgsGeometry result( QgsGeometry::unaryUnion( parts ) );
218+
// Geos may fail in some cases, let's try a slower but safer approach
219+
// See: https://issues.qgis.org/issues/20591 - Dissolve tool failing to produce outputs
220+
if ( ! result.lastError().isEmpty() && parts.count() > 2 )
221+
{
222+
feedback->pushDebugInfo( QObject::tr( "GEOS exception: taking the slower route ..." ) );
223+
result = QgsGeometry();
224+
for ( const auto &p : parts )
225+
{
226+
result = QgsGeometry::unaryUnion( QVector< QgsGeometry >() << result << p );
227+
}
228+
}
229+
if ( ! result.lastError().isEmpty() )
230+
{
231+
feedback->reportError( result.lastError(), true );
232+
if ( result.isEmpty() )
233+
throw QgsProcessingException( QObject::tr( "The algorithm returned no output." ) );
234+
}
235+
return result;
218236
}, 10000 );
219237
}
220238

0 commit comments

Comments
 (0)
Please sign in to comment.