Skip to content

Commit f6ab5f9

Browse files
committedJul 10, 2018
[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
1 parent 0a35d43 commit f6ab5f9

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed
 

‎src/analysis/processing/qgsalgorithmconvexhull.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,19 @@ QgsFeatureList QgsConvexHullAlgorithm::processFeature( const QgsFeature &feature
7474
QgsFeature f = feature;
7575
if ( f.hasGeometry() )
7676
{
77-
QgsGeometry outputGeometry = f.geometry().convexHull();
78-
if ( !outputGeometry )
79-
feedback->reportError( outputGeometry.lastError() );
80-
f.setGeometry( outputGeometry );
77+
QgsGeometry outputGeometry;
78+
if ( QgsWkbTypes::flatType( f.geometry().wkbType() ) == QgsWkbTypes::Point )
79+
{
80+
feedback->reportError( QObject::tr( "Cannot calculate convex hull for a single Point feature (try 'Minimum bounding geometry' algorithm instead)." ) );
81+
f.clearGeometry();
82+
}
83+
else
84+
{
85+
outputGeometry = f.geometry().convexHull();
86+
if ( !outputGeometry )
87+
feedback->reportError( outputGeometry.lastError() );
88+
f.setGeometry( outputGeometry );
89+
}
8190
if ( outputGeometry )
8291
{
8392
QgsAttributes attrs = f.attributes();

0 commit comments

Comments
 (0)
Please sign in to comment.