diff options
| -rw-r--r-- | src/gauss.cpp | 9 | ||||
| -rw-r--r-- | src/projections/bonne.cpp | 11 | ||||
| -rw-r--r-- | test/gie/builtins.gie | 28 |
3 files changed, 41 insertions, 7 deletions
diff --git a/src/gauss.cpp b/src/gauss.cpp index 49ccfa1c..a34a8f5b 100644 --- a/src/gauss.cpp +++ b/src/gauss.cpp @@ -65,13 +65,18 @@ void *pj_gauss_ini(double e, double phi0, double *chi, double *rc) { } *chi = asin(sphi / en->C); en->ratexp = 0.5 * en->C * e; + double srat_val = srat(en->e * sphi, en->ratexp); + if (srat_val == 0.0) { + free(en); + return nullptr; + } if( .5 * phi0 + M_FORTPI < 1e-10 ) { - en->K = 1.0 / srat(en->e * sphi, en->ratexp); + en->K = 1.0 / srat_val; } else { en->K = tan(.5 * *chi + M_FORTPI) / ( pow(tan(.5 * phi0 + M_FORTPI), en->C) * - srat(en->e * sphi, en->ratexp) ); + srat_val ); } return ((void *)en); } diff --git a/src/projections/bonne.cpp b/src/projections/bonne.cpp index 0e9bae79..289eb23d 100644 --- a/src/projections/bonne.cpp +++ b/src/projections/bonne.cpp @@ -26,9 +26,14 @@ static PJ_XY e_forward (PJ_LP lp, PJ *P) { /* Ellipsoidal, forward */ double rh, E, c; rh = Q->am1 + Q->m1 - pj_mlfn(lp.phi, E = sin(lp.phi), c = cos(lp.phi), Q->en); - E = c * lp.lam / (rh * sqrt(1. - P->es * E * E)); - xy.x = rh * sin(E); - xy.y = Q->am1 - rh * cos(E); + if (fabs(rh) > EPS10) { + E = c * lp.lam / (rh * sqrt(1. - P->es * E * E)); + xy.x = rh * sin(E); + xy.y = Q->am1 - rh * cos(E); + } else { + xy.x = 0.; + xy.y = 0.; + } return xy; } diff --git a/test/gie/builtins.gie b/test/gie/builtins.gie index 2cc44632..5f78c979 100644 --- a/test/gie/builtins.gie +++ b/test/gie/builtins.gie @@ -618,7 +618,7 @@ Bonne (Werner lat_1=90) =============================================================================== ------------------------------------------------------------------------------- -operation +proj=bonne +ellps=GRS80 +lat_1=0.5 +lat_2=2 +operation +proj=bonne +ellps=GRS80 +lat_1=0.5 ------------------------------------------------------------------------------- tolerance 0.1 mm accept 2 1 @@ -641,7 +641,18 @@ accept -200 -100 expect -0.001796698 0.499095631 ------------------------------------------------------------------------------- -operation +proj=bonne +R=6400000 +lat_1=0.5 +lat_2=2 +operation +proj=bonne +ellps=GRS80 +lat_1=90 +------------------------------------------------------------------------------- +tolerance 0.1 mm +accept 0 90 +expect 0 0 + +direction inverse +accept 0 0 +expect 0 90 + +------------------------------------------------------------------------------- +operation +proj=bonne +R=6400000 +lat_1=0.5 ------------------------------------------------------------------------------- tolerance 0.1 mm accept 2 1 @@ -663,6 +674,16 @@ expect -0.001790562 0.500895246 accept -200 -100 expect -0.001790561 0.499104753 +------------------------------------------------------------------------------- +operation +proj=bonne +R=6400000 +lat_1=90 +------------------------------------------------------------------------------- +tolerance 0.1 mm +accept 0 90 +expect 0 0 + +direction inverse +accept 0 0 +expect 0 90 =============================================================================== Cal Coop Ocean Fish Invest Lines/Stations @@ -4946,6 +4967,9 @@ accept 0 0 expect 0.000000000000 12493602.143489977345 +operation +proj=sterea +a=9999 +b=.9 +lat_0=73 +expect failure + =============================================================================== Gauss-Schreiber Transverse Mercator (aka Gauss-Laborde Reunion) Cyl, Sph&Ell |
