Skip to content
Permalink
Browse files

[processing] Use distance parameter for more algorithms

  • Loading branch information
nyalldawson committed Apr 20, 2018
1 parent 1d0d223 commit 0dfb3c2d8c3f401c9d32eba657361f18608dc72b
Showing with 101 additions and 93 deletions.
  1. +4 −4 python/plugins/processing/algs/qgis/DensifyGeometriesInterval.py
  2. +5 −5 python/plugins/processing/algs/qgis/ExtendLines.py
  3. +13 −12 python/plugins/processing/algs/qgis/Grid.py
  4. +4 −4 python/plugins/processing/algs/qgis/Heatmap.py
  5. +5 −4 python/plugins/processing/algs/qgis/OffsetLine.py
  6. +3 −2 python/plugins/processing/algs/qgis/PointsAlongGeometry.py
  7. +7 −6 python/plugins/processing/algs/qgis/PointsDisplacement.py
  8. +5 −4 python/plugins/processing/algs/qgis/PoleOfInaccessibility.py
  9. +4 −4 python/plugins/processing/algs/qgis/RandomPointsAlongLines.py
  10. +4 −4 python/plugins/processing/algs/qgis/RandomPointsExtent.py
  11. +4 −4 python/plugins/processing/algs/qgis/RandomPointsLayer.py
  12. +4 −4 python/plugins/processing/algs/qgis/RandomPointsPolygons.py
  13. +5 −4 python/plugins/processing/algs/qgis/RegularPoints.py
  14. +3 −2 python/plugins/processing/algs/qgis/SnapGeometries.py
  15. +3 −2 python/plugins/processing/algs/qgis/VoronoiPolygons.py
  16. +4 −0 python/plugins/processing/gui/NumberInputPanel.py
  17. +1 −0 python/plugins/processing/gui/wrappers.py
  18. BIN python/plugins/processing/tests/testdata/custom/circular_strings.gpkg
  19. +2 −3 src/analysis/processing/qgsalgorithmmultiringconstantbuffer.cpp
  20. +2 −2 src/analysis/processing/qgsalgorithmprojectpointcartesian.cpp
  21. +2 −3 src/analysis/processing/qgsalgorithmremoveduplicatevertices.cpp
  22. +3 −3 src/analysis/processing/qgsalgorithmsegmentize.cpp
  23. +2 −3 src/analysis/processing/qgsalgorithmsimplify.cpp
  24. +4 −6 src/analysis/processing/qgsalgorithmsnaptogrid.cpp
  25. +2 −2 src/analysis/processing/qgsalgorithmtransect.cpp
  26. +6 −6 src/analysis/processing/qgsalgorithmtranslate.cpp
@@ -26,7 +26,7 @@

__revision__ = '$Format:%H$'

