Skip to content

fix: guard perimeter computation for MultiPolygon geometries#338

Closed
saschabuehrle wants to merge 1 commit intofib-international:mainfrom
saschabuehrle:fix/issue-329
Closed

fix: guard perimeter computation for MultiPolygon geometries#338
saschabuehrle wants to merge 1 commit intofib-international:mainfrom
saschabuehrle:fix/issue-329

Conversation

@saschabuehrle
Copy link

Bug

#329gross_properties raises AttributeError: 'MultiPolygon' object has no attribute 'exterior' when the section geometry is a MultiPolygon (e.g. disconnected rectangles).

Fix

The if isinstance(polygon, MultiPolygon) block correctly sets gp.perimeter = 0.0 and emits a warning, but the code then falls through to polygon.exterior.length unconditionally. This adds an else branch so the .exterior access only runs for single Polygon geometries.

Testing

Verified that the code path now correctly short-circuits for MultiPolygon and only accesses .exterior on single Polygon instances. The existing test suite continues to pass for single-polygon sections.

Happy to address any feedback.

Greetings, saschabuehrle

@talledodiego
Copy link
Collaborator

Thanks @saschabuehrle for taking the time to fix this.
We fixed this in PR #332 already merged with dev.

Thanks for your time!

@saschabuehrle
Copy link
Author

Ah, missed that #332 already landed. Closing — thanks for letting me know!

@github-project-automation github-project-automation bot moved this to Under review 👀 in PR tracker Mar 23, 2026
@mortenengen mortenengen moved this from Under review 👀 to Closed 😑 in PR tracker Mar 23, 2026
@mortenengen mortenengen added the bug Something isn't working label Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Closed 😑

Development

Successfully merging this pull request may close these issues.

3 participants