From 244a24104ded3a4573aeffa32160af21f76cbce6 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 15 Dec 2020 00:51:46 +0100 Subject: Revise error codes to have a reduced set exposed in the public API. Fixes #2482 And also add proj_context_errno_string() Revise gie 'expect failure errno XXXX' strings --- src/fwd.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/fwd.cpp') diff --git a/src/fwd.cpp b/src/fwd.cpp index 962a5051..97ba5999 100644 --- a/src/fwd.cpp +++ b/src/fwd.cpp @@ -52,10 +52,19 @@ static PJ_COORD fwd_prepare (PJ *P, PJ_COORD coo) { /* check for latitude or longitude over-range */ t = (coo.lp.phi < 0 ? -coo.lp.phi : coo.lp.phi) - M_HALFPI; - if (t > PJ_EPS_LAT || coo.lp.lam > 10 || coo.lp.lam < -10) { - proj_errno_set (P, PJD_ERR_LAT_OR_LON_EXCEED_LIMIT); + if (t > PJ_EPS_LAT) + { + proj_log_error(P, _("Invalid latitude")); + proj_errno_set (P, PROJ_ERR_COORD_TRANSFM_INVALID_COORD); return proj_coord_error (); } + if (coo.lp.lam > 10 || coo.lp.lam < -10) + { + proj_log_error(P, _("Invalid longitude")); + proj_errno_set (P, PROJ_ERR_COORD_TRANSFM_INVALID_COORD); + return proj_coord_error (); + } + /* Clamp latitude to -90..90 degree range */ if (coo.lp.phi > M_HALFPI) @@ -186,7 +195,7 @@ PJ_XY pj_fwd(PJ_LP lp, PJ *P) { else if (P->fwd4d) coo = P->fwd4d (coo, P); else { - proj_errno_set (P, EINVAL); + proj_errno_set (P, PROJ_ERR_OTHER_NO_INVERSE_OP); return proj_coord_error ().xy; } if (HUGE_VAL==coo.v[0]) @@ -220,7 +229,7 @@ PJ_XYZ pj_fwd3d(PJ_LPZ lpz, PJ *P) { else if (P->fwd) coo.xy = P->fwd (coo.lp, P); else { - proj_errno_set (P, EINVAL); + proj_errno_set (P, PROJ_ERR_OTHER_NO_INVERSE_OP); return proj_coord_error ().xyz; } if (HUGE_VAL==coo.v[0]) @@ -250,7 +259,7 @@ PJ_COORD pj_fwd4d (PJ_COORD coo, PJ *P) { else if (P->fwd) coo.xy = P->fwd (coo.lp, P); else { - proj_errno_set (P, EINVAL); + proj_errno_set (P, PROJ_ERR_OTHER_NO_INVERSE_OP); return proj_coord_error (); } if (HUGE_VAL==coo.v[0]) -- cgit v1.2.3