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

ClassCastException when reversing MultiLineString with only a single LineString #627

Closed
DTMDTM opened this issue Oct 29, 2020 · 1 comment · Fixed by #628
Closed

ClassCastException when reversing MultiLineString with only a single LineString #627

DTMDTM opened this issue Oct 29, 2020 · 1 comment · Fixed by #628
Assignees

Comments

@DTMDTM
Copy link

DTMDTM commented Oct 29, 2020

On version 1.17.1.

Since #513 was merged, a MultiLineString cannot be reversed if it only contains a single LineString.

The following is a minimal example:

GeometryFactory f = new GeometryFactory();

Coordinate[] coordinates = new Coordinate[2];
coordinates[0] = new Coordinate(1,1);
coordinates[1] = new Coordinate(2,2);

LineString[] lineStrings = new LineString[1];
lineStrings[0] = f.createLineString(coordinates);

MultiLineString multiLineString = f.createMultiLineString(lineStrings);
multiLineString.reverse();

This results in the following ClassCastException:

java.lang.ClassCastException: class org.locationtech.jts.geom.LineString cannot be cast to class org.locationtech.jts.geom.GeometryCollection

@dr-jts
Copy link
Contributor

dr-jts commented Oct 29, 2020

Good find. And there are other bugs too - for instance, CoordinateSequences.reverse doesn't handle zero-length sequences.

Working on a fix -with a more complete set of test data!

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

Successfully merging a pull request may close this issue.

2 participants