simplify_points.py 552 B

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