[Boost-bugs] [Boost C++ Libraries] #11982: distance between point and linestring on spherical_equatorial ignores radius when using haversine.

Subject: [Boost-bugs] [Boost C++ Libraries] #11982: distance between point and linestring on spherical_equatorial ignores radius when using haversine.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-02-12 12:05:13


#11982: distance between point and linestring on spherical_equatorial ignores
radius when using haversine.
------------------------------+---------------------------
 Reporter: anonymous | Owner: barendgehrels
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: geometry
  Version: Boost 1.60.0 | Severity: Problem
 Keywords: |
------------------------------+---------------------------
 Distance between a point and a linestring is incorrect when using
 spherical_equatorial coordinates and haversine strategy. It looks like it
 is always using radius = 1.0.

 Example:
 {{{
 #include <iostream>
 #include <boost/geometry.hpp>

 namespace bg = boost::geometry;
 typedef bg::model::point<double, 2,
 bg::cs::spherical_equatorial<bg::degree> > pt;
 typedef bg::model::linestring<pt> pt_line;

 int main()
 {
     const double earthRadius = 6371.0 * 1000.0;
     pt oslo(10.733557, 59.911923);
     pt sandvika(10.521812, 59.887214);
     pt trondheim(10.4, 63.43);

     // works correct
     double d1 = bg::distance(sandvika, trondheim,
 bg::strategy::distance::haversine<double>(earthRadius));
     double d2 = bg::distance(oslo, trondheim,
 bg::strategy::distance::haversine<double>(earthRadius));
     std::cout << "Sandvika-Trondheim " << d1 << std::endl;
     std::cout << "Oslo-Trondheim " << d2 << std::endl;

     pt_line ll;
     ll.push_back(oslo);
     ll.push_back(sandvika);

     // Does not work
     double d3 = bg::distance(trondheim, ll,
 bg::strategy::distance::haversine<double>(earthRadius));
     std::cout << "Oslo-Sandvika - Trondheim " << d3 << std::endl;

     return 0;
 }
 }}}

 Output:
 {{{
 Sandvika-Trondheim 393992
 Oslo-Trondheim 391587
 Oslo-Sandvika - Trondheim 0.0614639
 }}}

 Note that the last number differs with a factor of 6371000 from the
 correct 391587.

 It looks like distance/backward_compatibility.hpp is ignoring the incoming
 strategy in last argument to apply.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11982>
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