aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/PJ_tmerc.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/PJ_tmerc.c b/src/PJ_tmerc.c
index bac2db3e..6f56c6ad 100644
--- a/src/PJ_tmerc.c
+++ b/src/PJ_tmerc.c
@@ -24,6 +24,21 @@ PROJ_HEAD(utm, "Universal Transverse Mercator (UTM)")
FORWARD(e_forward); /* ellipse */
double al, als, n, cosphi, sinphi, t;
+ /*
+ * Fail if our longitude is more than 90 degrees from the
+ * central meridian since the results are essentially garbage.
+ * Is error -20 really an appropriate return value?
+ *
+ * http://trac.osgeo.org/proj/ticket/5
+ */
+ if( lp.lam < -HALFPI || lp.lam > HALFPI )
+ {
+ xy.x = HUGE_VAL;
+ xy.y = HUGE_VAL;
+ pj_errno = -14;
+ return xy;
+ }
+
sinphi = sin(lp.phi); cosphi = cos(lp.phi);
t = fabs(cosphi) > 1e-10 ? sinphi/cosphi : 0.;
t *= t;
@@ -47,6 +62,21 @@ FORWARD(e_forward); /* ellipse */
FORWARD(s_forward); /* sphere */
double b, cosphi;
+ /*
+ * Fail if our longitude is more than 90 degrees from the
+ * central meridian since the results are essentially garbage.
+ * Is error -20 really an appropriate return value?
+ *
+ * http://trac.osgeo.org/proj/ticket/5
+ */
+ if( lp.lam < -HALFPI || lp.lam > HALFPI )
+ {
+ xy.x = HUGE_VAL;
+ xy.y = HUGE_VAL;
+ pj_errno = -14;
+ return xy;
+ }
+
b = (cosphi = cos(lp.phi)) * sin(lp.lam);
if (fabs(fabs(b) - 1.) <= EPS10) F_ERROR;
xy.x = aks5 * log((1. + b) / (1. - b));