23QString QgsRoundnessAlgorithm::name()
const
25 return QStringLiteral(
"roundness" );
28QString QgsRoundnessAlgorithm::displayName()
const
30 return QObject::tr(
"Roundness" );
33QStringList QgsRoundnessAlgorithm::tags()
const
35 return QObject::tr(
"roundness,circle" ).split(
',' );
38QString QgsRoundnessAlgorithm::group()
const
40 return QObject::tr(
"Vector geometry" );
43QString QgsRoundnessAlgorithm::groupId()
const
45 return QStringLiteral(
"vectorgeometry" );
48QString QgsRoundnessAlgorithm::outputName()
const
50 return QObject::tr(
"Roundness" );
53QString QgsRoundnessAlgorithm::shortHelpString()
const
55 return QObject::tr(
"Calculates the roundness of each feature and stores it as a new field. The input vector layer must contain polygons.\n\n"
56 "The roundness of a polygon is defined as 4π × polygon area / perimeter². The roundness value varies between 0 and 1. A perfect circle has a roundness of 1, while a completely flat polygon has a roundness of 0." );
59QString QgsRoundnessAlgorithm::shortDescription()
const
61 return QObject::tr(
"Calculates the roundness of polygon features." );
64QgsRoundnessAlgorithm *QgsRoundnessAlgorithm::createInstance()
const
66 return new QgsRoundnessAlgorithm();
69QList<int> QgsRoundnessAlgorithm::inputLayerTypes()
const
82 outputFields.
append(
QgsField( QStringLiteral(
"roundness" ), QVariant::Double ) );
95 double roundness = poly->roundness();
96 attributes << QVariant( roundness );
100 attributes << QVariant();
105 attributes << QVariant();
virtual const QgsAbstractGeometry * simplifiedTypeRef() const
Returns a reference to the simplest lossless representation of this geometry, e.g.
Curve polygon geometry type.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
bool hasGeometry() const
Returns true if the feature has an associated geometry.
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
bool append(const QgsField &field, FieldOrigin origin=OriginProvider, int originIndex=-1)
Appends a field. The field must have unique name, otherwise it is rejected (returns false)
A geometry is the spatial representation of a feature.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
Contains information about the context in which a processing algorithm is executed.
Base class for providing feedback from a processing algorithm.
SourceType
Data source types enum.
@ TypeVectorPolygon
Vector polygon layers.
QList< QgsFeature > QgsFeatureList