from qgis.core import (QgsProcessingParameterNumber,
from qgis.core import (QgsProcessingParameterDistance,
QgsProcessing)

from processing.algs.qgis.QgisAlgorithm import QgisFeatureBasedAlgorithm
@@ -50,9 +50,9 @@ def __init__(self):
self.interval = None

def initParameters(self, config=None):
self.addParameter(QgsProcessingParameterNumber(self.INTERVAL,
self.tr('Interval between vertices to add'), QgsProcessingParameterNumber.Double,
1, False, 0, 10000000))
self.addParameter(QgsProcessingParameterDistance(self.INTERVAL,
self.tr('Interval between vertices to add'),
1, 'INPUT', False, 0, 10000000))

def name(self):
return 'densifygeometriesgivenaninterval'
@@ -25,7 +25,7 @@

__revision__ = '$Format:%H$'

from qgis.core import (QgsProcessingParameterNumber,
from qgis.core import (QgsProcessingParameterDistance,
QgsProcessingException,
QgsProcessing)
from processing.algs.qgis.QgisAlgorithm import QgisFeatureBasedAlgorithm
@@ -48,10 +48,10 @@ def __init__(self):
self.end_distance = None

def initParameters(self, config=None):
self.addParameter(QgsProcessingParameterNumber(self.START_DISTANCE,
self.tr('Start distance'), type=QgsProcessingParameterNumber.Double, defaultValue=0.0))
self.addParameter(QgsProcessingParameterNumber(self.END_DISTANCE,
self.tr('End distance'), type=QgsProcessingParameterNumber.Double, defaultValue=0.0))
self.addParameter(QgsProcessingParameterDistance(self.START_DISTANCE,
self.tr('Start distance'), defaultValue=0.0, parentParameterName='INPUT'))
self.addParameter(QgsProcessingParameterDistance(self.END_DISTANCE,
self.tr('End distance'), defaultValue=0.0, parentParameterName='INPUT'))

def name(self):
return 'extendlines'
@@ -44,6 +44,7 @@
QgsProcessingParameterEnum,
QgsProcessingParameterExtent,
QgsProcessingParameterNumber,
QgsProcessingParameterDistance,
QgsProcessingParameterCrs,
QgsProcessingParameterFeatureSink,
QgsFields)
@@ -90,18 +91,18 @@ def initAlgorithm(self, config=None):

self.addParameter(QgsProcessingParameterExtent(self.EXTENT, self.tr('Grid extent')))

self.addParameter(QgsProcessingParameterNumber(self.HSPACING,
self.tr('Horizontal spacing'), QgsProcessingParameterNumber.Double,
0.0001, False, 0, 1000000000.0))
self.addParameter(QgsProcessingParameterNumber(self.VSPACING,
self.tr('Vertical spacing'), QgsProcessingParameterNumber.Double,
0.0001, False, 0, 1000000000.0))
self.addParameter(QgsProcessingParameterNumber(self.HOVERLAY,
self.tr('Horizontal overlay'), QgsProcessingParameterNumber.Double,
0.0, False, 0, 1000000000.0))
self.addParameter(QgsProcessingParameterNumber(self.VOVERLAY,
self.tr('Vertical overlay'), QgsProcessingParameterNumber.Double,
0.0, False, 0, 1000000000.0))
self.addParameter(QgsProcessingParameterDistance(self.HSPACING,
self.tr('Horizontal spacing'),
0.0001, self.CRS, False, 0, 1000000000.0))
self.addParameter(QgsProcessingParameterDistance(self.VSPACING,
self.tr('Vertical spacing'),
0.0001, self.CRS, False, 0, 1000000000.0))
self.addParameter(QgsProcessingParameterDistance(self.HOVERLAY,
self.tr('Horizontal overlay'),
0.0, self.CRS, False, 0, 1000000000.0))
self.addParameter(QgsProcessingParameterDistance(self.VOVERLAY,
self.tr('Vertical overlay'),
0.0, self.CRS, False, 0, 1000000000.0))

self.addParameter(QgsProcessingParameterCrs(self.CRS, 'Grid CRS', 'ProjectCrs'))

@@ -37,6 +37,7 @@
QgsProcessingException,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterNumber,
QgsProcessingParameterDistance,
QgsProcessingParameterField,
QgsProcessingParameterEnum,
QgsProcessingParameterDefinition,
@@ -96,10 +97,9 @@ def initAlgorithm(self, config=None):
self.tr('Point layer'),
[QgsProcessing.TypeVectorPoint]))

self.addParameter(QgsProcessingParameterNumber(self.RADIUS,
self.tr('Radius (layer units)'),
QgsProcessingParameterNumber.Double,
100.0, False, 0.0, 9999999999.99))
self.addParameter(QgsProcessingParameterDistance(self.RADIUS,
self.tr('Radius (layer units)'),
100.0, self.INPUT, False, 0.0, 9999999999.99))

radius_field_param = QgsProcessingParameterField(self.RADIUS_FIELD,
self.tr('Radius from field'),
@@ -32,6 +32,7 @@
QgsProcessingException,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterNumber,
QgsProcessingParameterDistance,
QgsProcessingParameterEnum,
QgsProcessingParameterFeatureSink)

