Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#7462 closed Bugs (fixed)

geometry::union_ yields degenerated results

Reported by: Danvil <danvil@…> Owned by: Barend Gehrels
Milestone: To Be Determined Component: geometry
Version: Boost 1.48.0 Severity: Problem
Keywords: Cc:

Description

The following data gives wrong results with geometry::union.

float data1[][2] = {{0,0}, {-0.3681253195,0.9297761917}, {2.421203136,2.034152031}, {2.789328575,1.104375958}, {0,0}};
float data2[][2] = {{2.76143527,1.093332171}, {2.076887131,1.822299719}, {4.263789177,3.875944376}, {4.948337555,3.146976948}, {2.76143527,1.093332171}};

polygon_t p1, p2;
boost::geometry::append(p1, data1);
boost::geometry::append(p2, data2);

std::vector<polygon_t> output;
boost::geometry::union_(p1, p2, output);

Please find attached the whole main file and program output.

Attachments (2)

boost_geometry_union_bug.cpp (1.3 KB ) - added by Danvil <danvil@…> 10 years ago.
boost_geometry_union_bug_output.txt (431 bytes ) - added by Danvil <danvil@…> 10 years ago.

Download all attachments as: .zip

Change History (6)

by Danvil <danvil@…>, 10 years ago

by Danvil <danvil@…>, 10 years ago

comment:1 by Danvil <danvil@…>, 10 years ago

Actually union(p1,p2) yields a degenerated polygon while union(p2,p1) gives the correct result. In my use case, wrong results occur in ~0.5% of the cases.

comment:2 by Barend Gehrels, 10 years ago

Resolution: fixed
Status: newclosed

(In [83481]) [geometry] Fix ticket 7462, degenerate union for float. This was caused by two distances being wrong (by floating point precision). We now use earlier the alternative sort method (sorting on left/right), using relaxed_epsilon. This fixes the cause.

comment:3 by Barend Gehrels, 10 years ago

(In [83482]) [geometry] Fix ticket 7462, (unit tests)

in reply to:  3 comment:4 by anonymous, 10 years ago

Replying to barendgehrels:

(In [83482]) [geometry] Fix ticket 7462, (unit tests)

Thanks for fixing this!

Note: See TracTickets for help on using tickets.