fix multipolygon issue (#1364)

pull/1378/head
Kaalleen 2021-10-09 10:04:13 +02:00 zatwierdzone przez GitHub
rodzic c75b90154b
commit 0224794a08
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 4 dodań i 1 usunięć

Wyświetl plik

@ -158,10 +158,13 @@ class Fill(EmbroideryElement):
message = re.match(r".+?(?=\[)", why)
if message.group(0) == "Self-intersection":
buffered = polygon.buffer(0)
# if we receive a multipolygon, only use the first one of it
if type(buffered) == shgeo.MultiPolygon:
buffered = buffered[0]
# we do not want to break apart into multiple objects (possibly in the future?!)
# best way to distinguish the resulting polygon is to compare the area size of the two
# and make sure users will not experience significantly altered shapes without a warning
if math.isclose(polygon.area, buffered.area):
if type(buffered) == shgeo.Polygon and math.isclose(polygon.area, buffered.area, abs_tol=0.5):
polygon = shgeo.MultiPolygon([buffered])
return polygon