Skip to content

Use bounding rectangle to avoid problem introduced by polygons with weird points

Yoann Schneider requested to merge fix-div-by-zero-move-lines into master

Closes #1074 (closed)

The division by zero was due to a polygon where the top-left point and the bottom-right point had the same vertical coordinate. The code only considers rectangle because computing irregular polygons' areas is much more complicated. This means that the created rectangle in this case is a single horizontal line with height=0. This means an area=0 and a ZeroDivisionError.

To bypass this case, I now use bounding rectangle, that will be larger than the original polygon in this case but will avoid this error. In case it still comes up, Child elements with an area=0 won't be moved at all. However, this should never happen because of how the backend forbids polygons with only 3 different points.

Merge request reports

Loading