23QString QgsAffineTransformationAlgorithm::name()
 const 
   25  return QStringLiteral( 
"affinetransform" );
 
   28QString QgsAffineTransformationAlgorithm::displayName()
 const 
   30  return QObject::tr( 
"Affine transform" );
 
   33QStringList QgsAffineTransformationAlgorithm::tags()
 const 
   35  return QObject::tr( 
"move,shift,transform,affine,scale,rotate,resize,matrix" ).split( 
',' );
 
   38QString QgsAffineTransformationAlgorithm::group()
 const 
   40  return QObject::tr( 
"Vector geometry" );
 
   43QString QgsAffineTransformationAlgorithm::groupId()
 const 
   45  return QStringLiteral( 
"vectorgeometry" );
 
   48QString QgsAffineTransformationAlgorithm::outputName()
 const 
   50  return QObject::tr( 
"Transformed" );
 
   53QString QgsAffineTransformationAlgorithm::shortHelpString()
 const 
   55  return QObject::tr( 
"This algorithm applies an affine transformation to the geometries from a layer. Affine transformations can include " 
   56                      "translation, scaling and rotation. The operations are performed in a scale, rotation, translation order." )
 
   57         + QStringLiteral( 
"\n\n" )
 
   58         + QObject::tr( 
"Z and M values present in the geometry can also be translated and scaled independently." );
 
   61QString QgsAffineTransformationAlgorithm::shortDescription()
 const 
   63  return QObject::tr( 
"Applies an affine transformation to geometries." );
 
   66QgsAffineTransformationAlgorithm *QgsAffineTransformationAlgorithm::createInstance()
 const 
   68  return new QgsAffineTransformationAlgorithm();
 
   71void QgsAffineTransformationAlgorithm::initParameters( 
const QVariantMap & )
 
   73  auto xOffset = std::make_unique<QgsProcessingParameterDistance>( QStringLiteral( 
"DELTA_X" ), QObject::tr( 
"Translation (x-axis)" ), 0.0, QStringLiteral( 
"INPUT" ) );
 
   74  xOffset->setIsDynamic( 
true );
 
   76  xOffset->setDynamicLayerParameterName( QStringLiteral( 
"INPUT" ) );
 
   77  addParameter( xOffset.release() );
 
   79  auto yOffset = std::make_unique<QgsProcessingParameterDistance>( QStringLiteral( 
"DELTA_Y" ), QObject::tr( 
"Translation (y-axis)" ), 0.0, QStringLiteral( 
"INPUT" ) );
 
   80  yOffset->setIsDynamic( 
true );
 
   82  yOffset->setDynamicLayerParameterName( QStringLiteral( 
"INPUT" ) );
 
   83  addParameter( yOffset.release() );
 
   86  zOffset->setIsDynamic( 
true );
 
   88  zOffset->setDynamicLayerParameterName( QStringLiteral( 
"INPUT" ) );
 
   89  addParameter( zOffset.release() );
 
   92  mOffset->setIsDynamic( 
true );
 
   94  mOffset->setDynamicLayerParameterName( QStringLiteral( 
"INPUT" ) );
 
   95  addParameter( mOffset.release() );
 
   98  xScale->setIsDynamic( 
true );
 
  100  xScale->setDynamicLayerParameterName( QStringLiteral( 
"INPUT" ) );
 
  101  addParameter( xScale.release() );
 
  104  yScale->setIsDynamic( 
true );
 
  106  yScale->setDynamicLayerParameterName( QStringLiteral( 
"INPUT" ) );
 
  107  addParameter( yScale.release() );
 
  110  zScale->setIsDynamic( 
true );
 
  112  zScale->setDynamicLayerParameterName( QStringLiteral( 
"INPUT" ) );
 
  113  addParameter( zScale.release() );
 
  116  mScale->setIsDynamic( 
true );
 
  118  mScale->setDynamicLayerParameterName( QStringLiteral( 
"INPUT" ) );
 
  119  addParameter( mScale.release() );
 
  121  auto rotation = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( 
"ROTATION_Z" ), QObject::tr( 
"Rotation around z-axis (degrees counter-clockwise)" ), 
Qgis::ProcessingNumberParameterType::Double, 0.0 );
 
  122  rotation->setIsDynamic( 
true );
 
  124  rotation->setDynamicLayerParameterName( QStringLiteral( 
"INPUT" ) );
 
  125  addParameter( rotation.release() );
 
  130  mDeltaX = parameterAsDouble( parameters, QStringLiteral( 
"DELTA_X" ), context );
 
  132  if ( mDynamicDeltaX )
 
  133    mDeltaXProperty = parameters.value( QStringLiteral( 
"DELTA_X" ) ).value<
QgsProperty>();
 
  135  mDeltaY = parameterAsDouble( parameters, QStringLiteral( 
"DELTA_Y" ), context );
 
  137  if ( mDynamicDeltaY )
 
  138    mDeltaYProperty = parameters.value( QStringLiteral( 
"DELTA_Y" ) ).value<
QgsProperty>();
 
  140  mDeltaZ = parameterAsDouble( parameters, QStringLiteral( 
"DELTA_Z" ), context );
 
  142  if ( mDynamicDeltaZ )
 
  143    mDeltaZProperty = parameters.value( QStringLiteral( 
"DELTA_Z" ) ).value<
QgsProperty>();
 
  145  mDeltaM = parameterAsDouble( parameters, QStringLiteral( 
"DELTA_M" ), context );
 
  147  if ( mDynamicDeltaM )
 
  148    mDeltaMProperty = parameters.value( QStringLiteral( 
"DELTA_M" ) ).value<
QgsProperty>();
 
  150  mScaleX = parameterAsDouble( parameters, QStringLiteral( 
"SCALE_X" ), context );
 
  152  if ( mDynamicScaleX )
 
  153    mScaleXProperty = parameters.value( QStringLiteral( 
"SCALE_X" ) ).value<
QgsProperty>();
 
  155  mScaleY = parameterAsDouble( parameters, QStringLiteral( 
"SCALE_Y" ), context );
 
  157  if ( mDynamicScaleY )
 
  158    mScaleYProperty = parameters.value( QStringLiteral( 
"SCALE_Y" ) ).value<
QgsProperty>();
 
  160  mScaleZ = parameterAsDouble( parameters, QStringLiteral( 
"SCALE_Z" ), context );
 
  162  if ( mDynamicScaleZ )
 
  163    mScaleZProperty = parameters.value( QStringLiteral( 
"SCALE_Z" ) ).value<
QgsProperty>();
 
  165  mScaleM = parameterAsDouble( parameters, QStringLiteral( 
"SCALE_M" ), context );
 
  167  if ( mDynamicScaleM )
 
  168    mScaleMProperty = parameters.value( QStringLiteral( 
"SCALE_M" ) ).value<
QgsProperty>();
 
  170  mRotationZ = parameterAsDouble( parameters, QStringLiteral( 
"ROTATION_Z" ), context );
 
  172  if ( mDynamicRotationZ )
 
  173    mRotationZProperty = parameters.value( QStringLiteral( 
"ROTATION_Z" ) ).value<
QgsProperty>();
 
  185    double deltaX = mDeltaX;
 
  186    if ( mDynamicDeltaX )
 
  188    double deltaY = mDeltaY;
 
  189    if ( mDynamicDeltaY )
 
  191    double deltaZ = mDeltaZ;
 
  192    if ( mDynamicDeltaZ )
 
  194    double deltaM = mDeltaM;
 
  195    if ( mDynamicDeltaM )
 
  203    double scaleX = mScaleX;
 
  204    if ( mDynamicScaleX )
 
  206    double scaleY = mScaleY;
 
  207    if ( mDynamicScaleY )
 
  209    double scaleZ = mScaleZ;
 
  210    if ( mDynamicScaleZ )
 
  212    double scaleM = mScaleM;
 
  213    if ( mDynamicScaleM )
 
  216    double rotationZ = mRotationZ;
 
  217    if ( mDynamicRotationZ )
 
  220    QTransform transform;
 
  221    transform.translate( deltaX, deltaY );
 
  222    transform.rotate( rotationZ );
 
  223    transform.scale( scaleX, scaleY );
 
  225    geometry.
