aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Karney <charles@karney.com>2018-03-19 09:53:34 -0400
committerGitHub <noreply@github.com>2018-03-19 09:53:34 -0400
commita2c0a414f75af15a4b9e53d92adf91e8131fb5f2 (patch)
tree3953bbc413a1c5f05ac548dbaf27d5371e7ef97f /src
parentdb3e0ae30446498cec7e7f931d9be2ed65547691 (diff)
parent6978bd29ce1e6ced6cdc224dbbff9ed7fe3dcb05 (diff)
downloadPROJ-a2c0a414f75af15a4b9e53d92adf91e8131fb5f2.tar.gz
PROJ-a2c0a414f75af15a4b9e53d92adf91e8131fb5f2.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.c45
-rw-r--r--src/geodesic.h2
-rw-r--r--src/geodtest.c3
3 files changed, 32 insertions, 18 deletions
diff --git a/src/geodesic.c b/src/geodesic.c
index 40dffbc1..91af23f9 100644
--- a/src/geodesic.c
+++ b/src/geodesic.c
@@ -193,12 +193,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);
@@ -239,7 +239,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 */
@@ -248,13 +249,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) {
@@ -658,6 +659,14 @@ real geod_genposition(const struct geod_geodesicline* l,
S12 = l->c2 * atan2(salp12, calp12) + l->A4 * (B42 - l->B41);
}
+ /* 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)
@@ -1127,7 +1136,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--) {
@@ -1894,7 +1903,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 = 0, lon = 0, 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);
@@ -2031,6 +2042,8 @@ unsigned geod_polygon_testedge(const struct geod_geodesic* g,
tempsum = p->A[0];
crossings = p->crossings;
{
+ /* 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,
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 8cc48134..1025ce08 100644
--- a/src/geodtest.c
+++ b/src/geodtest.c
@@ -616,7 +616,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;
}