Closed
Description
Details of feature
Especially with a nested GeometryCollection, and a open polygon deep inside a wkt, it's not trivial to close polygons without help from libraries like this one. Is there some way to force the library to load it, to let us interact with the wkt?
# Using shapely, since they use this library behind the scenes, and it's what I know how to use
from shapely import wkt
wkt.loads("POLYGON ((0 0, 1 0, 1 1, 0 1))") # missing the last "0 0"
llegalArgumentException: Points of LinearRing do not form a closed linestring
Proposal
One idea is to add a strict=True
, that the user can switch to False if they hit this too. (Theoretically exposing this feature to shapely). This will let the user decide how to repair it.
OR
Add a repair=False
flag, that if flipped, will close the linestring automatically instead. (And other possible repairs that are common).
from shapely import wkt
poly = wkt.loads("POLYGON ((0 0, 1 0, 1 1, 0 1))", repair=True)
print(poly.wkt)
# If you repair automatically
'POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))'
# If you set "strict=False", letting the user decide how to repair it
'POLYGON ((0 0, 0 1, 1 1, 1 0))'