transform( transform, deltaZ, scaleZ, deltaM, scaleM );
 
  234  if ( mDeltaZ != 0.0 )
 
  236  if ( mDeltaM != 0.0 )
 
  242bool QgsAffineTransformationAlgorithm::supportInPlaceEdit( 
const QgsMapLayer *l )
 const 
  244  const QgsVectorLayer *layer = qobject_cast<const QgsVectorLayer *>( l );
 
  253  return inPlaceWkbType == outputWkbType( inPlaceWkbType );
 
WkbType
The WKB type describes the number of dimensions a geometry has.
 
@ Double
Double/float values.
 
virtual bool addZValue(double zValue=0)=0
Adds a z-dimension to the geometry, initialized to a preset value.
 
bool isMeasure() const
Returns true if the geometry contains m values.
 
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
 
virtual bool addMValue(double mValue=0)=0
Adds a measure to the geometry, initialized to a preset value.
 
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.
 
Qgis::GeometryOperationResult transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool transformZ=false)
Transforms this geometry as described by the coordinate transform ct.
 
QgsAbstractGeometry * get()
Returns a modifiable (non-const) reference to the underlying abstract geometry primitive.
 
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
 
Base class for all map layer types.
 
Contains information about the context in which a processing algorithm is executed.
 
QgsExpressionContext & expressionContext()
Returns the expression context.
 
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 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.
 
@ Double
Double value (including negative values)
 
A store for object properties.
 
double valueAsDouble(const QgsExpressionContext &context, double defaultValue=0.0, bool *ok=nullptr) const
Calculates the current value of the property and interprets it as a double.
 
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.
 
static Qgis::WkbType addM(Qgis::WkbType type)
Adds the m dimension to a WKB type and returns the new type.
 
static Qgis::WkbType addZ(Qgis::WkbType type)
Adds the z dimension to a WKB type and returns the new type.
 
QList< QgsFeature > QgsFeatureList