aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
}