23 QString QgsRoundnessAlgorithm::name()
const
25 return QStringLiteral(
"roundness" );
28 QString QgsRoundnessAlgorithm::displayName()
const
30 return QObject::tr(
"Roundness" );
33 QStringList QgsRoundnessAlgorithm::tags()
const
35 return QObject::tr(
"roundness,circle" ).split(
',' );
38 QString QgsRoundnessAlgorithm::group()
const
40 return QObject::tr(
"Vector geometry" );
43 QString QgsRoundnessAlgorithm::groupId()
const
45 return QStringLiteral(
"vectorgeometry" );
48 QString QgsRoundnessAlgorithm::outputName()
const
50 return QObject::tr(
"Roundness" );
53 QString 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." );
59 QString QgsRoundnessAlgorithm::shortDescription()
const
61 return QObject::tr(
"Calculates the roundness of polygon features." );
64 QgsRoundnessAlgorithm *QgsRoundnessAlgorithm::createInstance()
const
66 return new QgsRoundnessAlgorithm();
69 QList<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();