handle GeometryCollections in ensure_polygon (#3708)

pull/3718/head
Kaalleen 2025-05-09 20:25:08 +02:00 zatwierdzone przez GitHub
rodzic 21216f1616
commit d41b99dba8
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
1 zmienionych plików z 3 dodań i 1 usunięć

Wyświetl plik

@ -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)