mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
[processing] Much faster random points in polygon by using
prepared geometries
This commit is contained in:
parent
81aa2f956e
commit
2defaff796
@ -136,6 +136,9 @@ class RandomPointsPolygons(QgisAlgorithm):
|
||||
if feedback.isCanceled():
|
||||
break
|
||||
|
||||
if not f.hasGeometry():
|
||||
continue
|
||||
|
||||
current_progress = total * current
|
||||
feedback.setProgress(current_progress)
|
||||
|
||||
@ -147,6 +150,9 @@ class RandomPointsPolygons(QgisAlgorithm):
|
||||
continue
|
||||
|
||||
fGeom = f.geometry()
|
||||
engine = QgsGeometry.createGeometryEngine(fGeom.constGet())
|
||||
engine.prepareGeometry()
|
||||
|
||||
bbox = fGeom.boundingBox()
|
||||
if strategy == 0:
|
||||
pointCount = int(value)
|
||||
@ -176,7 +182,7 @@ class RandomPointsPolygons(QgisAlgorithm):
|
||||
|
||||
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user