23QString QgsTranslateAlgorithm::name()
 const 
   25  return QStringLiteral( 
"translategeometry" );
 
   28QString QgsTranslateAlgorithm::displayName()
 const 
   30  return QObject::tr( 
"Translate" );
 
   33QStringList QgsTranslateAlgorithm::tags()
 const 
   35  return QObject::tr( 
"move,shift,transform,z,m,values,add" ).split( 
',' );
 
   38QString QgsTranslateAlgorithm::group()
 const 
   40  return QObject::tr( 
"Vector geometry" );
 
   43QString QgsTranslateAlgorithm::groupId()
 const 
   45  return QStringLiteral( 
"vectorgeometry" );
 
   48QString QgsTranslateAlgorithm::outputName()
 const 
   50  return QObject::tr( 
"Translated" );
 
   53QString QgsTranslateAlgorithm::shortHelpString()
 const 
   55  return QObject::tr( 
"This algorithm moves the geometries within a layer, by offsetting them with a specified x and y displacement." )
 
   56         + QStringLiteral( 
"\n\n" )
 
   57         + QObject::tr( 
"Z and M values present in the geometry can also be translated." );
 
   60QString QgsTranslateAlgorithm::shortDescription()
 const 
   62  return QObject::tr( 
"Moves the geometries within a layer, by offsetting them with a specified x, y, z or m displacement." );
 
   65QgsTranslateAlgorithm *QgsTranslateAlgorithm::createInstance()
 const 
   67  return new QgsTranslateAlgorithm();
 
   70void QgsTranslateAlgorithm::initParameters( 
const QVariantMap & )
 
   72  auto xOffset = std::make_unique<QgsProcessingParameterDistance>( QStringLiteral( 
"DELTA_X" ), QObject::tr( 
"Offset distance (x-axis)" ), 0.0, QStringLiteral( 
"INPUT" ) );
 
   73  xOffset->setIsDynamic( 
true );
 
   75  xOffset->setDynamicLayerParameterName( QStringLiteral( 
"INPUT" ) );
 
   76  addParameter( xOffset.release() );
 
   78  auto yOffset = std::make_unique<QgsProcessingParameterDistance>( QStringLiteral( 
"DELTA_Y" ), QObject::tr( 
"Offset distance (y-axis)" ), 0.0, QStringLiteral( 
"INPUT" ) );
 
   79  yOffset->setIsDynamic( 
true );
 
   81  yOffset->setDynamicLayerParameterName( QStringLiteral( 
"INPUT" ) );
 
   82  addParameter( yOffset.release() );
 
   85  zOffset->setIsDynamic( 
true );
 
   87  zOffset->setDynamicLayerParameterName( QStringLiteral( 
"INPUT" ) );
 
   88  addParameter( zOffset.release() );
 
   91  mOffset->setIsDynamic( 
true );
 
   93  mOffset->setDynamicLayerParameterName( QStringLiteral( 
"INPUT" ) );
 
   94  addParameter( mOffset.release() );
 
   99  mDeltaX = parameterAsDouble( parameters, QStringLiteral( 
"DELTA_X" ), context );
 
  101  if ( mDynamicDeltaX )
 
  102    mDeltaXProperty = parameters.value( QStringLiteral( 
"DELTA_X" ) ).value<
QgsProperty>();
 
  104  mDeltaY = parameterAsDouble( parameters, QStringLiteral( 
"DELTA_Y" ), context );
 
  106  if ( mDynamicDeltaY )
 
  107    mDeltaYProperty = parameters.value( QStringLiteral( 
"DELTA_Y" ) ).value<
QgsProperty>();
 
  109  mDeltaZ = parameterAsDouble( parameters, QStringLiteral( 
"DELTA_Z" ), context );
 
  111  if ( mDynamicDeltaZ )
 
  112    mDeltaZProperty = parameters.value( QStringLiteral( 
"DELTA_Z" ) ).value<
QgsProperty>();
 
  114  mDeltaM = parameterAsDouble( parameters, QStringLiteral( 
"DELTA_M" ), context );
 
  116  if ( mDynamicDeltaM )
 
  117    mDeltaMProperty = parameters.value( QStringLiteral( 
"DELTA_M" ) ).value<
QgsProperty>();
 
  129    double deltaX = mDeltaX;
 
  130    if ( mDynamicDeltaX )
 
  132    double deltaY = mDeltaY;
 
  133    if ( mDynamicDeltaY )
 
  135    double deltaZ = mDeltaZ;
 
  136    if ( mDynamicDeltaZ )
 
  138    double deltaM = mDeltaM;
 
  139    if ( mDynamicDeltaM )
 
  147    geometry.
translate( deltaX, deltaY, deltaZ, deltaM );
 
  156  if ( mDynamicDeltaZ || mDeltaZ != 0.0 )
 
  158  if ( mDynamicDeltaM || mDeltaM != 0.0 )
 
  163bool QgsTranslateAlgorithm::supportInPlaceEdit( 
const QgsMapLayer *l )
 const 
  165  const QgsVectorLayer *layer = qobject_cast<const QgsVectorLayer *>( l );
 
  173  if ( mDeltaX != 0.0 || mDeltaY != 0.0 )
 
  178  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.
 
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.
 
Qgis::GeometryOperationResult translate(double dx, double dy, double dz=0.0, double dm=0.0)
Translates this geometry by dx, dy, dz and dm.
 
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