Boost C++ Libraries: Ticket #8376: difference of non-closed polygons returns closed polygon https://svn.boost.org/trac10/ticket/8376 <p> The output multi-polygon from boost::geometry::difference should have the same orientation, closed-ness and underlying scalar data type, as the input (multi-)polygons. My polygon type is <strong>oriented counter-clockwise</strong> and <strong>not closed</strong>, my point type is based on <strong>int</strong>. Please find below some code that results in a <strong>closed</strong> polygon. </p> <p> <em>Note: The sym_difference algorithm has the same problem which I filed as a separate ticket <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8375" title="#8375: Bugs: sym_difference of non-closed polygons returns closed polygon (closed: fixed)">#8375</a>.</em> </p> <p> This is the data used as input to difference: </p> <pre class="wiki">_TPolygon&lt;int&gt; const polygon = _TPolygon&lt;int&gt;("MULTIPOLYGON(((1920 1462,3720 1462,3720 3262,1920 3262)))") - _TPolygon&lt;int&gt;("MULTIPOLYGON(((1918 1957,1918 1657,2218 2189)),((3718 1957,3360 2233,3718 1561)),((3360 2233,2818 3253,2218 2189,2818 2653)))"); </pre><p> This is the resulting multi-polygon, with the first contained polygon being closed: </p> <pre class="wiki">MULTIPOLYGON(((1920 1660,1920 1462,3720 1462,3720 3262,1920 3262,1920 1958,2218 2189,1920 1660),(3718 1561,3360 2233,3718 1957),(2818 2653,2218 2189,2818 3253,3360 2233))) </pre><p> This is my code that wraps boost::geometry to implement the operator used above: </p> <pre class="wiki">template&lt;typename T&gt; template&lt;typename Geometry&gt; _TPolygon&lt; T &gt; _TPolygon&lt; T &gt;::operator-(Geometry const&amp; geometry) const { // should not be necessary //if( boost::geometry::area(geometry)==0 ) return *this; _TPolygon&lt; T &gt; polygonOut; boost::geometry::difference(*this, geometry, polygonOut); // should not be necessary //boost::geometry::correct( polygonOut ); return polygonOut; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8376 Trac 1.4.3 Volker Schöch <vschoech@…> Wed, 03 Apr 2013 13:16:05 GMT <link>https://svn.boost.org/trac10/ticket/8376#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8376#comment:1</guid> <description> <p> Our conversation on the geometry mailing list regarding this issue in 1.48.0: <a class="ext-link" href="http://lists.boost.org/geometry/2012/02/1829.php"><span class="icon">​</span>http://lists.boost.org/geometry/2012/02/1829.php</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Barend Gehrels</dc:creator> <pubDate>Sat, 24 Aug 2013 22:59:30 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/8376#comment:2 https://svn.boost.org/trac10/ticket/8376#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket vschoech@… Wed, 13 Nov 2013 12:43:21 GMT version changed https://svn.boost.org/trac10/ticket/8376#comment:3 https://svn.boost.org/trac10/ticket/8376#comment:3 <ul> <li><strong>version</strong> <span class="trac-field-old">Boost 1.52.0</span> → <span class="trac-field-new">Boost 1.55.0</span> </li> </ul> <p> Still reproducible in 1.55. </p> Ticket mkaravel Fri, 01 Aug 2014 20:21:37 GMT attachment set https://svn.boost.org/trac10/ticket/8376 https://svn.boost.org/trac10/ticket/8376 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">ticket_8376.cpp</span> </li> </ul> <p> stand-alone test program for ticket <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8376" title="#8376: Bugs: difference of non-closed polygons returns closed polygon (closed: fixed)">#8376</a> </p> Ticket mkaravel Fri, 01 Aug 2014 20:21:56 GMT attachment set https://svn.boost.org/trac10/ticket/8376 https://svn.boost.org/trac10/ticket/8376 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">ticket_8376.out</span> </li> </ul> <p> output of test program for ticket <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8376" title="#8376: Bugs: difference of non-closed polygons returns closed polygon (closed: fixed)">#8376</a> </p> Ticket mkaravel Fri, 01 Aug 2014 20:23:54 GMT status changed; cc, resolution set https://svn.boost.org/trac10/ticket/8376#comment:4 https://svn.boost.org/trac10/ticket/8376#comment:4 <ul> <li><strong>cc</strong> <span class="trac-author">mkaravel</span> added </li> <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">worksforme</span> </li> </ul> <p> Please see attached test program and output. See also comments for ticket <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/9828" title="#9828: Bugs: boost::geometry::union_(...) creates redundant closing point (closed: fixed)">#9828</a>. </p> Ticket mkaravel Fri, 01 Aug 2014 20:26:28 GMT attachment set https://svn.boost.org/trac10/ticket/8376 https://svn.boost.org/trac10/ticket/8376 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">ticket_8375.cpp</span> </li> </ul> <p> Replace irrelevant attachment by an empty file </p> Ticket mkaravel Fri, 01 Aug 2014 20:27:26 GMT <link>https://svn.boost.org/trac10/ticket/8376#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8376#comment:5</guid> <description> <p> The attachment with file name ticket_8375.cpp was uploaded by error, and to avoid any confusion is has been replaced by an empty file. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>mkaravel</dc:creator> <pubDate>Tue, 05 Aug 2014 06:58:25 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/8376#comment:6 https://svn.boost.org/trac10/ticket/8376#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">worksforme</span> </li> </ul> Ticket mkaravel Tue, 05 Aug 2014 06:58:38 GMT status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/8376#comment:7 https://svn.boost.org/trac10/ticket/8376#comment:7 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</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.56.0</span> </li> </ul> Ticket