aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/apps/gie.cpp3
-rw-r--r--src/projections/krovak.cpp16
2 files changed, 16 insertions, 3 deletions
diff --git a/src/apps/gie.cpp b/src/apps/gie.cpp
index 912113b4..f0f7968f 100644
--- a/src/apps/gie.cpp
+++ b/src/apps/gie.cpp
@@ -1005,7 +1005,8 @@ Tell GIE what to expect, when transforming the ACCEPTed input
else
d = proj_xyz_dist (co, ce);
- if (d > T.tolerance)
+ // Test written like that to handle NaN
+ if (!(d <= T.tolerance))
return expect_message (d, args);
succs++;
diff --git a/src/projections/krovak.cpp b/src/projections/krovak.cpp
index 591f8dcc..c30be411 100644
--- a/src/projections/krovak.cpp
+++ b/src/projections/krovak.cpp
@@ -115,7 +115,14 @@ static PJ_XY e_forward (PJ_LP lp, PJ *P) { /* Ellipsoidal, forwar
deltav = -lp.lam * Q->alpha;
s = asin(cos(Q->ad) * sin(u) + sin(Q->ad) * cos(u) * cos(deltav));
- d = asin(cos(u) * sin(deltav) / cos(s));
+ const double cos_s = cos(s);
+ if( cos_s < 1e-12 )
+ {
+ xy.x = 0;
+ xy.y = 0;
+ return xy;
+ }
+ d = asin(cos(u) * sin(deltav) / cos_s);
eps = Q->n * d;
rho = Q->rho0 * pow(tan(S0 / 2. + M_PI_4) , Q->n) / pow(tan(s / 2. + M_PI_4) , Q->n);
@@ -148,7 +155,12 @@ static PJ_LP e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal, invers
eps = atan2(xy.y, xy.x);
d = eps / sin(S0);
- s = 2. * (atan( pow(Q->rho0 / rho, 1. / Q->n) * tan(S0 / 2. + M_PI_4)) - M_PI_4);
+ if( rho == 0.0 ) {
+ s = M_PI_2;
+ }
+ else {
+ s = 2. * (atan( pow(Q->rho0 / rho, 1. / Q->n) * tan(S0 / 2. + M_PI_4)) - M_PI_4);
+ }
u = asin(cos(Q->ad) * sin(s) - sin(Q->ad) * cos(s) * cos(d));
deltav = asin(cos(s) * sin(d) / cos(u));