Modify

Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#7462 closed Bugs (fixed)

geometry::union_ yields degenerated results

Reported by: Danvil <danvil@…> Owned by: barendgehrels
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@…> 5 years ago.
boost_geometry_union_bug_output.txt (431 bytes) - added by Danvil <danvil@…> 5 years ago.

Download all attachments as: .zip

Change History (6)

Changed 5 years ago by Danvil <danvil@…>

Changed 5 years ago by Danvil <danvil@…>

comment:1 Changed 5 years ago by Danvil <danvil@…>

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 Changed 4 years ago by barendgehrels

  • Resolution set to fixed
  • Status changed from new to closed

(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 follow-up: Changed 4 years ago by barendgehrels

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

comment:4 in reply to: ↑ 3 Changed 4 years ago by anonymous

Replying to barendgehrels:

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

Thanks for fixing this!

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain barendgehrels.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.