Boost C++ Libraries: Ticket #12752: difference algorithm returning invalid geometry (regression over 1.59.0) https://svn.boost.org/trac10/ticket/12752 <p> My "tc::geo::polygon" type is actually a <strong>multi-polygon</strong>, using a polygon type that is based on <strong>int</strong>, oriented <strong>counter-clockwise</strong> and <strong>open</strong> (not closed). Please consider the following example: </p> <pre class="wiki">tc::geo::polygon&lt;int&gt; polygonA; boost::geometry::read_wkt("MULTIPOLYGON(((3232 2413,2136 2646,3232 2412,3232 2413)),((3232 2532,3232 2856,1031 2856,1031 1056,3232 1056,3232 2221,2136 2328,1032 1212,1032 1458,1032 1764,2136 2790,3232 2532)))", polygonA); // does not throw _ASSERT( boost::geometry::is_valid(polygonA) ); // returns true tc::geo::polygon&lt;int&gt; polygonB; boost::geometry::read_wkt("MULTIPOLYGON(((1032 2130,1032 1764,2052 2712,1032 2130)),((3234 2580,2558 2690,3234 2532,3234 2580)),((2558 2690,2136 2790,2052 2712,2136 2760,2558 2690)))", polygonB); // does not throw _ASSERT( boost::geometry::is_valid(polygonB) ); // returns true tc::geo::polygon&lt;int&gt; polygonC; boost::geometry::difference(polygonA, polygonB, polygonC); // does not throw // polygonC: MULTIPOLYGON(((3232 2413,2136 2646,3232 2412,3232 2413)),((2568 2688,3232 2580,3232 2856,1031 2856,1031 1056,3232 1056,3232 2221,2136 2328,1032 1212,1032 1458,1032 1764,2052 2712,2136 2790,2568 2688),(1032 1764,1032 2130,2052 2712,1032 1764)),((2952 2598,3232 2532,3232 2533,2952 2598))) boost::geometry::is_valid(polygonC); // returns false! </pre><p> The difference of two valid multi-polygons yields an invalid multi-polygon. </p> <p> May be related to tickets <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/10661" title="#10661: Bugs: difference algorithm returning invalid geometry (closed: duplicate)">#10661</a>, <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/11674" title="#11674: Bugs: difference algorithm returning invalid geometry (closed: duplicate)">#11674</a>, <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/11676" title="#11676: Bugs: difference algorithm returning invalid geometry (closed: fixed)">#11676</a>, <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/12751" title="#12751: Bugs: difference algorithm returning invalid geometry (closed: fixed)">#12751</a>. </p> <p> This problem was NOT present in boost 1.59.0. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12752 Trac 1.4.3 Volker Schöch <vschoech@…> Thu, 12 Jan 2017 12:38:07 GMT <link>https://svn.boost.org/trac10/ticket/12752#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12752#comment:1</guid> <description> <p> This is urgent because I do not have a work-around. I tried correct(...), remove_spikes(...) and unique(...), to no avail. Even if you cannot fix it right away, any hints to a useful work-around are welcome! </p> </description> <category>Ticket</category> </item> <item> <author>Volker Schöch <vschoech@…></author> <pubDate>Thu, 12 Jan 2017 12:51:23 GMT</pubDate> <title>keywords set https://svn.boost.org/trac10/ticket/12752#comment:2 https://svn.boost.org/trac10/ticket/12752#comment:2 <ul> <li><strong>keywords</strong> difference multi-polygon polygon added </li> </ul> Ticket Barend Gehrels Sun, 26 Mar 2017 12:27:50 GMT status changed https://svn.boost.org/trac10/ticket/12752#comment:3 https://svn.boost.org/trac10/ticket/12752#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> Also, not yet fixed in 1.64. Case is added to unit test suite (and also <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/12751" title="#12751: Bugs: difference algorithm returning invalid geometry (closed: fixed)">#12751</a>). It is tested for int/open/ccw, but it also fails for double/clockwise/closed </p> Ticket Volker Schöch <vschoech@…> Thu, 04 Jan 2018 16:22:20 GMT version changed https://svn.boost.org/trac10/ticket/12752#comment:4 https://svn.boost.org/trac10/ticket/12752#comment:4 <ul> <li><strong>version</strong> <span class="trac-field-old">Boost 1.63.0</span> → <span class="trac-field-new">Boost 1.66.0</span> </li> </ul> <p> Still present in boost 1.66.0. </p> Ticket Volker Schöch <vschoech@…> Mon, 25 Jun 2018 07:32:44 GMT <link>https://svn.boost.org/trac10/ticket/12752#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12752#comment:5</guid> <description> <p> No longer reproducible in 1.67.0. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Barend Gehrels</dc:creator> <pubDate>Mon, 25 Jun 2018 18:31:42 GMT</pubDate> <title>status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/12752#comment:6 https://svn.boost.org/trac10/ticket/12752#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.67.0</span> </li> </ul> <p> Thanks for verifying! </p> Ticket