@@ -62,10 +63,10 @@ def __init__(self):
self.miter_limit = None

def initParameters(self, config=None):
self.addParameter(QgsProcessingParameterNumber(self.DISTANCE,
self.tr('Distance'),
type=QgsProcessingParameterNumber.Double,
defaultValue=10.0))
self.addParameter(QgsProcessingParameterDistance(self.DISTANCE,
self.tr('Distance'),
defaultValue=10.0,
parentParameterName='INPUT'))
self.addParameter(QgsProcessingParameterNumber(self.SEGMENTS,
self.tr('Segments'),
type=QgsProcessingParameterNumber.Integer,
@@ -37,6 +37,7 @@
QgsField,
QgsProcessing,
QgsProcessingUtils,
QgsProcessingParameterDistance,
QgsProcessingParameterNumber,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterFeatureSink)
@@ -72,8 +73,8 @@ def __init__(self):
def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
self.tr('Input layer'), [QgsProcessing.TypeVectorPolygon, QgsProcessing.TypeVectorLine]))
self.addParameter(QgsProcessingParameterNumber(self.DISTANCE,
self.tr('Distance'), type=QgsProcessingParameterNumber.Double, minValue=0.0, defaultValue=1.0))
self.addParameter(QgsProcessingParameterDistance(self.DISTANCE,
self.tr('Distance'), parentParameterName=self.INPUT, minValue=0.0, defaultValue=1.0))
self.addParameter(QgsProcessingParameterNumber(self.START_OFFSET,
self.tr('Start offset'), type=QgsProcessingParameterNumber.Double, minValue=0.0, defaultValue=0.0))
self.addParameter(QgsProcessingParameterNumber(self.END_OFFSET,
@@ -33,6 +33,7 @@
QgsRectangle,
QgsProcessing,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterDistance,
QgsProcessingParameterNumber,
QgsProcessingParameterBoolean,
QgsProcessingParameterFeatureSink)
@@ -59,12 +60,12 @@ def __init__(self):
def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
self.tr('Input layer'), [QgsProcessing.TypeVectorPoint]))
self.addParameter(QgsProcessingParameterNumber(self.PROXIMITY,
self.tr('Minimum distance to other points'), type=QgsProcessingParameterNumber.Double,
minValue=0.00001, defaultValue=0.00015))
self.addParameter(QgsProcessingParameterNumber(self.DISTANCE,
self.tr('Displacement distance'), type=QgsProcessingParameterNumber.Double,
minValue=0.00001, defaultValue=0.00015))
self.addParameter(QgsProcessingParameterDistance(self.PROXIMITY,
self.tr('Minimum distance to other points'), parentParameterName='INPUT',
minValue=0.00001, defaultValue=0.00015))
self.addParameter(QgsProcessingParameterDistance(self.DISTANCE,
self.tr('Displacement distance'), parentParameterName='INPUT',
minValue=0.00001, defaultValue=0.00015))
self.addParameter(QgsProcessingParameterBoolean(self.HORIZONTAL,
self.tr('Horizontal distribution for two point case')))
self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Displaced'), QgsProcessing.TypeVectorPoint))
@@ -33,6 +33,7 @@
QgsFeatureSink,
QgsProcessing,
QgsProcessingException,
QgsProcessingParameterDistance,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterNumber,
QgsProcessingParameterFeatureSink)
@@ -69,10 +70,10 @@ def __init__(self):
def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT, self.tr('Input layer'),
[QgsProcessing.TypeVectorPolygon]))
self.addParameter(QgsProcessingParameterNumber(self.TOLERANCE,
self.tr('Tolerance (layer units)'),
type=QgsProcessingParameterNumber.Double,
defaultValue=1.0, minValue=0.0))
self.addParameter(QgsProcessingParameterDistance(self.TOLERANCE,
self.tr('Tolerance (layer units)'),
parentParameterName=self.INPUT,
defaultValue=1.0, minValue=0.0))

