|
|
@@ -22,7 +22,7 @@
|
|
|
# import xml.etree.ElementTree as ET
|
|
|
from svg.path import Line, Arc, CubicBezier, QuadraticBezier, parse_path
|
|
|
from svg.path.path import Move
|
|
|
-from shapely.geometry import LineString
|
|
|
+from shapely.geometry import LineString, LinearRing, MultiLineString
|
|
|
from shapely.affinity import skew, affine_transform, rotate
|
|
|
import numpy as np
|
|
|
|
|
|
@@ -71,7 +71,6 @@ def path2shapely(path, object_type, res=1.0):
|
|
|
rings = []
|
|
|
|
|
|
for component in path:
|
|
|
-
|
|
|
# Line
|
|
|
if isinstance(component, Line):
|
|
|
start = component.start
|
|
|
@@ -123,6 +122,8 @@ def path2shapely(path, object_type, res=1.0):
|
|
|
|
|
|
if points:
|
|
|
rings.append(points)
|
|
|
+
|
|
|
+ rings = MultiLineString(rings)
|
|
|
if len(rings) > 0:
|
|
|
if len(rings) == 1:
|
|
|
# Polygons are closed and require more than 2 points
|
|
|
@@ -131,7 +132,14 @@ def path2shapely(path, object_type, res=1.0):
|
|
|
else:
|
|
|
geo_element = LineString(rings[0])
|
|
|
else:
|
|
|
- geo_element = Polygon(rings[0], rings[1:])
|
|
|
+ try:
|
|
|
+ geo_element = Polygon(rings[0], rings[1:])
|
|
|
+ except Exception as e:
|
|
|
+ coords = list()
|
|
|
+ for line in rings:
|
|
|
+ coords.append(line.coords[0])
|
|
|
+ coords.append(line.coords[1])
|
|
|
+ geo_element = Polygon(coords)
|
|
|
geometry.append(geo_element)
|
|
|
|
|
|
return geometry
|