Menu

[r4420]: / trunk / toolkits / basemap / src / pj_inv.c  Maximize  Restore  History

Download this file

33 lines (31 with data), 917 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* general inverse projection */
#ifndef lint
static const char SCCSID[]="@(#)pj_inv.c 4.5 93/06/12 GIE REL";
#endif
#define PJ_LIB__
#include <projects.h>
#include <errno.h>
# define EPS 1.0e-12
LP /* inverse projection entry */
pj_inv(XY xy, PJ *P) {
LP lp;
/* can't do as much preliminary checking as with forward */
if (xy.x == HUGE_VAL || xy.y == HUGE_VAL) {
lp.lam = lp.phi = HUGE_VAL;
pj_errno = -15;
}
errno = pj_errno = 0;
xy.x = (xy.x * P->to_meter - P->x0) * P->ra; /* descale and de-offset */
xy.y = (xy.y * P->to_meter - P->y0) * P->ra;
lp = (*P->inv)(xy, P); /* inverse project */
if (pj_errno || (pj_errno = errno))
lp.lam = lp.phi = HUGE_VAL;
else {
lp.lam += P->lam0; /* reduce from del lp.lam */
if (!P->over)
lp.lam = adjlon(lp.lam); /* adjust longitude to CM */
if (P->geoc && fabs(fabs(lp.phi)-HALFPI) > EPS)
lp.phi = atan(P->one_es * tan(lp.phi));
}
return lp;
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.