Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libjni-proj4 / src / PJ_merc.c @ 21615

History | View | Annotate | Download (1.29 KB)

1
#ifndef lint
2
static const char SCCSID[]="@(#)PJ_merc.c        4.1        94/02/15        GIE        REL";
3
#endif
4
#define PJ_LIB__
5
#include        <projects.h>
6
PROJ_HEAD(merc, "Mercator") "\n\tCyl, Sph&Ell\n\tlat_ts=";
7
#define EPS10 1.e-10
8
FORWARD(e_forward); /* ellipsoid */
9
        if (fabs(fabs(lp.phi) - HALFPI) <= EPS10) F_ERROR;
10
        xy.x = P->k0 * lp.lam;
11
        xy.y = - P->k0 * log(pj_tsfn(lp.phi, sin(lp.phi), P->e));
12
        return (xy);
13
}
14
FORWARD(s_forward); /* spheroid */
15
        if (fabs(fabs(lp.phi) - HALFPI) <= EPS10) F_ERROR;
16
        xy.x = P->k0 * lp.lam;
17
        xy.y = P->k0 * log(tan(FORTPI + .5 * lp.phi));
18
        return (xy);
19
}
20
INVERSE(e_inverse); /* ellipsoid */
21
        if ((lp.phi = pj_phi2(exp(- xy.y / P->k0), P->e)) == HUGE_VAL) I_ERROR;
22
        lp.lam = xy.x / P->k0;
23
        return (lp);
24
}
25
INVERSE(s_inverse); /* spheroid */
26
        lp.phi = HALFPI - 2. * atan(exp(-xy.y / P->k0));
27
        lp.lam = xy.x / P->k0;
28
        return (lp);
29
}
30
FREEUP; if (P) pj_dalloc(P); }
31
ENTRY0(merc)
32
        double phits=0.0;
33
        int is_phits;
34

    
35
        if( (is_phits = pj_param(P->params, "tlat_ts").i) ) {
36
                phits = fabs(pj_param(P->params, "rlat_ts").f);
37
                if (phits >= HALFPI) E_ERROR(-24);
38
        }
39
        if (P->es) { /* ellipsoid */
40
                if (is_phits)
41
                        P->k0 = pj_msfn(sin(phits), cos(phits), P->es);
42
                P->inv = e_inverse;
43
                P->fwd = e_forward;
44
        } else { /* sphere */
45
                if (is_phits)
46
                        P->k0 = cos(phits);
47
                P->inv = s_inverse;
48
                P->fwd = s_forward;
49
        }
50
ENDENTRY(P)