aboutsummaryrefslogtreecommitdiff
path: root/src/PJ_robin.c
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2018-05-06 17:43:26 +0300
committerKristian Evers <kristianevers@gmail.com>2018-05-08 09:16:07 +0200
commit58cbb9fe4f89b9febd780f7bdcfa4c2bb74a723e (patch)
treedec50c945b01d09c5cf94d0665a6996e2d34ae5d /src/PJ_robin.c
parent8fef2126f1c9fa17b79e6669f4457c299c0e33bf (diff)
downloadPROJ-58cbb9fe4f89b9febd780f7bdcfa4c2bb74a723e.tar.gz
PROJ-58cbb9fe4f89b9febd780f7bdcfa4c2bb74a723e.zip
Replace int typecasts with calls to lround to avoid bad conversions on NaN input. Added test to check for those cases.
Diffstat (limited to 'src/PJ_robin.c')
-rw-r--r--src/PJ_robin.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/PJ_robin.c b/src/PJ_robin.c
index a1d5ad4d..ca9e5fc7 100644
--- a/src/PJ_robin.c
+++ b/src/PJ_robin.c
@@ -78,12 +78,12 @@ static const struct COEFS Y[] = {
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
- int i;
+ long i;
double dphi;
(void) P;
dphi = fabs(lp.phi);
- i = isnan(lp.phi) ? -1 : (int)floor(dphi * C1);
+ i = isnan(lp.phi) ? -1 : lround(floor(dphi * C1));
if( i < 0 ){
proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION);
return xy;
@@ -100,7 +100,7 @@ static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
- int i;
+ long i;
double t, t1;
struct COEFS T;
int iters;
@@ -118,7 +118,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
}
} else { /* general problem */
/* in Y space, reduce to table interval */
- i = isnan(lp.phi) ? -1 : (int)floor(lp.phi * NODES);
+ i = isnan(lp.phi) ? -1 : lround(floor(lp.phi * NODES));
if( i < 0 || i >= NODES ) {
proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION);
return lp;