Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-closed polygon parsing caused unexpected Exception #1035

Open
RiseOfDeath opened this issue Feb 2, 2024 · 1 comment
Open

Non-closed polygon parsing caused unexpected Exception #1035

RiseOfDeath opened this issue Feb 2, 2024 · 1 comment

Comments

@RiseOfDeath
Copy link

RiseOfDeath commented Feb 2, 2024

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

@dr-jts dr-jts changed the title Non closed polygon parsing caused Unexpected Exception Non-closed polygon parsing caused unexpected Exception Mar 14, 2024
@dr-jts
Copy link
Contributor

dr-jts commented Mar 14, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants