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

/Proj4/PJ_loxim.c

http://github.com/route-me/route-me
C | 44 lines | 44 code | 0 blank | 0 comment | 8 complexity | 8ad24112c66d8685ca14a3a171c8515a MD5 | raw file
 1#ifndef lint
 2static const char SCCSID[]="@(#)PJ_loxim.c	4.1 94/02/15     GIE     REL";
 3#endif
 4#define PROJ_PARMS__ \
 5	double phi1; \
 6	double cosphi1; \
 7	double tanphi1;
 8#define PJ_LIB__
 9#include	"projects.h"
10PROJ_HEAD(loxim, "Loximuthal") "\n\tPCyl Sph";
11#define EPS	1e-8
12FORWARD(s_forward); /* spheroid */
13	xy.y = lp.phi - P->phi1;
14	if (fabs(xy.y) < EPS)
15		xy.x = lp.lam * P->cosphi1;
16	else {
17		xy.x = FORTPI + 0.5 * lp.phi;
18		if (fabs(xy.x) < EPS || fabs(fabs(xy.x) - HALFPI) < EPS)
19			xy.x = 0.;
20		else
21			xy.x = lp.lam * xy.y / log( tan(xy.x) / P->tanphi1 );
22	}
23	return (xy);
24}
25INVERSE(s_inverse); /* spheroid */
26	lp.phi = xy.y + P->phi1;
27	if (fabs(xy.y) < EPS)
28		lp.lam = xy.x / P->cosphi1;
29	else
30		if (fabs( lp.lam = FORTPI + 0.5 * lp.phi ) < EPS ||
31			fabs(fabs(lp.lam) - HALFPI) < EPS)
32			lp.lam = 0.;
33		else
34			lp.lam = xy.x * log( tan(lp.lam) / P->tanphi1 ) / xy.y ;
35	return (lp);
36}
37FREEUP; if (P) pj_dalloc(P); }
38ENTRY0(loxim);
39	P->phi1 = pj_param(P->params, "rlat_1").f;
40	if ((P->cosphi1 = cos(P->phi1)) < EPS) E_ERROR(-22);
41	P->tanphi1 = tan(FORTPI + 0.5 * P->phi1);
42	P->inv = s_inverse; P->fwd = s_forward;
43	P->es = 0.;
44ENDENTRY(P)