Statistics
| Revision:

svn-gvsig-desktop / tags / v1_10_0_Build_1257 / libraries / libjni-proj4 / src / PJ_nocol.c @ 42039

History | View | Annotate | Download (1.14 KB)

1
#ifndef lint
2
static const char SCCSID[]="@(#)PJ_nocol.c        4.1        94/02/15        GIE        REL";
3
#endif
4
#define PJ_LIB__
5
#include        <projects.h>
6
PROJ_HEAD(nicol, "Nicolosi Globular") "\n\tMisc Sph, no inv.";
7
#define EPS        1e-10
8
FORWARD(s_forward); /* spheroid */
9
        if (fabs(lp.lam) < EPS) {
10
                xy.x = 0;
11
                xy.y = lp.phi;
12
        } else if (fabs(lp.phi) < EPS) {
13
                xy.x = lp.lam;
14
                xy.y = 0.;
15
        } else if (fabs(fabs(lp.lam) - HALFPI) < EPS) {
16
                xy.x = lp.lam * cos(lp.phi);
17
                xy.y = HALFPI * sin(lp.phi);
18
        } else if (fabs(fabs(lp.phi) - HALFPI) < EPS) {
19
                xy.x = 0;
20
                xy.y = lp.phi;
21
        } else {
22
                double tb, c, d, m, n, r2, sp;
23

    
24
                tb = HALFPI / lp.lam - lp.lam / HALFPI;
25
                c = lp.phi / HALFPI;
26
                d = (1 - c * c)/((sp = sin(lp.phi)) - c);
27
                r2 = tb / d;
28
                r2 *= r2;
29
                m = (tb * sp / d - 0.5 * tb)/(1. + r2);
30
                n = (sp / r2 + 0.5 * d)/(1. + 1./r2);
31
                xy.x = cos(lp.phi);
32
                xy.x = sqrt(m * m + xy.x * xy.x / (1. + r2));
33
                xy.x = HALFPI * ( m + (lp.lam < 0. ? -xy.x : xy.x));
34
                xy.y = sqrt(n * n - (sp * sp / r2 + d * sp - 1.) /
35
                        (1. + 1./r2));
36
                xy.y = HALFPI * ( n + (lp.phi < 0. ? xy.y : -xy.y ));
37
        }
38
        return (xy);
39
}
40
FREEUP; if (P) pj_dalloc(P); }
41
ENTRY0(nicol) P->es = 0.; P->fwd = s_forward; ENDENTRY(P)