Skip to content

fix(jts): align GEOMETRYCOLLECTION with MULTIPOLYGON WKT parse - #238

Closed
arimu1 wants to merge 1 commit into
locationtech:masterfrom
arimu1:fix/issue-232-geometrycollection-multipolygon
Closed

arimu1 wants to merge 1 commit into
locationtech:masterfrom
arimu1:fix/issue-232-geometrycollection-multipolygon

Conversation

@arimu1

@arimu1 arimu1 commented Sep 26, 2026 •

Copy link
Copy Markdown

Summary

Test plan

  • mvn test (full suite, JDK 17)
  • Manual repro: bare MULTIPOLYGON and wrapped GEOMETRYCOLLECTION both parse successfully on JtsSpatialContext.GEO

Contributor notes

Fixes #232

JtsMultiShapeBuilder re-wrapped homogeneous children via makeShapeFromGeometry,
which re-validated geometries that multi* builders already accept via makeShape.
Return a lone child unchanged and use makeShape for homogeneous Multi* merges.

Fixes locationtech#232

Signed-off-by: arimu1 <19286898+arimu1@users.noreply.github.com>
}

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?

@arimu1

arimu1 commented Oct 3, 2026

Copy link
Copy Markdown
Author

I rechecked #232 against current master (5c9e2ef8) and against this branch, on Temurin 21 and JBR 17.

MULTIPOLYGON (((5 5, 10 5, 10 10, 5 5)), ((6 6, 10 5, 10 10, 6 6))) and the same polygon wrapped in GEOMETRYCOLLECTION both throw:

InvalidShapeException: Self-intersection at or near point (6.0, 6.0, NaN)

That result is the same with and without the JtsMultiShapeBuilder change. The 0.8 asymmetry is already gone on master. The new test expected both parses to return a shape, which is why build (8), build (11), and build (21) fail at JtsWktShapeParserTest line 148. JDK 17 in CI passes that test because that run accepts the geometry; both forms still agree there.

Closing this. The shapes.size() == 1 check is not what makes the two forms agree on master. I can add a regression that only asserts the two forms agree, with no builder change, if you want that pinned.

@arimu1 arimu1 closed this Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validation for self-intersection WKT Multipolygon fails at the WKTReader, while works when wrapped in a GEOMETRYCOLLECTION

2 participants