OGCGeometry#union of geometries of different dimensions is incorrect
See original GitHub issueI’m seeing incorrect results when calling OGCGeometry#union
on geometries of different dimensions, e.g. point and linestring, linestring and polygon, etc.
For example, the following tests
public class TestOGCUnion
{
@Test
public void testPoint()
{
assertUnion("POINT (1 2)", "LINESTRING EMPTY", "POINT (1 2)");
}
@Test
public void testPointWithLinestring()
{
assertUnion("POINT (1 2)", "LINESTRING (3 4, 5 6)", "GEOMETRYCOLLECTION (POINT (1 2), LINESTRING (3 4, 5 6))");
}
@Test
public void testLinestring()
{
assertUnion("LINESTRING (1 2, 3 4)", "POLYGON EMPTY", "LINESTRING (1 2, 3 4)");
}
@Test
public void testLinestringWithPolygon()
{
assertUnion("LINESTRING (1 2, 3 4)", "POLYGON ((0 0, 1 1, 0 1, 0 0))", "GEOMETRYCOLLECTION (LINESTRING (1 2, 3 4), POLYGON ((0 0, 1 1, 0 1, 0 0)))");
}
private void assertUnion(String leftWkt, String rightWkt, String expectedWkt)
{
OGCGeometry union = OGCGeometry.fromText(leftWkt).union(OGCGeometry.fromText(rightWkt));
assertEquals(expectedWkt, union.asText());
}
}
fail with
Expected :POINT (1 2)
Actual :MULTILINESTRING EMPTY
at com.esri.core.geometry.TestOGCUnion.testPoint(TestOGCUnion.java:26)
Expected :GEOMETRYCOLLECTION (POINT (1 2), LINESTRING (3 4, 5 6))
Actual :LINESTRING (3 4, 5 6)
at com.esri.core.geometry.TestOGCUnion.testPointWithLinestring(TestOGCUnion.java:32)
Expected :LINESTRING (1 2, 3 4)
Actual :MULTIPOLYGON EMPTY
at com.esri.core.geometry.TestOGCUnion.testLinestring(TestOGCUnion.java:38)
Expected :GEOMETRYCOLLECTION (LINESTRING (1 2, 3 4), POLYGON ((0 0, 1 1, 0 1, 0 0)))
Actual :POLYGON ((0 0, 1 1, 0 1, 0 0))
at com.esri.core.geometry.TestOGCUnion.testLinestringWithPolygon(TestOGCUnion.java:44)
I’m also seeing union of POLYGON ((0 0, 1 1, 0 1, 0 0))
and POLYGON ((0.5 0.5, 0.7 0.7, 0.5 0.7, 0.5 0.5))
being POLYGON ((0.7 0.7, 1 1, 0 1, 0 0, 0.5 0.5, 0.7 0.7))
and not POLYGON ((0 0, 1 1, 0 1, 0 0))
. The shapes are the same, but union result has redundant points. Is this expected?
Issue Analytics
- State:
- Created 5 years ago
- Comments:17 (15 by maintainers)
Top Results From Across the Web
Check Geometry—ArcGIS Pro | Documentation
The Check Geometry check finds features that contain invalid geometry. This includes features that contain null or empty geometries, empty envelopes, ...
Read more >Class Geometry | NetTopologySuite - NTS Topology Suite
Linear geometries are simple if they do not self-intersect at points other than boundary points. Zero-dimensional geometries (points) are simple if they have...
Read more >Simple feature access - Part 1 - OGC Portal
represented as the union of other geometric primitives of smaller dimension within the same set. NOTE The geometric primitives in the set ...
Read more >GEOS API - Django documentation
Unioning a set of Polygon s will always return a Polygon or MultiPolygon geometry (unlike GEOSGeometry.union() , which may return geometries of lower...
Read more >OGRGeometry Class Reference - GDAL
Returns if two geometries are different. ... Attempts to make an invalid geometry valid without losing vertices. More. ... Compute union using cascading....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jgravois John, thanks for explaining. @stolstov Looks like Sergey’s PR https://github.com/Esri/geometry-api-java/pull/178 improves
union
method to perform simplification inline. With these change, we’ll be able to useunion
in Presto directly.@mbasmanova Nothing else, unless you would like to do more verification.