From 7cf952dce27173c918340a839694802f332ae26a Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Sun, 18 Aug 2024 20:05:37 +0200 Subject: fill: ensure polygon in pull comp adjusted shape (#3143) --- lib/utils/geometry.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/utils/geometry.py') diff --git a/lib/utils/geometry.py b/lib/utils/geometry.py index 541d9cbc..e5296ef0 100644 --- a/lib/utils/geometry.py +++ b/lib/utils/geometry.py @@ -179,6 +179,18 @@ def ensure_multi_point(thing): return multi_point +def ensure_polygon(thing): + """Given a Polygon or a MultiPolygon + + Returns the Polygon or the biggest Polygon of the MultiPolygon""" + + if thing.geom_type == "MultiPolygon": + thing = list(thing.geoms) + thing.sort(key=lambda thing: thing.area, reverse=True) + return thing[0] + return thing + + def cut_path(points, length): """Return a subsection of at the start of the path that is length units long. -- cgit v1.2.3