From 953a49b5fd0c6b3ea130ab37f5776b3372b09ee3 Mon Sep 17 00:00:00 2001 From: Frank Warmerdam Date: Sat, 15 Sep 2001 22:47:40 +0000 Subject: 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 --- src/geocent.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src') 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) -- cgit v1.2.3