Skip to content
Permalink
Browse files

Merge pull request #8530 from elpaso/bugfix-20591-dissolve-show-error

[processing] Show error when dissolve fails
  • Loading branch information
elpaso committed Nov 23, 2018
2 parents 0e5718d + eb05f0a commit 697e7044f52b00895c46269b84a1eb742a415d85
Showing with 20 additions and 2 deletions.
  1. +20 −2 src/analysis/processing/qgsalgorithmdissolve.cpp
@@ -212,9 +212,27 @@ QgsDissolveAlgorithm *QgsDissolveAlgorithm::createInstance() const

QVariantMap QgsDissolveAlgorithm::processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
{
return processCollection( parameters, context, feedback, []( const QVector< QgsGeometry > &parts )->QgsGeometry
return processCollection( parameters, context, feedback, [ & ]( const QVector< QgsGeometry > &parts )->QgsGeometry
{
return QgsGeometry::unaryUnion( parts );
QgsGeometry result( QgsGeometry::unaryUnion( parts ) );
// Geos may fail in some cases, let's try a slower but safer approach
// See: https://issues.qgis.org/issues/20591 - Dissolve tool failing to produce outputs
if ( ! result.lastError().isEmpty() && parts.count() > 2 )
{
feedback->pushDebugInfo( QObject::tr( "GEOS exception: taking the slower route ..." ) );
result = QgsGeometry();
for ( const auto &p : parts )
{
result = QgsGeometry::unaryUnion( QVector< QgsGeometry >() << result << p );
}
}
if ( ! result.lastError().isEmpty() )
{
feedback->reportError( result.lastError(), true );
if ( result.isEmpty() )
throw QgsProcessingException( QObject::tr( "The algorithm returned no output." ) );
}
return result;
}, 10000 );
}

0 comments on commit 697e704

Please sign in to comment.
You can’t perform that action at this time.