Revision: 8868
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8868&view=rev
Author: jswhit
Date: 2010-12-30 16:14:19 +0000 (Thu, 30 Dec 2010)
Log Message:
-----------
detect projection out of range, set error flag.
Modified Paths:
--------------
trunk/toolkits/basemap/src/PJ_hammer.c
Modified: trunk/toolkits/basemap/src/PJ_hammer.c
===================================================================
--- trunk/toolkits/basemap/src/PJ_hammer.c 2010-12-30 13:09:06 UTC (rev 8867)
+++ trunk/toolkits/basemap/src/PJ_hammer.c 2010-12-30 16:14:19 UTC (rev 8868)
@@ -2,6 +2,7 @@
double w; \
double m, rm;
#define PJ_LIB__
+# define EPS 1.0e-10
# include <projects.h>
PROJ_HEAD(hammer, "Hammer & Eckert-Greifendorff")
"\n\tMisc Sph, \n\tW= M=";
@@ -15,9 +16,15 @@
}
INVERSE(s_inverse); /* spheroid */
double z;
- z = sqrt(1. - (0.5 * P->w * xy.x) * (0.5 * P->w * xy.x) - (0.5 * xy.y) * (0.5 * xy.y));
- lp.lam = aatan2(P->w * xy.x * z,2. * z * z - 1)/P->w;
- lp.phi = aasin(z * xy.y);
+ z = sqrt(1. - 0.25*P->w*P->w*xy.x*xy.x - 0.25*xy.y*xy.y);
+ if (fabs(2.*z*z-1.) < EPS) {
+ lp.lam = HUGE_VAL;
+ lp.phi = HUGE_VAL;
+ pj_errno = -14;
+ } else {
+ lp.lam = aatan2(P->w * xy.x * z,2. * z * z - 1)/P->w;
+ lp.phi = aasin(z * xy.y);
+ }
return (lp);
}
FREEUP; if (P) pj_dalloc(P); }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|