aboutsummaryrefslogtreecommitdiff
path: root/src/projections/robin.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2019-02-24 15:58:16 +0100
committerEven Rouault <even.rouault@spatialys.com>2019-02-24 16:59:55 +0100
commit911852371a6a109445cd79e5176a89c539b2e768 (patch)
tree55f50ca248928072f98d168106bc0525f47377b8 /src/projections/robin.cpp
parent38a1525b01b45420de01b0df71befd030253ebe3 (diff)
downloadPROJ-911852371a6a109445cd79e5176a89c539b2e768.tar.gz
PROJ-911852371a6a109445cd79e5176a89c539b2e768.zip
Robinson: fix wrong values for forward path for latitudes >= 87.5 (fixes #1172), and fix inaccurate inverse method
Diffstat (limited to 'src/projections/robin.cpp')
-rw-r--r--src/projections/robin.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/projections/robin.cpp b/src/projections/robin.cpp
index 8f142aad..9f7908f6 100644
--- a/src/projections/robin.cpp
+++ b/src/projections/robin.cpp
@@ -7,7 +7,7 @@
PROJ_HEAD(robin, "Robinson") "\n\tPCyl, Sph";
#define V(C,z) (C.c0 + z * (C.c1 + z * (C.c2 + z * C.c3)))
-#define DV(C,z) (C.c1 + z * (C.c2 + C.c2 + z * 3. * C.c3))
+#define DV(C,z) (C.c1 + 2 * z * C.c2 + z * z * 3. * C.c3)
/*
note: following terms based upon 5 deg. intervals in degrees.
@@ -74,7 +74,7 @@ static const struct COEFS Y[] = {
#define RC1 0.08726646259971647884
#define NODES 18
#define ONEEPS 1.000001
-#define EPS 1e-8
+#define EPS 1e-10
/* Not sure at all of the appropriate number for MAX_ITER... */
#define MAX_ITER 100
@@ -90,7 +90,7 @@ static PJ_XY s_forward (PJ_LP lp, PJ *P) { /* Spheroidal, forward */
proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION);
return xy;
}
- if (i >= NODES) i = NODES - 1;
+ if (i >= NODES) i = NODES;
dphi = RAD_TO_DEG * (dphi - RC1 * i);
xy.x = V(X[i], dphi) * FXC * lp.lam;
xy.y = V(Y[i], dphi) * FYC;
@@ -133,10 +133,8 @@ static PJ_LP s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inverse */
T = Y[i];
/* first guess, linear interp */
t = 5. * (lp.phi - T.c0)/(Y[i+1].c0 - T.c0);
- /* make into root */
- T.c0 = (float)(T.c0 - lp.phi);
for (iters = MAX_ITER; iters ; --iters) { /* Newton-Raphson */
- t -= t1 = V(T,t) / DV(T,t);
+ t -= t1 = (V(T,t) - lp.phi) / DV(T,t);
if (fabs(t1) < EPS)
break;
}