Subject: [ggl] Intersection of two polygons returning empty result
From: Phillip Seaver (gtflip)
Date: 2011-07-05 13:50:57
On Sat, Jul 2, 2011 at 11:31 AM, Barend Gehrels <barend_at_[hidden]> wrote:
> Hi Phillip,
> On 27-6-2011 22:10, Phillip Seaver wrote:
> I think I found a bug in intersection(). I have two polygons for which
>> intersects() correctly returns true, but intersect() results in an empty
>> multi-polygon instead of the intersection:
> It is solved and Trunk is updated, including your testcase in the unit
> For those who are interested: the reason was that the segment intersection
> did not found this intersection-point, for the type "double". For "float" it
> did, but not on gcc on Linux. After that, if there are no intersections
> found, it should have detected that one was inside the other. But I selected
> a "midpoint" for that, I mean a point halfway on a segment (usually the
> first segment). That midpoint happened to fall outside (due to FP
> precision). I now, if there are no intersection points, select the a vertex
> from the polygon (so not a midpoint), to have one of the points used for
> segment intersection. That makes it mutually consistent and solves the
> I also included this testcase in the union and difference test. The
> difference test returns now an empty polygon for double, a very small
> polygon for float and an even smaller polygon for ttmath high precision. So
> another codepath is used for different precisions, and the output is zero or
> nearly zero. This is also the case in SQL Server/PostGIS: SQL Server returns
> a very small polygon, PostGIS returns the empty set.
> Thanks again for reporting this issue.
> Regards, Barend
> ggl mailing list
Thanks for the quick fix! I got the latest code this morning and my code
now works correctly.
-------------- next part --------------
An HTML attachment was scrubbed...
Geometry list run by mateusz at loskot.net