[Boost-bugs] [Boost C++ Libraries] #11789: Boost 1.59.0: geometry::intersection() asserts for spherical_equatorial coordinate system

Subject: [Boost-bugs] [Boost C++ Libraries] #11789: Boost 1.59.0: geometry::intersection() asserts for spherical_equatorial coordinate system
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-11-09 14:45:06


#11789: Boost 1.59.0: geometry::intersection() asserts for spherical_equatorial
coordinate system
--------------------------------------+---------------------------
 Reporter: Dave Stacey <drstacey@…> | Owner: barendgehrels
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: geometry
  Version: Boost 1.59.0 | Severity: Problem
 Keywords: |
--------------------------------------+---------------------------
 For disjoint polygons, geometry::intersection() assert()s when used with
 the spherical_equatorial coordinate system. assert() comes from
 geometry::math::detail::normalize_spheroidal_coordinates<>::apply(), as
 shown by the following code:

 {{{
 #include <iostream>
 #include <deque>

 #include <boost/geometry.hpp>
 #include <boost/geometry/geometries/point_xy.hpp>
 #include <boost/geometry/geometries/polygon.hpp>
 #include <boost/geometry/geometries/adapted/c_array.hpp>
 #include <boost/foreach.hpp>

 typedef boost::geometry::cs::spherical_equatorial<boost::geometry::degree>
 coordinate_system;
 BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(coordinate_system)

 int main()
 {
     typedef boost::geometry::model::point<double, 2, coordinate_system>
 point_t;
     typedef boost::geometry::model::polygon<point_t> 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<polygon_t> output;
     // assert() comes from the following call...
     boost::geometry::intersection(green, blue, output);

     int i = 0;
     std::cout << "green && blue:" << std::endl;
     BOOST_FOREACH(polygon_t const& p, output)
     {
         std::cout << i++ << ": " << boost::geometry::area(p) << std::endl;
     }

     return 0;
 }
 }}}

 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.

 assert() is only generated when using the cs::spherical_equatorial
 coordinate system; if cs::cartesian is used instead then the assert() is
 not generated.

 Many thanks for your work on Boost and for looking at this ticket.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11789>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:19 UTC