[geos-devel] Bug in Intersection Routine

Pete Gerritson pgerritson at adelphia.net
Fri Oct 5 11:33:08 EDT 2007


I found what I think to be a bug in the Intersection routine. 

I defined a polygon with the following wkt: POLYGON( (0 0, 1 0, 1 1, 0 1, 0 0), (.5 .1, 1 .5, .5 .9, .5 .1))  This polygon has an exterior ring that is a square, and one interior ring that is a triangle.  The interior ring touches the exterior ring in one point.  I believe this is considered a valid polygon.

When I call the GEOSIntersection method using this polygon for both parameters, I would expect to get back the same polygon.  Instead I get back a geometry collection of 8 linestrings and a polygon:

GEOMETRYCOLLECTION (LINESTRING (0.0000000000000000 0.0000000000000000, 1.0000000000000000 0.0000000000000000), LINESTRING (1.0000000000000000 0.0000000000000000, 1.0000000000000000 0.5000000000000000), LINESTRING (1.0000000000000000 0.5000000000000000, 1.0000000000000000 1.0000000000000000), LINESTRING (1.0000000000000000 1.0000000000000000, 0.0000000000000000 1.0000000000000000), LINESTRING (0.0000000000000000 1.0000000000000000, 0.0000000000000000 0.0000000000000000), LINESTRING (0.5000000000000000 0.1000000000000000, 1.0000000000000000 0.5000000000000000), LINESTRING (1.0000000000000000 0.5000000000000000, 0.5000000000000000 0.9000000000000000), LINESTRING (0.5000000000000000 0.9000000000000000, 0.5000000000000000 0.1000000000000000), POLYGON ((1.0000000000000000 0.0000000000000000, 0.0000000000000000 0.0000000000000000, 0.0000000000000000 1.0000000000000000, 1.0000000000000000 1.0000000000000000, 1.0000000000000000 0.5000000000000000, 1.0000000000000000 0.0000000000000000), (1.0000000000000000 0.5000000000000000, 0.5000000000000000 0.9000000000000000, 0.5000000000000000 0.1000000000000000, 1.0000000000000000 0.5000000000000000)))

The last polygon appears to be equivalent to my input, but with one extra point in the exterior ring.  The 8 linestrings appear to be the pieces of the boundary of the polygon.

I believe this is a bug. If I change the input polygon so that the interior ring doesn't touch the exterior ring, I get the expected result.

Thanks,

Pete Gerritson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/geos-devel/attachments/20071005/9f6f82cb/attachment.html


More information about the geos-devel mailing list