This looks like a bug, alright. JTS returns the expected answer of POLYGON ((1 0, 0 0, 0 1, 1 1, 1 0.5, 1 0),
 (1 0.5, 0.5 0.9, 0.5 0.1, 1 0.5))

Martin

Pete Gerritson wrote:

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

------------------------------------------------------------------------

_______________________________________________
geos-devel mailing list
geos-devel@geos.refractions.net
http://geos.refractions.net/mailman/listinfo/geos-devel

--
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022

_______________________________________________
geos-devel mailing list
geos-devel@geos.refractions.net
http://geos.refractions.net/mailman/listinfo/geos-devel

Reply via email to