Skip to content
Permalink
Browse files

[processing] Fix error in dissolve

Backported from master
  • Loading branch information
elpaso committed Nov 23, 2018
1 parent 8f1c51b commit 894cc7c148d06c7b4ba9a1a4fcf2cc7d4a2bc1d0
Showing with 21 additions and 2 deletions.
  1. +21 −2 src/analysis/processing/qgsalgorithmdissolve.cpp
@@ -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 )
{
QgsDebugMsg( 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 );
}

0 comments on commit 894cc7c

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