8000 Feature Request: Add flag to close polygons automatically, instead of throwing llegalArgumentException · Issue #587 · libgeos/geos · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Feature Request: Add flag to close polygons automatically, instead of throwing llegalArgumentException #587
Closed
@Cameronsplaze

Description

@Cameronsplaze

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))'

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNew feature or feature improvement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0