diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2020-12-16 15:12:51 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-16 15:12:51 +0100 |
| commit | 5e077729274f5d28e137e1a41f7d3350146614ef (patch) | |
| tree | d1ef799526f06828328b58ce8ee92c028f723b6a /src/fwd.cpp | |
| parent | 8b1ef9504d0bcfbd8433df943e307bbd1aa30c4f (diff) | |
| parent | a27c0255e7b8e6aab1b91e49fd7870d1ee4e1a80 (diff) | |
| download | PROJ-5e077729274f5d28e137e1a41f7d3350146614ef.tar.gz PROJ-5e077729274f5d28e137e1a41f7d3350146614ef.zip | |
Merge pull request #2487 from rouault/error_mgt_improvements
Error management: revise error codes and expose them to the public API
Diffstat (limited to 'src/fwd.cpp')
| -rw-r--r-- | src/fwd.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
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]) |
