From 9c5782e6c898b098ce887388c1daaa6f57190ddf Mon Sep 17 00:00:00 2001 From: Fabian Wunsch Date: Mon, 11 Apr 2022 21:35:57 +0200 Subject: [PATCH] More balanced approach to centroid vs pole of inaccessability --- tools/calculate_center.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/calculate_center.py b/tools/calculate_center.py index c77abda3..c220941f 100644 --- a/tools/calculate_center.py +++ b/tools/calculate_center.py @@ -2,7 +2,7 @@ From https://github.com/Twista/python-polylabel/, which is in turn implemented from https://github.com/mapbox/polylabel """ -from math import sqrt +from math import sqrt, log10 import time 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(): _, __, 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 if debug: