diff options
| author | Frank Warmerdam <warmerdam@pobox.com> | 2001-09-15 22:47:40 +0000 |
|---|---|---|
| committer | Frank Warmerdam <warmerdam@pobox.com> | 2001-09-15 22:47:40 +0000 |
| commit | 953a49b5fd0c6b3ea130ab37f5776b3372b09ee3 (patch) | |
| tree | ff3843c6f97b2194506a0c05d545c93b02c61773 /src/geocent.c | |
| parent | a08dfcd769f4c64c241cfe501f7ad6f1dc7ca2a6 (diff) | |
| download | PROJ-953a49b5fd0c6b3ea130ab37f5776b3372b09ee3.tar.gz PROJ-953a49b5fd0c6b3ea130ab37f5776b3372b09ee3.zip | |
fixed lat/long range check sensitivity to edges in geodetic_to_geocentric
git-svn-id: http://svn.osgeo.org/metacrs/proj/trunk@980 4e78687f-474d-0410-85f9-8d5e500ac6b2
Diffstat (limited to 'src/geocent.c')
| -rw-r--r-- | src/geocent.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/geocent.c b/src/geocent.c index e4fbad94..09ebdaba 100644 --- a/src/geocent.c +++ b/src/geocent.c @@ -188,14 +188,20 @@ long Convert_Geodetic_To_Geocentric (double Latitude, double Sin2_Lat; /* Square of sin(Latitude) */ double Cos_Lat; /* cos(Latitude) */ - if ((Latitude < -PI_OVER_2) || (Latitude > PI_OVER_2)) + /* + ** Don't blow up if Latitude is just a little out of the value + ** range as it may just be a rounding issue. Also removed longitude + ** test, it should be wrapped by cos() and sin(). NFW for PROJ.4, Sep/2001. + */ + if( Latitude < -PI_OVER_2 && Latitude > -1.001 * PI_OVER_2 ) + Latitude = -PI_OVER_2; + else if( Latitude > -PI_OVER_2 && Latitude < 1.001 * PI_OVER_2 ) + Latitude = PI_OVER_2; + else if ((Latitude < -PI_OVER_2) || (Latitude > PI_OVER_2)) { /* Latitude out of range */ Error_Code |= GEOCENT_LAT_ERROR; } - if ((Longitude < -PI) || (Longitude > (2*PI))) - { /* Longitude out of range */ - Error_Code |= GEOCENT_LON_ERROR; - } + if (!Error_Code) { /* no errors */ if (Longitude > PI) |
