aboutsummaryrefslogtreecommitdiff
path: root/src/pj_inv.c
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2018-03-12 13:38:03 +0100
committerGitHub <noreply@github.com>2018-03-12 13:38:03 +0100
commitd422d4547a1e99ecdedc3bde146ab3c304bc5c6a (patch)
tree3a556f186a77c1fdce10bc972556348fa7964a9b /src/pj_inv.c
parenta5ee6c5543aa0d81f37adafc0efc7bffec476e5c (diff)
parent22203cc0677f7f60fd81f719125c3c1768e498ac (diff)
downloadPROJ-d422d4547a1e99ecdedc3bde146ab3c304bc5c6a.tar.gz
PROJ-d422d4547a1e99ecdedc3bde146ab3c304bc5c6a.zip
Merge pull request #857 from kbevers/return-error-instead-of-zeros
Make sure that transient errors are returned correctly
Diffstat (limited to 'src/pj_inv.c')
-rw-r--r--src/pj_inv.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/pj_inv.c b/src/pj_inv.c
index 1e84ff30..4c2266fb 100644
--- a/src/pj_inv.c
+++ b/src/pj_inv.c
@@ -172,11 +172,22 @@ static PJ_COORD inv_finalize (PJ *P, PJ_COORD coo) {
}
+static PJ_COORD error_or_coord(PJ *P, PJ_COORD coord, int last_errno) {
+ if (proj_errno(P))
+ return proj_coord_error();
+
+ proj_errno_restore(P, last_errno);
+ return coord;
+}
+
LP pj_inv(XY xy, PJ *P) {
+ int last_errno;
PJ_COORD coo = {{0,0,0,0}};
coo.xy = xy;
+ last_errno = proj_errno_reset(P);
+
if (!P->skip_inv_prepare)
coo = inv_prepare (P, coo);
if (HUGE_VAL==coo.v[0])
@@ -198,15 +209,19 @@ LP pj_inv(XY xy, PJ *P) {
if (!P->skip_inv_finalize)
coo = inv_finalize (P, coo);
- return coo.lp;
+
+ return error_or_coord(P, coo, last_errno).lp;
}
LPZ pj_inv3d (XYZ xyz, PJ *P) {
+ int last_errno;
PJ_COORD coo = {{0,0,0,0}};
coo.xyz = xyz;
+ last_errno = proj_errno_reset(P);
+
if (!P->skip_inv_prepare)
coo = inv_prepare (P, coo);
if (HUGE_VAL==coo.v[0])
@@ -228,12 +243,15 @@ LPZ pj_inv3d (XYZ xyz, PJ *P) {
if (!P->skip_inv_finalize)
coo = inv_finalize (P, coo);
- return coo.lpz;
+
+ return error_or_coord(P, coo, last_errno).lpz;
}
PJ_COORD pj_inv4d (PJ_COORD coo, PJ *P) {
+ int last_errno = proj_errno_reset(P);
+
if (!P->skip_inv_prepare)
coo = inv_prepare (P, coo);
if (HUGE_VAL==coo.v[0])
@@ -255,5 +273,6 @@ PJ_COORD pj_inv4d (PJ_COORD coo, PJ *P) {
if (!P->skip_inv_finalize)
coo = inv_finalize (P, coo);
- return coo;
+
+ return error_or_coord(P, coo, last_errno);
}