aboutsummaryrefslogtreecommitdiff
path: root/src/pj_inv.c
diff options
context:
space:
mode:
authorFrank Warmerdam <warmerdam@pobox.com>1999-03-18 16:34:52 +0000
committerFrank Warmerdam <warmerdam@pobox.com>1999-03-18 16:34:52 +0000
commit565a4bd035b9d4a83955808efef20f1d8dfa24cf (patch)
tree75785fc897708023f1ccdaf40079afcbaaf0fd3a /src/pj_inv.c
downloadPROJ-565a4bd035b9d4a83955808efef20f1d8dfa24cf.tar.gz
PROJ-565a4bd035b9d4a83955808efef20f1d8dfa24cf.zip
New
git-svn-id: http://svn.osgeo.org/metacrs/proj/trunk@776 4e78687f-474d-0410-85f9-8d5e500ac6b2
Diffstat (limited to 'src/pj_inv.c')
-rw-r--r--src/pj_inv.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/pj_inv.c b/src/pj_inv.c
new file mode 100644
index 00000000..16dd90dd
--- /dev/null
+++ b/src/pj_inv.c
@@ -0,0 +1,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;
+}