summaryrefslogtreecommitdiff
path: root/lib/utils/clamp_path.py
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2024-01-25 17:54:08 +0100
committerGitHub <noreply@github.com>2024-01-25 17:54:08 +0100
commit2677c30a0f210d14586c83016f45e5a75fb9d647 (patch)
tree04a91f0ee9a7f5723abe362890006ed383ddf74e /lib/utils/clamp_path.py
parentf44eff9e74b36507cd512aea7aa6f4d698a374d5 (diff)
Second chance for invalid fill stitch graphs (#2643)
Diffstat (limited to 'lib/utils/clamp_path.py')
-rw-r--r--lib/utils/clamp_path.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/utils/clamp_path.py b/lib/utils/clamp_path.py
index 432f618a..f6db66a8 100644
--- a/lib/utils/clamp_path.py
+++ b/lib/utils/clamp_path.py
@@ -56,8 +56,10 @@ def adjust_line_end(line, end):
def find_border(polygon, point):
+ """Finds subpath of polygon which intersects with the point.
+ Ignores small border fragments"""
for border in polygon.interiors:
- if border.intersects(point):
+ if border.length > 0.1 and border.intersects(point):
return border
else:
return polygon.exterior
@@ -76,7 +78,10 @@ def clamp_path_to_polygon(path, polygon):
# This splits the path at the points where it intersects with the polygon
# border and returns the pieces in the same order as the original path.
- split_path = ensure_geometry_collection(LineString(path).difference(polygon.boundary))
+ try:
+ split_path = ensure_geometry_collection(LineString(path).difference(polygon.boundary))
+ except FloatingPointError:
+ return path
if len(split_path.geoms) == 1:
# The path never intersects with the polygon, so it's entirely inside.