Boost C++ Libraries: Ticket #11674: difference algorithm returning invalid geometry https://svn.boost.org/trac10/ticket/11674 <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(((529 3217,529 998,5337 998,5337 1834,5070 2000,5337 2072,5337 3475,529 3475,529 3312,1734 2054,2934 1670,3230 1690,2934 1400,1734 1784,529 3217),(4140 2582,5071 2001,4140 1754,3231 1691,4140 2582)))", polygonA); // does not throw boost::geometry::is_valid(polygonA); // returns true tc::geo::polygon&lt;int&gt; polygonB; boost::geometry::read_wkt("MULTIPOLYGON(((528 3218,528 2498,1734 1406,2556 1522,1734 1784,528 3218)),((4610 2288,5340 1178,5340 1832,4609 2289,4140 3002,2934 1574,2555 1521,2934 1400,4140 2582,4610 2288)))", polygonB); // does not throw 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(((2553 1521,1734 1406,529 2498,529 998,5337 998,5337 1183,4839 1939,4140 1754,3231 1691,4140 2582,3230 1690,2934 1400,2555 1521,2556 1522,2553 1521)),((1734 1784,529 3217,529 3216,1734 1784)),((3020 1676,4140 3002,4609 2289,5071 2001,5337 2072,5337 3475,529 3475,529 3312,1734 2054,2934 1670,3020 1676))) 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 Ticket <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/10661" title="#10661: Bugs: difference algorithm returning invalid geometry (closed: duplicate)">#10661</a>. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11674 Trac 1.4.3 Barend Gehrels Sun, 01 Nov 2015 16:06:51 GMT <link>https://svn.boost.org/trac10/ticket/11674#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11674#comment:1</guid> <description> <ul><li>Still a problem in beta for 1.60 </li><li>It generates spikes. </li><li>The sym_difference complains about invalid input </li><li>Added test case to unit test suite </li></ul> </description> <category>Ticket</category> </item> <item> <dc:creator>Barend Gehrels</dc:creator> <pubDate>Sun, 26 Mar 2017 12:02:18 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/11674#comment:2 https://svn.boost.org/trac10/ticket/11674#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> So, alas still problematic </p> Ticket Volker Schöch <vschoech@…> Thu, 04 Jan 2018 16:26:02 GMT version changed https://svn.boost.org/trac10/ticket/11674#comment:3 https://svn.boost.org/trac10/ticket/11674#comment:3 <ul> <li><strong>version</strong> <span class="trac-field-old">Boost 1.59.0</span> → <span class="trac-field-new">Boost 1.66.0</span> </li> </ul> <p> Related problem <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/12753" title="#12753: Bugs: difference algorithm returning invalid geometry (closed: duplicate)">#12753</a> still present in 1.66.0. </p> Ticket Volker Schöch <vschoech@…> Thu, 14 Jun 2018 10:20:14 GMT <link>https://svn.boost.org/trac10/ticket/11674#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11674#comment:4</guid> <description> <p> Still reproducible in 1.67.0. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Barend Gehrels</dc:creator> <pubDate>Wed, 26 Jun 2019 10:14:00 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/11674#comment:5 https://svn.boost.org/trac10/ticket/11674#comment:5 <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">duplicate</span> </li> </ul> <p> Transferred to <a class="ext-link" href="https://github.com/boostorg/geometry/issues/602"><span class="icon">​</span>https://github.com/boostorg/geometry/issues/602</a> </p> Ticket