Skip to content

Commit 9b4b1df

Browse files
committed
init random generator before creating points
1 parent 9f4e107 commit 9b4b1df

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

python/plugins/processing/algs/qgis/RandomPointsExtent.py

+2
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ def processAlgorithm(self, progress):
8383
index = QgsSpatialIndex()
8484
points = dict()
8585

86+
random.seed()
87+
8688
while nIterations < maxIterations and nPoints < pointCount:
8789
rx = xMin + (xMax - xMin) * random.random()
8890
ry = yMin + (yMax - yMin) * random.random()

python/plugins/processing/algs/qgis/RandomPointsLayer.py

+2
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ def processAlgorithm(self, progress):
8484

8585
request = QgsFeatureRequest()
8686

87+
random.seed()
88+
8789
while nIterations < maxIterations and nPoints < pointCount:
8890
rx = bbox.xMinimum() + bbox.width() * random.random()
8991
ry = bbox.yMinimum() + bbox.height() * random.random()

python/plugins/processing/algs/qgis/RandomPointsPolygonsFixed.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,9 @@ def processAlgorithm(self, progress):
8080
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
8181
fields, QGis.WKBPoint, layer.dataProvider().crs())
8282

83-
8483
request = QgsFeatureRequest()
85-
8684
da = QgsDistanceArea()
85+
8786
features = vector.features(layer)
8887
for current, f in enumerate(features):
8988
fGeom = QgsGeometry(f.geometry())
@@ -101,6 +100,8 @@ def processAlgorithm(self, progress):
101100
maxIterations = pointCount * 200
102101
total = 100.0 / pointCount
103102

103+
random.seed()
104+
104105
while nIterations < maxIterations and nPoints < pointCount:
105106
rx = bbox.xMinimum() + bbox.width() * random.random()
106107
ry = bbox.yMinimum() + bbox.height() * random.random()

python/plugins/processing/algs/qgis/RandomPointsPolygonsVariable.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ def processAlgorithm(self, progress):
8282
fields, QGis.WKBPoint, layer.dataProvider().crs())
8383

8484
request = QgsFeatureRequest()
85-
8685
da = QgsDistanceArea()
86+
8787
features = vector.features(layer)
8888
for current, f in enumerate(features):
8989
fGeom = QgsGeometry(f.geometry())
@@ -101,6 +101,8 @@ def processAlgorithm(self, progress):
101101
maxIterations = pointCount * 200
102102
total = 100.0 / pointCount
103103

104+
random.seed()
105+
104106
while nIterations < maxIterations and nPoints < pointCount:
105107
rx = bbox.xMinimum() + bbox.width() * random.random()
106108
ry = bbox.yMinimum() + bbox.height() * random.random()

0 commit comments

Comments
 (0)