diff options
| author | Charles Karney <charles@karney.com> | 2017-12-18 17:56:24 -0500 |
|---|---|---|
| committer | Charles Karney <charles@karney.com> | 2017-12-18 17:56:24 -0500 |
| commit | 2162ad57c190f5c924eb61fa47325c48fd894832 (patch) | |
| tree | 88924ecc806a98f53e662403f41a5d9ca63fca61 /src | |
| parent | ca9a448edc35149c1bdb5d90ffbdae88b43dadb1 (diff) | |
| download | PROJ-2162ad57c190f5c924eb61fa47325c48fd894832.tar.gz PROJ-2162ad57c190f5c924eb61fa47325c48fd894832.zip | |
Fix issue #715. Merge 1.49.1 of geodesic library (tagged as v1.49.1-c
in GeographicLib). Details:
Workaround bugs in handling of -0.0 in fmod and sin in Visual Studio 10,
11, and 12.
Relax unrealistically strict delta for GeodSolve59 in geodtest.
Diffstat (limited to 'src')
| -rw-r--r-- | src/geodesic.c | 25 | ||||
| -rw-r--r-- | src/geodesic.h | 2 | ||||
| -rw-r--r-- | src/geodtest.c | 2 |
3 files changed, 25 insertions, 4 deletions
diff --git a/src/geodesic.c b/src/geodesic.c index 84951d7f..233dc34c 100644 --- a/src/geodesic.c +++ b/src/geodesic.c @@ -185,8 +185,18 @@ static real AngNormalize(real x) { x = remainder(x, (real)(360)); return x != -180 ? x : 180; #else - x = fmod(x, (real)(360)); - return x <= -180 ? x + 360 : (x <= 180 ? x : x - 360); + real y = fmod(x, (real)(360)); +#if defined(_MSC_VER) && _MSC_VER < 1900 + /* + Before version 14 (2015), Visual Studio had problems dealing + with -0.0. Specifically + VC 10,11,12 and 32-bit compile: fmod(-0.0, 360.0) -> +0.0 + sincosdx has a similar fix. + python 2.7 on Windows 32-bit machines has the same problem. + */ + if (x == 0) y = x; +#endif + return y <= -180 ? y + 360 : (y <= 180 ? y : y - 360); #endif } @@ -231,6 +241,17 @@ static void sincosdx(real x, real* sinx, real* cosx) { r *= degree; /* Possibly could call the gnu extension sincos */ s = sin(r); c = cos(r); +#if defined(_MSC_VER) && _MSC_VER < 1900 + /* + Before version 14 (2015), Visual Studio had problems dealing + with -0.0. Specifically + VC 10,11,12 and 32-bit compile: fmod(-0.0, 360.0) -> +0.0 + VC 12 and 64-bit compile: sin(-0.0) -> +0.0 + AngNormalize has a similar fix. + python 2.7 on Windows 32-bit machines has the same problem. + */ + if (x == 0) s = x; +#endif switch ((unsigned)q & 3U) { case 0U: *sinx = s; *cosx = c; break; case 1U: *sinx = c; *cosx = -s; break; diff --git a/src/geodesic.h b/src/geodesic.h index ab18a01f..43fd0d1f 100644 --- a/src/geodesic.h +++ b/src/geodesic.h @@ -132,7 +132,7 @@ * The patch level of the geodesic library. (This tracks the version of * GeographicLib.) **********************************************************************/ -#define GEODESIC_VERSION_PATCH 0 +#define GEODESIC_VERSION_PATCH 1 /** * Pack the version components into a single integer. Users should not rely on diff --git a/src/geodtest.c b/src/geodtest.c index 5b41b72c..0f2c0ac2 100644 --- a/src/geodtest.c +++ b/src/geodtest.c @@ -505,7 +505,7 @@ static int GeodSolve59() { geod_inverse(&g, 5, 0.00000000000001, 10, 180, &s12, &azi1, &azi2); result += assertEquals(azi1, 0.000000000000035, 1.5e-14); result += assertEquals(azi2, 179.99999999999996, 1.5e-14); - result += assertEquals(s12, 18345191.174332713, 2.5e-9); + result += assertEquals(s12, 18345191.174332713, 5e-9); return result; } |
