PageRenderTime 27ms CodeModel.GetById 16ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/Proj4/PJ_goode.c

http://github.com/route-me/route-me
C | 49 lines | 49 code | 0 blank | 0 comment | 11 complexity | 723ddbf7acdfde8ff6bd99524c7cce07 MD5 | raw file
 1#ifndef lint
 2static const char SCCSID[]="@(#)PJ_goode.c	4.1 94/02/15     GIE     REL";
 3#endif
 4#define PROJ_PARMS__ \
 5	struct PJconsts	*sinu; \
 6	struct PJconsts	*moll;
 7#define PJ_LIB__
 8#include	"projects.h"
 9PROJ_HEAD(goode, "Goode Homolosine") "\n\tPCyl, Sph.";
10	C_NAMESPACE PJ
11*pj_sinu(PJ *), *pj_moll(PJ *);
12#define Y_COR		0.05280
13#define PHI_LIM	.71093078197902358062
14FORWARD(s_forward); /* spheroid */
15	if (fabs(lp.phi) <= PHI_LIM)
16		xy = P->sinu->fwd(lp, P->sinu);
17	else {
18		xy = P->moll->fwd(lp, P->moll);
19		xy.y -= lp.phi >= 0.0 ? Y_COR : -Y_COR;
20	}
21	return (xy);
22}
23INVERSE(s_inverse); /* spheroid */
24	if (fabs(xy.y) <= PHI_LIM)
25		lp = P->sinu->inv(xy, P->sinu);
26	else {
27		xy.y += xy.y >= 0.0 ? Y_COR : -Y_COR;
28		lp = P->moll->inv(xy, P->moll);
29	}
30	return (lp);
31}
32FREEUP;
33	if (P) {
34		if (P->sinu)
35			(*(P->sinu->pfree))(P->sinu);
36		if (P->moll)
37			(*(P->moll->pfree))(P->moll);
38		pj_dalloc(P);
39	}
40}
41ENTRY2(goode, sinu, moll)
42	P->es = 0.;
43	if (!(P->sinu = pj_sinu(0)) || !(P->moll = pj_moll(0)))
44		E_ERROR_0;
45	if (!(P->sinu = pj_sinu(P->sinu)) || !(P->moll = pj_moll(P->moll)))
46		E_ERROR_0;
47	P->fwd = s_forward;
48	P->inv = s_inverse;
49ENDENTRY(P)