24using namespace Qt::StringLiterals;
28QString QgsOrientedMinimumBoundingBoxAlgorithm::name()
const
30 return u
"orientedminimumboundingbox"_s;
33QString QgsOrientedMinimumBoundingBoxAlgorithm::displayName()
const
35 return QObject::tr(
"Oriented minimum bounding box" );
38QStringList QgsOrientedMinimumBoundingBoxAlgorithm::tags()
const
40 return QObject::tr(
"bounding,boxes,envelope,rectangle,extent,oriented,angle" ).split(
',' );
43QString QgsOrientedMinimumBoundingBoxAlgorithm::group()
const
45 return QObject::tr(
"Vector geometry" );
48QString QgsOrientedMinimumBoundingBoxAlgorithm::groupId()
const
50 return u
"vectorgeometry"_s;
53QString QgsOrientedMinimumBoundingBoxAlgorithm::outputName()
const
55 return QObject::tr(
"Bounding boxes" );
63QString QgsOrientedMinimumBoundingBoxAlgorithm::shortHelpString()
const
65 return QObject::tr(
"This algorithm calculates the minimum area rotated rectangle which covers each feature in an input layer." ) + u
"\n\n"_s + QObject::tr(
"For singlepart point features, the output corresponds to the bounding box of the geometry." ) + u
"\n\n"_s + QObject::tr(
"See the 'Minimum bounding geometry' algorithm for an oriented bounding box calculation which covers the whole layer or grouped subsets of features." );
68QString QgsOrientedMinimumBoundingBoxAlgorithm::shortDescription()
const
70 return QObject::tr(
"Calculates the minimum area rotated rectangle which covers each feature in an input layer." );
73QgsOrientedMinimumBoundingBoxAlgorithm *QgsOrientedMinimumBoundingBoxAlgorithm::createInstance()
const
75 return new QgsOrientedMinimumBoundingBoxAlgorithm();
78bool QgsOrientedMinimumBoundingBoxAlgorithm::supportInPlaceEdit(
const QgsMapLayer *l )
const
80 const QgsVectorLayer *layer = qobject_cast<const QgsVectorLayer *>( l );
90QgsFields QgsOrientedMinimumBoundingBoxAlgorithm::outputFields(
const QgsFields &inputFields )
const
93 newFields.
append(
QgsField( u
"width"_s, QMetaType::Type::Double, QString(), 20, 6 ) );
94 newFields.
append(
QgsField( u
"height"_s, QMetaType::Type::Double, QString(), 20, 6 ) );
95 newFields.
append(
QgsField( u
"angle"_s, QMetaType::Type::Double, QString(), 20, 6 ) );
96 newFields.
append(
QgsField( u
"area"_s, QMetaType::Type::Double, QString(), 20, 6 ) );
97 newFields.
append(
QgsField( u
"perimeter"_s, QMetaType::Type::Double, QString(), 20, 6 ) );
117 << 2 * width + 2 * height;
WkbType
The WKB type describes the number of dimensions a geometry has.
@ MultiPolygon
MultiPolygon.
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.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
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.
QgsGeometry orientedMinimumBoundingBox(double &area, double &angle, double &width, double &height) const
Returns the oriented minimum bounding box for the geometry, which is the smallest (by area) rotated r...
Base class for all map layer types.
Contains information about the context in which a processing algorithm is executed.
bool supportInPlaceEdit(const QgsMapLayer *layer) const override
Checks whether this algorithm supports in-place editing on the given layer Default implementation for...
Base class for providing feedback from a processing algorithm.
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).
Represents a vector layer which manages a vector based dataset.
Q_INVOKABLE Qgis::WkbType wkbType() const final
Returns the WKBType or WKBUnknown in case of error.
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored).
QList< QgsFeature > QgsFeatureList