aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2016-10-20 21:56:06 +0200
committerKristian Evers <kristianevers@gmail.com>2016-10-20 22:23:15 +0200
commita8e73a544ca446fe3579f2b300ee398bef59da28 (patch)
treead0fd8e7d483f34340bb91d48803d503b0b0ec94
parentf253355bc22b118049c0f205bdd47e7fee6afe23 (diff)
downloadPROJ-a8e73a544ca446fe3579f2b300ee398bef59da28.tar.gz
PROJ-a8e73a544ca446fe3579f2b300ee398bef59da28.zip
Fixes #138 (spherical tmerc with negative northing gives inverted latitude)
-rw-r--r--src/PJ_tmerc.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/PJ_tmerc.c b/src/PJ_tmerc.c
index 0ae683bf..793f1e95 100644
--- a/src/PJ_tmerc.c
+++ b/src/PJ_tmerc.c
@@ -1,12 +1,12 @@
#define PJ_LIB__
-#include <projects.h>
+#include <projects.h>
PROJ_HEAD(tmerc, "Transverse Mercator") "\n\tCyl, Sph&Ell";
struct pj_opaque {
- double esp; \
- double ml0; \
+ double esp;
+ double ml0;
double *en;
};
@@ -146,7 +146,10 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
g = .5 * (h - 1. / h);
h = cos (P->phi0 + xy.y / P->opaque->esp);
lp.phi = asin(sqrt((1. - h * h) / (1. + g * g)));
- if (xy.y < 0.) lp.phi = -lp.phi;
+
+ /* Make sure that phi is on the correct hemisphere when false northing is used */
+ if (xy.y < 0. && -lp.phi+P->phi0 < 0.0) lp.phi = -lp.phi;
+
lp.lam = (g || h) ? atan2 (g, h) : 0.;
return lp;
}