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 --- ChangeLog | 9 +++++++++ src/geocent.c | 16 +++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4bf441f8..b822fedd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2001-09-15 Frank Warmerdam + + * src/geocent.c: I have modified the Convert_Geodetic_To_Geocentric() + function to clamp Latitudes just a little out of the range + -PI/2 to PI/2 and to no longer do error checks on Longitudes since + they will be auto-wrapped by sin() and cos(). + + See http://bugzilla.remotesensing.org/show_bug.cgi?id=17 + 2001-08-23 Frank Warmerdam * src/makefile.vc: improved the setting of PROJ_LIB defaults. 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