summaryrefslogtreecommitdiff
path: root/lib/utils
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2024-08-18 20:05:37 +0200
committerGitHub <noreply@github.com>2024-08-18 20:05:37 +0200
commit7cf952dce27173c918340a839694802f332ae26a (patch)
tree3f5ec23ba29bedc403c39bb035acefe73ecad6d3 /lib/utils
parent8591f81ecbf82bcd3538d81cefb5a5b5d5080c5c (diff)
fill: ensure polygon in pull comp adjusted shape (#3143)
Diffstat (limited to 'lib/utils')
-rw-r--r--lib/utils/geometry.py12
1 files changed, 12 insertions, 0 deletions
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.