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 = qgis::make_unique< QgsProcessingParameterNumber >( QStringLiteral(
"ANGLE" ),
69 rotation->setIsDynamic(
true );
71 rotation->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
72 addParameter( rotation.release() );
74 std::unique_ptr< QgsProcessingParameterPoint > anchor = qgis::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() ) );