QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
22 QString QgsRotateFeaturesAlgorithm::name()
const
24 return QStringLiteral(
"rotatefeatures" );
27 QString QgsRotateFeaturesAlgorithm::displayName()
const
29 return QObject::tr(
"Rotate" );
32 QStringList QgsRotateFeaturesAlgorithm::tags()
const
34 return QObject::tr(
"rotate,around,center,point" ).split(
',' );
37 QString QgsRotateFeaturesAlgorithm::group()
const
39 return QObject::tr(
"Vector geometry" );
42 QString QgsRotateFeaturesAlgorithm::groupId()
const
44 return QStringLiteral(
"vectorgeometry" );
47 QString QgsRotateFeaturesAlgorithm::outputName()
const
49 return QObject::tr(
"Rotated" );
52 QString QgsRotateFeaturesAlgorithm::shortHelpString()
const
54 return QObject::tr(
"This algorithm rotates feature geometries, by the specified angle clockwise" )
55 + QStringLiteral(
"\n\n" )
56 + QObject::tr(
"Optionally, the rotation can occur around a preset point. If not set the rotation occurs around each feature's centroid." );
59 QgsRotateFeaturesAlgorithm *QgsRotateFeaturesAlgorithm::createInstance()
const
61 return new QgsRotateFeaturesAlgorithm();
64 void QgsRotateFeaturesAlgorithm::initParameters(
const QVariantMap & )
66 std::unique_ptr< QgsProcessingParameterNumber > rotation = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral(
"ANGLE" ),
69 rotation->setIsDynamic(
true );
71 rotation->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
72 addParameter( rotation.release() );
74 std::unique_ptr< QgsProcessingParameterPoint > anchor = std::make_unique< QgsProcessingParameterPoint >( QStringLiteral(
"ANCHOR" ),
75 QObject::tr(
"Rotation anchor point" ), QVariant(),
true );
76 addParameter( anchor.release() );
81 mAngle = parameterAsDouble( parameters, QStringLiteral(
"ANGLE" ), context );
84 mAngleProperty = parameters.value( QStringLiteral(
"ANGLE" ) ).value<
QgsProperty >();
86 mUseAnchor = parameters.
value( QStringLiteral(
"ANCHOR" ) ).isValid();
89 mAnchor = parameterAsPoint( parameters, QStringLiteral(
"ANCHOR" ), context );
90 mAnchorCrs = parameterAsPointCrs( parameters, QStringLiteral(
"ANCHOR" ), context );
98 if ( mUseAnchor && !mTransformedAnchor )
100 mTransformedAnchor =
true;
101 if ( mAnchorCrs != sourceCrs() )
106 mAnchor = ct.transform( mAnchor );
120 double angle = mAngle;
139 feedback->
reportError( QObject::tr(
"Could not calculate centroid for feature %1: %2" ).arg( feature.
id() ).arg(
centroid.lastError() ) );
@ Double
Double/float values.
A store for object properties.
static bool isDynamic(const QVariantMap ¶meters, const QString &name)
Returns true if the parameter with matching name is a dynamic parameter, and must be evaluated once f...
Base class for providing feedback from a processing algorithm.
CORE_EXPORT QgsMeshVertex centroid(const QgsMeshFace &face, const QVector< QgsMeshVertex > &vertices)
Returns the centroid of the face.
virtual void reportError(const QString &error, bool fatalError=false)
Reports that the algorithm encountered an error while executing.
QgsGeometry centroid() const
Returns the center of mass of a geometry.
QVariant value(const QgsExpressionContext &context, const QVariant &defaultValue=QVariant(), bool *ok=nullptr) const
Calculates the current value of the property, including any transforms which are set for the property...
@ Rotation
Rotation (value between 0-360 degrees)
Custom exception class for Coordinate Reference System related exceptions.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
Contains information about the context in which a processing algorithm is executed.
Qgis::GeometryOperationResult rotate(double rotation, const QgsPointXY ¢er)
Rotate this geometry around the Z axis.
QList< QgsFeature > QgsFeatureList
Definition for a property.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context.
A geometry is the spatial representation of a feature.
bool hasGeometry() const
Returns true if the feature has an associated geometry.
QgsExpressionContext & expressionContext()
Returns the expression context.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
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)
Custom exception class for processing related exceptions.