jts
jts copied to clipboard
Non-closed polygon parsing caused unexpected Exception
Demo code:
@ExtendWith(MockitoExtension.class)
public class WKTReadTest
{
@Test
void wrongGeometryTest() {
String openPolygon = "POLYGON ((0 0, 1 1, 1 0))";
var reader = new WKTReader();
Assertions.assertThrows(ParseException.class, () -> reader.read(openPolygon));
}
}
Expected :class org.locationtech.jts.io.ParseException Actual :class java.lang.IllegalArgumentException
Affected versions: 1.19.0 and 1.18.2, others not checked
JTS considers this to be not a parsing error, but a malformed geometry error (which is what IllegalArgumentException
indicates. So this is as per design. Just check for both errors.