Moved log out of loop

This commit is contained in:
Fabian Wunsch 2022-04-11 22:31:25 +02:00
parent 9c5782e6c8
commit 24bed2a73c

View file

@ -150,11 +150,13 @@ def polylabel(polygon: Polygon, precision: float=0.5, debug: bool=False):
if bbox_cell.min_dist > best_cell.min_dist:
best_cell = bbox_cell
threshold: float = log10(cell_size) / 2.0
num_of_probes = cell_queue.qsize()
while not cell_queue.empty():
_, __, cell = cell_queue.get()
if cell.min_dist > best_cell.min_dist or (cell.center_dist < best_cell.center_dist and cell.min_dist > best_cell.min_dist - log10(cell_size) / 2.0):
if cell.min_dist > best_cell.min_dist or (cell.center_dist < best_cell.center_dist and cell.min_dist > best_cell.min_dist - threshold):
best_cell = cell
if debug: