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() ) );
 
Custom exception class for Coordinate Reference System related exceptions.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
bool hasGeometry() const
Returns true if the feature has an associated geometry.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
A geometry is the spatial representation of a feature.
OperationResult rotate(double rotation, const QgsPointXY ¢er)
Rotate this geometry around the Z axis.
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
QgsGeometry centroid() const
Returns the center of mass of a geometry.
QString lastError() const SIP_HOLDGIL
Returns an error string referring to the last error encountered either when this geometry was created...
Contains information about the context in which a processing algorithm is executed.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context.
QgsExpressionContext & expressionContext()
Returns the expression context.
Custom exception class for processing related exceptions.
Base class for providing feedback from a processing algorithm.
virtual void reportError(const QString &error, bool fatalError=false)
Reports that the algorithm encountered an error while executing.
@ Double
Double/float values.
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...
Definition for a property.
@ Rotation
Rotation (value between 0-360 degrees)
A store for object properties.
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...
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