1 #define PJ_LIB__
2 
3 #include <errno.h>
4 #include <math.h>
5 
6 #include "proj.h"
7 #include "proj_internal.h"
8 
9 PROJ_HEAD(wink1, "Winkel I") "\n\tPCyl, Sph\n\tlat_ts=";
10 
11 namespace { // anonymous namespace
12 struct pj_opaque {
13 	double	cosphi1;
14 };
15 } // anonymous namespace
16 
17 
18 
wink1_s_forward(PJ_LP lp,PJ * P)19 static PJ_XY wink1_s_forward (PJ_LP lp, PJ *P) {           /* Spheroidal, forward */
20     PJ_XY xy = {0.0,0.0};
21 	xy.x = .5 * lp.lam * (static_cast<struct pj_opaque*>(P->opaque)->cosphi1 + cos(lp.phi));
22 	xy.y = lp.phi;
23 	return (xy);
24 }
25 
26 
wink1_s_inverse(PJ_XY xy,PJ * P)27 static PJ_LP wink1_s_inverse (PJ_XY xy, PJ *P) {           /* Spheroidal, inverse */
28     PJ_LP lp = {0.0,0.0};
29 	lp.phi = xy.y;
30 	lp.lam = 2. * xy.x / (static_cast<struct pj_opaque*>(P->opaque)->cosphi1 + cos(lp.phi));
31 	return (lp);
32 }
33 
34 
PROJECTION(wink1)35 PJ *PROJECTION(wink1) {
36     struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque)));
37     if (nullptr==Q)
38         return pj_default_destructor(P, ENOMEM);
39     P->opaque = Q;
40 
41 	static_cast<struct pj_opaque*>(P->opaque)->cosphi1 = cos (pj_param(P->ctx, P->params, "rlat_ts").f);
42 	P->es = 0.;
43     P->inv = wink1_s_inverse;
44     P->fwd = wink1_s_forward;
45 
46     return P;
47 }
48