-
Notifications
You must be signed in to change notification settings - Fork 449
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Unexpected union of two MultiPolygons #825
Comments
This is OverlayNG working as designed. The input is not node-aligned - as can be seen using the TestBuilder in Reveal Topology mode: The reason the result is heterogeneous (i.e. including the additional LineString) is for legacy reasons, to match the semantics of the original overlay implementation. OverlayNG does provide a strict mode, which allows forcing results to be homogeneous. This is available in the TestBuilder: Or, you can remove lower-dimension elements in a post-processing step. |
Also note that the With a suitable snapping distance (here 1E-7) the result is a single triangle polygon:
|
Thank you for a quick investigation and a thorough explanation. The Reveal Topology looks very useful, thank you. Took me a while to find it 😅 It seems that ultimately we should use both I looked into the code a bit, and did not find a way to configure this via system properties or Should I close the issue now that it's clear that it's not a bug? |
Yes, implementing a (set of) wrapper functions providing an API for the OverlayNG settings you want is a good approach. I'll close this now. |
This is likely also caused by high-precision numbers, similar to #784 and #820.
JTS version used: 1.18.2 with OverlayNG enabled.
Can be reproduced by copy-pasting WKT to JTS TestBuilder:
A:
MULTIPOLYGON (((1.4020000000000001 0.6152725855529207, 2.017272585552921 0, 0 0, 0 2.0172725855529214, 0.6152725855529207 1.4020000000000001, 1.4020000000000001 1.4020000000000001, 1.4020000000000001 0.6152725855529207)), ((3.9999999999999996 0, 2.0172725856347586 0, 3.0086362927764605 0.9913637072235397, 3.9999999999999996 0)), ((0.9913637072235395 3.0086362927764605, 0 2.017272585634758, 0 3.9999999999999996, 0.9913637072235395 3.0086362927764605)))
B:
MULTIPOLYGON (((1.4020000000000001 0.6152725856097978, 1.4020000000000001 1.4020000000000001, 0.6152725855778813 1.4020000000000001, -0.0000000000000002 2.017272585552921, 0.9913637072235395 3.0086362927764605, 3.0086362927764605 0.9913637072235397, 2.0172725856347586 0.0000000000000001, 1.4020000000000001 0.6152725856097978)))
Result of A union B:
GEOMETRYCOLLECTION (POLYGON ((2.017272585552921 0, 0 0, 0 2.017272585552921, 0 2.0172725855529214, 0.0000000000000002 2.0172725855529214, 0.9913637072235395 3.0086362927764605, 3.0086362927764605 0.9913637072235397, 2.0172725856347586 0.0000000000000001, 1.4020000000000001 0.6152725856097978, 1.4020000000000001 0.6152725855529207, 2.017272585552921 0), (0.6152725855529207 1.4020000000000001, 0.6152725855778813 1.4020000000000001, 0.0000161232623158 2.0172564622906055, 0.6152725855529207 1.4020000000000001)), POLYGON ((2.0172725856347586 0, 3.0086362927764605 0.9913637072235397, 3.9999999999999996 0, 2.0172725856347586 0)), POLYGON ((0 2.017272585634758, 0 3.9999999999999996, 0.9913637072235395 3.0086362927764605, 0 2.017272585634758)), LINESTRING (0 2.017272585552921, -0.0000000000000002 2.017272585552921))
Expected result:
The text was updated successfully, but these errors were encountered: