Skip to content

Commit

Permalink
Proposed fix for non-recognized holes
Browse files Browse the repository at this point in the history
When the geometries resulting from an operation result in a MultiPolygon that only touch at points, a hole is not recognized in shapely but it is "recognized" by humans. To fix this problem, the hole needs to be recognized by shapely as part of a Polygon. One solution to fix this would be to buffer the geometry by a very small amount to force this switch from MultiPolygon to Polygon.
  • Loading branch information
connorferster committed Sep 30, 2023
1 parent d13940d commit e227bc3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/sectionproperties/pre/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2384,7 +2384,10 @@ def compile_geometry(self) -> None:
# Determine if new holes have been created or if existing
# holes have been destroyed (or "filled in").
resultant_holes = []
SCALE_CONSTANT = 1e-9
unionized_poly = unary_union([geom.geom for geom in self.geoms])
buffer_amount = unionized_poly.area * SCALE_CONSTANT
unionized_poly = unionized_poly.buffer(buffer_amount)

if isinstance(unionized_poly, MultiPolygon):
for poly in unionized_poly.geoms:
Expand Down

0 comments on commit e227bc3

Please sign in to comment.