Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,16 @@ public Shape build() {
last = s.getClass();
}

return makeShapeFromGeometry(geometryFactory.buildGeometry(geoms));
if (shapes.size() == 1) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear why this check is here, relative to the fix. If this is an unrelated optimization, it could go at the start of build(); yes?

return shapes.get(0);
}

Geometry combined = geometryFactory.buildGeometry(geoms);
// Homogeneous collections become Multi* types; match multi* builders (no re-validate).
if (combined.getClass().equals(GeometryCollection.class)) {
return makeShapeFromGeometry(combined);
}
return makeShape(combined);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,17 @@ public void testLineStringDateline() throws ParseException {
assertEquals(30, s.getBoundingBox().getWidth(), 0.0 );
}

@Test
public void selfIntersectingMultiPolygonSameInGeometryCollection() throws ParseException {
WKTReader geoReader = (WKTReader) JtsSpatialContext.GEO.getFormats().getWktReader();
String multi =
"MULTIPOLYGON (((5 5, 10 5, 10 10, 5 5)), ((6 6, 10 5, 10 10, 6 6)))";
String collection =
"GEOMETRYCOLLECTION ( MULTIPOLYGON (((5 5, 10 5, 10 10, 5 5)), ((6 6, 10 5, 10 10, 6 6))) )";
geoReader.parse(multi);
geoReader.parse(collection);
}

@Test
public void testWrapTopologyException() throws Exception {
//test that we can catch ParseException without having to detect TopologyException too
Expand Down
Loading