[geos-devel] Union of linestrings

Mateusz Loskot mateusz at loskot.net
Mon Feb 29 10:18:08 PST 2016


I've started adding tests for OverlayOp [1] and I noticed
curious results for basic test case.

OverlayOp(UNION) on Four segments of a sqare
always construct a MultiLineString.
I'd have expected a polygon, shouldn't I?

In this case, I noticed OverlayOp always labels edges
as UNDEF or BOUNDARY this simply leads to non-area
results and the PolygonBuilder never receives any input
which qualifies as a polygon.

As you can see in the test, the union is constructed

GeometryPtr lines12(line1->Union(line2.get()));
GeometryPtr lines123(lines12->Union(line3.get()));
GeometryPtr lines1234(lines123->Union(line4.get()));

but the same result (MultiLineString) is returned
if I union via UnaryUnion on MultiLineString or GeometryCollection.

My questions are:
1. Is this expected behaviour?
2. Am I missing any trick to actually obtain the polygon?

[1] https://trac.osgeo.org/geos/changeset/4153

Best regards,
Mateusz Łoskot, http://mateusz.loskot.net

More information about the geos-devel mailing list