Boost C++ Libraries: Ticket #9206: intersection of non-closed polygons returns closed polygon https://svn.boost.org/trac10/ticket/9206 <p> The output multi-polygon from boost::geometry::intersection 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 closed polygon. </p> <p> <em>Note: The sym_difference and difference algorithms have the same problem which I filed as separate tickets <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>, <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>.</em> </p> <p> This is the data used as input to intersection: </p> <pre class="wiki">_TPolygon&lt;int&gt; const polygon = _TPolygon&lt;int&gt;("MULTIPOLYGON(((1374 1092,1734 1092,3174 2526,3174 2886,1374 2886)))") &amp; _TPolygon&lt;int&gt;("POLYGON((2817 2449,2817 2603,3134 2603,3134 2449,2817 2449))"); </pre><p> This is the resulting multi-polygon, with the polygon being closed: </p> <pre class="wiki">MULTIPOLYGON(((3134 2486,3134 2603,2817 2603,2817 2449,3096 2449,3134 2486))) </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&amp;(Geometry const&amp; geometry) const { _TPolygon&lt; T &gt; polygonOut; boost::geometry::intersection(*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/9206 Trac 1.4.3 vschoech@… Wed, 13 Nov 2013 14:49:50 GMT version changed https://svn.boost.org/trac10/ticket/9206#comment:1 https://svn.boost.org/trac10/ticket/9206#comment:1 <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 boost 1.55.0. </p> Ticket mkaravel Fri, 01 Aug 2014 11:56:42 GMT attachment set https://svn.boost.org/trac10/ticket/9206 https://svn.boost.org/trac10/ticket/9206 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">ticket_9206.out</span> </li> </ul> <p> output of the ticket_9206.cpp program </p> Ticket mkaravel Fri, 01 Aug 2014 12:01:58 GMT <link>https://svn.boost.org/trac10/ticket/9206#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9206#comment:2</guid> <description> <p> I have attached my own stand-alone test program. </p> <p> First of all I am checking whether the two polygons are valid (new functionality in develop branch and soon in boost 1.56). As you can see the second polygon is reported as invalid. Indeed it is supposed to be counter-clockwise and open, but it is given as clockwise and open. </p> <p> So after I correct this polygon, I run intersects and display the output in WKT format and using boost::geometry::dsv. I also print the number of points of the output polygon. As you can see, the WKT output "closes" the polygon. This behavior is new in the develop branch and in the upcoming boost 1.56 release: the WKT description of a polygon always reports the polygon as if it were closed. On the other hand the dsv output displays the polygon as open, which is also in sync with what num_points reports: 5 points. So the resulting polygon (at least with my program) is still open, but in order to see that you cannot rely on the WKT output. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>mkaravel</dc:creator> <pubDate>Fri, 01 Aug 2014 12:04:06 GMT</pubDate> <title>status changed; cc, resolution set https://svn.boost.org/trac10/ticket/9206#comment:3 https://svn.boost.org/trac10/ticket/9206#comment:3 <ul> <li><strong>cc</strong> <span class="trac-author">mkaravel</span> added </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">worksforme</span> </li> </ul> Ticket mkaravel Fri, 01 Aug 2014 13:48:53 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/9206#comment:4 https://svn.boost.org/trac10/ticket/9206#comment:4 <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 Fri, 01 Aug 2014 13:49:03 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/9206#comment:5 https://svn.boost.org/trac10/ticket/9206#comment:5 <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">invalid</span> </li> </ul> Ticket mkaravel Fri, 01 Aug 2014 13:56:30 GMT attachment set https://svn.boost.org/trac10/ticket/9206 https://svn.boost.org/trac10/ticket/9206 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">ticket_9206.cpp</span> </li> </ul> <p> stand-alone test program to be used with the BG develop branch </p> Ticket