| 123456789101112131415 |
- from shapely.geometry import Polygon
- class SimplifyPoints:
- def __init__(self):
- # tolerance 参数就是 RDP 算法的阈值(epsilon)
- # 它决定了简化的程度,单位与你的坐标单位相同。
- self.tolerance_small = 0.8
- def simplify_points(self, points):
- original_polygon = Polygon(points)
- simplified_polygon_small = original_polygon.simplify(self.tolerance_small, preserve_topology=True)
- points_small = list(simplified_polygon_small.exterior.coords)
- return points_small
|