Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix parameter type for the BUFFER parameter of the Voronoi polygons alg
Fixes #19294

(cherry-picked from a756fb1)
  • Loading branch information
havatv authored and nyalldawson committed Jun 29, 2018
1 parent 9b44a4a commit c409d5a
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions python/plugins/processing/algs/qgis/VoronoiPolygons.py
Expand Up @@ -72,11 +72,15 @@ def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT, self.tr('Input layer'), [QgsProcessing.TypeVectorPoint]))
self.addParameter(QgsProcessingParameterDistance(self.BUFFER, self.tr('Buffer region'), parentParameterName=self.INPUT,
minValue=0.0, maxValue=9999999999, defaultValue=0.0))
self.addParameter(QgsProcessingParameterFeatureSource(
self.INPUT, self.tr('Input layer'), [QgsProcessing.TypeVectorPoint]))
self.addParameter(
QgsProcessingParameterNumber(
self.BUFFER, self.tr('Buffer region (% of extent)'),
minValue=0.0, maxValue=9999999999, defaultValue=0.0))

self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Voronoi polygons'), type=QgsProcessing.TypeVectorPolygon))
self.addParameter(QgsProcessingParameterFeatureSink(
self.OUTPUT, self.tr('Voronoi polygons'), type=QgsProcessing.TypeVectorPolygon))

def name(self):
return 'voronoipolygons'
Expand All @@ -87,13 +91,15 @@ def displayName(self):
def processAlgorithm(self, parameters, context, feedback):
source = self.parameterAsSource(parameters, self.INPUT, context)
if source is None:
raise QgsProcessingException(self.invalidSourceError(parameters, self.INPUT))
raise QgsProcessingException(
self.invalidSourceError(parameters, self.INPUT))

buf = self.parameterAsDouble(parameters, self.BUFFER, context)
(sink, dest_id) = self.parameterAsSink(parameters, self.OUTPUT, context,
source.fields(), QgsWkbTypes.Polygon, source.sourceCrs())
if sink is None:
raise QgsProcessingException(self.invalidSinkError(parameters, self.OUTPUT))
raise QgsProcessingException(
self.invalidSinkError(parameters, self.OUTPUT))

outFeat = QgsFeature()
extent = source.sourceExtent()
Expand Down Expand Up @@ -145,7 +151,8 @@ def processAlgorithm(self, parameters, context, feedback):

request = QgsFeatureRequest().setFilterFid(ptDict[ids[site]])
inFeat = next(source.getFeatures(request))
lines = self.clip_voronoi(edges, c, width, height, extent, extraX, extraY)
lines = self.clip_voronoi(
edges, c, width, height, extent, extraX, extraY)

geom = QgsGeometry.fromMultiPointXY(lines)
geom = QgsGeometry(geom.convexHull())
Expand Down

0 comments on commit c409d5a

Please sign in to comment.