summaryrefslogtreecommitdiff
path: root/src/3rdparty/proj/PJ_rpoly.c
blob: 1440327dfef719e7930c9a2c9b13d7596f814c5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#define PROJ_PARMS__ \
	double	phi1; \
	double	fxa; \
	double	fxb; \
	int		mode;
#define EPS	1e-9
#define PJ_LIB__
#include	<projects.h>
PROJ_HEAD(rpoly, "Rectangular Polyconic")
	"\n\tConic, Sph., no inv.\n\tlat_ts=";
FORWARD(s_forward); /* spheroid */
	double fa;

	if (P->mode)
		fa = tan(lp.lam * P->fxb) * P->fxa;
	else
		fa = 0.5 * lp.lam;
	if (fabs(lp.phi) < EPS) {
		xy.x = fa + fa;
		xy.y = - P->phi0;
	} else {
		xy.y = 1. / tan(lp.phi);
		xy.x = sin(fa = 2. * atan(fa * sin(lp.phi))) * xy.y;
		xy.y = lp.phi - P->phi0 + (1. - cos(fa)) * xy.y;
	}
	return (xy);
}
FREEUP; if (P) pj_dalloc(P); }
ENTRY0(rpoly)
	if ((P->mode = (P->phi1 = fabs(pj_param(P->params, "rlat_ts").f)) > EPS)) {
		P->fxb = 0.5 * sin(P->phi1);
		P->fxa = 0.5 / P->fxb;
	}
	P->es = 0.; P->fwd = s_forward;
ENDENTRY(P)