Boost C++ Libraries: Ticket #9756: boost::geometry::union_ no result https://svn.boost.org/trac10/ticket/9756 <p> I'm trying to merge some polygons using boost::geometry::union_ but the output vector is empty for some entries. </p> <p> here is an example : </p> <pre class="wiki">#include &lt;iostream&gt; #include &lt;vector&gt; #include &lt;boost/geometry.hpp&gt; #include &lt;boost/geometry/geometries/point_xy.hpp&gt; #include &lt;boost/geometry/geometries/polygon.hpp&gt; #include &lt;boost/geometry/io/wkt/wkt.hpp&gt; #include &lt;boost/foreach.hpp&gt; int main() { typedef boost::geometry::model::polygon&lt;boost::geometry::model::d2::point_xy&lt;double&gt; &gt; polygon; polygon green, blue; boost::geometry::read_wkt( "POLYGON((440820.110024126 4047009.80267429, 440806.545727707 4046942.39533656, 440797.171880196 4046895.8425726, 440804.202135392 4046888.73092639, 440813.573458131 4046935.27114371, 440827.140279322 4047002.69102807))", green); boost::geometry::read_wkt( "POLYGON((440855.857887967 4046932.1248641, 440813.740724389 4046942.21109839, 440806.376538684 4046935.44583646, 440848.493702262 4046925.35960217))", blue); if(boost::geometry::area(green) &lt; 0) boost::geometry::reverse(green); if(boost::geometry::area(blue) &lt; 0 ) boost::geometry::reverse(blue); std::vector&lt;polygon&gt; output; boost::geometry::union_(green, blue, output); std::cout &lt;&lt; " output size is : " &lt;&lt; output.size() &lt;&lt; std::endl; int i = 0; std::cout &lt;&lt; "green || blue:" &lt;&lt; std::endl; BOOST_FOREACH(polygon const&amp; p, output) { std::cout &lt;&lt; i++ &lt;&lt; ": " &lt;&lt; boost::geometry::area(p) &lt;&lt; std::endl; } system("pause"); return 0; } </pre><p> when I drew the two polygons I obtained : (attached image) </p> <p> but the result of the code above was : </p> <p> output size is : 0 </p> <p> green | | blue: </p> <p> Press any key to continue . . . </p> <p> is this a bug in this function or there is a mistake in my code ? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9756 Trac 1.4.3 anonymous Fri, 07 Mar 2014 21:28:30 GMT attachment set https://svn.boost.org/trac10/ticket/9756 https://svn.boost.org/trac10/ticket/9756 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">testPolygons.PNG</span> </li> </ul> Ticket Barend Gehrels Sat, 22 Mar 2014 23:01:17 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/9756#comment:1 https://svn.boost.org/trac10/ticket/9756#comment:1 <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">invalid</span> </li> </ul> <p> Your polygons are not closed. Please close them in the WKT, or call geometry::correct. If they are closed, the union works correctly. Or use a non-closed polygon as type. </p> Ticket