diff --git a/python/plugins/processing/algs/gdal/offsetcurve.py b/python/plugins/processing/algs/gdal/offsetcurve.py index 5317822605c..03318053f99 100644 --- a/python/plugins/processing/algs/gdal/offsetcurve.py +++ b/python/plugins/processing/algs/gdal/offsetcurve.py @@ -27,6 +27,7 @@ __revision__ = '$Format:%H$' from processing.core.parameters import ParameterVector from processing.core.parameters import ParameterString +from processing.core.parameters import ParameterNumber from processing.core.parameters import ParameterBoolean from processing.core.parameters import ParameterTableField from processing.core.parameters import ParameterSelection @@ -46,8 +47,6 @@ class OffsetCurve(GdalAlgorithm): INPUT_LAYER = 'INPUT_LAYER' GEOMETRY = 'GEOMETRY' RADIUS = 'RADIUS' - LEFTRIGHT = 'LEFTRIGHT' - LEFTRIGHTLIST = ['Right', 'Left'] DISSOLVEALL = 'DISSOLVEALL' FIELD = 'FIELD' MULTI = 'MULTI' @@ -62,10 +61,10 @@ class OffsetCurve(GdalAlgorithm): self.addParameter(ParameterString(self.GEOMETRY, self.tr('Geometry column name ("geometry" for Shapefiles, may be different for other formats)'), 'geometry', optional=False)) - self.addParameter(ParameterString(self.RADIUS, - self.tr('Offset distance'), '1000', optional=False)) - self.addParameter(ParameterSelection(self.LEFTRIGHT, - self.tr('Offset side'), self.LEFTRIGHTLIST, 0)) + self.addParameter(ParameterNumber(self.RADIUS, + self.tr('Offset distance (positive value for left-sided and negative - for right-sided)'), + 0.0, 99999999.999999, 1000.0, + optional=False)) self.addParameter(ParameterBoolean(self.DISSOLVEALL, self.tr('Dissolve all results'), False)) self.addParameter(ParameterTableField(self.FIELD, @@ -82,7 +81,6 @@ class OffsetCurve(GdalAlgorithm): inLayer = self.getParameterValue(self.INPUT_LAYER) geometry = self.getParameterValue(self.GEOMETRY) distance = self.getParameterValue(self.RADIUS) - leftright = self.getParameterValue(self.LEFTRIGHT) dissolveall = self.getParameterValue(self.DISSOLVEALL) field = self.getParameterValue(self.FIELD) multi = self.getParameterValue(self.MULTI) @@ -106,9 +104,9 @@ class OffsetCurve(GdalAlgorithm): arguments.append('-sql') if dissolveall or field is not None: - sql = "SELECT ST_Union(ST_OffsetCurve({}, {}, {})) * FROM '{}'".format(geometry, distance, leftright, layername) + sql = "SELECT ST_Union(ST_OffsetCurve({}, {})) * FROM '{}'".format(geometry, distance, layername) else: - sql = "SELECT ST_OffsetCurve({}, {}, {}), * FROM '{}'".format(geometry, distance, leftright, layername) + sql = "SELECT ST_OffsetCurve({}, {}), * FROM '{}'".format(geometry, distance, layername) if field is not None: sql = '"{} GROUP BY {}"'.format(sql, field) @@ -118,7 +116,7 @@ class OffsetCurve(GdalAlgorithm): if field is not None and multi: arguments.append('-explodecollections') - if len(options) > 0: + if options is not None and len(options.strip()) > 0: arguments.append(options) commands = [] diff --git a/python/plugins/processing/algs/gdal/onesidebuffer.py b/python/plugins/processing/algs/gdal/onesidebuffer.py index 65b3a870a00..29fc7f730da 100644 --- a/python/plugins/processing/algs/gdal/onesidebuffer.py +++ b/python/plugins/processing/algs/gdal/onesidebuffer.py @@ -27,6 +27,7 @@ __revision__ = '$Format:%H$' from processing.core.parameters import ParameterVector from processing.core.parameters import ParameterString +from processing.core.parameters import ParameterNumber from processing.core.parameters import ParameterBoolean from processing.core.parameters import ParameterTableField from processing.core.parameters import ParameterSelection @@ -62,8 +63,10 @@ class OneSideBuffer(GdalAlgorithm): self.addParameter(ParameterString(self.GEOMETRY, self.tr('Geometry column name ("geometry" for Shapefiles, may be different for other formats)'), 'geometry', optional=False)) - self.addParameter(ParameterString(self.RADIUS, - self.tr('Buffer distance'), '1000', optional=False)) + self.addParameter(ParameterNumber(self.RADIUS, + self.tr('Buffer distance'), + 0.0, 99999999.999999, 1000.0, + optional=False)) self.addParameter(ParameterSelection(self.LEFTRIGHT, self.tr('Buffer side'), self.LEFTRIGHTLIST, 0)) self.addParameter(ParameterBoolean(self.DISSOLVEALL, @@ -118,7 +121,7 @@ class OneSideBuffer(GdalAlgorithm): if field is not None and multi: arguments.append('-explodecollections') - if len(options) > 0: + if options is not None and len(options.strip()) > 0: arguments.append(options) commands = []