Skip to content

Commit

Permalink
Merge pull request #8535 from elpaso/bugfix-20591-dissolve-show-error…
Browse files Browse the repository at this point in the history
…-backport

[processing] Fix error in dissolve
  • Loading branch information
elpaso committed Nov 23, 2018
2 parents 1047e69 + 26baf0c commit 3f197f7
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/analysis/processing/qgsalgorithmdissolve.cpp
Expand Up @@ -210,11 +210,30 @@ QgsDissolveAlgorithm *QgsDissolveAlgorithm::createInstance() const
return new QgsDissolveAlgorithm();
}


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( QStringLiteral( "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 3f197f7

Please sign in to comment.