Merge pull request #571 from vissarion/fix/distance_acos
Fix nan result in geo distance
This commit is contained in:
commit
aede53101b
@ -30,6 +30,7 @@
|
||||
[*Bugfixes]
|
||||
|
||||
* [@https://github.com/boostorg/geometry/pull/553 553] Pass spheroid correctly in geographic comparable strategies.
|
||||
* [@https://github.com/boostorg/geometry/pull/571 571] Fix nan result in geographic distance.
|
||||
|
||||
[/=================]
|
||||
[heading Boost 1.69]
|
||||
|
@ -409,7 +409,7 @@ private :
|
||||
return non_iterative_case(lon2, lat2, lon3, lat3, spheroid);
|
||||
}
|
||||
|
||||
// Guess s14 (SPHERICAL)
|
||||
// Guess s14 (SPHERICAL) aka along-track distance
|
||||
typedef geometry::model::point
|
||||
<
|
||||
CT, 2,
|
||||
@ -425,7 +425,12 @@ private :
|
||||
|
||||
geometry::strategy::distance::haversine<CT> str(earth_radius);
|
||||
CT s13 = str.apply(p1, p3);
|
||||
CT s14 = acos( cos(s13/earth_radius) / cos(s34/earth_radius) ) * earth_radius;
|
||||
|
||||
//CT s14 = acos( cos(s13/earth_radius) / cos(s34/earth_radius) ) * earth_radius;
|
||||
CT cos_frac = cos(s13/earth_radius) / cos(s34/earth_radius);
|
||||
CT s14 = cos_frac >= 1 ? CT(0)
|
||||
: cos_frac <= -1 ? pi * earth_radius
|
||||
: acos(cos_frac) * earth_radius;
|
||||
|
||||
#ifdef BOOST_GEOMETRY_DEBUG_GEOGRAPHIC_CROSS_TRACK
|
||||
std::cout << "s34=" << s34 << std::endl;
|
||||
|
@ -351,6 +351,13 @@ void test_distance_point_segment(Strategy_pp const& strategy_pp,
|
||||
"SEGMENT(1 -1,1 0)",
|
||||
pp_distance("POINT(2 0)", "POINT(1 0)", strategy_pp),
|
||||
strategy_ps, true, true);
|
||||
|
||||
tester::apply("p-s-acos",
|
||||
"POINT(0 90)",
|
||||
"SEGMENT(90 0,0 1.000005)",
|
||||
pp_distance("POINT(0 90)", "POINT(0.3017072304435489 1.000018955050697)",
|
||||
strategy_pp),
|
||||
strategy_ps, true, true);
|
||||
}
|
||||
|
||||
template <typename Strategy_pp, typename Strategy_ps>
|
||||
|
Loading…
Reference in New Issue
Block a user