Boost C++ Libraries: Ticket #11789: Boost 1.59.0: geometry::intersection() asserts for spherical_equatorial coordinate system https://svn.boost.org/trac10/ticket/11789 <p> For disjoint polygons, geometry::intersection() assert()s when used with the spherical_equatorial coordinate system. assert() comes from geometry::math::detail::normalize_spheroidal_coordinates&lt;&gt;::apply(), as shown by the following code: </p> <pre class="wiki">#include &lt;iostream&gt; #include &lt;deque&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/geometries/adapted/c_array.hpp&gt; #include &lt;boost/foreach.hpp&gt; typedef boost::geometry::cs::spherical_equatorial&lt;boost::geometry::degree&gt; coordinate_system; BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(coordinate_system) int main() { typedef boost::geometry::model::point&lt;double, 2, coordinate_system&gt; point_t; typedef boost::geometry::model::polygon&lt;point_t&gt; polygon_t; double green_pts[][2] = { {-4.5726431789237223,52.142932977753595}, {-4.5743166242433153,52.143359442355219}, {-4.5739141406075410,52.143957260988416}, {-4.5722406991324354,52.143530796430468}, {-4.5726431789237223,52.142932977753595}}; polygon_t green; boost::geometry::append(green, green_pts); double blue_pts[][2] = { {-4.5714644516017975,52.143819810922480}, {-4.5670821923630358,52.143819810922480}, {-4.5670821923630358,52.143649055226163}, {-4.5714644516017975,52.143649055226163}, {-4.5714644516017975,52.143819810922480}}; polygon_t blue; boost::geometry::append(blue, green_pts); std::deque&lt;polygon_t&gt; output; // assert() comes from the following call... boost::geometry::intersection(green, blue, output); int i = 0; std::cout &lt;&lt; "green &amp;&amp; blue:" &lt;&lt; std::endl; BOOST_FOREACH(polygon_t const&amp; p, output) { std::cout &lt;&lt; i++ &lt;&lt; ": " &lt;&lt; boost::geometry::area(p) &lt;&lt; std::endl; } return 0; } </pre><p> assert() is generated in the call to geometry::intersection(). Tested with both g++-4.9.3 and MSVC 2005 SP1. This is a regression on Boost 1.57.0, where the assert() is not produced. </p> <p> assert() is only generated when using the cs::spherical_equatorial coordinate system; if cs::cartesian is used instead then the assert() is not generated. </p> <p> Many thanks for your work on Boost and for looking at this ticket. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11789 Trac 1.4.3 Dave Stacey <drstacey@…> Thu, 12 Nov 2015 09:21:26 GMT <link>https://svn.boost.org/trac10/ticket/11789#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11789#comment:1</guid> <description> <p> Looking at the normalize_spheroidal_coordinates&lt;&gt;::apply() code, I tried defining BOOST_GEOMETRY_NORMALIZE_LATITUDE, but this did not fix the assert(). </p> <p> I also tried calling geometry::correct() on the two polygons before calling geometry::intersection(), but likewise this had no effect and the assert() still occured. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>awulkiew</dc:creator> <pubDate>Mon, 25 Jan 2016 19:48:51 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11789#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11789#comment:2</guid> <description> <p> This assertion fails because <code>expand()</code> function is called for Points containing very big integral coordinates. The reason is that currently, by default, floating-point coordinates are rescaled into integral coordinates internally in set operations and these integral coordinates are passed into <code>expand()</code> to calculate <a class="missing wiki">BoundingBoxes</a>. This probably also means that since these coordinates are normalized, the result is not correct. </p> <p> To fix it we could disable the rescaling entirely or for non-cartesian coordinate systems, or always use cartesian <code>robust_point_type</code> in rescale policy. </p> <p> To work around it, for now you could disable the rescaling by defining <code>BOOST_GEOMETRY_NO_ROBUSTNESS</code>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>awulkiew</dc:creator> <pubDate>Sun, 06 Mar 2016 21:43:34 GMT</pubDate> <title>status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/11789#comment:3 https://svn.boost.org/trac10/ticket/11789#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> Fix: <a class="ext-link" href="https://github.com/boostorg/geometry/pull/341"><span class="icon">​</span>https://github.com/boostorg/geometry/pull/341</a> </p> Ticket