diff --git a/include/boost/geometry/srs/projections/proj/aea.hpp b/include/boost/geometry/srs/projections/proj/aea.hpp index b2e4d6c13..a76f117b2 100644 --- a/include/boost/geometry/srs/projections/proj/aea.hpp +++ b/include/boost/geometry/srs/projections/proj/aea.hpp @@ -141,7 +141,7 @@ namespace projections { CalculationType rho = 0.0; if ((rho = this->m_proj_parm.c - (this->m_proj_parm.ellips ? this->m_proj_parm.n * pj_qsfn(sin(lp_lat), - this->m_par.e, this->m_par.one_es) : this->m_proj_parm.n2 * sin(lp_lat))) < 0.) throw proj_exception(); + this->m_par.e, this->m_par.one_es) : this->m_proj_parm.n2 * sin(lp_lat))) < 0.) throw proj_exception(-20); rho = this->m_proj_parm.dd * sqrt(rho); xy_x = rho * sin( lp_lon *= this->m_proj_parm.n ); xy_y = this->m_proj_parm.rho0 - rho * cos(lp_lon); @@ -165,7 +165,7 @@ namespace projections lp_lat = (this->m_proj_parm.c - lp_lat * lp_lat) / this->m_proj_parm.n; if (fabs(this->m_proj_parm.ec - fabs(lp_lat)) > TOL7) { if ((lp_lat = phi1_(lp_lat, this->m_par.e, this->m_par.one_es)) == HUGE_VAL) - throw proj_exception(); + throw proj_exception(-20); } else lp_lat = lp_lat < 0. ? -HALFPI : HALFPI; } else if (fabs(lp_lat = (this->m_proj_parm.c - lp_lat * lp_lat) / this->m_proj_parm.n2) <= 1.) diff --git a/include/boost/geometry/srs/projections/proj/aeqd.hpp b/include/boost/geometry/srs/projections/proj/aeqd.hpp index 2f9c0fe84..a2a5caa23 100644 --- a/include/boost/geometry/srs/projections/proj/aeqd.hpp +++ b/include/boost/geometry/srs/projections/proj/aeqd.hpp @@ -283,7 +283,7 @@ namespace projections oblcon: if (fabs(fabs(xy_y) - 1.) < TOL) if (xy_y < 0.) - throw proj_exception(); + throw proj_exception(-20); else xy_x = xy_y = 0.; else { @@ -298,7 +298,7 @@ namespace projections lp_lat = -lp_lat; coslam = -coslam; case S_POLE: - if (fabs(lp_lat - HALFPI) < EPS10) throw proj_exception();; + if (fabs(lp_lat - HALFPI) < EPS10) throw proj_exception(-20); xy_x = (xy_y = (HALFPI + lp_lat)) * sin(lp_lon); xy_y *= coslam; break; @@ -315,7 +315,7 @@ namespace projections CalculationType cosc, c_rh, sinc; if ((c_rh = boost::math::hypot(xy_x, xy_y)) > ONEPI) { - if (c_rh - EPS10 > ONEPI) throw proj_exception();; + if (c_rh - EPS10 > ONEPI) throw proj_exception(-20); c_rh = ONEPI; } else if (c_rh < EPS10) { lp_lat = this->m_par.phi0; diff --git a/include/boost/geometry/srs/projections/proj/airy.hpp b/include/boost/geometry/srs/projections/proj/airy.hpp index 94ad3ae15..44ac89b6c 100644 --- a/include/boost/geometry/srs/projections/proj/airy.hpp +++ b/include/boost/geometry/srs/projections/proj/airy.hpp @@ -118,7 +118,7 @@ namespace projections if (this->m_proj_parm.mode == OBLIQ) cosz = this->m_proj_parm.sinph0 * sinphi + this->m_proj_parm.cosph0 * cosz; if (!this->m_proj_parm.no_cut && cosz < -EPS) - throw proj_exception();; + throw proj_exception(-20); if (fabs(s = 1. - cosz) > EPS) { t = 0.5 * (1. + cosz); Krho = -log(t)/s - this->m_proj_parm.Cb / t; @@ -135,7 +135,7 @@ namespace projections case N_POLE: lp_lat = fabs(this->m_proj_parm.p_halfpi - lp_lat); if (!this->m_proj_parm.no_cut && (lp_lat - EPS) > HALFPI) - throw proj_exception();; + throw proj_exception(-20); if ((lp_lat *= 0.5) > EPS) { t = tan(lp_lat); Krho = -2.*(log(cos(lp_lat)) / t + t * this->m_proj_parm.Cb); diff --git a/include/boost/geometry/srs/projections/proj/bipc.hpp b/include/boost/geometry/srs/projections/proj/bipc.hpp index c7f85e959..c3bade240 100644 --- a/include/boost/geometry/srs/projections/proj/bipc.hpp +++ b/include/boost/geometry/srs/projections/proj/bipc.hpp @@ -130,7 +130,7 @@ namespace projections sdlam = sin(sdlam); z = S20 * sphi + C20 * cphi * cdlam; if (fabs(z) > 1.) { - if (fabs(z) > ONEEPS) throw proj_exception(); + if (fabs(z) > ONEEPS) throw proj_exception(-20); else z = z < 0. ? -1. : 1.; } else z = acos(z); @@ -141,19 +141,19 @@ namespace projections } else { z = S45 * (sphi + cphi * cdlam); if (fabs(z) > 1.) { - if (fabs(z) > ONEEPS) throw proj_exception(); + if (fabs(z) > ONEEPS) throw proj_exception(-20); else z = z < 0. ? -1. : 1.; } else z = acos(z); Av = Azba; xy_y = -rhoc; } - if (z < 0.) throw proj_exception();; + if (z < 0.) throw proj_exception(-20); r = F * (t = pow(tan(.5 * z), n)); - if ((al = .5 * (R104 - z)) < 0.) throw proj_exception();; + if ((al = .5 * (R104 - z)) < 0.) throw proj_exception(-20); al = (t + pow(al, n)) / T; if (fabs(al) > 1.) { - if (fabs(al) > ONEEPS) throw proj_exception(); + if (fabs(al) > ONEEPS) throw proj_exception(-20); else al = al < 0. ? -1. : 1.; } else al = acos(al); @@ -203,7 +203,7 @@ namespace projections break; rl = r; } - if (! i) throw proj_exception();; + if (! i) throw proj_exception(-20); Az = Av - Az / n; lp_lat = asin(s * cos(z) + c * sin(z) * cos(Az)); lp_lon = atan2(sin(Az), c / tan(z) - s * cos(Az)); diff --git a/include/boost/geometry/srs/projections/proj/bonne.hpp b/include/boost/geometry/srs/projections/proj/bonne.hpp index 8d878e5f8..5f19e15a1 100644 --- a/include/boost/geometry/srs/projections/proj/bonne.hpp +++ b/include/boost/geometry/srs/projections/proj/bonne.hpp @@ -120,7 +120,7 @@ namespace projections sqrt(1. - this->m_par.es * s * s) / cos(lp_lat); } else if (fabs(s - HALFPI) <= EPS10) lp_lon = 0.; - else throw proj_exception();; + else throw proj_exception(-20); } static inline std::string get_name() @@ -169,7 +169,7 @@ namespace projections rh = boost::math::hypot(xy_x, xy_y = this->m_proj_parm.cphi1 - xy_y); lp_lat = this->m_proj_parm.cphi1 + this->m_proj_parm.phi1 - rh; - if (fabs(lp_lat) > HALFPI) throw proj_exception(); + if (fabs(lp_lat) > HALFPI) throw proj_exception(-20); if (fabs(fabs(lp_lat) - HALFPI) <= EPS10) lp_lon = 0.; else diff --git a/include/boost/geometry/srs/projections/proj/cc.hpp b/include/boost/geometry/srs/projections/proj/cc.hpp index 68beb4065..418a3df6c 100644 --- a/include/boost/geometry/srs/projections/proj/cc.hpp +++ b/include/boost/geometry/srs/projections/proj/cc.hpp @@ -92,7 +92,7 @@ namespace projections { static const CalculationType HALFPI = detail::HALFPI(); - if (fabs(fabs(lp_lat) - HALFPI) <= EPS10) throw proj_exception(); + if (fabs(fabs(lp_lat) - HALFPI) <= EPS10) throw proj_exception(-20); xy_x = lp_lon; xy_y = tan(lp_lat); } diff --git a/include/boost/geometry/srs/projections/proj/cea.hpp b/include/boost/geometry/srs/projections/proj/cea.hpp index 213f64608..fbcebb6ae 100644 --- a/include/boost/geometry/srs/projections/proj/cea.hpp +++ b/include/boost/geometry/srs/projections/proj/cea.hpp @@ -149,7 +149,7 @@ namespace projections else lp_lat = asin(xy_y); lp_lon = xy_x / this->m_par.k0; - } else throw proj_exception(); + } else throw proj_exception(-20); } static inline std::string get_name() diff --git a/include/boost/geometry/srs/projections/proj/collg.hpp b/include/boost/geometry/srs/projections/proj/collg.hpp index 514640ed8..4bb2dffe3 100644 --- a/include/boost/geometry/srs/projections/proj/collg.hpp +++ b/include/boost/geometry/srs/projections/proj/collg.hpp @@ -100,7 +100,7 @@ namespace projections lp_lat = xy_y / FYC - 1.; if (fabs(lp_lat = 1. - lp_lat * lp_lat) < 1.) lp_lat = asin(lp_lat); - else if (fabs(lp_lat) > ONEEPS) throw proj_exception(); + else if (fabs(lp_lat) > ONEEPS) throw proj_exception(-20); else lp_lat = lp_lat < 0. ? -geometry::math::half_pi() : geometry::math::half_pi(); if ((lp_lon = 1. - sin(lp_lat)) <= 0.) lp_lon = 0.; diff --git a/include/boost/geometry/srs/projections/proj/eck2.hpp b/include/boost/geometry/srs/projections/proj/eck2.hpp index 26905386c..a08fc8399 100644 --- a/include/boost/geometry/srs/projections/proj/eck2.hpp +++ b/include/boost/geometry/srs/projections/proj/eck2.hpp @@ -101,7 +101,7 @@ namespace projections lp_lon = xy_x / (FXC * ( lp_lat = 2. - fabs(xy_y) / FYC) ); lp_lat = (4. - lp_lat * lp_lat) * C13; if (fabs(lp_lat) >= 1.) { - if (fabs(lp_lat) > ONEEPS) throw proj_exception(); + if (fabs(lp_lat) > ONEEPS) throw proj_exception(-20); else lp_lat = lp_lat < 0. ? -HALFPI : HALFPI; } else diff --git a/include/boost/geometry/srs/projections/proj/geos.hpp b/include/boost/geometry/srs/projections/proj/geos.hpp index b05112976..591e996bb 100644 --- a/include/boost/geometry/srs/projections/proj/geos.hpp +++ b/include/boost/geometry/srs/projections/proj/geos.hpp @@ -112,7 +112,7 @@ namespace projections Vz = r * sin (lp_lat); /* Check visibility. */ if (((this->m_proj_parm.radius_g - Vx) * Vx - Vy * Vy - Vz * Vz * this->m_proj_parm.radius_p_inv2) < 0.) - throw proj_exception();; + throw proj_exception(-20); /* Calculation based on view angles from satellite. */ tmp = this->m_proj_parm.radius_g - Vx; if(this->m_proj_parm.flip_axis) @@ -149,7 +149,7 @@ namespace projections a = Vz / this->m_proj_parm.radius_p; a = Vy * Vy + a * a + Vx * Vx; b = 2 * this->m_proj_parm.radius_g * Vx; - if ((det = (b * b) - 4 * a * this->m_proj_parm.C) < 0.) throw proj_exception();; + if ((det = (b * b) - 4 * a * this->m_proj_parm.C) < 0.) throw proj_exception(-20); /* Calculation of three components of vector from satellite to position.*/ k = (-b - sqrt(det)) / (2. * a); Vx = this->m_proj_parm.radius_g + k * Vx; @@ -196,7 +196,7 @@ namespace projections Vy = sin (lp_lon) * tmp; Vz = sin (lp_lat); /* Check visibility.*/ - if (((this->m_proj_parm.radius_g - Vx) * Vx - Vy * Vy - Vz * Vz) < 0.) throw proj_exception();; + if (((this->m_proj_parm.radius_g - Vx) * Vx - Vy * Vy - Vz * Vz) < 0.) throw proj_exception(-20); /* Calculation based on view angles from satellite.*/ tmp = this->m_proj_parm.radius_g - Vx; if(this->m_proj_parm.flip_axis) @@ -232,7 +232,7 @@ namespace projections /* Calculation of terms in cubic equation and determinant.*/ a = Vy * Vy + Vz * Vz + Vx * Vx; b = 2 * this->m_proj_parm.radius_g * Vx; - if ((det = (b * b) - 4 * a * this->m_proj_parm.C) < 0.) throw proj_exception();; + if ((det = (b * b) - 4 * a * this->m_proj_parm.C) < 0.) throw proj_exception(-20); /* Calculation of three components of vector from satellite to position.*/ k = (-b - sqrt(det)) / (2 * a); Vx = this->m_proj_parm.radius_g + k * Vx; diff --git a/include/boost/geometry/srs/projections/proj/gn_sinu.hpp b/include/boost/geometry/srs/projections/proj/gn_sinu.hpp index de3d751bc..aaf0313a3 100644 --- a/include/boost/geometry/srs/projections/proj/gn_sinu.hpp +++ b/include/boost/geometry/srs/projections/proj/gn_sinu.hpp @@ -119,7 +119,7 @@ namespace projections lp_lon = xy_x * sqrt(1. - this->m_par.es * s * s) / cos(lp_lat); } else if ((s - EPS10) < HALFPI) lp_lon = 0.; - else throw proj_exception();; + else throw proj_exception(-20); } /* General spherical sinusoidals */ @@ -163,7 +163,7 @@ namespace projections break; } if (!i) - throw proj_exception(); + throw proj_exception(-20); } xy_x = this->m_proj_parm.C_x * lp_lon * (this->m_proj_parm.m + cos(lp_lat)); xy_y = this->m_proj_parm.C_y * lp_lat; diff --git a/include/boost/geometry/srs/projections/proj/gnom.hpp b/include/boost/geometry/srs/projections/proj/gnom.hpp index 2623733dd..9f7aeccd7 100644 --- a/include/boost/geometry/srs/projections/proj/gnom.hpp +++ b/include/boost/geometry/srs/projections/proj/gnom.hpp @@ -116,7 +116,7 @@ namespace projections xy_y = sinphi; break; } - if (xy_y <= EPS10) throw proj_exception();; + if (xy_y <= EPS10) throw proj_exception(-20); xy_x = (xy_y = 1. / xy_y) * cosphi * sin(lp_lon); switch (this->m_proj_parm.mode) { case EQUIT: diff --git a/include/boost/geometry/srs/projections/proj/hatano.hpp b/include/boost/geometry/srs/projections/proj/hatano.hpp index b40156ddd..412faca71 100644 --- a/include/boost/geometry/srs/projections/proj/hatano.hpp +++ b/include/boost/geometry/srs/projections/proj/hatano.hpp @@ -114,19 +114,28 @@ namespace projections CalculationType th; th = xy_y * ( xy_y < 0. ? RYCS : RYCN); - if (fabs(th) > 1.) - if (fabs(th) > ONETOL) throw proj_exception(); - else th = th > 0. ? geometry::math::half_pi() : - geometry::math::half_pi(); - else + if (fabs(th) > 1.) { + if (fabs(th) > ONETOL) { + throw proj_exception(-20); + } else { + th = th > 0. ? geometry::math::half_pi() : - geometry::math::half_pi(); + } + } else { th = asin(th); + } + lp_lon = RXC * xy_x / cos(th); th += th; lp_lat = (th + sin(th)) * (xy_y < 0. ? RCS : RCN); - if (fabs(lp_lat) > 1.) - if (fabs(lp_lat) > ONETOL) throw proj_exception(); - else lp_lat = lp_lat > 0. ? geometry::math::half_pi() : - geometry::math::half_pi(); - else + if (fabs(lp_lat) > 1.) { + if (fabs(lp_lat) > ONETOL) { + throw proj_exception(-20); + } else { + lp_lat = lp_lat > 0. ? geometry::math::half_pi() : - geometry::math::half_pi(); + } + } else { lp_lat = asin(lp_lat); + } } static inline std::string get_name() diff --git a/include/boost/geometry/srs/projections/proj/laea.hpp b/include/boost/geometry/srs/projections/proj/laea.hpp index 04596eb04..5eccdf7a8 100644 --- a/include/boost/geometry/srs/projections/proj/laea.hpp +++ b/include/boost/geometry/srs/projections/proj/laea.hpp @@ -135,7 +135,7 @@ namespace projections q = this->m_proj_parm.qp + q; break; } - if (fabs(b) < EPS10) throw proj_exception();; + if (fabs(b) < EPS10) throw proj_exception(-20); switch (this->m_proj_parm.mode) { case OBLIQ: xy_y = this->m_proj_parm.ymf * ( b = sqrt(2. / b) ) @@ -242,7 +242,7 @@ namespace projections case OBLIQ: xy_y = 1. + this->m_proj_parm.sinb1 * sinphi + this->m_proj_parm.cosb1 * cosphi * coslam; oblcon: - if (xy_y <= EPS10) throw proj_exception();; + if (xy_y <= EPS10) throw proj_exception(-20); xy_x = (xy_y = sqrt(2. / xy_y)) * cosphi * sin(lp_lon); xy_y *= this->m_proj_parm.mode == EQUIT ? sinphi : this->m_proj_parm.cosb1 * sinphi - this->m_proj_parm.sinb1 * cosphi * coslam; @@ -250,7 +250,7 @@ namespace projections case N_POLE: coslam = -coslam; case S_POLE: - if (fabs(lp_lat + this->m_par.phi0) < EPS10) throw proj_exception();; + if (fabs(lp_lat + this->m_par.phi0) < EPS10) throw proj_exception(-20); xy_y = FORTPI - lp_lat * .5; xy_y = 2. * (this->m_proj_parm.mode == S_POLE ? cos(xy_y) : sin(xy_y)); xy_x = xy_y * sin(lp_lon); @@ -268,7 +268,7 @@ namespace projections CalculationType cosz=0.0, rh, sinz=0.0; rh = boost::math::hypot(xy_x, xy_y); - if ((lp_lat = rh * .5 ) > 1.) throw proj_exception();; + if ((lp_lat = rh * .5 ) > 1.) throw proj_exception(-20); lp_lat = 2. * asin(lp_lat); if (this->m_proj_parm.mode == OBLIQ || this->m_proj_parm.mode == EQUIT) { sinz = sin(lp_lat); diff --git a/include/boost/geometry/srs/projections/proj/lagrng.hpp b/include/boost/geometry/srs/projections/proj/lagrng.hpp index 2e03901f9..4b025eba0 100644 --- a/include/boost/geometry/srs/projections/proj/lagrng.hpp +++ b/include/boost/geometry/srs/projections/proj/lagrng.hpp @@ -103,7 +103,7 @@ namespace projections lp_lat = sin(lp_lat); v = this->m_proj_parm.a1 * pow((1. + lp_lat)/(1. - lp_lat), this->m_proj_parm.hrw); if ((c = 0.5 * (v + 1./v) + cos(lp_lon *= this->m_proj_parm.rw)) < TOL) - throw proj_exception();; + throw proj_exception(-20); xy_x = 2. * sin(lp_lon) / c; xy_y = (v - 1./v) / c; } diff --git a/include/boost/geometry/srs/projections/proj/lcc.hpp b/include/boost/geometry/srs/projections/proj/lcc.hpp index 409c4fd01..93afcd678 100644 --- a/include/boost/geometry/srs/projections/proj/lcc.hpp +++ b/include/boost/geometry/srs/projections/proj/lcc.hpp @@ -105,7 +105,7 @@ namespace projections CalculationType rho; if (fabs(fabs(lp_lat) - HALFPI) < EPS10) { - if ((lp_lat * this->m_proj_parm.n) <= 0.) throw proj_exception();; + if ((lp_lat * this->m_proj_parm.n) <= 0.) throw proj_exception(-20); rho = 0.; } else @@ -133,7 +133,7 @@ namespace projections if (this->m_proj_parm.ellips) { if ((lp_lat = pj_phi2(pow(rho / this->m_proj_parm.c, 1./this->m_proj_parm.n), this->m_par.e)) == HUGE_VAL) - throw proj_exception();; + throw proj_exception(-20); } else lp_lat = 2. * atan(pow(this->m_proj_parm.c / rho, 1./this->m_proj_parm.n)) - HALFPI; lp_lon = atan2(xy_x, xy_y) / this->m_proj_parm.n; diff --git a/include/boost/geometry/srs/projections/proj/lcca.hpp b/include/boost/geometry/srs/projections/proj/lcca.hpp index 888d44e0d..201521711 100644 --- a/include/boost/geometry/srs/projections/proj/lcca.hpp +++ b/include/boost/geometry/srs/projections/proj/lcca.hpp @@ -132,7 +132,7 @@ namespace projections S -= (dif = (fS(S, this->m_proj_parm.C) - dr) / fSp(S, this->m_proj_parm.C)); if (fabs(dif) < DEL_TOL) break; } - if (!i) throw proj_exception(); + if (!i) throw proj_exception(-20); lp_lat = pj_inv_mlfn(S + this->m_proj_parm.M0, this->m_par.es, this->m_proj_parm.en); } diff --git a/include/boost/geometry/srs/projections/proj/mbtfpp.hpp b/include/boost/geometry/srs/projections/proj/mbtfpp.hpp index 80112fe4f..fa347c263 100644 --- a/include/boost/geometry/srs/projections/proj/mbtfpp.hpp +++ b/include/boost/geometry/srs/projections/proj/mbtfpp.hpp @@ -110,14 +110,18 @@ namespace projections lp_lat = xy_y / FYC; if (fabs(lp_lat) >= 1.) { - if (fabs(lp_lat) > ONEEPS) throw proj_exception(); - else lp_lat = (lp_lat < 0.) ? -HALFPI : HALFPI; + if (fabs(lp_lat) > ONEEPS) + throw proj_exception(-20); + else + lp_lat = (lp_lat < 0.) ? -HALFPI : HALFPI; } else lp_lat = asin(lp_lat); lp_lon = xy_x / ( FXC * (2. * cos(C23 * (lp_lat *= 3.)) - 1.) ); if (fabs(lp_lat = sin(lp_lat) / CS_) >= 1.) { - if (fabs(lp_lat) > ONEEPS) throw proj_exception(); - else lp_lat = (lp_lat < 0.) ? -HALFPI : HALFPI; + if (fabs(lp_lat) > ONEEPS) + throw proj_exception(-20); + else + lp_lat = (lp_lat < 0.) ? -HALFPI : HALFPI; } else lp_lat = asin(lp_lat); } diff --git a/include/boost/geometry/srs/projections/proj/mbtfpq.hpp b/include/boost/geometry/srs/projections/proj/mbtfpq.hpp index be6da0c1f..0f9798ebe 100644 --- a/include/boost/geometry/srs/projections/proj/mbtfpq.hpp +++ b/include/boost/geometry/srs/projections/proj/mbtfpq.hpp @@ -115,7 +115,7 @@ namespace projections lp_lat = RYC * xy_y; if (fabs(lp_lat) > 1.) { - if (fabs(lp_lat) > ONETOL) throw proj_exception(); + if (fabs(lp_lat) > ONETOL) throw proj_exception(-20); else if (lp_lat < 0.) { t = -1.; lp_lat = -ONEPI; } else { t = 1.; lp_lat = ONEPI; } } else @@ -123,7 +123,7 @@ namespace projections lp_lon = RXC * xy_x / (1. + 2. * cos(lp_lat)/cos(0.5 * lp_lat)); lp_lat = RC * (t + sin(lp_lat)); if (fabs(lp_lat) > 1.) - if (fabs(lp_lat) > ONETOL) throw proj_exception(); + if (fabs(lp_lat) > ONETOL) throw proj_exception(-20); else lp_lat = lp_lat < 0. ? -HALFPI : HALFPI; else lp_lat = asin(lp_lat); diff --git a/include/boost/geometry/srs/projections/proj/merc.hpp b/include/boost/geometry/srs/projections/proj/merc.hpp index 5e0959083..a7c1ec5b9 100644 --- a/include/boost/geometry/srs/projections/proj/merc.hpp +++ b/include/boost/geometry/srs/projections/proj/merc.hpp @@ -88,7 +88,8 @@ namespace projections { static const CalculationType HALFPI = detail::HALFPI(); - if (fabs(fabs(lp_lat) - HALFPI) <= EPS10) throw proj_exception(); + if (fabs(fabs(lp_lat) - HALFPI) <= EPS10) + throw proj_exception(-20); xy_x = this->m_par.k0 * lp_lon; xy_y = - this->m_par.k0 * log(pj_tsfn(lp_lat, sin(lp_lat), this->m_par.e)); } @@ -97,7 +98,8 @@ namespace projections // Project coordinates from cartesian (x, y) to geographic (lon, lat) inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const { - if ((lp_lat = pj_phi2(exp(- xy_y / this->m_par.k0), this->m_par.e)) == HUGE_VAL) throw proj_exception(); + if ((lp_lat = pj_phi2(exp(- xy_y / this->m_par.k0), this->m_par.e)) == HUGE_VAL) + throw proj_exception(-20); lp_lon = xy_x / this->m_par.k0; } @@ -129,7 +131,8 @@ namespace projections static const CalculationType HALFPI = detail::HALFPI(); static const CalculationType FORTPI = detail::FORTPI(); - if (fabs(fabs(lp_lat) - HALFPI) <= EPS10) throw proj_exception(); + if (fabs(fabs(lp_lat) - HALFPI) <= EPS10) + throw proj_exception(-20); xy_x = this->m_par.k0 * lp_lon; xy_y = this->m_par.k0 * log(tan(FORTPI + .5 * lp_lat)); } diff --git a/include/boost/geometry/srs/projections/proj/nsper.hpp b/include/boost/geometry/srs/projections/proj/nsper.hpp index 6aebd999f..7f9b4605c 100644 --- a/include/boost/geometry/srs/projections/proj/nsper.hpp +++ b/include/boost/geometry/srs/projections/proj/nsper.hpp @@ -128,7 +128,7 @@ namespace projections xy_y = sinphi; break; } - if (xy_y < this->m_proj_parm.rp) throw proj_exception();; + if (xy_y < this->m_proj_parm.rp) throw proj_exception(-20); xy_y = this->m_proj_parm.pn1 / (this->m_proj_parm.p - xy_y); xy_x = xy_y * cosphi * sin(lp_lon); switch (this->m_proj_parm.mode) { @@ -171,7 +171,7 @@ namespace projections xy_y = bq * this->m_proj_parm.cg - bm * this->m_proj_parm.sg; } rh = boost::math::hypot(xy_x, xy_y); - if ((sinz = 1. - rh * rh * this->m_proj_parm.pfact) < 0.) throw proj_exception();; + if ((sinz = 1. - rh * rh * this->m_proj_parm.pfact) < 0.) throw proj_exception(-20); sinz = (this->m_proj_parm.p - sqrt(sinz)) / (this->m_proj_parm.pn1 / rh + rh / this->m_proj_parm.pn1); cosz = sqrt(1. - sinz * sinz); if (fabs(rh) <= EPS10) { diff --git a/include/boost/geometry/srs/projections/proj/omerc.hpp b/include/boost/geometry/srs/projections/proj/omerc.hpp index e79a04a5b..497621616 100644 --- a/include/boost/geometry/srs/projections/proj/omerc.hpp +++ b/include/boost/geometry/srs/projections/proj/omerc.hpp @@ -108,7 +108,7 @@ namespace projections V = sin(this->m_proj_parm.B * lp_lon); U = (S * this->m_proj_parm.singam - V * this->m_proj_parm.cosgam) / T; if (fabs(fabs(U) - 1.0) < EPS) - throw proj_exception();; + throw proj_exception(-20); v = 0.5 * this->m_proj_parm.ArB * log((1. - U)/(1. + U)); temp = cos(this->m_proj_parm.B * lp_lon); if(fabs(temp) < TOL) { @@ -156,7 +156,7 @@ namespace projections } else { lp_lat = this->m_proj_parm.E / sqrt((1. + Up) / (1. - Up)); if ((lp_lat = pj_phi2(pow(lp_lat, 1. / this->m_proj_parm.B), this->m_par.e)) == HUGE_VAL) - throw proj_exception();; + throw proj_exception(-20); lp_lon = - this->m_proj_parm.rB * atan2((Sp * this->m_proj_parm.cosgam - Vp * this->m_proj_parm.singam), cos(this->m_proj_parm.BrA * u)); } diff --git a/include/boost/geometry/srs/projections/proj/ortho.hpp b/include/boost/geometry/srs/projections/proj/ortho.hpp index 0dc42db0f..42014feb0 100644 --- a/include/boost/geometry/srs/projections/proj/ortho.hpp +++ b/include/boost/geometry/srs/projections/proj/ortho.hpp @@ -105,18 +105,18 @@ namespace projections coslam = cos(lp_lon); switch (this->m_proj_parm.mode) { case EQUIT: - if (cosphi * coslam < - EPS10) throw proj_exception(); + if (cosphi * coslam < - EPS10) throw proj_exception(-20); xy_y = sin(lp_lat); break; case OBLIQ: if (this->m_proj_parm.sinph0 * (sinphi = sin(lp_lat)) + - this->m_proj_parm.cosph0 * cosphi * coslam < - EPS10) throw proj_exception(); + this->m_proj_parm.cosph0 * cosphi * coslam < - EPS10) throw proj_exception(-20); xy_y = this->m_proj_parm.cosph0 * sinphi - this->m_proj_parm.sinph0 * cosphi * coslam; break; case N_POLE: coslam = - coslam; case S_POLE: - if (fabs(lp_lat - this->m_par.phi0) - EPS10 > HALFPI) throw proj_exception(); + if (fabs(lp_lat - this->m_par.phi0) - EPS10 > HALFPI) throw proj_exception(-20); xy_y = cosphi * coslam; break; } @@ -132,7 +132,7 @@ namespace projections CalculationType rh, cosc, sinc; if ((sinc = (rh = boost::math::hypot(xy_x, xy_y))) > 1.) { - if ((sinc - 1.) > EPS10) throw proj_exception(); + if ((sinc - 1.) > EPS10) throw proj_exception(-20); sinc = 1.; } cosc = sqrt(1. - sinc * sinc); /* in this range OK */ diff --git a/include/boost/geometry/srs/projections/proj/poly.hpp b/include/boost/geometry/srs/projections/proj/poly.hpp index 7e4450653..7813ba4df 100644 --- a/include/boost/geometry/srs/projections/proj/poly.hpp +++ b/include/boost/geometry/srs/projections/proj/poly.hpp @@ -111,8 +111,10 @@ namespace projections inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const { xy_y += this->m_proj_parm.ml0; - if (fabs(xy_y) <= TOL) { lp_lon = xy_x; lp_lat = 0.; } - else { + if (fabs(xy_y) <= TOL) { + lp_lon = xy_x; + lp_lat = 0.; + } else { CalculationType r, c, sp, cp, s2ph, ml, mlb, mlp, dPhi; int i; @@ -121,7 +123,7 @@ namespace projections sp = sin(lp_lat); s2ph = sp * ( cp = cos(lp_lat)); if (fabs(cp) < ITOL) - throw proj_exception();; + throw proj_exception(-20); c = sp * (mlp = sqrt(1. - this->m_par.es * sp * sp)) / cp; ml = pj_mlfn(lp_lat, sp, cp, this->m_proj_parm.en); mlb = ml * ml + r; @@ -134,7 +136,7 @@ namespace projections break; } if (!i) - throw proj_exception();; + throw proj_exception(-20); c = sin(lp_lat); lp_lon = asin(xy_x * tan(lp_lat) * sqrt(1. - this->m_par.es * c * c)) / sin(lp_lat); } @@ -168,8 +170,10 @@ namespace projections { CalculationType cot, E; - if (fabs(lp_lat) <= TOL) { xy_x = lp_lon; xy_y = this->m_proj_parm.ml0; } - else { + if (fabs(lp_lat) <= TOL) { + xy_x = lp_lon; + xy_y = this->m_proj_parm.ml0; + } else { cot = 1. / tan(lp_lat); xy_x = sin(E = lp_lon * sin(lp_lat)) * cot; xy_y = lp_lat - this->m_par.phi0 + cot * (1. - cos(E)); @@ -183,8 +187,10 @@ namespace projections CalculationType B, dphi, tp; int i; - if (fabs(xy_y = this->m_par.phi0 + xy_y) <= TOL) { lp_lon = xy_x; lp_lat = 0.; } - else { + if (fabs(xy_y = this->m_par.phi0 + xy_y) <= TOL) { + lp_lon = xy_x; + lp_lat = 0.; + } else { lp_lat = xy_y; B = xy_x * xy_x + xy_y * xy_y; i = N_ITER; @@ -194,7 +200,7 @@ namespace projections .5 * ( lp_lat * lp_lat + B) * tp) / ((lp_lat - xy_y) / tp - 1.)); } while (fabs(dphi) > CONV && --i); - if (! i) throw proj_exception();; + if (! i) throw proj_exception(-20); lp_lon = asin(xy_x * tan(lp_lat)) / sin(lp_lat); } } diff --git a/include/boost/geometry/srs/projections/proj/somerc.hpp b/include/boost/geometry/srs/projections/proj/somerc.hpp index f3b74238a..de5bd0e48 100644 --- a/include/boost/geometry/srs/projections/proj/somerc.hpp +++ b/include/boost/geometry/srs/projections/proj/somerc.hpp @@ -136,7 +136,7 @@ namespace projections lp_lat = phip; lp_lon = lamp / this->m_proj_parm.c; } else - throw proj_exception(); + throw proj_exception(-20); } static inline std::string get_name() diff --git a/include/boost/geometry/srs/projections/proj/stere.hpp b/include/boost/geometry/srs/projections/proj/stere.hpp index eec4e84b1..7947b3f7e 100644 --- a/include/boost/geometry/srs/projections/proj/stere.hpp +++ b/include/boost/geometry/srs/projections/proj/stere.hpp @@ -190,7 +190,7 @@ namespace projections return; } } - throw proj_exception();; + throw proj_exception(-20); } static inline std::string get_name() diff --git a/include/boost/geometry/srs/projections/proj/tcc.hpp b/include/boost/geometry/srs/projections/proj/tcc.hpp index 654cd2377..eb720623e 100644 --- a/include/boost/geometry/srs/projections/proj/tcc.hpp +++ b/include/boost/geometry/srs/projections/proj/tcc.hpp @@ -91,7 +91,7 @@ namespace projections CalculationType b, bt; b = cos(lp_lat) * sin(lp_lon); - if ((bt = 1. - b * b) < EPS10) throw proj_exception(); + if ((bt = 1. - b * b) < EPS10) throw proj_exception(-20); xy_x = b / sqrt(bt); xy_y = atan2(tan(lp_lat) , cos(lp_lon)); } diff --git a/include/boost/geometry/srs/projections/proj/tmerc.hpp b/include/boost/geometry/srs/projections/proj/tmerc.hpp index 95117f1e6..363012d4a 100644 --- a/include/boost/geometry/srs/projections/proj/tmerc.hpp +++ b/include/boost/geometry/srs/projections/proj/tmerc.hpp @@ -134,22 +134,23 @@ namespace projections CalculationType al, als, n, cosphi, sinphi, t; - /* - * Fail if our longitude is more than 90 degrees from the - * central meridian since the results are essentially garbage. - * Is error -20 really an appropriate return value? - * - * http://trac.osgeo.org/proj/ticket/5 - */ - if( lp_lon < -HALFPI || lp_lon > HALFPI ) - { - xy_x = HUGE_VAL; - xy_y = HUGE_VAL; - throw proj_exception( -14 ); - return; - } + /* + * Fail if our longitude is more than 90 degrees from the + * central meridian since the results are essentially garbage. + * Is error -20 really an appropriate return value? + * + * http://trac.osgeo.org/proj/ticket/5 + */ + if( lp_lon < -HALFPI || lp_lon > HALFPI ) + { + xy_x = HUGE_VAL; + xy_y = HUGE_VAL; + throw proj_exception( -14 ); + return; + } - sinphi = sin(lp_lat); cosphi = cos(lp_lat); + sinphi = sin(lp_lat); + cosphi = cos(lp_lat); t = fabs(cosphi) > 1e-10 ? sinphi/cosphi : 0.; t *= t; al = cosphi * lp_lon; @@ -242,30 +243,39 @@ namespace projections CalculationType b, cosphi; - /* - * Fail if our longitude is more than 90 degrees from the - * central meridian since the results are essentially garbage. - * Is error -20 really an appropriate return value? - * - * http://trac.osgeo.org/proj/ticket/5 - */ - if( lp_lon < -HALFPI || lp_lon > HALFPI ) - { - xy_x = HUGE_VAL; - xy_y = HUGE_VAL; - throw proj_exception( -14 ); - return; - } + /* + * Fail if our longitude is more than 90 degrees from the + * central meridian since the results are essentially garbage. + * Is error -20 really an appropriate return value? + * + * http://trac.osgeo.org/proj/ticket/5 + */ + if( lp_lon < -HALFPI || lp_lon > HALFPI ) + { + xy_x = HUGE_VAL; + xy_y = HUGE_VAL; + throw proj_exception( -14 ); + return; + } + + cosphi = cos(lp_lat); + b = cosphi * sin(lp_lon); + if (fabs(fabs(b) - 1.) <= EPS10) + throw proj_exception(-20); - b = (cosphi = cos(lp_lat)) * sin(lp_lon); - if (fabs(fabs(b) - 1.) <= EPS10) throw proj_exception();; xy_x = this->m_proj_parm.ml0 * log((1. + b) / (1. - b)); - if ((b = fabs( xy_y = cosphi * cos(lp_lon) / sqrt(1. - b * b) )) >= 1.) { - if ((b - 1.) > EPS10) throw proj_exception(); + xy_y = cosphi * cos(lp_lon) / sqrt(1. - b * b); + + b = fabs( xy_y ); + if (b >= 1.) { + if ((b - 1.) > EPS10) + throw proj_exception(-20); else xy_y = 0.; } else xy_y = acos(xy_y); - if (lp_lat < 0.) xy_y = -xy_y; + + if (lp_lat < 0.) + xy_y = -xy_y; xy_y = this->m_proj_parm.esp * (xy_y - this->m_par.phi0); } diff --git a/include/boost/geometry/srs/projections/proj/vandg.hpp b/include/boost/geometry/srs/projections/proj/vandg.hpp index d241d6816..2a1b2ab17 100644 --- a/include/boost/geometry/srs/projections/proj/vandg.hpp +++ b/include/boost/geometry/srs/projections/proj/vandg.hpp @@ -105,7 +105,7 @@ namespace projections CalculationType al, al2, g, g2, p2; p2 = fabs(lp_lat / HALFPI); - if ((p2 - TOL) > 1.) throw proj_exception();; + if ((p2 - TOL) > 1.) throw proj_exception(-20); if (p2 > 1.) p2 = 1.; if (fabs(lp_lat) <= TOL) { @@ -128,9 +128,11 @@ namespace projections if (lp_lon < 0.) xy_x = -xy_x; xy_y = fabs(xy_x / ONEPI); xy_y = 1. - xy_y * (xy_y + 2. * al); - if (xy_y < -TOL) throw proj_exception();; - if (xy_y < 0.) xy_y = 0.; - else xy_y = sqrt(xy_y) * (lp_lat < 0. ? -ONEPI : ONEPI); + if (xy_y < -TOL) throw proj_exception(-20); + if (xy_y < 0.) + xy_y = 0.; + else + xy_y = sqrt(xy_y) * (lp_lat < 0. ? -ONEPI : ONEPI); } } @@ -177,7 +179,7 @@ namespace projections lp_lon = fabs(xy_x) <= TOL ? 0. : .5 * (r - PISQ + (t <= 0. ? 0. : sqrt(t))) / xy_x; } else - throw proj_exception();; + throw proj_exception(-20); } static inline std::string get_name()