diff options
| author | Howard Butler <howard@hobu.co> | 2015-12-13 15:55:02 -0600 |
|---|---|---|
| committer | Howard Butler <howard@hobu.co> | 2015-12-13 15:55:02 -0600 |
| commit | 3795cdf7cb98c0b89f16351a7bd2348831786525 (patch) | |
| tree | b2f3a9fc29806fbb08dfee24d8f37f222a9ae910 | |
| parent | 953cc00fd87425395cabe37641cda905c4b587c1 (diff) | |
| parent | 659b9e542c4622c4344c49cbe989af849666a59a (diff) | |
| download | PROJ-3795cdf7cb98c0b89f16351a7bd2348831786525.tar.gz PROJ-3795cdf7cb98c0b89f16351a7bd2348831786525.zip | |
Merge pull request #329 from jswhit/master
inverse for hammer projection
| -rw-r--r-- | ChangeLog | 3 | ||||
| -rwxr-xr-x | nad/testvarious | 16 | ||||
| -rw-r--r-- | nad/tv_out.dist | 8 | ||||
| -rw-r--r-- | src/PJ_hammer.c | 18 |
4 files changed, 43 insertions, 2 deletions
@@ -1,3 +1,6 @@ +2015-12-13: jswhit <https://github.com/jswhit> + * : Add inverse hammer transform (pull request #329). + 2015-09-10 sisyphus <https://github.com/sisyphus> * : Rename PVALUE in pj_param.cto prevent Windows variable name clash diff --git a/nad/testvarious b/nad/testvarious index 4f3ca324..972dc222 100755 --- a/nad/testvarious +++ b/nad/testvarious @@ -266,6 +266,22 @@ $EXE +proj=robin +datum=WGS84 \ 1741397.30 4276351.58 0.00 EOF echo "##############################################################" >> ${OUT} +echo "Test hammer projection (pull request #329)" >> ${OUT} +$EXE +proj=latlong +datum=WGS84 \ + +to +proj=hammer +datum=WGS84 \ + -E >>${OUT} <<EOF +-30 40 +-35 45 +20 40 +EOF +$EXE +proj=hammer +datum=WGS84 \ + +to +proj=latlong +datum=WGS84 \ + -E >>${OUT} <<EOF +-2711575.08 4395506.62 0.00 +-2964412.70 4929091.33 0.00 +1811748.54 4377349.50 0.00 +EOF +echo "##############################################################" >> ${OUT} echo "Test healpix forward projection on sphere" >> ${OUT} $EXE +proj=latlong +a=1 +lon_0=0 \ +to +proj=healpix +a=1 +lon_0=0 -f '%.'5'f' \ diff --git a/nad/tv_out.dist b/nad/tv_out.dist index f3c6c39f..e58f6da1 100644 --- a/nad/tv_out.dist +++ b/nad/tv_out.dist @@ -92,6 +92,14 @@ Test robinson projection (#113) -2963455.42 4805073.65 0.00 35dW 45dN 0.000 1741397.30 4276351.58 0.00 20d0'0.002"E 40d0'0.066"N 0.000 ############################################################## +Test hammer projection (pull request #329) +-30 40 -2711575.08 4395506.62 0.00 +-35 45 -2964412.70 4929091.33 0.00 +20 40 1811748.54 4377349.50 0.00 +-2711575.08 4395506.62 0.00 30dW 40dN 0.000 +-2964412.70 4929091.33 0.00 35dW 45dN 0.000 +1811748.54 4377349.50 0.00 20dE 40dN 0.000 +############################################################## Test healpix forward projection on sphere 0 41.81031 0.00000 0.78540 0.00000 -90 0 -1.57080 0.00000 0.00000 diff --git a/src/PJ_hammer.c b/src/PJ_hammer.c index 719a2ce4..31e7a127 100644 --- a/src/PJ_hammer.c +++ b/src/PJ_hammer.c @@ -2,9 +2,10 @@ 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, no inv.\n\tW= M="; + "\n\tMisc Sph, \n\tW= M="; FORWARD(s_forward); /* spheroid */ double cosphi, d; @@ -13,6 +14,19 @@ FORWARD(s_forward); /* spheroid */ 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); + 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(P->ctx,z * xy.y); + } + return (lp); +} FREEUP; if (P) pj_dalloc(P); } ENTRY0(hammer) if (pj_param(P->ctx, P->params, "tW").i) { @@ -25,5 +39,5 @@ ENTRY0(hammer) 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) |
