diff options
| -rw-r--r-- | src/projections/misrsom.cpp | 8 | ||||
| -rw-r--r-- | src/projections/omerc.cpp | 4 | ||||
| -rw-r--r-- | test/gie/builtins.gie | 7 |
3 files changed, 17 insertions, 2 deletions
diff --git a/src/projections/misrsom.cpp b/src/projections/misrsom.cpp index c53f22a1..d16dd62d 100644 --- a/src/projections/misrsom.cpp +++ b/src/projections/misrsom.cpp @@ -151,10 +151,14 @@ static PJ_LP e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal, inverse */ lamdp -= TOL; spp = sin(phidp); sppsq = spp * spp; + const double denom = 1. - sppsq * (1. + Q->u); + if( denom == 0.0 ) { + proj_errno_set(P, PJD_ERR_NON_CONVERGENT); + return proj_coord_error().lp; + } lamt = atan(((1. - sppsq * P->rone_es) * tan(lamdp) * Q->ca - spp * Q->sa * sqrt((1. + Q->q * dd) * ( - 1. - sppsq) - sppsq * Q->u) / cos(lamdp)) / (1. - sppsq - * (1. + Q->u))); + 1. - sppsq) - sppsq * Q->u) / cos(lamdp)) / denom); sl = lamt >= 0. ? 1. : -1.; scl = cos(lamdp) >= 0. ? 1. : -1; lamt -= M_HALFPI * (1. - scl) * sl; diff --git a/src/projections/omerc.cpp b/src/projections/omerc.cpp index e9b7b4a0..c33f6489 100644 --- a/src/projections/omerc.cpp +++ b/src/projections/omerc.cpp @@ -97,6 +97,10 @@ static PJ_LP e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal, inverse */ u = xy.y * Q->cosrot + xy.x * Q->sinrot + Q->u_0; } Qp = exp(- Q->BrA * v); + if( Qp == 0 ) { + proj_errno_set(P, PJD_ERR_INVALID_X_OR_Y); + return proj_coord_error().lp; + } Sp = .5 * (Qp - 1. / Qp); Tp = .5 * (Qp + 1. / Qp); Vp = sin(Q->BrA * u); diff --git a/test/gie/builtins.gie b/test/gie/builtins.gie index 0855bec7..a4fb5055 100644 --- a/test/gie/builtins.gie +++ b/test/gie/builtins.gie @@ -3801,6 +3801,13 @@ expect 0.000898315 -0.001808739 accept -200 -100 expect -0.000898315 -0.001808739 +------------------------------------------------------------------------------- +operation +proj=omerc +R=1 +lat_0=1 +lat_1=2 +no_rot +------------------------------------------------------------------------------- +direction inverse +accept 0 1e200 +expect failure errno invalid_x_or_y + =============================================================================== Ortelius Oval |
