[GRASS-SVN] r30809 - grass/trunk/lib/proj
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Mar 30 08:06:05 EDT 2008
Author: pkelly
Date: 2008-03-30 08:06:05 -0400 (Sun, 30 Mar 2008)
New Revision: 30809
Modified:
grass/trunk/lib/proj/convert.c
Log:
Use rf for comparisons and add a special case for sphere rather than always
using the (less precise) es value. Should fix Gforge bug 603.
Modified: grass/trunk/lib/proj/convert.c
===================================================================
--- grass/trunk/lib/proj/convert.c 2008-03-30 12:01:07 UTC (rev 30808)
+++ grass/trunk/lib/proj/convert.c 2008-03-30 12:06:05 UTC (rev 30809)
@@ -516,13 +516,15 @@
{
char *ellps = NULL;
struct ellps_list *list, *listhead;
- double a = atof(pszSemiMajor), flat = atof(pszInvFlat);
+ double a = atof(pszSemiMajor), invflat = atof(pszInvFlat), flat;
double es;
/* Allow for incorrect WKT describing a sphere where InvFlat
* is given as 0 rather than inf */
- if( flat > 0 )
- flat = 1 / flat;
+ if( invflat > 0 )
+ flat = 1 / invflat;
+ else
+ flat = 0;
es = flat * (2.0 - flat);
@@ -535,7 +537,8 @@
* by trial and error and could be fine-tuned, or possibly
* a direct comparison of IEEE floating point values used. */
if ( ( a == list->a || fabs(a - list->a) < 0.1 || fabs(1 - a/list->a) < 0.0000001 ) &&
- ( es == list->es || fabs(es - list->es) < 0.000000001 || fabs(1 - es/list->es) < 0.0000001) )
+ ( ( es == 0 && list->es == 0 ) || /* Special case for sphere */
+ ( invflat == list->rf || fabs(invflat - list->rf) < 0.0000001 ) ) )
{
ellps = G_store(list->name);
break;
More information about the grass-commit
mailing list