Statistics
| Revision:

svn-gvsig-desktop / branches / v10 / libraries / libjni-proj4 / src / PJ_lagrng.c @ 40603

History | View | Annotate | Download (996 Bytes)

1
#ifndef lint
2
static const char SCCSID[]="@(#)PJ_lagrng.c        4.1        94/02/15        GIE        REL";
3
#endif
4
#define PROJ_PARMS__ \
5
        double        hrw; \
6
        double        rw; \
7
        double        a1;
8
#define TOL        1e-10
9
#define PJ_LIB__
10
#include        <projects.h>
11
PROJ_HEAD(lagrng, "Lagrange") "\n\tMisc Sph, no inv.\n\tW=";
12
FORWARD(s_forward); /* spheroid */
13
        double v, c;
14

    
15
        if (fabs(fabs(lp.phi) - HALFPI) < TOL) {
16
                xy.x = 0;
17
                xy.y = lp.phi < 0 ? -2. : 2.;
18
        } else {
19
                lp.phi = sin(lp.phi);
20
                v = P->a1 * pow((1. + lp.phi)/(1. - lp.phi), P->hrw);
21
                if ((c = 0.5 * (v + 1./v) + cos(lp.lam *= P->rw)) < TOL)
22
                        F_ERROR;
23
                xy.x = 2. * sin(lp.lam) / c;
24
                xy.y = (v - 1./v) / c;
25
        }
26
        return (xy);
27
}
28
FREEUP; if (P) pj_dalloc(P); }
29
ENTRY0(lagrng)
30
        double phi1;
31

    
32
        if ((P->rw = pj_param(P->params, "dW").f) <= 0) E_ERROR(-27);
33
        P->hrw = 0.5 * (P->rw = 1. / P->rw);
34
        phi1 = pj_param(P->params, "rlat_1").f;
35
        if (fabs(fabs(phi1 = sin(phi1)) - 1.) < TOL) E_ERROR(-22);
36
        P->a1 = pow((1. - phi1)/(1. + phi1), P->hrw);
37
        P->es = 0.; P->fwd = s_forward;
38
ENDENTRY(P)