[Boost-bugs] [Boost C++ Libraries] #13353: Distance segment-box wrong result for spherical CS

Subject: [Boost-bugs] [Boost C++ Libraries] #13353: Distance segment-box wrong result for spherical CS
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-12-20 13:07:53


#13353: Distance segment-box wrong result for spherical CS
------------------------------------------------+--------------------------
 Reporter: Vissarion Fisikopoulos <fisikop@…> | Owner: Barend
                                                | Gehrels
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: geometry
  Version: Boost Development Trunk | Severity: Problem
 Keywords: |
------------------------------------------------+--------------------------
 The distance algorithm for segment-box for spherical CS does not treat
 correctly some cases. For example when the segment endpoints are not
 inside the box but the segment intersects it (because of curvature,
 segment follow a geodesic/great circle but box horizontal segment not). An
 example code follows:

 {{{
 #include <iostream>
 #include <boost/geometry.hpp>
 #include <boost/geometry/geometries/point_xy.hpp>

 namespace bg = boost::geometry;

 template <typename point, typename CT>
 void test_all_geometry_types(CT radius_multiplier)
 {
     bg::model::segment<point> s;
     bg::model::box<point> b;

     std::cout.precision(15);

     {
         bg::read_wkt("SEGMENT(10 9.99, 20 9.99)", s);
         bg::read_wkt("BOX(10 10, 20 20)", b);

         std::cout << "dist=" << bg::distance(b, s) * radius_multiplier <<
 std::endl;
         std::cout << "disj=" << bg::disjoint(b, s) << std::endl;
     }
     {
         bg::read_wkt("SEGMENT(10 10, 20 10)", s);
         bg::read_wkt("BOX(10 10, 20 20)", b);

         std::cout << "dist=" << bg::distance(b, s) * radius_multiplier <<
 std::endl;
         std::cout << "disj=" << bg::disjoint(b, s) << std::endl;
     }
 }

 int main()
 {
     typedef double CT;

     std::cout << "Cartesian" << std::endl;
     typedef bg::model::point<CT, 2, bg::cs::cartesian > cpoint;
     test_all_geometry_types<cpoint>(1);

     std::cout << "Spherical" << std::endl;
     typedef bg::model::point<CT, 2,
 bg::cs::spherical_equatorial<bg::degree> > spoint;
 test_all_geometry_types<spoint>(bg::formula::mean_radius<CT>(bg::srs::spheroid<CT>()));

     return 0;
 }
 }}}

 the output in my system (i.e. gcc version 4.8.5 (Ubuntu
 4.8.5-2ubuntu1~14.04.1)) is

 {{{
 Cartesian
 dist=0.00999999999999979
 disj=1
 dist=0
 disj=0
 Spherical
 dist=63710.0877141492
 disj=0
 dist=0
 disj=0
 }}}

 the case where dist=63710.0877141492 and disj=0 is wrong since the objects
 intersect but the distance is not 0.

-- 
Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13353>
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-12-20 13:15:07 UTC