Skip to content
Permalink
Browse files

[processing] Much faster random points in polygon by using

prepared geometries
  • Loading branch information
nyalldawson committed Feb 14, 2018
1 parent 81aa2f9 commit 2defaff7966e54ea8300273f0566d0428e8a488c
Showing with 7 additions and 1 deletion.
  1. +7 −1 python/plugins/processing/algs/qgis/RandomPointsPolygons.py
@@ -136,6 +136,9 @@ def processAlgorithm(self, parameters, context, feedback):
if feedback.isCanceled():
break

if not f.hasGeometry():
continue

current_progress = total * current
feedback.setProgress(current_progress)

@@ -147,6 +150,9 @@ def processAlgorithm(self, parameters, context, feedback):
continue

fGeom = f.geometry()
engine = QgsGeometry.createGeometryEngine(fGeom.constGet())
engine.prepareGeometry()

bbox = fGeom.boundingBox()
if strategy == 0:
pointCount = int(value)
@@ -176,7 +182,7 @@ def processAlgorithm(self, parameters, context, feedback):

p = QgsPointXY(rx, ry)
geom = QgsGeometry.fromPointXY(p)
if geom.within(fGeom) and \
if engine.contains(geom.constGet()) and \
vector.checkMinDistance(p, index, minDistance, points):
f = QgsFeature(nPoints)
f.initAttributes(1)

0 comments on commit 2defaff

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