Пример #1
0
def unpack_polygons(polygons: Sequence[Polygon],
                    context: Context) -> Union[Empty, Multipolygon, Polygon]:
    return ((context.multipolygon_cls(polygons)
             if len(polygons) > 1
             else polygons[0])
            if polygons
            else context.empty)
Пример #2
0
def unpack_regions(regions: Sequence[Contour],
                   context: Context) -> Union[Empty, Polygon, Multipolygon]:
    polygon_cls = context.polygon_cls
    return ((context.multipolygon_cls([polygon_cls(region, [])
                                       for region in regions])
             if len(regions) > 1
             else polygon_cls(regions[0], []))
            if regions
            else context.empty)