diff --git a/python/plugins/processing/algs/qgis/QGISAlgorithmProvider.py b/python/plugins/processing/algs/qgis/QGISAlgorithmProvider.py
index 700746eec5b..a78395b1456 100644
--- a/python/plugins/processing/algs/qgis/QGISAlgorithmProvider.py
+++ b/python/plugins/processing/algs/qgis/QGISAlgorithmProvider.py
@@ -143,7 +143,6 @@ from .SymmetricalDifference import SymmetricalDifference
from .TextToFloat import TextToFloat
from .TinInterpolation import TinInterpolation
from .TopoColors import TopoColor
-from .Translate import Translate
from .TruncateTable import TruncateTable
from .Union import Union
from .UniqueValues import UniqueValues
@@ -268,7 +267,6 @@ class QGISAlgorithmProvider(QgsProcessingProvider):
TextToFloat(),
TinInterpolation(),
TopoColor(),
- Translate(),
TruncateTable(),
Union(),
UniqueValues(),
diff --git a/python/plugins/processing/algs/qgis/Translate.py b/python/plugins/processing/algs/qgis/Translate.py
deleted file mode 100644
index 7a1f9af6c4d..00000000000
--- a/python/plugins/processing/algs/qgis/Translate.py
+++ /dev/null
@@ -1,76 +0,0 @@
-# -*- coding: utf-8 -*-
-
-"""
-***************************************************************************
- Translate.py
- --------------
- Date : August 2016
- Copyright : (C) 2016 by Nyall Dawson
- Email : nyall dot dawson at gmail dot com
-***************************************************************************
-* *
-* This program is free software; you can redistribute it and/or modify *
-* it under the terms of the GNU General Public License as published by *
-* the Free Software Foundation; either version 2 of the License, or *
-* (at your option) any later version. *
-* *
-***************************************************************************
-"""
-
-__author__ = 'Nyall Dawson'
-__date__ = 'August 2016'
-__copyright__ = '(C) 2016, Nyall Dawson'
-
-# This will get replaced with a git SHA1 when you do a git archive323
-
-__revision__ = '$Format:%H$'
-
-from qgis.core import (QgsProcessingException,
- QgsProcessingParameterNumber)
-from processing.algs.qgis.QgisAlgorithm import QgisFeatureBasedAlgorithm
-
-
-class Translate(QgisFeatureBasedAlgorithm):
-
- DELTA_X = 'DELTA_X'
- DELTA_Y = 'DELTA_Y'
-
- def group(self):
- return self.tr('Vector geometry')
-
- def __init__(self):
- super().__init__()
- self.delta_x = 0
- self.delta_y = 0
-
- def initParameters(self, config=None):
- self.addParameter(QgsProcessingParameterNumber(self.DELTA_X,
- self.tr('Offset distance (x-axis)'), QgsProcessingParameterNumber.Double, defaultValue=0.0))
- self.addParameter(QgsProcessingParameterNumber(self.DELTA_Y,
- self.tr('Offset distance (y-axis)'), QgsProcessingParameterNumber.Double, defaultValue=0.0))
-
- def name(self):
- return 'translategeometry'
-
- def displayName(self):
- return self.tr('Translate geometry')
-
- def outputName(self):
- return self.tr('Translated')
-
- def prepareAlgorithm(self, parameters, context, feedback):
- self.delta_x = self.parameterAsDouble(parameters, self.DELTA_X, context)
- self.delta_y = self.parameterAsDouble(parameters, self.DELTA_Y, context)
- return True
-
- def processFeature(self, feature, feedback):
- input_geometry = feature.geometry()
- if input_geometry:
- output_geometry = input_geometry
- output_geometry.translate(self.delta_x, self.delta_y)
- if not output_geometry:
- raise QgsProcessingException(
- self.tr('Error translating geometry'))
-
- feature.setGeometry(output_geometry)
- return feature
diff --git a/python/plugins/processing/tests/testdata/expected/buffer_polys.gfs b/python/plugins/processing/tests/testdata/expected/buffer_polys.gfs
new file mode 100644
index 00000000000..96b8f2bc468
--- /dev/null
+++ b/python/plugins/processing/tests/testdata/expected/buffer_polys.gfs
@@ -0,0 +1,32 @@
+
+
+ buffer_polys
+ buffer_polys
+
+ 3
+ EPSG:4326
+
+ 6
+ -1.50000
+ 10.50000
+ -3.50000
+ 6.50000
+
+
+ name
+ name
+ String
+ 5
+
+
+ intval
+ intval
+ Integer
+
+
+ floatval
+ floatval
+ Real
+
+
+
diff --git a/python/plugins/processing/tests/testdata/expected/gridify_lines.gfs b/python/plugins/processing/tests/testdata/expected/gridify_lines.gfs
new file mode 100644
index 00000000000..415afa3fda2
--- /dev/null
+++ b/python/plugins/processing/tests/testdata/expected/gridify_lines.gfs
@@ -0,0 +1,16 @@
+
+
+ gridify_lines
+ gridify_lines
+
+ 2
+ EPSG:4326
+
+ 7
+ -2.00000
+ 12.00000
+ -4.00000
+ 6.00000
+
+
+
diff --git a/python/plugins/processing/tests/testdata/expected/gridify_polys.gfs b/python/plugins/processing/tests/testdata/expected/gridify_polys.gfs
new file mode 100644
index 00000000000..f6e24622a57
--- /dev/null
+++ b/python/plugins/processing/tests/testdata/expected/gridify_polys.gfs
@@ -0,0 +1,32 @@
+
+
+ gridify_polys
+ gridify_polys
+
+ 3
+ EPSG:4326
+
+ 6
+ -2.00000
+ 10.00000
+ -4.00000
+ 6.00000
+
+
+ name
+ name
+ String
+ 5
+
+
+ intval
+ intval
+ Integer
+
+
+ floatval
+ floatval
+ Real
+
+
+
diff --git a/python/plugins/processing/tests/testdata/expected/lines_bounds.gfs b/python/plugins/processing/tests/testdata/expected/lines_bounds.gfs
new file mode 100644
index 00000000000..4c72469a490
--- /dev/null
+++ b/python/plugins/processing/tests/testdata/expected/lines_bounds.gfs
@@ -0,0 +1,16 @@
+
+
+ lines_bounds
+ lines_bounds
+
+ 3
+ EPSG:4326
+
+ 7
+ -1.00000
+ 11.00000
+ -3.00000
+ 5.00000
+
+
+
diff --git a/python/plugins/processing/tests/testdata/expected/multiline_offset.gfs b/python/plugins/processing/tests/testdata/expected/multiline_offset.gfs
new file mode 100644
index 00000000000..54cc4a24e55
--- /dev/null
+++ b/python/plugins/processing/tests/testdata/expected/multiline_offset.gfs
@@ -0,0 +1,16 @@
+
+
+ multiline_offset
+ multiline_offset
+
+ 5
+ EPSG:4326
+
+ 4
+ -1.00000
+ 6.02404
+ 0.00000
+ 5.11935
+
+
+
diff --git a/python/plugins/processing/tests/testdata/expected/variable_buffer_points.gfs b/python/plugins/processing/tests/testdata/expected/variable_buffer_points.gfs
new file mode 100644
index 00000000000..5f639072a0c
--- /dev/null
+++ b/python/plugins/processing/tests/testdata/expected/variable_buffer_points.gfs
@@ -0,0 +1,31 @@
+
+
+ variable_buffer_points
+ variable_buffer_points
+
+ 3
+ EPSG:3857
+
+ 9
+ -50000.00000
+ 990555.92635
+ -607305.25727
+ 384111.17140
+
+
+ id
+ id
+ Integer
+
+
+ id2
+ id2
+ Integer
+
+
+ buffer
+ buffer
+ Integer
+
+
+
diff --git a/python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml b/python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml
index d906df30872..1ccf19b6242 100755
--- a/python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml
+++ b/python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml
@@ -1087,7 +1087,7 @@ tests:
geometry:
precision: 7
- - algorithm: qgis:translategeometry
+ - algorithm: native:translategeometry
name: Lines translated
params:
DELTA_X: 0.1
diff --git a/src/analysis/CMakeLists.txt b/src/analysis/CMakeLists.txt
index d20e1da488b..8d851bd49ac 100644
--- a/src/analysis/CMakeLists.txt
+++ b/src/analysis/CMakeLists.txt
@@ -59,6 +59,7 @@ SET(QGIS_ANALYSIS_SRCS
processing/qgsalgorithmsubdivide.cpp
processing/qgsalgorithmtransect.cpp
processing/qgsalgorithmtransform.cpp
+ processing/qgsalgorithmtranslate.cpp
processing/qgsnativealgorithms.cpp
diff --git a/src/analysis/processing/qgsalgorithmtranslate.cpp b/src/analysis/processing/qgsalgorithmtranslate.cpp
new file mode 100644
index 00000000000..58cc976c3ef
--- /dev/null
+++ b/src/analysis/processing/qgsalgorithmtranslate.cpp
@@ -0,0 +1,114 @@
+/***************************************************************************
+ qgsalgorithmtranslate.cpp
+ ---------------------
+ begin : November 2017
+ copyright : (C) 2017 by Nyall Dawson
+ email : nyall dot dawson at gmail dot com
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "qgsalgorithmtranslate.h"
+
+///@cond PRIVATE
+
+QString QgsTranslateAlgorithm::name() const
+{
+ return QStringLiteral( "translategeometry" );
+}
+
+QString QgsTranslateAlgorithm::displayName() const
+{
+ return QObject::tr( "Translate geometry" );
+}
+
+QStringList QgsTranslateAlgorithm::tags() const
+{
+ return QObject::tr( "move,shift,transform,z,m,values,add" ).split( ',' );
+}
+
+QString QgsTranslateAlgorithm::group() const
+{
+ return QObject::tr( "Vector geometry" );
+}
+
+QString QgsTranslateAlgorithm::outputName() const
+{
+ return QObject::tr( "Translated" );
+}
+
+QString QgsTranslateAlgorithm::shortHelpString() const
+{
+ return QObject::tr( "This algorithm moves the geometries within a layer, by offsetting them with a specified x and y displacement." )
+ + QStringLiteral( "\n\n" )
+ + QObject::tr( "Z and M values present in the geometry can also be translated." );
+}
+
+QgsTranslateAlgorithm *QgsTranslateAlgorithm::createInstance() const
+{
+ return new QgsTranslateAlgorithm();
+}
+
+void QgsTranslateAlgorithm::initParameters( const QVariantMap & )
+{
+ addParameter( new QgsProcessingParameterNumber( QStringLiteral( "DELTA_X" ),
+ QObject::tr( "Offset distance (x-axis)" ), QgsProcessingParameterNumber::Double,
+ 0.0 ) );
+ addParameter( new QgsProcessingParameterNumber( QStringLiteral( "DELTA_Y" ),
+ QObject::tr( "Offset distance (y-axis)" ), QgsProcessingParameterNumber::Double,
+ 0.0 ) );
+ addParameter( new QgsProcessingParameterNumber( QStringLiteral( "DELTA_Z" ),
+ QObject::tr( "Offset distance (z-axis)" ), QgsProcessingParameterNumber::Double,
+ 0.0 ) );
+ addParameter( new QgsProcessingParameterNumber( QStringLiteral( "DELTA_M" ),
+ QObject::tr( "Offset distance (m values)" ), QgsProcessingParameterNumber::Double,
+ 0.0 ) );
+}
+
+bool QgsTranslateAlgorithm::prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback * )
+{
+ mDeltaX = parameterAsDouble( parameters, QStringLiteral( "DELTA_X" ), context );
+ mDeltaY = parameterAsDouble( parameters, QStringLiteral( "DELTA_Y" ), context );
+ mDeltaZ = parameterAsDouble( parameters, QStringLiteral( "DELTA_Z" ), context );
+ mDeltaM = parameterAsDouble( parameters, QStringLiteral( "DELTA_M" ), context );
+
+ return true;
+}
+
+QgsFeature QgsTranslateAlgorithm::processFeature( const QgsFeature &feature, QgsProcessingFeedback * )
+{
+ QgsFeature f = feature;
+ if ( f.hasGeometry() )
+ {
+ QgsGeometry geometry = f.geometry();
+ if ( mDeltaZ != 0 && !geometry.constGet()->is3D() )
+ geometry.get()->addZValue( 0 );
+ if ( mDeltaM != 0 && !geometry.constGet()->isMeasure() )
+ geometry.get()->addMValue( 0 );
+
+ geometry.translate( mDeltaX, mDeltaY, mDeltaZ, mDeltaM );
+ f.setGeometry( geometry );
+ }
+ return f;
+}
+
+QgsWkbTypes::Type QgsTranslateAlgorithm::outputWkbType( QgsWkbTypes::Type inputWkbType ) const
+{
+ QgsWkbTypes::Type wkb = inputWkbType;
+ if ( mDeltaZ != 0 )
+ wkb = QgsWkbTypes::addZ( wkb );
+ if ( mDeltaM != 0 )
+ wkb = QgsWkbTypes::addM( wkb );
+ return wkb;
+}
+
+///@endcond
+
+
diff --git a/src/analysis/processing/qgsalgorithmtranslate.h b/src/analysis/processing/qgsalgorithmtranslate.h
new file mode 100644
index 00000000000..b8e72467707
--- /dev/null
+++ b/src/analysis/processing/qgsalgorithmtranslate.h
@@ -0,0 +1,65 @@
+/***************************************************************************
+ qgsalgorithmtranslate.h
+ ---------------------
+ begin : November 2017
+ copyright : (C) 2017 by Nyall Dawson
+ email : nyall dot dawson at gmail dot com
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef QGSALGORITHMTRANSLATE_H
+#define QGSALGORITHMTRANSLATE_H
+
+#define SIP_NO_FILE
+
+#include "qgis.h"
+#include "qgsprocessingalgorithm.h"
+
+///@cond PRIVATE
+
+/**
+ * Native translate algorithm.
+ */
+class QgsTranslateAlgorithm : public QgsProcessingFeatureBasedAlgorithm
+{
+
+ public:
+
+ QgsTranslateAlgorithm() = default;
+ QString name() const override;
+ QString displayName() const override;
+ virtual QStringList tags() const override;
+ QString group() const override;
+ QString shortHelpString() const override;
+ QgsTranslateAlgorithm *createInstance() const override SIP_FACTORY;
+ void initParameters( const QVariantMap &configuration = QVariantMap() ) override;
+
+ protected:
+ QString outputName() const override;
+ bool prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
+ QgsFeature processFeature( const QgsFeature &feature, QgsProcessingFeedback *feedback ) override;
+ QgsWkbTypes::Type outputWkbType( QgsWkbTypes::Type inputWkbType ) const override;
+
+ private:
+
+ double mDeltaX = 0.0;
+ double mDeltaY = 0.0;
+ double mDeltaZ = 0.0;
+ double mDeltaM = 0.0;
+
+};
+
+
+///@endcond PRIVATE
+
+#endif // QGSALGORITHMTRANSLATE_H
+
+
diff --git a/src/analysis/processing/qgsnativealgorithms.cpp b/src/analysis/processing/qgsnativealgorithms.cpp
index 2ce0b8d46bc..9d1b46bfc16 100644
--- a/src/analysis/processing/qgsnativealgorithms.cpp
+++ b/src/analysis/processing/qgsnativealgorithms.cpp
@@ -56,6 +56,7 @@
#include "qgsalgorithmsubdivide.h"
#include "qgsalgorithmtransect.h"
#include "qgsalgorithmtransform.h"
+#include "qgsalgorithmtranslate.h"
///@cond PRIVATE
@@ -133,7 +134,7 @@ void QgsNativeAlgorithms::loadAlgorithms()
addAlgorithm( new QgsSubdivideAlgorithm() );
addAlgorithm( new QgsTransectAlgorithm() );
addAlgorithm( new QgsTransformAlgorithm() );
-
+ addAlgorithm( new QgsTranslateAlgorithm() );
}