[Proj] patch to PJ_hammer.c for inverse projection
Jeff Whitaker
jswhit at fastmail.fm
Wed Dec 29 14:13:48 EST 2010
Here's a patch against SVN head to PJ_hammer.c that implements the
inverse projection for Hammer and Eckert-Greifendorff (based on
http://mathworld.wolfram.com/Hammer-AitoffEqual-AreaProjection.html):
Index: PJ_hammer.c
===================================================================
--- PJ_hammer.c (revision 1954)
+++ PJ_hammer.c (working copy)
@@ -4,7 +4,7 @@
#define PJ_LIB__
# include <projects.h>
PROJ_HEAD(hammer, "Hammer & Eckert-Greifendorff")
- "\n\tMisc Sph, no inv.\n\tW= M=";
+ "\n\tMisc Sph, \n\tW= M=";
FORWARD(s_forward); /* spheroid */
double cosphi, d;
@@ -13,6 +13,13 @@
xy.y = P->rm * d * sin(lp.phi);
return (xy);
}
+INVERSE(s_inverse); /* spheroid */
+ double z;
+ z = sqrt(1.-0.25*P->w*P->w*xy.x*xy.x-0.25*xy.y*xy.y);
+ 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); }
ENTRY0(hammer)
if (pj_param(P->ctx, P->params, "tW").i) {
@@ -25,5 +32,5 @@
P->m = 1.;
P->rm = 1. / P->m;
P->m /= P->w;
- P->es = 0.; P->fwd = s_forward;
+ P->es = 0.; P->fwd = s_forward; P->inv = s_inverse;
ENDENTRY(P)
-Jeff
--
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker at noaa.gov
325 Broadway Office : Skaggs Research Cntr 1D-113
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
More information about the Proj
mailing list