Statistics
| Revision:

svn-gvsig-desktop / tags / v2_0_0_Build_2035 / libraries / libjni-proj4 / src / pj_inv.c @ 44890

History | View | Annotate | Download (917 Bytes)

1
/* general inverse projection */
2
#ifndef lint
3
static const char SCCSID[]="@(#)pj_inv.c        4.5        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
        LP /* inverse projection entry */
10
pj_inv(XY xy, PJ *P) {
11
        LP lp;
12

    
13
        /* can't do as much preliminary checking as with forward */
14
        if (xy.x == HUGE_VAL || xy.y == HUGE_VAL) {
15
                lp.lam = lp.phi = HUGE_VAL;
16
                pj_errno = -15;
17
        }
18
        errno = pj_errno = 0;
19
        xy.x = (xy.x * P->to_meter - P->x0) * P->ra; /* descale and de-offset */
20
        xy.y = (xy.y * P->to_meter - P->y0) * P->ra;
21
        lp = (*P->inv)(xy, P); /* inverse project */
22
        if (pj_errno || (pj_errno = errno))
23
                lp.lam = lp.phi = HUGE_VAL;
24
        else {
25
                lp.lam += P->lam0; /* reduce from del lp.lam */
26
                if (!P->over)
27
                        lp.lam = adjlon(lp.lam); /* adjust longitude to CM */
28
                if (P->geoc && fabs(fabs(lp.phi)-HALFPI) > EPS)
29
                        lp.phi = atan(P->one_es * tan(lp.phi));
30
        }
31
        return lp;
32
}