summaryrefslogtreecommitdiff
path: root/lib/utils/clamp_path.py
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2025-06-04 20:01:53 +0200
committerGitHub <noreply@github.com>2025-06-04 20:01:53 +0200
commit547237d50a201e7768ea3701f51c3d7036eb7f13 (patch)
treed1083092272bcdc50d4b51530e3f9cc8f21cc372 /lib/utils/clamp_path.py
parentc27098508b586ab2b1082d702661e8dba9db9604 (diff)
Smoothing and clamping (#3772)
* smoothing: ensure start and end of original path * clamp path: never intersecting path could also be entirely in the exterior of the shape
Diffstat (limited to 'lib/utils/clamp_path.py')
-rw-r--r--lib/utils/clamp_path.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/utils/clamp_path.py b/lib/utils/clamp_path.py
index fcb34a4b..6b3a56e5 100644
--- a/lib/utils/clamp_path.py
+++ b/lib/utils/clamp_path.py
@@ -106,7 +106,10 @@ def clamp_path_to_polygon(path, polygon):
except FloatingPointError:
return path
- if len(split_path.geoms) == 1:
+ # contains() checks can fail without the buffer.
+ buffered_polygon = prep(polygon.buffer(1e-9))
+
+ if len(split_path.geoms) == 1 and buffered_polygon.contains(split_path.geoms[0]):
# The path never intersects with the polygon, so it's entirely inside.
return path
@@ -114,9 +117,6 @@ def clamp_path_to_polygon(path, polygon):
# start or end coincides with the polygon boundary
split_path = [ShapelyPoint(start), *split_path.geoms, ShapelyPoint(end)]
- # contains() checks can fail without the buffer.
- buffered_polygon = prep(polygon.buffer(1e-9))
-
last_point_inside = None
was_inside = False
result = []