From b0fb037ea22e2e9452feda502455ac6110c3e1e3 Mon Sep 17 00:00:00 2001 From: Charles Karney Date: Sat, 24 Oct 2015 11:36:25 -0400 Subject: Switch utm to use etmerc to address issue #316. Add a test to check this. Output of an existing test changed in 7th decimal place. --- src/PJ_tmerc.c | 22 ---------------------- src/proj_etmerc.c | 33 +++++++++++++++++++++++++++++++-- src/projects.h | 2 +- 3 files changed, 32 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/PJ_tmerc.c b/src/PJ_tmerc.c index 3b1e0fb5..70e8e72f 100644 --- a/src/PJ_tmerc.c +++ b/src/PJ_tmerc.c @@ -5,8 +5,6 @@ #define PJ_LIB__ #include PROJ_HEAD(tmerc, "Transverse Mercator") "\n\tCyl, Sph&Ell"; -PROJ_HEAD(utm, "Universal Transverse Mercator (UTM)") - "\n\tCyl, Sph\n\tzone= south"; #define EPS10 1.e-10 #define aks0 P->esp #define aks5 P->ml0 @@ -153,23 +151,3 @@ setup(PJ *P) { /* general initialization */ } ENTRY1(tmerc, en) ENDENTRY(setup(P)) -ENTRY1(utm, en) - int zone; - - if (!P->es) E_ERROR(-34); - P->y0 = pj_param(P->ctx, P->params, "bsouth").i ? 10000000. : 0.; - P->x0 = 500000.; - if (pj_param(P->ctx, P->params, "tzone").i) /* zone input ? */ - if ((zone = pj_param(P->ctx, P->params, "izone").i) > 0 && zone <= 60) - --zone; - else - E_ERROR(-35) - else /* nearest central meridian input */ - if ((zone = floor((adjlon(P->lam0) + PI) * 30. / PI)) < 0) - zone = 0; - else if (zone >= 60) - zone = 59; - P->lam0 = (zone + .5) * PI / 30. - PI; - P->k0 = 0.9996; - P->phi0 = 0.; -ENDENTRY(setup(P)) diff --git a/src/proj_etmerc.c b/src/proj_etmerc.c index 1097eb3c..a5351f5d 100644 --- a/src/proj_etmerc.c +++ b/src/proj_etmerc.c @@ -52,6 +52,8 @@ PROJ_HEAD(etmerc, "Extended Transverse Mercator") "\n\tCyl, Sph\n\tlat_ts=(0)\nlat_0=(0)"; +PROJ_HEAD(utm, "Universal Transverse Mercator (UTM)") + "\n\tCyl, Sph\n\tzone= south"; #define PROJ_ETMERC_ORDER 6 @@ -211,7 +213,8 @@ INVERSE(e_inverse); /* ellipsoid */ FREEUP; if (P) free(P); } -ENTRY0(etmerc) + static PJ * +setup(PJ *P) { /* general initialization */ double f, n, np, Z; if (P->es <= 0) E_ERROR(-34); @@ -286,4 +289,30 @@ ENTRY0(etmerc) P->Zb = - P->Qn*(Z + clens(P->gtu, PROJ_ETMERC_ORDER, 2*Z)); P->inv = e_inverse; P->fwd = e_forward; -ENDENTRY(P) + return P; +} + +ENTRY0(etmerc) +ENDENTRY(setup(P)) + +/* utm uses etmerc for the underlying projection */ +ENTRY0(utm) + int zone; + + if (!P->es) E_ERROR(-34); + P->y0 = pj_param(P->ctx, P->params, "bsouth").i ? 10000000. : 0.; + P->x0 = 500000.; + if (pj_param(P->ctx, P->params, "tzone").i) /* zone input ? */ + if ((zone = pj_param(P->ctx, P->params, "izone").i) > 0 && zone <= 60) + --zone; + else + E_ERROR(-35) + else /* nearest central meridian input */ + if ((zone = floor((adjlon(P->lam0) + PI) * 30. / PI)) < 0) + zone = 0; + else if (zone >= 60) + zone = 59; + P->lam0 = (zone + .5) * PI / 30. - PI; + P->k0 = 0.9996; + P->phi0 = 0.; +ENDENTRY(setup(P)) diff --git a/src/projects.h b/src/projects.h index fe6a44c6..43287849 100644 --- a/src/projects.h +++ b/src/projects.h @@ -316,7 +316,7 @@ extern struct PJ_PRIME_MERIDIANS pj_prime_meridians[]; #endif #ifdef PJ_LIB__ - /* repeatative projection code */ + /* repetitive projection code */ #define PROJ_HEAD(id, name) static const char des_##id [] = name #define ENTRYA(name) \ C_NAMESPACE_VAR const char * const pj_s_##name = des_##name; \ -- cgit v1.2.3