diff options
Diffstat (limited to 'lib/utils')
| -rw-r--r-- | lib/utils/geometry.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/utils/geometry.py b/lib/utils/geometry.py index 64f6f16f..ab7f24c1 100644 --- a/lib/utils/geometry.py +++ b/lib/utils/geometry.py @@ -2,11 +2,14 @@ from shapely.geometry import LineString, Point as ShapelyPoint import math -def cut(line, distance): +def cut(line, distance, normalized=False): """ Cuts a LineString in two at a distance from its starting point. This is an example in the Shapely documentation. """ + if normalized: + distance *= line.length + if distance <= 0.0: return [None, line] elif distance >= line.length: @@ -47,6 +50,14 @@ def cut_path(points, length): return [Point(*point) for point in subpath.coords] +def collapse_duplicate_point(geometry): + if hasattr(geometry, 'geoms'): + if geometry.area < 0.01: + return geometry.representative_point() + + return geometry + + class Point: def __init__(self, x, y): self.x = x |
