Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libjni-proj4 / src / pj_fwd.c @ 7098

History | View | Annotate | Download (1.01 KB)

1
/* general forward projection */
2
#ifndef lint
3
static const char SCCSID[]="@(#)pj_fwd.c        4.4        93/06/12        GIE        REL";
4
#endif
5
#define PJ_LIB__
6
#include <projects.h>
7
#include <errno.h>
8
# define EPS 1.0e-12
9
        XY /* forward projection entry */
10
pj_fwd(LP lp, PJ *P) {
11
        XY xy;
12
        double t;
13

    
14
        /* check for forward and latitude or longitude overange */
15
        if ((t = fabs(lp.phi)-HALFPI) > EPS || fabs(lp.lam) > 10.) {
16
                xy.x = xy.y = HUGE_VAL;
17
                pj_errno = -14;
18
        } else { /* proceed with projection */
19
                errno = pj_errno = 0;
20
                if (fabs(t) <= EPS)
21
                        lp.phi = lp.phi < 0. ? -HALFPI : HALFPI;
22
                else if (P->geoc)
23
                        lp.phi = atan(P->rone_es * tan(lp.phi));
24
                lp.lam -= P->lam0;        /* compute del lp.lam */
25
                if (!P->over)
26
                        lp.lam = adjlon(lp.lam); /* adjust del longitude */
27
                xy = (*P->fwd)(lp, P); /* project */
28
                if (pj_errno || (pj_errno = errno))
29
                        xy.x = xy.y = HUGE_VAL;
30
                /* adjust for major axis and easting/northings */
31
                else {
32
                        xy.x = P->fr_meter * (P->a * xy.x + P->x0);
33
                        xy.y = P->fr_meter * (P->a * xy.y + P->y0);
34
                }
35
        }
36
        return xy;
37
}