Skip to content

Commit

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

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

Fixes #19348
  • Loading branch information
nyalldawson committed Jul 10, 2018
1 parent 0a35d43 commit f6ab5f9
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 f6ab5f9

Please sign in to comment.