diff options
| author | Frank Warmerdam <warmerdam@pobox.com> | 2008-06-18 02:39:04 +0000 |
|---|---|---|
| committer | Frank Warmerdam <warmerdam@pobox.com> | 2008-06-18 02:39:04 +0000 |
| commit | a693cc06b51ebccda6a312e460673709fbdf3c55 (patch) | |
| tree | ff2b6de3827098df1a09d3fd4cc96f78588d9457 /src | |
| parent | 68017d70d0783d20cdb919ba23e2683e040834e3 (diff) | |
| download | PROJ-a693cc06b51ebccda6a312e460673709fbdf3c55.tar.gz PROJ-a693cc06b51ebccda6a312e460673709fbdf3c55.zip | |
preliminary longitude range check (#5)
git-svn-id: http://svn.osgeo.org/metacrs/proj/trunk@1452 4e78687f-474d-0410-85f9-8d5e500ac6b2
Diffstat (limited to 'src')
| -rw-r--r-- | src/PJ_tmerc.c | 30 |
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)); |
