Skip to content

Commit

Permalink
In systematic sampling process, if offset = 0 it is not necessary to …
Browse files Browse the repository at this point in the history
…generate random points from center
  • Loading branch information
XavierCLL committed Feb 13, 2025
1 parent 11a342a commit 0015991
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/sampling_design.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,9 @@ def generate_systematic_sampling_points(self, task, sampling_conf):
x = self.thematic_map.extent().xMinimum() + initial_inset
while not task.isCanceled() and x <= self.thematic_map.extent().xMaximum():
attempts = 0
max_attempts = 1000
while not task.isCanceled():
if attempts == 1000:
if attempts >= max_attempts:
x += self.points_spacing
break
if self.max_xy_offset > 0:
Expand All @@ -650,6 +651,7 @@ def generate_systematic_sampling_points(self, task, sampling_conf):
else:
# systematic sampling aligned with the grid, offset = 0
random_sampling_point = RandomPoint(x, y)
attempts = max_attempts # if offset = 0, it is not necessary to generate random points from center

if not extent_engine.intersects(random_sampling_point.QgsGeom.constGet()):
attempts += 1
Expand Down

0 comments on commit 0015991

Please sign in to comment.