Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge pull request #8530 from elpaso/bugfix-20591-dissolve-show-error
[processing] Show error when dissolve fails
- Loading branch information
Showing
with
20 additions
and
2 deletions.
-
+20
−2
src/analysis/processing/qgsalgorithmdissolve.cpp
|
@@ -212,9 +212,27 @@ QgsDissolveAlgorithm *QgsDissolveAlgorithm::createInstance() const |
|
|
|
|
|
QVariantMap QgsDissolveAlgorithm::processAlgorithm( const QVariantMap ¶meters, 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 ); |
|
|
} |
|
|
|
|
|