Opened 4 years ago

#13571 new Bugs

difference results in invalid output

Reported by: anonymous Owned by: Barend Gehrels
Milestone: To Be Determined Component: geometry
Version: Boost 1.66.0 Severity: Problem
Keywords: Cc:

Description

The difference of the following polygons results in invalid output:

using point_type = boost::geometry::model::d2::point_xy<double>; typedef boost::geometry::model::ring<point_type, false, true> polygon; ring<Point, ClockWise, Closed, ..>

polygon op1, op2;

boost::geometry::read_wkt("POLYGON((-5.357134899522904 1.708858148436605, -5.357046447070072 1.70877395054338, -5.210065937318399 -4.255706093497865, -8.65742840572935 -7.877265427733816, -9.246259311414669 -8.490599384498884, -8.647097810281494 -9.763145957490103, -5.287187110528729 -8.539478296007726, 4.07689365108185 -12.90390576571258, 6.997906000870004 3.116694062477888, -3.776939893600782 18.69699618899459, -3.858843408040787 18.57007309862488, -2.981468369027455 17.54675359552481, -4.116369566376584 2.772428265346094, -5.357134899522904 1.708858148436605))", op1); boost::geometry::read_wkt("POLYGON((-8.382184938267567 -5.157754480221099, -11.2072487852155 -5.954897113329205, -12.6412056272337 -8.516183878234685, -11.8440629941256 -11.34124772518262, -9.282776229220117 -12.77520456720082, -6.457712382272181 -11.97806193409271, -5.023755540253982 -9.416775169187234, -5.820898173362086 -6.591711322239298, -8.382184938267567 -5.157754480221099))", op2); boost::geometry::validity_failure_type type0 = boost::geometry::no_failure; bool v0 = boost::geometry::is_valid(op1, type0);

boost::geometry::validity_failure_type type1 = boost::geometry::no_failure; bool v1 = boost::geometry::is_valid(op2, type1);

std::vector<polygon> polyOutTemp; boost::geometry::difference(op1, op2, polyOutTemp);

boost::geometry::validity_failure_type type3 = boost::geometry::no_failure; bool v2 = boost::geometry::is_valid(polyOutTemp[0], type3);

polyOutTemp[0] is invalid because of self intersections. It seems to be a precision issue, since the self intersection occurs in a part of the polygon that should not affected by the difference algorithm.

Change History (0)

Note: See TracTickets for help on using tickets.