diff options
| author | Kristian Evers <kristianevers@gmail.com> | 2016-10-18 23:00:49 +0200 |
|---|---|---|
| committer | Kristian Evers <kristianevers@gmail.com> | 2016-10-18 23:00:49 +0200 |
| commit | fde9ac79d8f62d49a5c22e499ddbf887db546752 (patch) | |
| tree | 10ccaae42af251f5de94790b4f5bab93bdc9b62d /src | |
| parent | e3346bb39c860883ed9a8ada0657139118e21ef0 (diff) | |
| download | PROJ-fde9ac79d8f62d49a5c22e499ddbf887db546752.tar.gz PROJ-fde9ac79d8f62d49a5c22e499ddbf887db546752.zip | |
Convert units for false northing/easting. Fixes #186.
Diffstat (limited to 'src')
| -rw-r--r-- | src/pj_inv.c | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/src/pj_inv.c b/src/pj_inv.c index 9a341769..3219d319 100644 --- a/src/pj_inv.c +++ b/src/pj_inv.c @@ -3,40 +3,39 @@ #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_ctx_set_errno( P->ctx, -15); - return lp; - } +/* inverse projection entry */ +LP pj_inv(XY xy, PJ *P) { + LP lp; - errno = pj_errno = 0; - P->ctx->last_errno = 0; + /* 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_ctx_set_errno( P->ctx, -15); + return lp; + } - 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; + errno = pj_errno = 0; + P->ctx->last_errno = 0; - /* Check for NULL pointer */ - if (P->inv != NULL) - { - lp = (*P->inv)(xy, P); /* inverse project */ - if (P->ctx->last_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)-M_HALFPI) > EPS) - lp.phi = atan(P->one_es * tan(lp.phi)); - } - } - else - { - lp.lam = lp.phi = HUGE_VAL; + xy.x = (xy.x * P->to_meter - P->x0 * P->to_meter) * P->ra; /* descale and de-offset */ + xy.y = (xy.y * P->to_meter - P->y0 * P->to_meter) * P->ra; + + /* Check for NULL pointer */ + if (P->inv != NULL) { + lp = (*P->inv)(xy, P); /* inverse project */ + if (P->ctx->last_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)-M_HALFPI) > EPS) + lp.phi = atan(P->one_es * tan(lp.phi)); } - return lp; + } else { + lp.lam = lp.phi = HUGE_VAL; + } + + return lp; } |
