Boost C++ Libraries: Ticket #11675: sym_difference yields bad result for int polygons https://svn.boost.org/trac10/ticket/11675 <p> My "_TPolygon" type is actually a <strong>multi-polygon</strong>, based on a polygon type that is oriented <strong>counter-clockwise</strong> and <strong>open</strong> (not closed). Please consider the following example, which apparently works fine: </p> <pre class="wiki">tc::geo::polygon&lt;double&gt; polygonA; // tc::geo::polygon&lt;...&gt; is actually a MULTIPOLYGON, with polygons oriented COUNTER-CLOCKWISE and OPEN (not closed). boost::geometry::read_wkt("MULTIPOLYGON(((564 2394,1548 2850,2526 2916,2526 1073741823,564 1073741823,564 2394)))", polygonA); // does not throw boost::geometry::is_valid(polygonA); // returns true tc::geo::polygon&lt;double&gt; polygonB; boost::geometry::read_wkt("MULTIPOLYGON(((564 3252,2526 3252,2526 1073741823,564 1073741823,564 3252)))", polygonB); // does not throw boost::geometry::is_valid(polygonB); // returns true tc::geo::polygon&lt;double&gt; polygonC; boost::geometry::sym_difference(polygonA, polygonB, polygonC); // does not throw boost::geometry::is_valid(polygonC); // returns true // polygonC is now "MULTIPOLYGON(((564 3252,564 2394,1548 2850,2526 2916,2526 3252,564 3252)))" </pre><p> Note: <em>std::numeric_limits&lt;int&gt;::max()/2 == 1073741823</em> Now, simply replace <strong>double</strong> by <strong>int</strong>: </p> <pre class="wiki">tc::geo::polygon&lt;int&gt; polygonA; // tc::geo::polygon&lt;...&gt; is actually a MULTIPOLYGON, with polygons oriented COUNTER-CLOCKWISE and OPEN (not closed). boost::geometry::read_wkt("MULTIPOLYGON(((564 2394,1548 2850,2526 2916,2526 1073741823,564 1073741823,564 2394)))", polygonA); // does not throw boost::geometry::is_valid(polygonA); // returns true tc::geo::polygon&lt;int&gt; polygonB; boost::geometry::read_wkt("MULTIPOLYGON(((564 3252,2526 3252,2526 1073741823,564 1073741823,564 3252)))", polygonB); // does not throw boost::geometry::is_valid(polygonB); // returns true tc::geo::polygon&lt;int&gt; polygonC; boost::geometry::sym_difference(polygonA, polygonB, polygonC); // does not throw boost::geometry::is_valid(polygonC); // returns true TRACE( "===================== polygonC2=" &lt;&lt; polygonC ); // polygonC is now "MULTIPOLYGON(((564 3252,564 2394,1548 2850,2526 2916,2526 *!*333412*!*,564 3252)))" </pre><p> As you can see, one value is completely off. This seems to happen reliably whenever the input is based on int and contains large numbers. </p> <p> This issue may be related to Ticket <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/10658" title="#10658: Bugs: sym_difference yields bad result for int polygons (closed: fixed)">#10658</a>. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11675 Trac 1.4.3 sghanta05@… Thu, 19 Jul 2018 13:32:06 GMT <link>https://svn.boost.org/trac10/ticket/11675#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11675#comment:1</guid> <description> <p> Hey I am new to boost and I would like to work on this bug. Could someone guide me? </p> </description> <category>Ticket</category> </item> </channel> </rss>