PageRenderTime 29ms CodeModel.GetById 20ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/Proj4/PJ_sts.c

http://github.com/route-me/route-me
C | 57 lines | 55 code | 2 blank | 0 comment | 4 complexity | 85e5f25c865abb56e6dad6f51a9da6a0 MD5 | raw file
 1#ifndef lint
 2static const char SCCSID[]="@(#)PJ_sts.c	4.1	94/02/15	GIE	REL";
 3#endif
 4#define PROJ_PARMS__ \
 5	double C_x, C_y, C_p; \
 6	int tan_mode;
 7#define PJ_LIB__
 8# include	"projects.h"
 9PROJ_HEAD(kav5, "Kavraisky V") "\n\tPCyl., Sph.";
10PROJ_HEAD(qua_aut, "Quartic Authalic") "\n\tPCyl., Sph.";
11PROJ_HEAD(mbt_s, "McBryde-Thomas Flat-Polar Sine (No. 1)") "\n\tPCyl., Sph.";
12PROJ_HEAD(fouc, "Foucaut") "\n\tPCyl., Sph.";
13FORWARD(s_forward); /* spheroid */
14	double c;
15
16	xy.x = P->C_x * lp.lam * cos(lp.phi);
17	xy.y = P->C_y;
18	lp.phi *= P->C_p;
19	c = cos(lp.phi);
20	if (P->tan_mode) {
21		xy.x *= c * c;
22		xy.y *= tan(lp.phi);
23	} else {
24		xy.x /= c;
25		xy.y *= sin(lp.phi);
26	}
27	return (xy);
28}
29INVERSE(s_inverse); /* spheroid */
30	double c;
31	
32	xy.y /= P->C_y;
33	c = cos(lp.phi = P->tan_mode ? atan(xy.y) : aasin(xy.y));
34	lp.phi /= P->C_p;
35	lp.lam = xy.x / (P->C_x * cos(lp.phi /= P->C_p));
36	if (P->tan_mode)
37		lp.lam /= c * c;
38	else
39		lp.lam *= c;
40	return (lp);
41}
42FREEUP; if (P) pj_dalloc(P); }
43	static PJ *
44setup(PJ *P, double p, double q, int mode) {
45	P->es = 0.;
46	P->inv = s_inverse;
47	P->fwd = s_forward;
48	P->C_x = q / p;
49	P->C_y = p;
50	P->C_p = 1/ q;
51	P->tan_mode = mode;
52	return P;
53}
54ENTRY0(kav5) ENDENTRY(setup(P, 1.50488, 1.35439, 0))
55ENTRY0(qua_aut) ENDENTRY(setup(P, 2., 2., 0))
56ENTRY0(mbt_s) ENDENTRY(setup(P, 1.48875, 1.36509, 0))
57ENTRY0(fouc) ENDENTRY(setup(P, 2., 2., 1))