self.addParameter(
QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Point'), QgsProcessing.TypeVectorPoint))
@@ -41,6 +41,7 @@
QgsProject,
QgsProcessing,
QgsProcessingException,
QgsProcessingParameterDistance,
QgsProcessingParameterNumber,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterFeatureSink,
@@ -74,10 +75,9 @@ def initAlgorithm(self, config=None):
self.tr('Number of points'),
QgsProcessingParameterNumber.Integer,
1, False, 1, 1000000000))
self.addParameter(QgsProcessingParameterNumber(self.MIN_DISTANCE,
self.tr('Minimum distance between points'),
QgsProcessingParameterNumber.Double,
0, False, 0, 1000000000))
self.addParameter(QgsProcessingParameterDistance(self.MIN_DISTANCE,
self.tr('Minimum distance between points'),
0, self.INPUT, False, 0, 1000000000))
self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT,
self.tr('Random points'),
type=QgsProcessing.TypeVectorPoint))
@@ -40,6 +40,7 @@
QgsSpatialIndex,
QgsProcessing,
QgsProcessingException,
QgsProcessingParameterDistance,
QgsProcessingParameterExtent,
QgsProcessingParameterNumber,
QgsProcessingParameterCrs,
@@ -78,10 +79,9 @@ def initAlgorithm(self, config=None):
self.tr('Number of points'),
QgsProcessingParameterNumber.Integer,
1, False, 1, 1000000000))
self.addParameter(QgsProcessingParameterNumber(self.MIN_DISTANCE,
self.tr('Minimum distance between points'),
QgsProcessingParameterNumber.Double,
0, False, 0, 1000000000))
self.addParameter(QgsProcessingParameterDistance(self.MIN_DISTANCE,
self.tr('Minimum distance between points'),
0, self.TARGET_CRS, False, 0, 1000000000))
self.addParameter(QgsProcessingParameterCrs(self.TARGET_CRS,
self.tr('Target CRS'),
'ProjectCrs'))
@@ -42,6 +42,7 @@
QgsProcessing,
QgsProcessingException,
QgsProcessingParameterNumber,
QgsProcessingParameterDistance,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterFeatureSink,
QgsProcessingParameterDefinition)
@@ -79,10 +80,9 @@ def initAlgorithm(self, config=None):
self.tr('Number of points'),
QgsProcessingParameterNumber.Integer,
1, False, 1, 1000000000))
self.addParameter(QgsProcessingParameterNumber(self.MIN_DISTANCE,
self.tr('Minimum distance between points'),
QgsProcessingParameterNumber.Double,
0, False, 0, 1000000000))
self.addParameter(QgsProcessingParameterDistance(self.MIN_DISTANCE,
self.tr('Minimum distance between points'),
0, self.INPUT, False, 0, 1000000000))
self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT,
self.tr('Random points'),
type=QgsProcessing.TypeVectorPoint))
@@ -44,6 +44,7 @@
QgsProject,
QgsProcessing,
QgsProcessingException,
QgsProcessingParameterDistance,
QgsProcessingParameterNumber,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterFeatureSink,
@@ -92,10 +93,9 @@ def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterExpression(self.EXPRESSION,
self.tr('Expression'),
parentLayerParameterName=self.INPUT))
self.addParameter(QgsProcessingParameterNumber(self.MIN_DISTANCE,
self.tr('Minimum distance between points'),
QgsProcessingParameterNumber.Double,
0, False, 0, 1000000000))
self.addParameter(QgsProcessingParameterDistance(self.MIN_DISTANCE,
self.tr('Minimum distance between points'),
0, self.INPUT, False, 0, 1000000000))
self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT,
self.tr('Random points'),
type=QgsProcessing.TypeVectorPoint))

0 comments on commit 0dfb3c2

Please sign in to comment.
You can’t perform that action at this time.