diff --git a/include/boost/geometry/extensions/gis/projections/impl/pj_ell_set.hpp b/include/boost/geometry/extensions/gis/projections/impl/pj_ell_set.hpp index b7c890627..8737e91eb 100644 --- a/include/boost/geometry/extensions/gis/projections/impl/pj_ell_set.hpp +++ b/include/boost/geometry/extensions/gis/projections/impl/pj_ell_set.hpp @@ -126,18 +126,21 @@ inline void pj_ell_set(std::vector& parameters, double &a, double &es) } else if (pj_param(parameters, "bR_h").i) { /* sphere--harmonic mean */ a = 2. * a * b / (a + b); es = 0.; - } else if ((int i = pj_param(parameters, "tR_lat_a").i) || /* sphere--arith. */ - pj_param(parameters, "tR_lat_g").i) { /* or geom. mean at latitude */ - double tmp; + } else { + int i = pj_param(parameters, "tR_lat_a").i; + if (i || /* sphere--arith. */ + pj_param(parameters, "tR_lat_g").i) { /* or geom. mean at latitude */ + double tmp; - tmp = sin(pj_param(parameters, i ? "rR_lat_a" : "rR_lat_g").f); - if (geometry::math::abs(tmp) > HALFPI) { - throw proj_exception(-11); + tmp = sin(pj_param(parameters, i ? "rR_lat_a" : "rR_lat_g").f); + if (geometry::math::abs(tmp) > HALFPI) { + throw proj_exception(-11); + } + tmp = 1. - es * tmp * tmp; + a *= i ? .5 * (1. - es + tmp) / ( tmp * sqrt(tmp)) : + sqrt(1. - es) / tmp; + es = 0.; } - tmp = 1. - es * tmp * tmp; - a *= i ? .5 * (1. - es + tmp) / ( tmp * sqrt(tmp)) : - sqrt(1. - es) / tmp; - es = 0.; } }