We encountered that parsing a WKT MultiPolygon containing a self-intersection works while it will raise a validation error when it is wrapped into a GEOMETRYCOLLECTION.
This code parses the WKT string into a valid MultiPolygon instance.
Caused by: org.locationtech.spatial4j.exception.InvalidShapeException: Self-intersection at or near point (10.0, 5.0, NaN)
at org.locationtech.spatial4j.shape.jts.JtsGeometry.validate(JtsGeometry.java:127)
at org.locationtech.spatial4j.shape.jts.JtsShapeFactory.makeShapeFromGeometry(JtsShapeFactory.java:502)
at org.locationtech.spatial4j.shape.jts.JtsShapeFactory.makeShapeFromGeometry(JtsShapeFactory.java:475)
at org.locationtech.spatial4j.shape.jts.JtsShapeFactory$JtsMultiShapeBuilder.build(JtsShapeFactory.java:446)
at org.locationtech.spatial4j.io.WKTReader.parseGeometryCollectionShape(WKTReader.java:356)
at org.locationtech.spatial4j.io.WKTReader.parseShapeByType(WKTReader.java:165)
at org.locationtech.spatial4j.io.WKTReader.parseIfSupported(WKTReader.java:110)
at org.locationtech.spatial4j.io.WKTReader.parse(WKTReader.java:81)
I would expect that both variants behave the same.
Used version
0.8
.We encountered that parsing a WKT MultiPolygon containing a self-intersection works while it will raise a validation error when it is wrapped into a
GEOMETRYCOLLECTION
.This code parses the WKT string into a valid
MultiPolygon
instance.While this one raises a
InvalidShapeException
:Stacktrace:
I would expect that both variants behave the same.