Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 7.0] utm/ups: make sure to set errno to PJD_ERR_ELLIPSOID_USE_REQUIRED if es==0 #2045

Merged
merged 1 commit into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/operations/projections/utm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ longigude.
+---------------------+----------------------------------------------------------+
| **Classification** | Transverse cylindrical, conformal |
+---------------------+----------------------------------------------------------+
| **Available forms** | Forward and inverse, Spherical and Elliptical |
| **Available forms** | Forward and inverse, Elliptical only |
+---------------------+----------------------------------------------------------+
| **Defined area** | Within the used zone, but transformations of coordinates |
| | in adjacent zones can be expected to be accurate as well |
Expand Down
5 changes: 2 additions & 3 deletions src/projections/stere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <math.h>

PROJ_HEAD(stere, "Stereographic") "\n\tAzi, Sph&Ell\n\tlat_ts=";
PROJ_HEAD(ups, "Universal Polar Stereographic") "\n\tAzi, Sph&Ell\n\tsouth";
PROJ_HEAD(ups, "Universal Polar Stereographic") "\n\tAzi, Ell\n\tsouth";


namespace { // anonymous namespace
Expand Down Expand Up @@ -320,8 +320,7 @@ PJ *PROJECTION(ups) {
/* International Ellipsoid */
P->phi0 = pj_param(P->ctx, P->params, "bsouth").i ? - M_HALFPI: M_HALFPI;
if (P->es == 0.0) {
proj_errno_set(P, PJD_ERR_ELLIPSOID_USE_REQUIRED);
return pj_default_destructor (P, ENOMEM);
return pj_default_destructor (P, PJD_ERR_ELLIPSOID_USE_REQUIRED);
}
P->k0 = .994;
P->x0 = 2000000.;
Expand Down
5 changes: 2 additions & 3 deletions src/projections/tmerc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

PROJ_HEAD(tmerc, "Transverse Mercator") "\n\tCyl, Sph&Ell\n\tapprox";
PROJ_HEAD(etmerc, "Extended Transverse Mercator") "\n\tCyl, Sph";
PROJ_HEAD(utm, "Universal Transverse Mercator (UTM)") "\n\tCyl, Sph\n\tzone= south approx";
PROJ_HEAD(utm, "Universal Transverse Mercator (UTM)") "\n\tCyl, Ell\n\tzone= south approx";

namespace { // anonymous namespace
struct pj_opaque_approx {
Expand Down Expand Up @@ -541,8 +541,7 @@ PJ *PROJECTION(etmerc) {
PJ *PROJECTION(utm) {
long zone;
if (P->es == 0.0) {
proj_errno_set(P, PJD_ERR_ELLIPSOID_USE_REQUIRED);
return pj_default_destructor(P, ENOMEM);
return pj_default_destructor(P, PJD_ERR_ELLIPSOID_USE_REQUIRED);
}
if (P->lam0 < -1000.0 || P->lam0 > 1000.0) {
return pj_default_destructor(P, PJD_ERR_INVALID_UTM_ZONE);
Expand Down
14 changes: 12 additions & 2 deletions test/gie/builtins.gie
Original file line number Diff line number Diff line change
Expand Up @@ -5554,7 +5554,7 @@ expect -0.001790432 -0.000841228

===============================================================================
Universal Polar Stereographic
Azi, Sph&Ell
Azi, Ell
south
===============================================================================

Expand All @@ -5581,6 +5581,10 @@ expect -45.004297076 64.915804281
accept -200 -100
expect -45.001432287 64.914588378

-------------------------------------------------------------------------------
operation +proj=ups +a=6400000
-------------------------------------------------------------------------------
expect failure errno ellipsoid_use_required

===============================================================================
Urmaev V
Expand Down Expand Up @@ -5636,7 +5640,7 @@ expect -0.002040721 -0.000785474

===============================================================================
Universal Transverse Mercator (UTM)
Cyl, Sph
Cyl, Ell
zone= south
===============================================================================

Expand Down Expand Up @@ -5674,6 +5678,12 @@ tolerance 0.001 mm
accept 12 56 0 2000
expect 687071.43911000 6210141.32675053 0.00000000 2000.0000


-------------------------------------------------------------------------------
operation +proj=utm +a=6400000 +zone=30
-------------------------------------------------------------------------------
expect failure errno ellipsoid_use_required

===============================================================================
van der Grinten (I)
Misc Sph
Expand Down