Opened 4 years ago

Closed 3 years ago

#10803 closed Bugs (fixed)

union algorithm returning invalid geometry

Reported by: Volker Schöch <vschoech@…> Owned by: Barend Gehrels
Milestone: Boost 1.60.0 Component: geometry
Version: Boost 1.57.0 Severity: Regression
Keywords: union, multi-polygon, polygon Cc:

Description

My "_intPolygon" type is actually a multi-polygon, using a polygon type that is based on int, oriented counter-clockwise and open (not closed). Please consider the following example:

_intPolygon polygonA;
boost::geometry::read_wkt("MULTIPOLYGON(((3174 1374,3174 2886,1374 2886,1374 2139,3174 1374)))", polygonA); // does not throw
boost::geometry::correct(polygonA); // remove redundant closing point returned by wkt
boost::geometry::is_valid(polygonA); // returns true

_intPolygon polygonB;
boost::geometry::read_wkt("MULTIPOLYGON(((1374 1092,1734 1092,3174 2526,3174 2886,1374 2886,1374 1092)))", polygonB); // does not throw
boost::geometry::correct(polygonB); // remove redundant closing point returned by wkt
boost::geometry::is_valid(polygonB); // returns true

_intPolygon polygonC;
boost::geometry::union_(polygonA, polygonB, polygonC);
// polygonC = MULTIPOLYGON(((1374 809,1374 1092,1734 1092,3529 1718,3174 1374,3174 2526,3174 2886,1374 2886,1374 2139,1374 809)))
boost::geometry::is_valid(polygonC); // returns FALSE

boost::geometry::remove_spikes(polygonC);
// polygonC = MULTIPOLYGON(((1374 1092,1734 1092,3529 1718,3174 1374,3174 2526,3174 2886,1374 2886,1374 2139,1374 1092)))
boost::geometry::is_valid(polygonC); // still returns FALSE

May be related to #10661.
May be related to #9828.

Change History (2)

comment:1 Changed 3 years ago by vschoech@…

This problem is still present in 1.59.0.

comment:2 Changed 3 years ago by Barend Gehrels

Milestone: To Be DeterminedBoost 1.60.0
Resolution: fixed
Status: newclosed

Checked in current code, should be fixed in 1.60. I did not modify the code but added a unit testcase for this ticket and checked validity too.

Current output is (((1374, 2139), (1374, 1092), (1734, 1092), (2364, 1718), (3174, 1374), (3174, 2526), (3174, 2886), (1374, 2886)))

(this is CSV (bg::dsv) - note that bg::wkt explicitly closes polygons to conform to wkt specification). The output is a bit different than in the ticket.

Note: See TracTickets for help on using tickets.