Skip to content

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

@fredpeertje

Description

@fredpeertje

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions