Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] Better error when 'Convex hull' algorithm is run on
single point feature layer

Which hints to users to use the 'Minimum bounding geometry' algorithm
instead.

Fixes #19348

(cherry-picked from f6ab5f9)
  • Loading branch information
nyalldawson committed Jul 10, 2018
1 parent 9e63678 commit c473ac0
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/analysis/processing/qgsalgorithmconvexhull.cpp
Expand Up @@ -74,10 +74,19 @@ QgsFeatureList QgsConvexHullAlgorithm::processFeature( const QgsFeature &feature
QgsFeature f = feature;
if ( f.hasGeometry() )
{
QgsGeometry outputGeometry = f.geometry().convexHull();
if ( !outputGeometry )
feedback->reportError( outputGeometry.lastError() );
f.setGeometry( outputGeometry );
QgsGeometry outputGeometry;
if ( QgsWkbTypes::flatType( f.geometry().wkbType() ) == QgsWkbTypes::Point )
{
feedback->reportError( QObject::tr( "Cannot calculate convex hull for a single Point feature (try 'Minimum bounding geometry' algorithm instead)." ) );
f.clearGeometry();
}
else
{
outputGeometry = f.geometry().convexHull();
if ( !outputGeometry )
feedback->reportError( outputGeometry.lastError() );
f.setGeometry( outputGeometry );
}
if ( outputGeometry )
{
QgsAttributes attrs = f.attributes();
Expand Down

0 comments on commit c473ac0

Please sign in to comment.