diff options
| author | Charles Karney <charles@karney.com> | 2018-03-19 09:53:34 -0400 |
|---|---|---|
| committer | Kristian Evers <kristianevers@gmail.com> | 2018-03-19 15:07:21 +0100 |
| commit | bb69e6e578a36a8501625f1239714d88b1685f67 (patch) | |
| tree | babf431a583aa9ea40b14a62feebf120f5803bf1 /src | |
| parent | 061e32f5750dc5eb11530da54e728651615eb6db (diff) | |
| download | PROJ-bb69e6e578a36a8501625f1239714d88b1685f67.tar.gz PROJ-bb69e6e578a36a8501625f1239714d88b1685f67.zip | |
Merge pull request #868 from cffk/geod-1.49.3
Patch 1.49.3 for geodesic package.
Closes #826, partially closes #843.
Diffstat (limited to 'src')
| -rw-r--r-- | src/geodesic.c | 49 | ||||
| -rw-r--r-- | src/geodesic.h | 2 | ||||
| -rw-r--r-- | src/geodtest.c | 3 |
3 files changed, 34 insertions, 20 deletions
diff --git a/src/geodesic.c b/src/geodesic.c index 23557b5c..a854c1f0 100644 --- a/src/geodesic.c +++ b/src/geodesic.c @@ -192,12 +192,12 @@ static real AngNormalize(real x) { 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. - */ + * 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); @@ -238,7 +238,8 @@ static void sincosdx(real x, real* sinx, real* cosx) { r = remquo(x, (real)(90), &q); #else r = fmod(x, (real)(360)); - q = (int)(floor(r / 90 + (real)(0.5))); + /* check for NaN */ + q = r == r ? (int)(floor(r / 90 + (real)(0.5))) : 0; r -= 90 * q; #endif /* now abs(r) <= 45 */ @@ -247,13 +248,13 @@ static void sincosdx(real x, real* sinx, real* cosx) { 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. - */ + * 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) { @@ -657,7 +658,15 @@ real geod_genposition(const struct geod_geodesicline* l, S12 = l->c2 * atan2(salp12, calp12) + l->A4 * (B42 - l->B41); } - if (outmask & GEOD_LATITUDE) + /* In the pattern + * + * if ((outmask & GEOD_XX) && pYY) + * *pYY = YY; + * + * the second check "&& pYY" is redundant. It's there to make the CLang + * static analyzer happy. + */ + if ((outmask & GEOD_LATITUDE) && plat2) *plat2 = lat2; if (outmask & GEOD_LONGITUDE) *plon2 = lon2; @@ -1126,7 +1135,7 @@ real SinCosSeries(boolx sinp, real sinx, real cosx, const real c[], int n) { real ar, y0, y1; c += (n + sinp); /* Point to one beyond last element */ ar = 2 * (cosx - sinx) * (cosx + sinx); /* 2 * cos(2 * x) */ - y0 = n & 1 ? *--c : 0; y1 = 0; /* accumulators for sum */ + y0 = (n & 1) ? *--c : 0; y1 = 0; /* accumulators for sum */ /* Now n is even */ n /= 2; while (n--) { @@ -1893,7 +1902,9 @@ void geod_polygon_addedge(const struct geod_geodesic* g, struct geod_polygon* p, real azi, real s) { if (p->num) { /* Do nothing is num is zero */ - real lat, lon, S12 = 0; /* Initialize S12 to stop Visual Studio warning */ + /* Initialize S12 to stop Visual Studio warning. Initialization of lat and + * lon is to make CLang static analyzer happy. */ + real lat = 0, lon = 0, S12 = 0; geod_gendirect(g, p->lat, p->lon, azi, GEOD_LONG_UNROLL, s, &lat, &lon, 0, 0, 0, 0, 0, p->polyline ? 0 : &S12); @@ -2030,7 +2041,9 @@ unsigned geod_polygon_testedge(const struct geod_geodesic* g, tempsum = p->A[0]; crossings = p->crossings; { - real lat, lon, s12, S12; + /* Initialization of lat, lon, and S12 is to make CLang static analyzer + happy. */ + real lat = 0, lon = 0, s12, S12 = 0; geod_gendirect(g, p->lat, p->lon, azi, GEOD_LONG_UNROLL, s, &lat, &lon, 0, 0, 0, 0, 0, &S12); diff --git a/src/geodesic.h b/src/geodesic.h index cd7c2b70..f9d612f3 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 2 +#define GEODESIC_VERSION_PATCH 3 /** * Pack the version components into a single integer. Users should not rely on diff --git a/src/geodtest.c b/src/geodtest.c index de729407..b62fbbbc 100644 --- a/src/geodtest.c +++ b/src/geodtest.c @@ -614,7 +614,8 @@ static int GeodSolve73() { &lat2, &lon2, &azi2); result += assertEquals(lat2, 81.04623, 0.5e-5); result += assertEquals(lon2, -170, 0.5e-5); - result += assertEquals(azi2, 0, 0.5e-5); + result += azi2 == 0 ? 0 : 1; + result += 1/azi2 > 0 ? 0 : 1; /* Check that azi2 = +0.0 not -0.0 */ return result; } |
