diff options
| author | Charles Karney <ckarney@karney.com> | 2015-10-24 11:36:25 -0400 |
|---|---|---|
| committer | Charles Karney <ckarney@karney.com> | 2015-10-24 11:36:25 -0400 |
| commit | b0fb037ea22e2e9452feda502455ac6110c3e1e3 (patch) | |
| tree | 9894bb2f23bb430641bf954976c4dbdf911e3a72 | |
| parent | f4b687baa69f7f76b0fc9ce5970890285090db9e (diff) | |
| download | PROJ-b0fb037ea22e2e9452feda502455ac6110c3e1e3.tar.gz PROJ-b0fb037ea22e2e9452feda502455ac6110c3e1e3.zip | |
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.
| -rwxr-xr-x | nad/testvarious | 23 | ||||
| -rw-r--r-- | nad/tv_out.dist | 12 | ||||
| -rw-r--r-- | src/PJ_tmerc.c | 22 | ||||
| -rw-r--r-- | src/proj_etmerc.c | 33 | ||||
| -rw-r--r-- | src/projects.h | 2 |
5 files changed, 61 insertions, 31 deletions
diff --git a/nad/testvarious b/nad/testvarious index c213456e..0ea4c133 100755 --- a/nad/testvarious +++ b/nad/testvarious @@ -675,19 +675,36 @@ echo "##############################################################" >> ${OUT} echo "Test bug 245 (use +datum=carthage)" >> ${OUT} # $EXE -f '%.7f' \ - +proj=longlat +datum=WGS84 +nodefs +to +proj=utm +zone=32 +datum=carthage +nodefs \ + +proj=longlat +datum=WGS84 +no_defs +to +proj=utm +zone=32 +datum=carthage +no_defs \ -E >>${OUT} <<EOF 10 34 EOF echo "##############################################################" >> ${OUT} -echo "Test bug 245 (use expension of +datum=carthage)" >> ${OUT} +echo "Test bug 245 (use expansion of +datum=carthage)" >> ${OUT} # $EXE -f '%.7f' \ - +proj=longlat +datum=WGS84 +nodefs +to +proj=utm +zone=32 +a=6378249.2 +b=6356515 +towgs84=-263.0,6.0,431.0 +nodefs \ + +proj=longlat +datum=WGS84 +no_defs +to +proj=utm +zone=32 +a=6378249.2 +b=6356515 +towgs84=-263.0,6.0,431.0 +no_defs \ -E >>${OUT} <<EOF 10 34 EOF ############################################################################## +echo "##############################################################" >> ${OUT} +echo "Test issue #316 (switch utm to use etmerc)" >> ${OUT} +# +$EXE -f '%.6f' \ + +proj=latlong +datum=WGS84 +no_defs +to +proj=utm +zone=35 +datum=WGS84 +no_defs \ + -E >>${OUT} <<EOF +0 83 +EOF +############################################################################## +echo "##############################################################" >> ${OUT} +echo "Test issue #316 (switch utm to use etmerc)" >> ${OUT} +# +$EXE -f '%.6f' \ + +proj=latlong +datum=WGS84 +no_defs +to +proj=etmerc +datum=WGS84 +no_defs +k=0.9996 +lon_0=27 +x_0=500000 -f %.6f \ + -E >>${OUT} <<EOF +0 83 +EOF # Done! # do 'diff' with distribution results echo "diff ${OUT} with ${OUT}.dist" diff --git a/nad/tv_out.dist b/nad/tv_out.dist index 76d5b1e2..00063c47 100644 --- a/nad/tv_out.dist +++ b/nad/tv_out.dist @@ -313,7 +313,13 @@ Test bug 244 (2) 987122.418330284 -14429896.539530909 -140.10000000000 -87.00000000000 0.00000000000 ############################################################## Test bug 245 (use +datum=carthage) -10 34 592302.9819462 3762148.7340610 -30.3110170 +10 34 592302.9819461 3762148.7340609 -30.3110170 ############################################################## -Test bug 245 (use expension of +datum=carthage) -10 34 592302.9819462 3762148.7340610 -30.3110170 +Test bug 245 (use expansion of +datum=carthage) +10 34 592302.9819461 3762148.7340609 -30.3110170 +############################################################## +Test issue #316 (switch utm to use etmerc) +0 83 145723.870553 9300924.845226 0.000000 +############################################################## +Test issue #316 (switch utm to use etmerc) +0 83 145723.870553 9300924.845226 0.000000 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 <projects.h> 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; \ |
