Skip to content

Conversation

@systemed
Copy link

Currently the as_polygon method uses Array.push to add an extra point to close the shape.

Array.push does of course modify the original array in-place. Since as_polygon is called by envelope, and envelope is called by parse_file, this means all polylines are erroneously turned into closed polygons on parsing.

This PR fixes this by using + instead of Array.push.

# to the last point will be created to close it.
def as_polygon
GeoRuby::SimpleFeatures::Polygon.from_points([@points[0] == @points[-1] ? @points : @points.push(@points[0].clone)])
GeoRuby::SimpleFeatures::Polygon.from_points([@points[0] == @points[-1] ? @points : (@points + [@points[0]])])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/SpaceAroundOperators: Operator ? should be surrounded by a single space.
Metrics/LineLength: Line is too long. [119/80]
Layout/ExtraSpacing: Unnecessary spacing detected.

@systemed
Copy link
Author

Ah, duplicate of #38!

@systemed systemed closed this Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants