Open
Description
I noticed that calculating the difference with a GeometryCollection that contains overlapping polygons results in the following error: TopologyException: side location conflict at 5 0. This can occur if the input geometry is invalid.
I found some threads from a few years back that stated already that this was not supported at that moment and that it might be considered in the future. I wonder, are there plans to support this in the future?
Script to reproduce in python:
import shapely
# Difference of geom: 1 polygon, geom: GeometryCollection of 2 overlapping polygons
# Result: TopologyException
geom = shapely.Polygon([(0, 0), (50, 0), (50, 50), (0, 50), (0, 0)])
geom_collection = shapely.GeometryCollection(
[
shapely.Polygon([(0, 0), (10, 0), (10, 10), (0, 10), (0, 0)]),
shapely.Polygon([(5, 0), (20, 0), (20, 10), (5, 10), (5, 0)]),
]
)
print(f"versions: shapely: {shapely.__version__}, geos-C-api: {shapely.geos_capi_version_string}")
print(f"is simple poly valid? {shapely.is_valid_reason(geom)}")
print(f"is collection valid? {shapely.is_valid_reason(geom_collection)}")
try:
result = shapely.difference(geom, geom_collection)
except Exception as ex:
print(f"Exception raised: {ex}")
Output:
versions: shapely: 2.0.1, geos-C-api: 3.12.0-CAPI-1.18.0
is simple poly valid? Valid Geometry
is collection valid? Valid Geometry
Exception raised: TopologyException: side location conflict at 5 10. This can occur if the input geometry is invalid.