From d41b99dba886d4b5974dde2f5dadf17647b659ff Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Fri, 9 May 2025 20:25:08 +0200 Subject: handle GeometryCollections in ensure_polygon (#3708) --- lib/utils/geometry.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/utils/geometry.py b/lib/utils/geometry.py index 568f883d..39bbd963 100644 --- a/lib/utils/geometry.py +++ b/lib/utils/geometry.py @@ -180,10 +180,12 @@ def ensure_multi_point(thing): def ensure_polygon(thing): - """Given a Polygon or a MultiPolygon + """Given a Polygon, a MultiPolygon or a GeometryCollection Returns the Polygon or the biggest Polygon of the MultiPolygon""" + if thing.geom_type == "GeometryCollection": + thing = ensure_multi_polygon(thing) if thing.geom_type == "MultiPolygon": thing = list(thing.geoms) thing.sort(key=lambda thing: thing.area, reverse=True) -- cgit v1.2.3