Boost C++ Libraries: Ticket #11725: union_ fails to create holes https://svn.boost.org/trac10/ticket/11725 <p> When uniting 2 polygons union_ does not create holes when it can also express the resulting polygon as a single ring, even if that ring has self-tangencies, which makes the polygon invalid. </p> <p> The following code </p> <pre class="wiki"> typedef double FloatType; typedef model::d2::point_xy&lt;FloatType&gt; Point; typedef model::polygon&lt;Point&gt; Polygon; typedef model::multi_polygon&lt;Polygon&gt; MultiPolygon; typedef model::ring&lt;Point&gt; Ring; typedef model::box&lt;Point&gt; Box; typedef model::linestring&lt;Point&gt; LineString; int main(int argc, char *argv[]) { using namespace std; Polygon p1, p2; boost::geometry::read_wkt("POLYGON((0 0, 0 1, 3 1, 3 0, 0 0))", p1); boost::geometry::read_wkt("POLYGON((0 1, 0 3, 3 3, 3 1, 2 2, 1 2 , 1 1, 0 1))", p2); boost::geometry::correct(p1); boost::geometry::correct(p2); MultiPolygon p3; boost::geometry::union_(p1, p2, p3); boost::geometry::correct(p3); cout &lt;&lt; "p1: " &lt;&lt; boost::geometry::wkt(p1) &lt;&lt; endl; cout &lt;&lt; "p2: " &lt;&lt; boost::geometry::wkt(p2) &lt;&lt; endl; cout &lt;&lt; "p3: " &lt;&lt; boost::geometry::wkt(p3) &lt;&lt; endl; cout &lt;&lt; "is_simple(p1): " &lt;&lt; boost::geometry::is_simple(p1) &lt;&lt; endl; cout &lt;&lt; "is_simple(p2): " &lt;&lt; boost::geometry::is_simple(p2) &lt;&lt; endl; cout &lt;&lt; "is_simple(p3): " &lt;&lt; boost::geometry::is_simple(p3) &lt;&lt; endl; cout &lt;&lt; "is_valid(p1): " &lt;&lt; boost::geometry::is_valid(p1) &lt;&lt; endl; cout &lt;&lt; "is_valid(p2): " &lt;&lt; boost::geometry::is_valid(p2) &lt;&lt; endl; cout &lt;&lt; "is_valid(p3): " &lt;&lt; boost::geometry::is_valid(p3) &lt;&lt; endl; return 0; } </pre><p> has the output </p> <pre class="wiki">p1: POLYGON((0 0,0 1,3 1,3 0,0 0)) p2: POLYGON((0 1,0 3,3 3,3 1,2 2,1 2,1 1,0 1)) p3: MULTIPOLYGON(((0 1,0 3,3 3,3 1,2 2,1 2,1 1,3 1,3 0,0 0,0 1))) is_simple(p1): 1 is_simple(p2): 1 is_simple(p3): 1 is_valid(p1): 1 is_valid(p2): 1 is_valid(p3): 0 </pre><p> but p3 should be </p> <pre class="wiki">MULTIPOLYGON(((0 1,0 3,3 3,3 0,0 0,0 1),(3 1,2 2,1 2,1 1,3 1))) </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11725 Trac 1.4.3 jan.kleemann@… Thu, 15 Oct 2015 06:14:40 GMT owner, component changed https://svn.boost.org/trac10/ticket/11725#comment:1 https://svn.boost.org/trac10/ticket/11725#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Marshall Clow</span> to <span class="trac-author">Barend Gehrels</span> </li> <li><strong>component</strong> <span class="trac-field-old">algorithm</span> → <span class="trac-field-new">geometry</span> </li> </ul> Ticket jan.kleemann@… Thu, 15 Oct 2015 11:53:53 GMT <link>https://svn.boost.org/trac10/ticket/11725#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11725#comment:2</guid> <description> <p> difference has the same problem: </p> <pre class="wiki">p1: POLYGON((0 0,0 3,3 3,3 0,0 0)) p2: POLYGON((3 1,1 1,1 2,2 2,3 1)) is_valid(p1): 1 is_valid(p2): 1 p1 - p2: MULTIPOLYGON(((3 1,3 0,0 0,0 3,3 3,3 1,2 2,1 2,1 1,3 1))) is_valid(p1 - p2): 0 </pre><p> Should also be </p> <pre class="wiki">p1 - p2: MULTIPOLYGON(((0 1,0 3,3 3,3 0,0 0,0 1),(3 1,2 2,1 2,1 1,3 1))) </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Barend Gehrels</dc:creator> <pubDate>Wed, 23 Mar 2016 15:28:42 GMT</pubDate> <title>status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/11725#comment:3 https://svn.boost.org/trac10/ticket/11725#comment:3 <ul> <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">fixed</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.61.0</span> </li> </ul> <p> Thanks for the report. It is fixed now in branch feature/cluster_touch. Hope to get it in 1.61 </p> Ticket jan.kleemann@… Wed, 23 Mar 2016 15:39:49 GMT <link>https://svn.boost.org/trac10/ticket/11725#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11725#comment:4</guid> <description> <p> Nice! Thank you for your work. </p> </description> <category>Ticket</category> </item> </channel> </rss>