22using namespace Qt::StringLiterals;
26QString QgsConvexHullAlgorithm::name()
const
28 return u
"convexhull"_s;
31QString QgsConvexHullAlgorithm::displayName()
const
33 return QObject::tr(
"Convex hull" );
36QStringList QgsConvexHullAlgorithm::tags()
const
38 return QObject::tr(
"convex,hull,bounds,bounding" ).split(
',' );
41QString QgsConvexHullAlgorithm::group()
const
43 return QObject::tr(
"Vector geometry" );
46QString QgsConvexHullAlgorithm::groupId()
const
48 return u
"vectorgeometry"_s;
51QString QgsConvexHullAlgorithm::outputName()
const
53 return QObject::tr(
"Convex hulls" );
56QString QgsConvexHullAlgorithm::shortHelpString()
const
58 return QObject::tr(
"This algorithm calculates the convex hull for each feature in an input layer." )
60 + QObject::tr(
"See the 'Minimum bounding geometry' algorithm for a convex hull calculation which covers the whole layer or grouped subsets of features." );
63QString QgsConvexHullAlgorithm::shortDescription()
const
65 return QObject::tr(
"Calculates the convex hull for each feature in an input layer." );
68QgsConvexHullAlgorithm *QgsConvexHullAlgorithm::createInstance()
const
70 return new QgsConvexHullAlgorithm();
76 newFields.
append(
QgsField( u
"area"_s, QMetaType::Type::Double, QString(), 20, 6 ) );
77 newFields.
append(
QgsField( u
"perimeter"_s, QMetaType::Type::Double, QString(), 20, 6 ) );
83 QGS_MARK_ALGORITHM_SOURCE
86 if ( f.hasGeometry() )
91 feedback->
reportError( QObject::tr(
"Cannot calculate convex hull for a single Point feature (try 'Minimum bounding geometry' algorithm instead)." ) );
97 if ( outputGeometry.
isNull() )
99 f.setGeometry( outputGeometry );
101 if ( !outputGeometry.
isNull() )
105 f.setAttributes( attrs );
110 attrs << QVariant() << QVariant();
111 f.setAttributes( attrs );
virtual double perimeter() const
Returns the planar, 2-dimensional perimeter of the geometry.
virtual double area() const
Returns the planar, 2-dimensional area of the geometry.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
bool append(const QgsField &field, Qgis::FieldOrigin origin=Qgis::FieldOrigin::Provider, int originIndex=-1)
Appends a field.
A geometry is the spatial representation of a feature.
QString lastError() const
Returns an error string referring to the last error encountered either when this geometry was created...
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QgsGeometry convexHull() const
Returns the smallest convex polygon that contains all the points in the geometry.
Contains information about the context in which a processing algorithm is executed.
Base class for providing feedback from a processing algorithm.
virtual void reportError(const QString &error, bool fatalError=false)
Reports that the algorithm encountered an error while executing.
static QgsFields combineFields(const QgsFields &fieldsA, const QgsFields &fieldsB, const QString &fieldsBPrefix=QString())
Combines two field lists, avoiding duplicate field names (in a case-insensitive manner).
static Qgis::WkbType flatType(Qgis::WkbType type)
Returns the flat type for a WKB type.
QList< QgsFeature > QgsFeatureList