svn-gvsig-desktop / trunk / libraries / libjni-proj4 / src / PJ_bonne.c @ 7098
History | View | Annotate | Download (2.01 KB)
1 |
#ifndef lint
|
---|---|
2 |
static const char SCCSID[]="@(#)PJ_bonne.c 4.1 94/02/15 GIE REL"; |
3 |
#endif
|
4 |
#define PROJ_PARMS__ \
|
5 |
double phi1; \
|
6 |
double cphi1; \
|
7 |
double am1; \
|
8 |
double m1; \
|
9 |
double *en;
|
10 |
#define PJ_LIB__
|
11 |
#include <projects.h> |
12 |
PROJ_HEAD(bonne, "Bonne (Werner lat_1=90)")
|
13 |
"\n\tConic Sph&Ell\n\tlat_1=";
|
14 |
#define EPS10 1e-10 |
15 |
FORWARD(e_forward); /* ellipsoid */
|
16 |
double rh, E, c;
|
17 |
|
18 |
rh = P->am1 + P->m1 - pj_mlfn(lp.phi, E = sin(lp.phi), c = cos(lp.phi), P->en); |
19 |
E = c * lp.lam / (rh * sqrt(1. - P->es * E * E));
|
20 |
xy.x = rh * sin(E); |
21 |
xy.y = P->am1 - rh * cos(E); |
22 |
return (xy);
|
23 |
} |
24 |
FORWARD(s_forward); /* spheroid */
|
25 |
double E, rh;
|
26 |
|
27 |
rh = P->cphi1 + P->phi1 - lp.phi; |
28 |
if (fabs(rh) > EPS10) {
|
29 |
xy.x = rh * sin(E = lp.lam * cos(lp.phi) / rh); |
30 |
xy.y = P->cphi1 - rh * cos(E); |
31 |
} else
|
32 |
xy.x = xy.y = 0.;
|
33 |
return (xy);
|
34 |
} |
35 |
INVERSE(s_inverse); /* spheroid */
|
36 |
double rh;
|
37 |
|
38 |
rh = hypot(xy.x, xy.y = P->cphi1 - xy.y); |
39 |
lp.phi = P->cphi1 + P->phi1 - rh; |
40 |
if (fabs(lp.phi) > HALFPI) I_ERROR;
|
41 |
if (fabs(fabs(lp.phi) - HALFPI) <= EPS10)
|
42 |
lp.lam = 0.;
|
43 |
else
|
44 |
lp.lam = rh * atan2(xy.x, xy.y) / cos(lp.phi); |
45 |
return (lp);
|
46 |
} |
47 |
INVERSE(e_inverse); /* ellipsoid */
|
48 |
double s, rh;
|
49 |
|
50 |
rh = hypot(xy.x, xy.y = P->am1 - xy.y); |
51 |
lp.phi = pj_inv_mlfn(P->am1 + P->m1 - rh, P->es, P->en); |
52 |
if ((s = fabs(lp.phi)) < HALFPI) {
|
53 |
s = sin(lp.phi); |
54 |
lp.lam = rh * atan2(xy.x, xy.y) * |
55 |
sqrt(1. - P->es * s * s) / cos(lp.phi);
|
56 |
} else if (fabs(s - HALFPI) <= EPS10) |
57 |
lp.lam = 0.;
|
58 |
else I_ERROR;
|
59 |
return (lp);
|
60 |
} |
61 |
FREEUP; |
62 |
if (P) {
|
63 |
if (P->en)
|
64 |
pj_dalloc(P->en); |
65 |
pj_dalloc(P); |
66 |
} |
67 |
} |
68 |
ENTRY1(bonne, en) |
69 |
double c;
|
70 |
|
71 |
P->phi1 = pj_param(P->params, "rlat_1").f;
|
72 |
if (fabs(P->phi1) < EPS10) E_ERROR(-23); |
73 |
if (P->es) {
|
74 |
P->en = pj_enfn(P->es); |
75 |
P->m1 = pj_mlfn(P->phi1, P->am1 = sin(P->phi1), |
76 |
c = cos(P->phi1), P->en); |
77 |
P->am1 = c / (sqrt(1. - P->es * P->am1 * P->am1) * P->am1);
|
78 |
P->inv = e_inverse; |
79 |
P->fwd = e_forward; |
80 |
} else {
|
81 |
if (fabs(P->phi1) + EPS10 >= HALFPI)
|
82 |
P->cphi1 = 0.;
|
83 |
else
|
84 |
P->cphi1 = 1. / tan(P->phi1);
|
85 |
P->inv = s_inverse; |
86 |
P->fwd = s_forward; |
87 |
} |
88 |
ENDENTRY(P) |