Skip to content

Commit 56affe2

Browse files
author
Robert Sachunsky
committed
resegment: join_polygons: allow non-contiguous input, too
1 parent db584d8 commit 56affe2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

ocrd_cis/ocropy/resegment.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import absolute_import
22

33
import os.path
4+
from itertools import chain
45
import numpy as np
56
from skimage import draw
67
from shapely.geometry import Polygon, asPolygon, LineString
@@ -482,6 +483,10 @@ def join_polygons(polygons, loc=''):
482483
# compoundp = unary_union(polygons)
483484
# jointp = compoundp.convex_hull
484485
LOG = getLogger('processor.OcropyResegment')
486+
polygons = list(chain.from_iterable([
487+
poly.geoms if poly.type in ['MultiPolygon', 'GeometryCollection']
488+
else [poly]
489+
for poly in polygons]))
485490
if len(polygons) == 1:
486491
return polygons[0]
487492
# get equidistant list of points along hull

0 commit comments

Comments
 (0)