Skip to content

Commit

Permalink
Merge pull request #8530 from elpaso/bugfix-20591-dissolve-show-error
Browse files Browse the repository at this point in the history
[processing] Show error when dissolve fails
  • Loading branch information
elpaso committed Nov 23, 2018
2 parents 0e5718d + eb05f0a commit 697e704
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/analysis/processing/qgsalgorithmdissolve.cpp
Expand Up @@ -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 );
}

Expand Down

0 comments on commit 697e704

Please sign in to comment.