pyclipper icon indicating copy to clipboard operation
pyclipper copied to clipboard

"IndexError: list index out of range" when using negative offset

Open fredpeertje opened this issue 4 years ago • 0 comments

When I use a negative offset of say 2 meter in a polygon square that is 2m2 (a small square), an "IndexError: list index out of range" error comes up. Ofcourse I would expect an error message in this situation. However, this invalid input offset is not properly handled.

The code that I use:

import pyclipper

negative_offset = -2
coordinates = # Small polygon of around 2m2
clipper_offset = pyclipper.PyclipperOffset()
coordinates_scaled = pyclipper.scale_to_clipper(coordinates)

clipper_offset.AddPath(coordinates_scaled, pyclipper.JT_ROUND, pyclipper.ET_CLOSEDPOLYGON)

new_coordinates = clipper_offset.Execute(pyclipper.scale_to_clipper(negative_offset))

new_coordinates_scaled = pyclipper.scale_from_clipper(new_coordinates)

fredpeertje avatar May 31 '21 07:05 fredpeertje