A bug is the treatment of NaNs by Geodesic::Inverse was introduced in
version 1.25. The symptoms is that finite bogus results are returned
when a NaN is provided as one of input arguments; for example
$ echo 0 10 20 nan | GeodSolve -i -70.06176456 -90.00000000 9987119.260
The following patch fixes this bug. This will be included in the next
release of GeographicLib.
diff --git a/src/Geodesic.cpp b/src/Geodesic.cpp index a428ae4..d62e518 100644 --- a/src/Geodesic.cpp +++ b/src/Geodesic.cpp @@ -710,7 +710,8 @@ namespace GeographicLib { calp1 = sbet12a - cbet2 * sbet1 * Math::sq(somg12) / (1 - comg12); } } - if (salp1 > 0) // Sanity check on starting guess + // Sanity check on starting guess. Backwards check allows NaN through. + if (!(salp1 <= 0)) SinCosNorm(salp1, calp1); else { salp1 = 1; calp1 = 0; diff --git a/src/GeodesicExact.cpp b/src/GeodesicExact.cpp index 47479e7..3912a24 100644 --- a/src/GeodesicExact.cpp +++ b/src/GeodesicExact.cpp @@ -721,7 +721,8 @@ namespace GeographicLib { calp1 = sbet12a - cbet2 * sbet1 * Math::sq(somg12) / (1 - comg12); } } - if (salp1 > 0) // Sanity check on starting guess + // Sanity check on starting guess. Backwards check allows NaN through. + if (!(salp1 <= 0)) SinCosNorm(salp1, calp1); else { salp1 = 1; calp1 = 0;