More balanced approach

to centroid vs pole of inaccessability
This commit is contained in:
Fabian Wunsch 2022-04-11 21:35:57 +02:00
parent 5aa211e120
commit 9c5782e6c8

View file

@ -2,7 +2,7 @@
From https://github.com/Twista/python-polylabel/, From https://github.com/Twista/python-polylabel/,
which is in turn implemented from https://github.com/mapbox/polylabel which is in turn implemented from https://github.com/mapbox/polylabel
""" """
from math import sqrt from math import sqrt, log10
import time import time
from typing import Tuple, List from typing import Tuple, List
@ -154,7 +154,7 @@ def polylabel(polygon: Polygon, precision: float=0.5, debug: bool=False):
while not cell_queue.empty(): while not cell_queue.empty():
_, __, cell = cell_queue.get() _, __, 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 - 0.5): 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):
best_cell = cell best_cell = cell
if debug: if debug: