diff options
Diffstat (limited to 'boost/geometry/srs/projections/proj')
98 files changed, 6060 insertions, 6490 deletions
diff --git a/boost/geometry/srs/projections/proj/aea.hpp b/boost/geometry/srs/projections/proj/aea.hpp index 1df5896c34..6deb9a8163 100644 --- a/boost/geometry/srs/projections/proj/aea.hpp +++ b/boost/geometry/srs/projections/proj/aea.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_AEA_HPP -#define BOOST_GEOMETRY_PROJECTIONS_AEA_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,10 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 + // Author: Gerald Evenden (1995) + // Thomas Knudsen (2016) - revise/add regression tests + +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -45,6 +44,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_AEA_HPP +#define BOOST_GEOMETRY_PROJECTIONS_AEA_HPP + #include <boost/core/ignore_unused.hpp> #include <boost/geometry/util/math.hpp> #include <boost/math/special_functions/hypot.hpp> @@ -74,11 +76,11 @@ namespace projections namespace detail { namespace aea { - static const double EPS10 = 1.e-10; - static const double TOL7 = 1.e-7; - static const double EPSILON = 1.0e-7; - static const double TOL = 1.0e-10; - static const int N_ITER = 15; + static const double epsilon10 = 1.e-10; + static const double tolerance7 = 1.e-7; + static const double epsilon = 1.0e-7; + static const double tolerance = 1.0e-10; + static const int n_iter = 15; template <typename T> struct par_aea @@ -91,7 +93,7 @@ namespace projections T rho0; T phi1; T phi2; - T en[EN_SIZE]; + detail::en<T> en; int ellips; }; @@ -103,9 +105,9 @@ namespace projections T Phi, sinpi, cospi, con, com, dphi; Phi = asin (.5 * qs); - if (Te < EPSILON) + if (Te < epsilon) return( Phi ); - i = N_ITER; + i = n_iter; do { sinpi = sin (Phi); cospi = cos (Phi); @@ -115,33 +117,30 @@ namespace projections sinpi / com + .5 / Te * log ((1. - con) / (1. + con))); Phi += dphi; - } while (fabs(dphi) > TOL && --i); + } while (fabs(dphi) > tolerance && --i); return( i ? Phi : HUGE_VAL ); } // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_aea_ellipsoid : public base_t_fi<base_aea_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_aea_ellipsoid + : public base_t_fi<base_aea_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_aea<CalculationType> m_proj_parm; + par_aea<T> m_proj_parm; inline base_aea_ellipsoid(const Parameters& par) - : base_t_fi<base_aea_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_aea_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) ellipsoid & spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - 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.) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + T 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)); + if (rho < 0.) + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); 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); @@ -149,11 +148,11 @@ namespace projections // INVERSE(e_inverse) ellipsoid & spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); - CalculationType rho = 0.0; + T rho = 0.0; if( (rho = boost::math::hypot(xy_x, xy_y = this->m_proj_parm.rho0 - xy_y)) != 0.0 ) { if (this->m_proj_parm.n < 0.) { rho = -rho; @@ -163,19 +162,19 @@ namespace projections lp_lat = rho / this->m_proj_parm.dd; if (this->m_proj_parm.ellips) { 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 (fabs(this->m_proj_parm.ec - fabs(lp_lat)) > tolerance7) { if ((lp_lat = phi1_(lp_lat, this->m_par.e, this->m_par.one_es)) == HUGE_VAL) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); } else - lp_lat = lp_lat < 0. ? -HALFPI : HALFPI; + lp_lat = lp_lat < 0. ? -half_pi : half_pi; } else if (fabs(lp_lat = (this->m_proj_parm.c - lp_lat * lp_lat) / this->m_proj_parm.n2) <= 1.) lp_lat = asin(lp_lat); else - lp_lat = lp_lat < 0. ? -HALFPI : HALFPI; + lp_lat = lp_lat < 0. ? -half_pi : half_pi; lp_lon = atan2(xy_x, xy_y) / this->m_proj_parm.n; } else { lp_lon = 0.; - lp_lat = this->m_proj_parm.n > 0. ? HALFPI : - HALFPI; + lp_lat = this->m_proj_parm.n > 0. ? half_pi : - half_pi; } } @@ -192,16 +191,15 @@ namespace projections T cosphi, sinphi; int secant; - if (fabs(proj_parm.phi1 + proj_parm.phi2) < EPS10) - BOOST_THROW_EXCEPTION( projection_exception(-21) ); + if (fabs(proj_parm.phi1 + proj_parm.phi2) < epsilon10) + BOOST_THROW_EXCEPTION( projection_exception(error_conic_lat_equal) ); proj_parm.n = sinphi = sin(proj_parm.phi1); cosphi = cos(proj_parm.phi1); - secant = fabs(proj_parm.phi1 - proj_parm.phi2) >= EPS10; + secant = fabs(proj_parm.phi1 - proj_parm.phi2) >= epsilon10; if( (proj_parm.ellips = (par.es > 0.))) { T ml1, m1; - if (!pj_enfn(par.es, proj_parm.en)) - BOOST_THROW_EXCEPTION( projection_exception(0) ); + proj_parm.en = pj_enfn<T>(par.es); m1 = pj_msfn(sinphi, cosphi, par.es); ml1 = pj_qsfn(sinphi, par.e, par.one_es); if (secant) { /* secant cone */ @@ -211,6 +209,9 @@ namespace projections cosphi = cos(proj_parm.phi2); m2 = pj_msfn(sinphi, cosphi, par.es); ml2 = pj_qsfn(sinphi, par.e, par.one_es); + if (ml2 == ml1) + BOOST_THROW_EXCEPTION( projection_exception(0) ); + proj_parm.n = (m1 * m1 - m2 * m2) / (ml2 - ml1); } proj_parm.ec = 1. - .5 * par.one_es * log((1. - par.e) / @@ -233,8 +234,8 @@ namespace projections template <typename Parameters, typename T> inline void setup_aea(Parameters& par, par_aea<T>& proj_parm) { - proj_parm.phi1 = pj_param(par.params, "rlat_1").f; - proj_parm.phi2 = pj_param(par.params, "rlat_2").f; + proj_parm.phi1 = pj_get_param_r(par.params, "lat_1"); + proj_parm.phi2 = pj_get_param_r(par.params, "lat_2"); setup(par, proj_parm); } @@ -242,10 +243,10 @@ namespace projections template <typename Parameters, typename T> inline void setup_leac(Parameters& par, par_aea<T>& proj_parm) { - static const T HALFPI = detail::HALFPI<T>(); + static const T half_pi = detail::half_pi<T>(); - proj_parm.phi2 = pj_param(par.params, "rlat_1").f; - proj_parm.phi1 = pj_param(par.params, "bsouth").i ? -HALFPI : HALFPI; + proj_parm.phi2 = pj_get_param_r(par.params, "lat_1"); + proj_parm.phi1 = pj_get_param_b(par.params, "south") ? -half_pi : half_pi; setup(par, proj_parm); } @@ -268,10 +269,10 @@ namespace projections \par Example \image html ex_aea.gif */ - template <typename CalculationType, typename Parameters> - struct aea_ellipsoid : public detail::aea::base_aea_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct aea_ellipsoid : public detail::aea::base_aea_ellipsoid<T, Parameters> { - inline aea_ellipsoid(const Parameters& par) : detail::aea::base_aea_ellipsoid<CalculationType, Parameters>(par) + inline aea_ellipsoid(const Parameters& par) : detail::aea::base_aea_ellipsoid<T, Parameters>(par) { detail::aea::setup_aea(this->m_par, this->m_proj_parm); } @@ -293,10 +294,10 @@ namespace projections \par Example \image html ex_leac.gif */ - template <typename CalculationType, typename Parameters> - struct leac_ellipsoid : public detail::aea::base_aea_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct leac_ellipsoid : public detail::aea::base_aea_ellipsoid<T, Parameters> { - inline leac_ellipsoid(const Parameters& par) : detail::aea::base_aea_ellipsoid<CalculationType, Parameters>(par) + inline leac_ellipsoid(const Parameters& par) : detail::aea::base_aea_ellipsoid<T, Parameters>(par) { detail::aea::setup_leac(this->m_par, this->m_proj_parm); } @@ -311,31 +312,31 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::leac, leac_ellipsoid, leac_ellipsoid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class aea_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class aea_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<aea_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<aea_ellipsoid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class leac_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class leac_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<leac_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<leac_ellipsoid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void aea_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void aea_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("aea", new aea_entry<CalculationType, Parameters>); - factory.add_to_factory("leac", new leac_entry<CalculationType, Parameters>); + factory.add_to_factory("aea", new aea_entry<T, Parameters>); + factory.add_to_factory("leac", new leac_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/aeqd.hpp b/boost/geometry/srs/projections/proj/aeqd.hpp index de499213db..cfc6860797 100644 --- a/boost/geometry/srs/projections/proj/aeqd.hpp +++ b/boost/geometry/srs/projections/proj/aeqd.hpp @@ -1,8 +1,4 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_AEQD_HPP -#define BOOST_GEOMETRY_PROJECTIONS_AEQD_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -45,7 +41,12 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_AEQD_HPP +#define BOOST_GEOMETRY_PROJECTIONS_AEQD_HPP + #include <boost/config.hpp> +#include <boost/geometry/formulas/vincenty_direct.hpp> +#include <boost/geometry/formulas/vincenty_inverse.hpp> #include <boost/geometry/util/math.hpp> #include <boost/math/special_functions/hypot.hpp> @@ -76,66 +77,67 @@ namespace projections namespace detail { namespace aeqd { - static const double EPS10 = 1.e-10; - static const double TOL = 1.e-14; - static const int N_POLE = 0; - static const int S_POLE = 1; - static const int EQUIT = 2; - static const int OBLIQ = 3; + static const double epsilon10 = 1.e-10; + static const double tolerance = 1.e-14; + enum mode_type { + n_pole = 0, + s_pole = 1, + equit = 2, + obliq = 3 + }; template <typename T> struct par_aeqd { T sinph0; T cosph0; - T en[EN_SIZE]; + detail::en<T> en; T M1; T N1; T Mp; T He; T G; - int mode; + mode_type mode; + srs::spheroid<T> spheroid; }; template <typename T, typename Par, typename ProjParm> inline void e_forward(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y, Par const& par, ProjParm const& proj_parm) { - T coslam, cosphi, sinphi, rho, s, H, H2, c, Az, t, ct, st, cA, sA; + T coslam, cosphi, sinphi, rho; + //T azi1, s12; + //T lam1, phi1, lam2, phi2; coslam = cos(lp_lon); cosphi = cos(lp_lat); sinphi = sin(lp_lat); switch (proj_parm.mode) { - case N_POLE: + case n_pole: coslam = - coslam; BOOST_FALLTHROUGH; - case S_POLE: + case s_pole: xy_x = (rho = fabs(proj_parm.Mp - pj_mlfn(lp_lat, sinphi, cosphi, proj_parm.en))) * sin(lp_lon); xy_y = rho * coslam; break; - case EQUIT: - case OBLIQ: - if (fabs(lp_lon) < EPS10 && fabs(lp_lat - par.phi0) < EPS10) { + case equit: + case obliq: + if (fabs(lp_lon) < epsilon10 && fabs(lp_lat - par.phi0) < epsilon10) { xy_x = xy_y = 0.; break; } - t = atan2(par.one_es * sinphi + par.es * proj_parm.N1 * proj_parm.sinph0 * - sqrt(1. - par.es * sinphi * sinphi), cosphi); - ct = cos(t); st = sin(t); - Az = atan2(sin(lp_lon) * ct, proj_parm.cosph0 * st - proj_parm.sinph0 * coslam * ct); - cA = cos(Az); sA = sin(Az); - s = aasin(fabs(sA) < TOL ? - (proj_parm.cosph0 * st - proj_parm.sinph0 * coslam * ct) / cA : - sin(lp_lon) * ct / sA ); - H = proj_parm.He * cA; - H2 = H * H; - c = proj_parm.N1 * s * (1. + s * s * (- H2 * (1. - H2)/6. + - s * ( proj_parm.G * H * (1. - 2. * H2 * H2) / 8. + - s * ((H2 * (4. - 7. * H2) - 3. * proj_parm.G * proj_parm.G * (1. - 7. * H2)) / - 120. - s * proj_parm.G * H / 48.)))); - xy_x = c * sA; - xy_y = c * cA; + + //phi1 = par.phi0; lam1 = par.lam0; + //phi2 = lp_lat; lam2 = lp_lon + par.lam0; + + formula::result_inverse<T> const inv = + formula::vincenty_inverse + < + T, true, true + >::apply(par.lam0, par.phi0, lp_lon + par.lam0, lp_lat, proj_parm.spheroid); + //azi1 = inv.azimuth; s12 = inv.distance; + xy_x = inv.distance * sin(inv.azimuth) / par.a; + xy_y = inv.distance * cos(inv.azimuth) / par.a; break; } } @@ -143,37 +145,32 @@ namespace projections template <typename T, typename Par, typename ProjParm> inline void e_inverse(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat, Par const& par, ProjParm const& proj_parm) { - static const T HALFPI = detail::HALFPI<T>(); + T c; - T c, Az, cosAz, A, B, D, E, F, psi, t; - - if ((c = boost::math::hypot(xy_x, xy_y)) < EPS10) { + if ((c = boost::math::hypot(xy_x, xy_y)) < epsilon10) { lp_lat = par.phi0; lp_lon = 0.; return; } - if (proj_parm.mode == OBLIQ || proj_parm.mode == EQUIT) { - cosAz = cos(Az = atan2(xy_x, xy_y)); - t = proj_parm.cosph0 * cosAz; - B = par.es * t / par.one_es; - A = - B * t; - B *= 3. * (1. - A) * proj_parm.sinph0; - D = c / proj_parm.N1; - E = D * (1. - D * D * (A * (1. + A) / 6. + B * (1. + 3.*A) * D / 24.)); - F = 1. - E * E * (A / 2. + B * E / 6.); - psi = aasin(proj_parm.sinph0 * cos(E) + t * sin(E)); - lp_lon = aasin(sin(Az) * sin(E) / cos(psi)); - if ((t = fabs(psi)) < EPS10) - lp_lat = 0.; - else if (fabs(t - HALFPI) < 0.) - lp_lat = HALFPI; - else - lp_lat = atan((1. - par.es * F * proj_parm.sinph0 / sin(psi)) * tan(psi) / - par.one_es); + if (proj_parm.mode == obliq || proj_parm.mode == equit) { + T const x2 = xy_x * par.a; + T const y2 = xy_y * par.a; + //T const lat1 = par.phi0; + //T const lon1 = par.lam0; + T const azi1 = atan2(x2, y2); + T const s12 = sqrt(x2 * x2 + y2 * y2); + formula::result_direct<T> const dir = + formula::vincenty_direct + < + T, true + >::apply(par.lam0, par.phi0, s12, azi1, proj_parm.spheroid); + lp_lat = dir.lat2; + lp_lon = dir.lon2; + lp_lon -= par.lam0; } else { /* Polar */ - lp_lat = pj_inv_mlfn(proj_parm.mode == N_POLE ? proj_parm.Mp - c : proj_parm.Mp + c, + lp_lat = pj_inv_mlfn(proj_parm.mode == n_pole ? proj_parm.Mp - c : proj_parm.Mp + c, par.es, proj_parm.en); - lp_lon = atan2(xy_x, proj_parm.mode == N_POLE ? -xy_y : xy_y); + lp_lon = atan2(xy_x, proj_parm.mode == n_pole ? -xy_y : xy_y); } } @@ -193,7 +190,7 @@ namespace projections template <typename T, typename Par, typename ProjParm> inline void e_guam_inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat, Par const& par, ProjParm const& proj_parm) { - T x2, t; + T x2, t = 0.0; int i; x2 = 0.5 * xy_x * xy_x; @@ -209,7 +206,7 @@ namespace projections template <typename T, typename Par, typename ProjParm> inline void s_forward(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y, Par const& /*par*/, ProjParm const& proj_parm) { - static const T HALFPI = detail::HALFPI<T>(); + static const T half_pi = detail::half_pi<T>(); T coslam, cosphi, sinphi; @@ -217,33 +214,33 @@ namespace projections cosphi = cos(lp_lat); coslam = cos(lp_lon); switch (proj_parm.mode) { - case EQUIT: + case equit: xy_y = cosphi * coslam; goto oblcon; - case OBLIQ: + case obliq: xy_y = proj_parm.sinph0 * sinphi + proj_parm.cosph0 * cosphi * coslam; oblcon: - if (fabs(fabs(xy_y) - 1.) < TOL) + if (fabs(fabs(xy_y) - 1.) < tolerance) if (xy_y < 0.) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); else xy_x = xy_y = 0.; else { xy_y = acos(xy_y); xy_y /= sin(xy_y); xy_x = xy_y * cosphi * sin(lp_lon); - xy_y *= (proj_parm.mode == EQUIT) ? sinphi : + xy_y *= (proj_parm.mode == equit) ? sinphi : proj_parm.cosph0 * sinphi - proj_parm.sinph0 * cosphi * coslam; } break; - case N_POLE: + case n_pole: lp_lat = -lp_lat; coslam = -coslam; BOOST_FALLTHROUGH; - case S_POLE: - if (fabs(lp_lat - HALFPI) < EPS10) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); - xy_x = (xy_y = (HALFPI + lp_lat)) * sin(lp_lon); + case s_pole: + if (fabs(lp_lat - half_pi) < epsilon10) + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + xy_x = (xy_y = (half_pi + lp_lat)) * sin(lp_lon); xy_y *= coslam; break; } @@ -252,24 +249,24 @@ namespace projections template <typename T, typename Par, typename ProjParm> inline void s_inverse(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat, Par const& par, ProjParm const& proj_parm) { - static const T ONEPI = detail::ONEPI<T>(); - static const T HALFPI = detail::HALFPI<T>(); + static const T pi = detail::pi<T>(); + static const T half_pi = detail::half_pi<T>(); T cosc, c_rh, sinc; - if ((c_rh = boost::math::hypot(xy_x, xy_y)) > ONEPI) { - if (c_rh - EPS10 > ONEPI) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); - c_rh = ONEPI; - } else if (c_rh < EPS10) { + if ((c_rh = boost::math::hypot(xy_x, xy_y)) > pi) { + if (c_rh - epsilon10 > pi) + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + c_rh = pi; + } else if (c_rh < epsilon10) { lp_lat = par.phi0; lp_lon = 0.; return; } - if (proj_parm.mode == OBLIQ || proj_parm.mode == EQUIT) { + if (proj_parm.mode == obliq || proj_parm.mode == equit) { sinc = sin(c_rh); cosc = cos(c_rh); - if (proj_parm.mode == EQUIT) { + if (proj_parm.mode == equit) { lp_lat = aasin(xy_y * sinc / c_rh); xy_x *= sinc; xy_y = cosc * c_rh; @@ -279,12 +276,12 @@ namespace projections xy_y = (cosc - proj_parm.sinph0 * sin(lp_lat)) * c_rh; xy_x *= sinc * proj_parm.cosph0; } - lp_lon = atan2(xy_x, xy_y); - } else if (proj_parm.mode == N_POLE) { - lp_lat = HALFPI - c_rh; + lp_lon = xy_y == 0. ? 0. : atan2(xy_x, xy_y); + } else if (proj_parm.mode == n_pole) { + lp_lat = half_pi - c_rh; lp_lon = atan2(xy_x, -xy_y); } else { - lp_lat = c_rh - HALFPI; + lp_lat = c_rh - half_pi; lp_lon = atan2(xy_x, xy_y); } } @@ -293,72 +290,71 @@ namespace projections template <typename Parameters, typename T> inline void setup_aeqd(Parameters& par, par_aeqd<T>& proj_parm, bool is_sphere, bool is_guam) { - static const T HALFPI = detail::HALFPI<T>(); + static const T half_pi = detail::half_pi<T>(); - par.phi0 = pj_param(par.params, "rlat_0").f; - if (fabs(fabs(par.phi0) - HALFPI) < EPS10) { - proj_parm.mode = par.phi0 < 0. ? S_POLE : N_POLE; + par.phi0 = pj_get_param_r(par.params, "lat_0"); + if (fabs(fabs(par.phi0) - half_pi) < epsilon10) { + proj_parm.mode = par.phi0 < 0. ? s_pole : n_pole; proj_parm.sinph0 = par.phi0 < 0. ? -1. : 1.; proj_parm.cosph0 = 0.; - } else if (fabs(par.phi0) < EPS10) { - proj_parm.mode = EQUIT; + } else if (fabs(par.phi0) < epsilon10) { + proj_parm.mode = equit; proj_parm.sinph0 = 0.; proj_parm.cosph0 = 1.; } else { - proj_parm.mode = OBLIQ; + proj_parm.mode = obliq; proj_parm.sinph0 = sin(par.phi0); proj_parm.cosph0 = cos(par.phi0); } if (is_sphere) { + /* empty */ } else { - if (!pj_enfn(par.es, proj_parm.en)) - BOOST_THROW_EXCEPTION( projection_exception(0) ); + proj_parm.en = pj_enfn<T>(par.es); if (is_guam) { proj_parm.M1 = pj_mlfn(par.phi0, proj_parm.sinph0, proj_parm.cosph0, proj_parm.en); } else { switch (proj_parm.mode) { - case N_POLE: - proj_parm.Mp = pj_mlfn<T>(HALFPI, 1., 0., proj_parm.en); + case n_pole: + proj_parm.Mp = pj_mlfn<T>(half_pi, 1., 0., proj_parm.en); break; - case S_POLE: - proj_parm.Mp = pj_mlfn<T>(-HALFPI, -1., 0., proj_parm.en); + case s_pole: + proj_parm.Mp = pj_mlfn<T>(-half_pi, -1., 0., proj_parm.en); break; - case EQUIT: - case OBLIQ: + case equit: + case obliq: proj_parm.N1 = 1. / sqrt(1. - par.es * proj_parm.sinph0 * proj_parm.sinph0); proj_parm.G = proj_parm.sinph0 * (proj_parm.He = par.e / sqrt(par.one_es)); proj_parm.He *= proj_parm.cosph0; break; } + // Boost.Geometry specific, in proj4 geodesic is initialized at the beginning + T const b = math::sqrt(math::sqr(par.a) * (1. - par.es)); + proj_parm.spheroid = srs::spheroid<T>(par.a, b); } } } // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_aeqd_e : public base_t_fi<base_aeqd_e<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_aeqd_e + : public base_t_fi<base_aeqd_e<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_aeqd<CalculationType> m_proj_parm; + par_aeqd<T> m_proj_parm; inline base_aeqd_e(const Parameters& par) - : base_t_fi<base_aeqd_e<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_aeqd_e<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) elliptical // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { e_forward(lp_lon, lp_lat, xy_x, xy_y, this->m_par, this->m_proj_parm); } // INVERSE(e_inverse) elliptical // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { e_inverse(xy_x, xy_y, lp_lon, lp_lat, this->m_par, this->m_proj_parm); } @@ -371,30 +367,26 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_aeqd_e_guam : public base_t_fi<base_aeqd_e_guam<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_aeqd_e_guam + : public base_t_fi<base_aeqd_e_guam<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_aeqd<CalculationType> m_proj_parm; + par_aeqd<T> m_proj_parm; inline base_aeqd_e_guam(const Parameters& par) - : base_t_fi<base_aeqd_e_guam<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_aeqd_e_guam<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_guam_fwd) Guam elliptical // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { e_guam_fwd(lp_lon, lp_lat, xy_x, xy_y, this->m_par, this->m_proj_parm); } // INVERSE(e_guam_inv) Guam elliptical // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { e_guam_inv(xy_x, xy_y, lp_lon, lp_lat, this->m_par, this->m_proj_parm); } @@ -407,15 +399,11 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename BGParameters, typename CalculationType, typename Parameters> - struct base_aeqd_e_static : public base_t_fi<base_aeqd_e_static<BGParameters, CalculationType, Parameters>, - CalculationType, Parameters> + template <typename BGParameters, typename T, typename Parameters> + struct base_aeqd_e_static + : public base_t_fi<base_aeqd_e_static<BGParameters, T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_aeqd<CalculationType> m_proj_parm; + par_aeqd<T> m_proj_parm; static const bool is_guam = ! boost::is_same < @@ -429,13 +417,12 @@ namespace projections >::value; inline base_aeqd_e_static(const Parameters& par) - : base_t_fi<base_aeqd_e_static<BGParameters, CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) + : base_t_fi<base_aeqd_e_static<BGParameters, T, Parameters>, T, Parameters>(*this, par) {} // FORWARD(e_forward or e_guam_fwd) elliptical // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { if (is_guam) e_guam_fwd(lp_lon, lp_lat, xy_x, xy_y, this->m_par, this->m_proj_parm); @@ -445,7 +432,7 @@ namespace projections // INVERSE(e_inverse or e_guam_inv) elliptical // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { if (is_guam) e_guam_inv(xy_x, xy_y, lp_lon, lp_lat, this->m_par, this->m_proj_parm); @@ -461,30 +448,26 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_aeqd_s : public base_t_fi<base_aeqd_s<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_aeqd_s + : public base_t_fi<base_aeqd_s<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_aeqd<CalculationType> m_proj_parm; + par_aeqd<T> m_proj_parm; inline base_aeqd_s(const Parameters& par) - : base_t_fi<base_aeqd_s<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_aeqd_s<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spherical // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { s_forward(lp_lon, lp_lat, xy_x, xy_y, this->m_par, this->m_proj_parm); } // INVERSE(s_inverse) spherical // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { s_inverse(xy_x, xy_y, lp_lon, lp_lat, this->m_par, this->m_proj_parm); } @@ -515,10 +498,10 @@ namespace projections \par Example \image html ex_aeqd.gif */ - template <typename CalculationType, typename Parameters> - struct aeqd_e : public detail::aeqd::base_aeqd_e<CalculationType, Parameters> + template <typename T, typename Parameters> + struct aeqd_e : public detail::aeqd::base_aeqd_e<T, Parameters> { - inline aeqd_e(const Parameters& par) : detail::aeqd::base_aeqd_e<CalculationType, Parameters>(par) + inline aeqd_e(const Parameters& par) : detail::aeqd::base_aeqd_e<T, Parameters>(par) { detail::aeqd::setup_aeqd(this->m_par, this->m_proj_parm, false, false); } @@ -540,10 +523,10 @@ namespace projections \par Example \image html ex_aeqd.gif */ - template <typename CalculationType, typename Parameters> - struct aeqd_e_guam : public detail::aeqd::base_aeqd_e_guam<CalculationType, Parameters> + template <typename T, typename Parameters> + struct aeqd_e_guam : public detail::aeqd::base_aeqd_e_guam<T, Parameters> { - inline aeqd_e_guam(const Parameters& par) : detail::aeqd::base_aeqd_e_guam<CalculationType, Parameters>(par) + inline aeqd_e_guam(const Parameters& par) : detail::aeqd::base_aeqd_e_guam<T, Parameters>(par) { detail::aeqd::setup_aeqd(this->m_par, this->m_proj_parm, false, true); } @@ -565,14 +548,14 @@ namespace projections \par Example \image html ex_aeqd.gif */ - template <typename BGParameters, typename CalculationType, typename Parameters> - struct aeqd_e_static : public detail::aeqd::base_aeqd_e_static<BGParameters, CalculationType, Parameters> + template <typename BGParameters, typename T, typename Parameters> + struct aeqd_e_static : public detail::aeqd::base_aeqd_e_static<BGParameters, T, Parameters> { - inline aeqd_e_static(const Parameters& par) : detail::aeqd::base_aeqd_e_static<BGParameters, CalculationType, Parameters>(par) + inline aeqd_e_static(const Parameters& par) : detail::aeqd::base_aeqd_e_static<BGParameters, T, Parameters>(par) { detail::aeqd::setup_aeqd(this->m_par, this->m_proj_parm, false, - detail::aeqd::base_aeqd_e_static<BGParameters, CalculationType, Parameters>::is_guam); + detail::aeqd::base_aeqd_e_static<BGParameters, T, Parameters>::is_guam); } }; @@ -592,10 +575,10 @@ namespace projections \par Example \image html ex_aeqd.gif */ - template <typename CalculationType, typename Parameters> - struct aeqd_s : public detail::aeqd::base_aeqd_s<CalculationType, Parameters> + template <typename T, typename Parameters> + struct aeqd_s : public detail::aeqd::base_aeqd_s<T, Parameters> { - inline aeqd_s(const Parameters& par) : detail::aeqd::base_aeqd_s<CalculationType, Parameters>(par) + inline aeqd_s(const Parameters& par) : detail::aeqd::base_aeqd_s<T, Parameters>(par) { detail::aeqd::setup_aeqd(this->m_par, this->m_proj_parm, true, false); } @@ -620,27 +603,27 @@ namespace projections //BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::aeqd_guam, aeqd_guam, aeqd_guam) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class aeqd_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class aeqd_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - bool const guam = pj_param(par.params, "bguam").i != 0; + bool const guam = pj_get_param_b(par.params, "guam"); if (par.es && ! guam) - return new base_v_fi<aeqd_e<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<aeqd_e<T, Parameters>, T, Parameters>(par); else if (par.es && guam) - return new base_v_fi<aeqd_e_guam<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<aeqd_e_guam<T, Parameters>, T, Parameters>(par); else - return new base_v_fi<aeqd_s<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<aeqd_s<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void aeqd_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void aeqd_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("aeqd", new aeqd_entry<CalculationType, Parameters>); + factory.add_to_factory("aeqd", new aeqd_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/airy.hpp b/boost/geometry/srs/projections/proj/airy.hpp index 557d95f3e4..1762dec800 100644 --- a/boost/geometry/srs/projections/proj/airy.hpp +++ b/boost/geometry/srs/projections/proj/airy.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_AIRY_HPP -#define BOOST_GEOMETRY_PROJECTIONS_AIRY_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,12 +15,13 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: // Purpose: Implementation of the airy (Airy) projection. -// Author: Gerald Evenden +// Author: Gerald Evenden (1995) +// Thomas Knudsen (2016) - revise/add regression tests // Copyright (c) 1995, Gerald Evenden // Permission is hereby granted, free of charge, to any person obtaining a @@ -45,6 +42,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_AIRY_HPP +#define BOOST_GEOMETRY_PROJECTIONS_AIRY_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -70,11 +70,13 @@ namespace projections namespace detail { namespace airy { - static const double EPS = 1.e-10; - static const int N_POLE = 0; - static const int S_POLE = 1; - static const int EQUIT = 2; - static const int OBLIQ = 3; + static const double epsilon = 1.e-10; + enum mode_type { + n_pole = 0, + s_pole = 1, + equit = 2, + obliq = 3 + }; template <typename T> struct par_airy @@ -83,68 +85,65 @@ namespace projections T sinph0; T cosph0; T Cb; - int mode; + mode_type mode; int no_cut; /* do not cut at hemisphere limit */ }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_airy_spheroid : public base_t_f<base_airy_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_airy_spheroid + : public base_t_f<base_airy_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_airy<CalculationType> m_proj_parm; + par_airy<T> m_proj_parm; inline base_airy_spheroid(const Parameters& par) - : base_t_f<base_airy_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_f<base_airy_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); - CalculationType sinlam, coslam, cosphi, sinphi, t, s, Krho, cosz; + T sinlam, coslam, cosphi, sinphi, t, s, Krho, cosz; sinlam = sin(lp_lon); coslam = cos(lp_lon); switch (this->m_proj_parm.mode) { - case EQUIT: - case OBLIQ: + case equit: + case obliq: sinphi = sin(lp_lat); cosphi = cos(lp_lat); cosz = cosphi * coslam; - if (this->m_proj_parm.mode == OBLIQ) + 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) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); - if (fabs(s = 1. - cosz) > EPS) { + if (!this->m_proj_parm.no_cut && cosz < -epsilon) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } + if (fabs(s = 1. - cosz) > epsilon) { t = 0.5 * (1. + cosz); Krho = -log(t)/s - this->m_proj_parm.Cb / t; } else Krho = 0.5 - this->m_proj_parm.Cb; xy_x = Krho * cosphi * sinlam; - if (this->m_proj_parm.mode == OBLIQ) + if (this->m_proj_parm.mode == obliq) xy_y = Krho * (this->m_proj_parm.cosph0 * sinphi - this->m_proj_parm.sinph0 * cosphi * coslam); else xy_y = Krho * sinphi; break; - case S_POLE: - case N_POLE: + case s_pole: + 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) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); - if ((lp_lat *= 0.5) > EPS) { + if (!this->m_proj_parm.no_cut && (lp_lat - epsilon) > half_pi) + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + if ((lp_lat *= 0.5) > epsilon) { t = tan(lp_lat); Krho = -2.*(log(cos(lp_lat)) / t + t * this->m_proj_parm.Cb); xy_x = Krho * sinlam; xy_y = Krho * coslam; - if (this->m_proj_parm.mode == N_POLE) + if (this->m_proj_parm.mode == n_pole) xy_y = -xy_y; } else xy_x = xy_y = 0.; @@ -162,31 +161,32 @@ namespace projections template <typename Parameters, typename T> inline void setup_airy(Parameters& par, par_airy<T>& proj_parm) { - static const T HALFPI = detail::HALFPI<T>(); + static const T half_pi = detail::half_pi<T>(); T beta; - proj_parm.no_cut = pj_param(par.params, "bno_cut").i; - beta = 0.5 * (HALFPI - pj_param(par.params, "rlat_b").f); - if (fabs(beta) < EPS) + proj_parm.no_cut = pj_get_param_b(par.params, "no_cut"); + beta = 0.5 * (half_pi - pj_get_param_r(par.params, "lat_b")); + if (fabs(beta) < epsilon) proj_parm.Cb = -0.5; else { proj_parm.Cb = 1./tan(beta); proj_parm.Cb *= proj_parm.Cb * log(cos(beta)); } - if (fabs(fabs(par.phi0) - HALFPI) < EPS) + + if (fabs(fabs(par.phi0) - half_pi) < epsilon) if (par.phi0 < 0.) { - proj_parm.p_halfpi = -HALFPI; - proj_parm.mode = S_POLE; + proj_parm.p_halfpi = -half_pi; + proj_parm.mode = s_pole; } else { - proj_parm.p_halfpi = HALFPI; - proj_parm.mode = N_POLE; + proj_parm.p_halfpi = half_pi; + proj_parm.mode = n_pole; } else { - if (fabs(par.phi0) < EPS) - proj_parm.mode = EQUIT; + if (fabs(par.phi0) < epsilon) + proj_parm.mode = equit; else { - proj_parm.mode = OBLIQ; + proj_parm.mode = obliq; proj_parm.sinph0 = sin(par.phi0); proj_parm.cosph0 = cos(par.phi0); } @@ -213,10 +213,10 @@ namespace projections \par Example \image html ex_airy.gif */ - template <typename CalculationType, typename Parameters> - struct airy_spheroid : public detail::airy::base_airy_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct airy_spheroid : public detail::airy::base_airy_spheroid<T, Parameters> { - inline airy_spheroid(const Parameters& par) : detail::airy::base_airy_spheroid<CalculationType, Parameters>(par) + inline airy_spheroid(const Parameters& par) : detail::airy::base_airy_spheroid<T, Parameters>(par) { detail::airy::setup_airy(this->m_par, this->m_proj_parm); } @@ -230,20 +230,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::airy, airy_spheroid, airy_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class airy_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class airy_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_f<airy_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_f<airy_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void airy_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void airy_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("airy", new airy_entry<CalculationType, Parameters>); + factory.add_to_factory("airy", new airy_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/aitoff.hpp b/boost/geometry/srs/projections/proj/aitoff.hpp index 7d34a23287..c09618d45e 100644 --- a/boost/geometry/srs/projections/proj/aitoff.hpp +++ b/boost/geometry/srs/projections/proj/aitoff.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_AITOFF_HPP -#define BOOST_GEOMETRY_PROJECTIONS_AITOFF_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,13 +15,15 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: // Purpose: Implementation of the aitoff (Aitoff) and wintri (Winkel Tripel) -// projections. -// Author: Gerald Evenden +// projections. +// Author: Gerald Evenden (1995) +// Drazen Tutic, Lovro Gradiser (2015) - add inverse +// Thomas Knudsen (2016) - revise/add regression tests // Copyright (c) 1995, Gerald Evenden // Permission is hereby granted, free of charge, to any person obtaining a @@ -46,6 +44,10 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_AITOFF_HPP +#define BOOST_GEOMETRY_PROJECTIONS_AITOFF_HPP + + #include <boost/core/ignore_unused.hpp> #include <boost/geometry/util/math.hpp> @@ -69,40 +71,41 @@ namespace projections #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace aitoff { + enum mode_type { + mode_aitoff = 0, + mode_winkel_tripel = 1 + }; + template <typename T> struct par_aitoff { T cosphi1; - int mode; + mode_type mode; }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_aitoff_spheroid : public base_t_fi<base_aitoff_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_aitoff_spheroid + : public base_t_fi<base_aitoff_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_aitoff<CalculationType> m_proj_parm; + par_aitoff<T> m_proj_parm; inline base_aitoff_spheroid(const Parameters& par) - : base_t_fi<base_aitoff_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_aitoff_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType c, d; + T c, d; if((d = acos(cos(lp_lat) * cos(c = 0.5 * lp_lon)))) {/* basic Aitoff */ xy_x = 2. * d * cos(lp_lat) * sin(c) * (xy_y = 1. / sin(d)); xy_y *= d * sin(lp_lat); } else xy_x = xy_y = 0.; - if (this->m_proj_parm.mode) { /* Winkel Tripel */ + if (this->m_proj_parm.mode == mode_winkel_tripel) { /* Winkel Tripel */ xy_x = (xy_x + lp_lon * this->m_proj_parm.cosphi1) * 0.5; xy_y = (xy_y + lp_lat) * 0.5; } @@ -116,7 +119,7 @@ namespace projections * Third International Symposium Mathematical & Computational Applications, * pages 175{182, Turkey, September 2002. * - * Expected accuracy is defined by EPSILON = 1e-12. Should be appropriate for + * Expected accuracy is defined by epsilon = 1e-12. Should be appropriate for * most applications of Aitoff and Winkel Tripel projections. * * Longitudes of 180W and 180E can be mixed in solution obtained. @@ -130,16 +133,19 @@ namespace projections // INVERSE(s_inverse) sphere // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType ONEPI = detail::ONEPI<CalculationType>(); - static const CalculationType TWOPI = detail::TWOPI<CalculationType>(); - static const CalculationType EPSILON = 1e-12; + static const T pi = detail::pi<T>(); + static const T two_pi = detail::two_pi<T>(); + static const T epsilon = 1e-12; - int iter, MAXITER = 10, round = 0, MAXROUND = 20; - CalculationType D, C, f1, f2, f1p, f1l, f2p, f2l, dp, dl, sl, sp, cp, cl, x, y; + int iter, max_iter = 10, round = 0, max_round = 20; + T D, C, f1, f2, f1p, f1l, f2p, f2l, dp, dl, sl, sp, cp, cl, x, y; - if ((fabs(xy_x) < EPSILON) && (fabs(xy_y) < EPSILON )) { lp_lat = 0.; lp_lon = 0.; return; } + if ((fabs(xy_x) < epsilon) && (fabs(xy_y) < epsilon )) { + lp_lat = 0.; lp_lon = 0.; + return; + } /* intial values for Newton-Raphson method */ lp_lat = xy_y; lp_lon = xy_x; @@ -149,15 +155,15 @@ namespace projections sl = sin(lp_lon * 0.5); cl = cos(lp_lon * 0.5); sp = sin(lp_lat); cp = cos(lp_lat); D = cp * cl; - C = 1. - D * D; - D = acos(D) / pow(C, 1.5); - f1 = 2. * D * C * cp * sl; - f2 = D * C * sp; - f1p = 2.* (sl * cl * sp * cp / C - D * sp * sl); - f1l = cp * cp * sl * sl / C + D * cp * cl * sp * sp; - f2p = sp * sp * cl / C + D * sl * sl * cp; - f2l = 0.5 * (sp * cp * sl / C - D * sp * cp * cp * sl * cl); - if (this->m_proj_parm.mode) { /* Winkel Tripel */ + C = 1. - D * D; + D = acos(D) / math::pow(C, T(1.5)); + f1 = 2. * D * C * cp * sl; + f2 = D * C * sp; + f1p = 2.* (sl * cl * sp * cp / C - D * sp * sl); + f1l = cp * cp * sl * sl / C + D * cp * cl * sp * sp; + f2p = sp * sp * cl / C + D * sl * sl * cp; + f2l = 0.5 * (sp * cp * sl / C - D * sp * cp * cp * sl * cl); + if (this->m_proj_parm.mode == mode_winkel_tripel) { /* Winkel Tripel */ f1 = 0.5 * (f1 + lp_lon * this->m_proj_parm.cosphi1); f2 = 0.5 * (f2 + lp_lat); f1p *= 0.5; @@ -168,28 +174,31 @@ namespace projections f1 -= xy_x; f2 -= xy_y; dl = (f2 * f1p - f1 * f2p) / (dp = f1p * f2l - f2p * f1l); dp = (f1 * f2l - f2 * f1l) / dp; - while (dl > ONEPI) dl -= ONEPI; /* set to interval [-ONEPI, ONEPI] */ - while (dl < -ONEPI) dl += ONEPI; /* set to interval [-ONEPI, ONEPI] */ + dl = fmod(dl, pi); /* set to interval [-M_PI, M_PI] */ lp_lat -= dp; lp_lon -= dl; - } while ((fabs(dp) > EPSILON || fabs(dl) > EPSILON) && (iter++ < MAXITER)); - if (lp_lat > TWOPI) lp_lat -= 2.*(lp_lat-TWOPI); /* correct if symmetrical solution for Aitoff */ - if (lp_lat < -TWOPI) lp_lat -= 2.*(lp_lat+TWOPI); /* correct if symmetrical solution for Aitoff */ - if ((fabs(fabs(lp_lat) - TWOPI) < EPSILON) && (!this->m_proj_parm.mode)) lp_lon = 0.; /* if pole in Aitoff, return longitude of 0 */ + } while ((fabs(dp) > epsilon || fabs(dl) > epsilon) && (iter++ < max_iter)); + if (lp_lat > two_pi) lp_lat -= 2.*(lp_lat-two_pi); /* correct if symmetrical solution for Aitoff */ + if (lp_lat < -two_pi) lp_lat -= 2.*(lp_lat+two_pi); /* correct if symmetrical solution for Aitoff */ + if ((fabs(fabs(lp_lat) - two_pi) < epsilon) && (!this->m_proj_parm.mode)) lp_lon = 0.; /* if pole in Aitoff, return longitude of 0 */ /* calculate x,y coordinates with solution obtained */ - if((D = acos(cos(lp_lat) * cos(C = 0.5 * lp_lon)))) {/* Aitoff */ + if((D = acos(cos(lp_lat) * cos(C = 0.5 * lp_lon))) != 0.0) {/* Aitoff */ x = 2. * D * cos(lp_lat) * sin(C) * (y = 1. / sin(D)); y *= D * sin(lp_lat); } else x = y = 0.; - if (this->m_proj_parm.mode) { /* Winkel Tripel */ + if (this->m_proj_parm.mode == mode_winkel_tripel) { /* Winkel Tripel */ x = (x + lp_lon * this->m_proj_parm.cosphi1) * 0.5; y = (y + lp_lat) * 0.5; } /* if too far from given values of x,y, repeat with better approximation of phi,lam */ - } while (((fabs(xy_x-x) > EPSILON) || (fabs(xy_y-y) > EPSILON)) && (round++ < MAXROUND)); + } while (((fabs(xy_x-x) > epsilon) || (fabs(xy_y-y) > epsilon)) && (round++ < max_round)); - //if (iter == MAXITER && round == MAXROUND) fprintf(stderr, "Warning: Accuracy of 1e-12 not reached. Last increments: dlat=%e and dlon=%e\n", dp, dl); + if (iter == max_iter && round == max_round) + { + BOOST_THROW_EXCEPTION( projection_exception(error_non_convergent) ); + //fprintf(stderr, "Warning: Accuracy of 1e-12 not reached. Last increments: dlat=%e and dlon=%e\n", dp, dl); + } } static inline std::string get_name() @@ -199,10 +208,9 @@ namespace projections }; - template <typename Parameters, typename T> - inline void setup(Parameters& par, par_aitoff<T>& proj_parm) + template <typename Parameters> + inline void setup(Parameters& par) { - boost::ignore_unused(proj_parm); par.es = 0.; } @@ -211,23 +219,25 @@ namespace projections template <typename Parameters, typename T> inline void setup_aitoff(Parameters& par, par_aitoff<T>& proj_parm) { - proj_parm.mode = 0; - setup(par, proj_parm); + proj_parm.mode = mode_aitoff; + setup(par); } // Winkel Tripel template <typename Parameters, typename T> inline void setup_wintri(Parameters& par, par_aitoff<T>& proj_parm) { - static const T TWO_D_PI = detail::TWO_D_PI<T>(); + static const T two_div_pi = detail::two_div_pi<T>(); + + T phi1; - proj_parm.mode = 1; - if (pj_param(par.params, "tlat_1").i) { - if ((proj_parm.cosphi1 = cos(pj_param(par.params, "rlat_1").f)) == 0.) - BOOST_THROW_EXCEPTION( projection_exception(-22) ); + proj_parm.mode = mode_winkel_tripel; + if (pj_param_r(par.params, "lat_1", phi1)) { + if ((proj_parm.cosphi1 = cos(phi1)) == 0.) + BOOST_THROW_EXCEPTION( projection_exception(error_lat_larger_than_90) ); } else /* 50d28' or phi1=acos(2/pi) */ - proj_parm.cosphi1 = TWO_D_PI; - setup(par, proj_parm); + proj_parm.cosphi1 = two_div_pi; + setup(par); } }} // namespace detail::aitoff @@ -245,10 +255,10 @@ namespace projections \par Example \image html ex_aitoff.gif */ - template <typename CalculationType, typename Parameters> - struct aitoff_spheroid : public detail::aitoff::base_aitoff_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct aitoff_spheroid : public detail::aitoff::base_aitoff_spheroid<T, Parameters> { - inline aitoff_spheroid(const Parameters& par) : detail::aitoff::base_aitoff_spheroid<CalculationType, Parameters>(par) + inline aitoff_spheroid(const Parameters& par) : detail::aitoff::base_aitoff_spheroid<T, Parameters>(par) { detail::aitoff::setup_aitoff(this->m_par, this->m_proj_parm); } @@ -268,10 +278,10 @@ namespace projections \par Example \image html ex_wintri.gif */ - template <typename CalculationType, typename Parameters> - struct wintri_spheroid : public detail::aitoff::base_aitoff_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct wintri_spheroid : public detail::aitoff::base_aitoff_spheroid<T, Parameters> { - inline wintri_spheroid(const Parameters& par) : detail::aitoff::base_aitoff_spheroid<CalculationType, Parameters>(par) + inline wintri_spheroid(const Parameters& par) : detail::aitoff::base_aitoff_spheroid<T, Parameters>(par) { detail::aitoff::setup_wintri(this->m_par, this->m_proj_parm); } @@ -286,31 +296,31 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::wintri, wintri_spheroid, wintri_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class aitoff_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class aitoff_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<aitoff_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<aitoff_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class wintri_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class wintri_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<wintri_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<wintri_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void aitoff_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void aitoff_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("aitoff", new aitoff_entry<CalculationType, Parameters>); - factory.add_to_factory("wintri", new wintri_entry<CalculationType, Parameters>); + factory.add_to_factory("aitoff", new aitoff_entry<T, Parameters>); + factory.add_to_factory("wintri", new wintri_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/august.hpp b/boost/geometry/srs/projections/proj/august.hpp index 7358cfb12f..a52edc7806 100644 --- a/boost/geometry/srs/projections/proj/august.hpp +++ b/boost/geometry/srs/projections/proj/august.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_AUGUST_HPP -#define BOOST_GEOMETRY_PROJECTIONS_AUGUST_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_AUGUST_HPP +#define BOOST_GEOMETRY_PROJECTIONS_AUGUST_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -64,26 +63,21 @@ namespace projections //static const double M = 1.333333333333333; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_august_spheroid : public base_t_f<base_august_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_august_spheroid + : public base_t_f<base_august_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_august_spheroid(const Parameters& par) - : base_t_f<base_august_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_f<base_august_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType M = 1.333333333333333333333333333333333333; + static const T M = 1.333333333333333333333333333333333333; - CalculationType t, c1, c, x1, x12, y1, y12; + T t, c1, c, x1, x12, y1, y12; t = tan(.5 * lp_lat); c1 = sqrt(1. - t * t); @@ -124,10 +118,10 @@ namespace projections \par Example \image html ex_august.gif */ - template <typename CalculationType, typename Parameters> - struct august_spheroid : public detail::august::base_august_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct august_spheroid : public detail::august::base_august_spheroid<T, Parameters> { - inline august_spheroid(const Parameters& par) : detail::august::base_august_spheroid<CalculationType, Parameters>(par) + inline august_spheroid(const Parameters& par) : detail::august::base_august_spheroid<T, Parameters>(par) { detail::august::setup_august(this->m_par); } @@ -141,20 +135,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::august, august_spheroid, august_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class august_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class august_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_f<august_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_f<august_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void august_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void august_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("august", new august_entry<CalculationType, Parameters>); + factory.add_to_factory("august", new august_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/bacon.hpp b/boost/geometry/srs/projections/proj/bacon.hpp index 5e8d37980f..d82e30aa1f 100644 --- a/boost/geometry/srs/projections/proj/bacon.hpp +++ b/boost/geometry/srs/projections/proj/bacon.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_BACON_HPP -#define BOOST_GEOMETRY_PROJECTIONS_BACON_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_BACON_HPP +#define BOOST_GEOMETRY_PROJECTIONS_BACON_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -65,8 +64,8 @@ namespace projections namespace detail { namespace bacon { - //static const double HLFPI2 = 2.46740110027233965467; - static const double EPS = 1e-10; + //static const double half_pi_sqr = 2.46740110027233965467; + static const double epsilon = 1e-10; struct par_bacon { @@ -75,35 +74,31 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_bacon_spheroid : public base_t_f<base_bacon_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_bacon_spheroid + : public base_t_f<base_bacon_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - par_bacon m_proj_parm; inline base_bacon_spheroid(const Parameters& par) - : base_t_f<base_bacon_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_f<base_bacon_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); - static const CalculationType HLFPI2 = detail::HALFPI_SQR<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); + static const T half_pi_sqr = detail::half_pi_sqr<T>(); - CalculationType ax, f; + T ax, f; - xy_y = this->m_proj_parm.bacn ? HALFPI * sin(lp_lat) : lp_lat; - if ((ax = fabs(lp_lon)) >= EPS) { - if (this->m_proj_parm.ortl && ax >= HALFPI) - xy_x = sqrt(HLFPI2 - lp_lat * lp_lat + EPS) + ax - HALFPI; + xy_y = this->m_proj_parm.bacn ? half_pi * sin(lp_lat) : lp_lat; + if ((ax = fabs(lp_lon)) >= epsilon) { + if (this->m_proj_parm.ortl && ax >= half_pi) + xy_x = sqrt(half_pi_sqr - lp_lat * lp_lat + epsilon) + ax - half_pi; else { - f = 0.5 * (HLFPI2 / ax + ax); + f = 0.5 * (half_pi_sqr / ax + ax); xy_x = ax - f + sqrt(f * f - xy_y * xy_y); } if (lp_lon < 0.) xy_x = - xy_x; @@ -160,10 +155,10 @@ namespace projections \par Example \image html ex_apian.gif */ - template <typename CalculationType, typename Parameters> - struct apian_spheroid : public detail::bacon::base_bacon_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct apian_spheroid : public detail::bacon::base_bacon_spheroid<T, Parameters> { - inline apian_spheroid(const Parameters& par) : detail::bacon::base_bacon_spheroid<CalculationType, Parameters>(par) + inline apian_spheroid(const Parameters& par) : detail::bacon::base_bacon_spheroid<T, Parameters>(par) { detail::bacon::setup_apian(this->m_par, this->m_proj_parm); } @@ -182,10 +177,10 @@ namespace projections \par Example \image html ex_ortel.gif */ - template <typename CalculationType, typename Parameters> - struct ortel_spheroid : public detail::bacon::base_bacon_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct ortel_spheroid : public detail::bacon::base_bacon_spheroid<T, Parameters> { - inline ortel_spheroid(const Parameters& par) : detail::bacon::base_bacon_spheroid<CalculationType, Parameters>(par) + inline ortel_spheroid(const Parameters& par) : detail::bacon::base_bacon_spheroid<T, Parameters>(par) { detail::bacon::setup_ortel(this->m_par, this->m_proj_parm); } @@ -204,10 +199,10 @@ namespace projections \par Example \image html ex_bacon.gif */ - template <typename CalculationType, typename Parameters> - struct bacon_spheroid : public detail::bacon::base_bacon_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct bacon_spheroid : public detail::bacon::base_bacon_spheroid<T, Parameters> { - inline bacon_spheroid(const Parameters& par) : detail::bacon::base_bacon_spheroid<CalculationType, Parameters>(par) + inline bacon_spheroid(const Parameters& par) : detail::bacon::base_bacon_spheroid<T, Parameters>(par) { detail::bacon::setup_bacon(this->m_par, this->m_proj_parm); } @@ -223,42 +218,42 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::ortel, ortel_spheroid, ortel_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class apian_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class apian_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_f<apian_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_f<apian_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class ortel_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class ortel_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_f<ortel_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_f<ortel_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class bacon_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class bacon_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_f<bacon_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_f<bacon_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void bacon_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void bacon_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("apian", new apian_entry<CalculationType, Parameters>); - factory.add_to_factory("ortel", new ortel_entry<CalculationType, Parameters>); - factory.add_to_factory("bacon", new bacon_entry<CalculationType, Parameters>); + factory.add_to_factory("apian", new apian_entry<T, Parameters>); + factory.add_to_factory("ortel", new ortel_entry<T, Parameters>); + factory.add_to_factory("bacon", new bacon_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/bipc.hpp b/boost/geometry/srs/projections/proj/bipc.hpp index 6f014d0e66..02af27ff62 100644 --- a/boost/geometry/srs/projections/proj/bipc.hpp +++ b/boost/geometry/srs/projections/proj/bipc.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_BIPC_HPP -#define BOOST_GEOMETRY_PROJECTIONS_BIPC_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_BIPC_HPP +#define BOOST_GEOMETRY_PROJECTIONS_BIPC_HPP + #include <boost/geometry/util/math.hpp> #include <boost/math/special_functions/hypot.hpp> @@ -64,16 +63,16 @@ namespace projections namespace detail { namespace bipc { - static const double EPS = 1e-10; - static const double EPS10 = 1e-10; - static const double ONEEPS = 1.000000001; - static const int NITER = 10; + static const double epsilon = 1e-10; + static const double epsilon10 = 1e-10; + static const double one_plus_eps = 1.000000001; + static const int n_iter = 10; static const double lamB = -.34894976726250681539; static const double n = .63055844881274687180; static const double F = 1.89724742567461030582; static const double Azab = .81650043674686363166; static const double Azba = 1.82261843856185925133; - static const double T = 1.27246578267089012270; + static const double const_T = 1.27246578267089012270; static const double rhoc = 1.20709121521568721927; static const double cAzc = .69691523038678375519; static const double sAzc = .71715351331143607555; @@ -90,36 +89,32 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_bipc_spheroid : public base_t_fi<base_bipc_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_bipc_spheroid + : public base_t_fi<base_bipc_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - par_bipc m_proj_parm; inline base_bipc_spheroid(const Parameters& par) - : base_t_fi<base_bipc_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_bipc_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); - static const CalculationType ONEPI = detail::ONEPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); + static const T pi = detail::pi<T>(); - CalculationType cphi, sphi, tphi, t, al, Az, z, Av, cdlam, sdlam, r; + T cphi, sphi, tphi, t, al, Az, z, Av, cdlam, sdlam, r; int tag; cphi = cos(lp_lat); sphi = sin(lp_lat); cdlam = cos(sdlam = lamB - lp_lon); sdlam = sin(sdlam); - if (fabs(fabs(lp_lat) - HALFPI) < EPS10) { - Az = lp_lat < 0. ? ONEPI : 0.; + if (fabs(fabs(lp_lat) - half_pi) < epsilon10) { + Az = lp_lat < 0. ? pi : 0.; tphi = HUGE_VAL; } else { tphi = sphi / cphi; @@ -130,8 +125,8 @@ namespace projections sdlam = sin(sdlam); z = S20 * sphi + C20 * cphi * cdlam; if (fabs(z) > 1.) { - if (fabs(z) > ONEEPS) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + if (fabs(z) > one_plus_eps) + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); else z = z < 0. ? -1. : 1.; } else @@ -143,8 +138,8 @@ namespace projections } else { z = S45 * (sphi + cphi * cdlam); if (fabs(z) > 1.) { - if (fabs(z) > ONEEPS) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + if (fabs(z) > one_plus_eps) + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); else z = z < 0. ? -1. : 1.; } else @@ -152,14 +147,17 @@ namespace projections Av = Azba; xy_y = -rhoc; } - if (z < 0.) BOOST_THROW_EXCEPTION( projection_exception(-20) ); - r = F * (t = pow(tan(.5 * z), n)); - if ((al = .5 * (R104 - z)) < 0.) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); - al = (t + pow(al, n)) / T; + if (z < 0.) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } + r = F * (t = math::pow(tan(T(0.5) * z), n)); + if ((al = .5 * (R104 - z)) < 0.) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } + al = (t + math::pow(al, n)) / const_T; if (fabs(al) > 1.) { - if (fabs(al) > ONEEPS) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + if (fabs(al) > one_plus_eps) + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); else al = al < 0. ? -1. : 1.; } else @@ -177,9 +175,9 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType t, r, rp, rl, al, z, fAz, Az, s, c, Av; + T t, r, rp, rl, al, z, fAz, Az, s, c, Av; int neg, i; if (this->m_proj_parm.noskew) { @@ -200,18 +198,18 @@ namespace projections } rl = rp = r = boost::math::hypot(xy_x, xy_y); fAz = fabs(Az = atan2(xy_x, xy_y)); - for (i = NITER; i ; --i) { - z = 2. * atan(pow(r / F,1 / n)); - al = acos((pow(tan(.5 * z), n) + - pow(tan(.5 * (R104 - z)), n)) / T); + for (i = n_iter; i ; --i) { + z = 2. * atan(math::pow(r / F,T(1) / n)); + al = acos((math::pow(tan(T(0.5) * z), n) + + math::pow(tan(T(0.5) * (R104 - z)), n)) / const_T); if (fAz < al) r = rp * cos(al + (neg ? Az : -Az)); - if (fabs(rl - r) < EPS) + if (fabs(rl - r) < epsilon) break; rl = r; } if (! i) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); 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)); @@ -232,7 +230,7 @@ namespace projections template <typename Parameters> inline void setup_bipc(Parameters& par, par_bipc& proj_parm) { - proj_parm.noskew = pj_param(par.params, "bns").i; + proj_parm.noskew = pj_get_param_b(par.params, "ns"); par.es = 0.; } @@ -253,10 +251,10 @@ namespace projections \par Example \image html ex_bipc.gif */ - template <typename CalculationType, typename Parameters> - struct bipc_spheroid : public detail::bipc::base_bipc_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct bipc_spheroid : public detail::bipc::base_bipc_spheroid<T, Parameters> { - inline bipc_spheroid(const Parameters& par) : detail::bipc::base_bipc_spheroid<CalculationType, Parameters>(par) + inline bipc_spheroid(const Parameters& par) : detail::bipc::base_bipc_spheroid<T, Parameters>(par) { detail::bipc::setup_bipc(this->m_par, this->m_proj_parm); } @@ -270,20 +268,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::bipc, bipc_spheroid, bipc_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class bipc_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class bipc_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<bipc_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<bipc_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void bipc_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void bipc_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("bipc", new bipc_entry<CalculationType, Parameters>); + factory.add_to_factory("bipc", new bipc_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/boggs.hpp b/boost/geometry/srs/projections/proj/boggs.hpp index 6c371e430f..c3c043faab 100644 --- a/boost/geometry/srs/projections/proj/boggs.hpp +++ b/boost/geometry/srs/projections/proj/boggs.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_BOGGS_HPP -#define BOOST_GEOMETRY_PROJECTIONS_BOGGS_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_BOGGS_HPP +#define BOOST_GEOMETRY_PROJECTIONS_BOGGS_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -63,52 +62,46 @@ namespace projections namespace detail { namespace boggs { - static const int NITER = 20; - static const double EPS = 1e-7; - static const double ONETOL = 1.000001; + static const int n_iter = 20; + static const double epsilon = 1e-7; static const double FXC = 2.00276; static const double FXC2 = 1.11072; static const double FYC = 0.49931; - static const double FYC2 = 1.41421356237309504880; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_boggs_spheroid : public base_t_f<base_boggs_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_boggs_spheroid + : public base_t_f<base_boggs_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_boggs_spheroid(const Parameters& par) - : base_t_f<base_boggs_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_f<base_boggs_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); - static const CalculationType ONEPI = detail::ONEPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); + static const T pi = detail::pi<T>(); + static const T root_two = boost::math::constants::root_two<T>(); - CalculationType theta, th1, c; + T theta, th1, c; int i; theta = lp_lat; - if (fabs(fabs(lp_lat) - HALFPI) < EPS) + if (fabs(fabs(lp_lat) - half_pi) < epsilon) xy_x = 0.; else { - c = sin(theta) * ONEPI; - for (i = NITER; i; --i) { + c = sin(theta) * pi; + for (i = n_iter; i; --i) { theta -= th1 = (theta + sin(theta) - c) / (1. + cos(theta)); - if (fabs(th1) < EPS) break; + if (fabs(th1) < epsilon) break; } theta *= 0.5; xy_x = FXC * lp_lon / (1. / cos(lp_lat) + FXC2 / cos(theta)); } - xy_y = FYC * (lp_lat + FYC2 * sin(theta)); + xy_y = FYC * (lp_lat + root_two * sin(theta)); } static inline std::string get_name() @@ -141,10 +134,10 @@ namespace projections \par Example \image html ex_boggs.gif */ - template <typename CalculationType, typename Parameters> - struct boggs_spheroid : public detail::boggs::base_boggs_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct boggs_spheroid : public detail::boggs::base_boggs_spheroid<T, Parameters> { - inline boggs_spheroid(const Parameters& par) : detail::boggs::base_boggs_spheroid<CalculationType, Parameters>(par) + inline boggs_spheroid(const Parameters& par) : detail::boggs::base_boggs_spheroid<T, Parameters>(par) { detail::boggs::setup_boggs(this->m_par); } @@ -158,20 +151,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::boggs, boggs_spheroid, boggs_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class boggs_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class boggs_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_f<boggs_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_f<boggs_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void boggs_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void boggs_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("boggs", new boggs_entry<CalculationType, Parameters>); + factory.add_to_factory("boggs", new boggs_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/bonne.hpp b/boost/geometry/srs/projections/proj/bonne.hpp index 52120a905f..3699537721 100644 --- a/boost/geometry/srs/projections/proj/bonne.hpp +++ b/boost/geometry/srs/projections/proj/bonne.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_BONNE_HPP -#define BOOST_GEOMETRY_PROJECTIONS_BONNE_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_BONNE_HPP +#define BOOST_GEOMETRY_PROJECTIONS_BONNE_HPP + #include <boost/geometry/util/math.hpp> #include <boost/math/special_functions/hypot.hpp> @@ -65,7 +64,7 @@ namespace projections namespace detail { namespace bonne { - static const double EPS10 = 1e-10; + static const double epsilon10 = 1e-10; template <typename T> struct par_bonne @@ -74,29 +73,25 @@ namespace projections T cphi1; T am1; T m1; - T en[EN_SIZE]; + detail::en<T> en; }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_bonne_ellipsoid : public base_t_fi<base_bonne_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_bonne_ellipsoid + : public base_t_fi<base_bonne_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_bonne<CalculationType> m_proj_parm; + par_bonne<T> m_proj_parm; inline base_bonne_ellipsoid(const Parameters& par) - : base_t_fi<base_bonne_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_bonne_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) ellipsoid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType rh, E, c; + T rh, E, c; rh = this->m_proj_parm.am1 + this->m_proj_parm.m1 - pj_mlfn(lp_lat, E = sin(lp_lat), c = cos(lp_lat), this->m_proj_parm.en); E = c * lp_lon / (rh * sqrt(1. - this->m_par.es * E * E)); @@ -106,22 +101,22 @@ namespace projections // INVERSE(e_inverse) ellipsoid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); - CalculationType s, rh; + T s, rh; rh = boost::math::hypot(xy_x, xy_y = this->m_proj_parm.am1 - xy_y); lp_lat = pj_inv_mlfn(this->m_proj_parm.am1 + this->m_proj_parm.m1 - rh, this->m_par.es, this->m_proj_parm.en); - if ((s = fabs(lp_lat)) < HALFPI) { + if ((s = fabs(lp_lat)) < half_pi) { s = sin(lp_lat); lp_lon = rh * atan2(xy_x, xy_y) * sqrt(1. - this->m_par.es * s * s) / cos(lp_lat); - } else if (fabs(s - HALFPI) <= EPS10) + } else if (fabs(s - half_pi) <= epsilon10) lp_lon = 0.; else - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); } static inline std::string get_name() @@ -132,28 +127,24 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_bonne_spheroid : public base_t_fi<base_bonne_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_bonne_spheroid + : public base_t_fi<base_bonne_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_bonne<CalculationType> m_proj_parm; + par_bonne<T> m_proj_parm; inline base_bonne_spheroid(const Parameters& par) - : base_t_fi<base_bonne_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_bonne_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType E, rh; + T E, rh; rh = this->m_proj_parm.cphi1 + this->m_proj_parm.phi1 - lp_lat; - if (fabs(rh) > EPS10) { + if (fabs(rh) > epsilon10) { xy_x = rh * sin(E = lp_lon * cos(lp_lat) / rh); xy_y = this->m_proj_parm.cphi1 - rh * cos(E); } else @@ -162,17 +153,18 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); - CalculationType rh; + T rh; 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) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); - if (fabs(fabs(lp_lat) - HALFPI) <= EPS10) + if (fabs(lp_lat) > half_pi) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } + if (fabs(fabs(lp_lat) - half_pi) <= epsilon10) lp_lon = 0.; else lp_lon = rh * atan2(xy_x, xy_y) / cos(lp_lat); @@ -189,20 +181,21 @@ namespace projections template <typename Parameters, typename T> inline void setup_bonne(Parameters& par, par_bonne<T>& proj_parm) { - static const T HALFPI = detail::HALFPI<T>(); + static const T half_pi = detail::half_pi<T>(); T c; - proj_parm.phi1 = pj_param(par.params, "rlat_1").f; - if (fabs(proj_parm.phi1) < EPS10) - BOOST_THROW_EXCEPTION( projection_exception(-23) ); - if (par.es) { - pj_enfn(par.es, proj_parm.en); + proj_parm.phi1 = pj_get_param_r(par.params, "lat_1"); + if (fabs(proj_parm.phi1) < epsilon10) + BOOST_THROW_EXCEPTION( projection_exception(error_lat1_is_zero) ); + + if (par.es != 0.0) { + proj_parm.en = pj_enfn<T>(par.es); proj_parm.m1 = pj_mlfn(proj_parm.phi1, proj_parm.am1 = sin(proj_parm.phi1), c = cos(proj_parm.phi1), proj_parm.en); proj_parm.am1 = c / (sqrt(1. - par.es * proj_parm.am1 * proj_parm.am1) * proj_parm.am1); } else { - if (fabs(proj_parm.phi1) + EPS10 >= HALFPI) + if (fabs(proj_parm.phi1) + epsilon10 >= half_pi) proj_parm.cphi1 = 0.; else proj_parm.cphi1 = 1. / tan(proj_parm.phi1); @@ -227,10 +220,10 @@ namespace projections \par Example \image html ex_bonne.gif */ - template <typename CalculationType, typename Parameters> - struct bonne_ellipsoid : public detail::bonne::base_bonne_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct bonne_ellipsoid : public detail::bonne::base_bonne_ellipsoid<T, Parameters> { - inline bonne_ellipsoid(const Parameters& par) : detail::bonne::base_bonne_ellipsoid<CalculationType, Parameters>(par) + inline bonne_ellipsoid(const Parameters& par) : detail::bonne::base_bonne_ellipsoid<T, Parameters>(par) { detail::bonne::setup_bonne(this->m_par, this->m_proj_parm); } @@ -251,10 +244,10 @@ namespace projections \par Example \image html ex_bonne.gif */ - template <typename CalculationType, typename Parameters> - struct bonne_spheroid : public detail::bonne::base_bonne_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct bonne_spheroid : public detail::bonne::base_bonne_spheroid<T, Parameters> { - inline bonne_spheroid(const Parameters& par) : detail::bonne::base_bonne_spheroid<CalculationType, Parameters>(par) + inline bonne_spheroid(const Parameters& par) : detail::bonne::base_bonne_spheroid<T, Parameters>(par) { detail::bonne::setup_bonne(this->m_par, this->m_proj_parm); } @@ -268,23 +261,23 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::bonne, bonne_spheroid, bonne_ellipsoid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class bonne_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class bonne_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { if (par.es) - return new base_v_fi<bonne_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<bonne_ellipsoid<T, Parameters>, T, Parameters>(par); else - return new base_v_fi<bonne_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<bonne_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void bonne_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void bonne_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("bonne", new bonne_entry<CalculationType, Parameters>); + factory.add_to_factory("bonne", new bonne_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/cass.hpp b/boost/geometry/srs/projections/proj/cass.hpp index b5f32b5aab..e46750cb6f 100644 --- a/boost/geometry/srs/projections/proj/cass.hpp +++ b/boost/geometry/srs/projections/proj/cass.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_CASS_HPP -#define BOOST_GEOMETRY_PROJECTIONS_CASS_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_CASS_HPP +#define BOOST_GEOMETRY_PROJECTIONS_CASS_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -63,7 +62,7 @@ namespace projections namespace detail { namespace cass { - //static const double EPS10 = 1e-10; + //static const double epsilon10 = 1e-10; //static const double C1 = .16666666666666666666; //static const double C2 = .00833333333333333333; //static const double C3 = .04166666666666666666; @@ -85,40 +84,37 @@ namespace projections struct par_cass { T m0; - T en[EN_SIZE]; + detail::en<T> en; }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_cass_ellipsoid : public base_t_fi<base_cass_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_cass_ellipsoid + : public base_t_fi<base_cass_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_cass<CalculationType> m_proj_parm; + par_cass<T> m_proj_parm; inline base_cass_ellipsoid(const Parameters& par) - : base_t_fi<base_cass_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_cass_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) ellipsoid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType C1 = cass::C1<CalculationType>(); - static const CalculationType C2 = cass::C2<CalculationType>(); - static const CalculationType C3 = cass::C3<CalculationType>(); + static const T C1 = cass::C1<T>(); + static const T C2 = cass::C2<T>(); + static const T C3 = cass::C3<T>(); - CalculationType n = sin(lp_lat); - CalculationType c = cos(lp_lat); + T n = sin(lp_lat); + T c = cos(lp_lat); xy_y = pj_mlfn(lp_lat, n, c, this->m_proj_parm.en); n = 1./sqrt(1. - this->m_par.es * n * n); - CalculationType tn = tan(lp_lat); CalculationType t = tn * tn; - CalculationType a1 = lp_lon * c; + T tn = tan(lp_lat); + T t = tn * tn; + T a1 = lp_lon * c; c *= this->m_par.es * c / (1 - this->m_par.es); - CalculationType a2 = a1 * a1; + T a2 = a1 * a1; xy_x = n * a1 * (1. - a2 * t * (C1 - (8. - t + 8. * c) * a2 * C2)); xy_y -= this->m_proj_parm.m0 - n * tn * a2 * @@ -127,22 +123,22 @@ namespace projections // INVERSE(e_inverse) ellipsoid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType C3 = cass::C3<CalculationType>(); - static const CalculationType C4 = cass::C4<CalculationType>(); - static const CalculationType C5 = cass::C5<CalculationType>(); + static const T C3 = cass::C3<T>(); + static const T C4 = cass::C4<T>(); + static const T C5 = cass::C5<T>(); - CalculationType ph1; + T ph1; ph1 = pj_inv_mlfn(this->m_proj_parm.m0 + xy_y, this->m_par.es, this->m_proj_parm.en); - CalculationType tn = tan(ph1); CalculationType t = tn * tn; - CalculationType n = sin(ph1); - CalculationType r = 1. / (1. - this->m_par.es * n * n); + T tn = tan(ph1); T t = tn * tn; + T n = sin(ph1); + T r = 1. / (1. - this->m_par.es * n * n); n = sqrt(r); r *= (1. - this->m_par.es) * n; - CalculationType dd = xy_x / n; - CalculationType d2 = dd * dd; + T dd = xy_x / n; + T d2 = dd * dd; lp_lat = ph1 - (n * tn / r) * d2 * (.5 - (1. + 3. * t) * d2 * C3); lp_lon = dd * (1. + t * d2 * @@ -157,23 +153,19 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_cass_spheroid : public base_t_fi<base_cass_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_cass_spheroid + : public base_t_fi<base_cass_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_cass<CalculationType> m_proj_parm; + par_cass<T> m_proj_parm; inline base_cass_spheroid(const Parameters& par) - : base_t_fi<base_cass_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_cass_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { xy_x = asin(cos(lp_lat) * sin(lp_lon)); xy_y = atan2(tan(lp_lat) , cos(lp_lon)) - this->m_par.phi0; @@ -181,9 +173,9 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType dd = xy_y + this->m_par.phi0; + T dd = xy_y + this->m_par.phi0; lp_lat = asin(sin(dd) * cos(xy_x)); lp_lon = atan2(tan(xy_x), cos(dd)); } @@ -200,8 +192,7 @@ namespace projections inline void setup_cass(Parameters& par, par_cass<T>& proj_parm) { if (par.es) { - if (!pj_enfn(par.es, proj_parm.en)) - BOOST_THROW_EXCEPTION( projection_exception(0) ); + proj_parm.en = pj_enfn<T>(par.es); proj_parm.m0 = pj_mlfn(par.phi0, sin(par.phi0), cos(par.phi0), proj_parm.en); } else { } @@ -223,10 +214,10 @@ namespace projections \par Example \image html ex_cass.gif */ - template <typename CalculationType, typename Parameters> - struct cass_ellipsoid : public detail::cass::base_cass_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct cass_ellipsoid : public detail::cass::base_cass_ellipsoid<T, Parameters> { - inline cass_ellipsoid(const Parameters& par) : detail::cass::base_cass_ellipsoid<CalculationType, Parameters>(par) + inline cass_ellipsoid(const Parameters& par) : detail::cass::base_cass_ellipsoid<T, Parameters>(par) { detail::cass::setup_cass(this->m_par, this->m_proj_parm); } @@ -245,10 +236,10 @@ namespace projections \par Example \image html ex_cass.gif */ - template <typename CalculationType, typename Parameters> - struct cass_spheroid : public detail::cass::base_cass_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct cass_spheroid : public detail::cass::base_cass_spheroid<T, Parameters> { - inline cass_spheroid(const Parameters& par) : detail::cass::base_cass_spheroid<CalculationType, Parameters>(par) + inline cass_spheroid(const Parameters& par) : detail::cass::base_cass_spheroid<T, Parameters>(par) { detail::cass::setup_cass(this->m_par, this->m_proj_parm); } @@ -262,23 +253,23 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::cass, cass_spheroid, cass_ellipsoid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class cass_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class cass_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { if (par.es) - return new base_v_fi<cass_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<cass_ellipsoid<T, Parameters>, T, Parameters>(par); else - return new base_v_fi<cass_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<cass_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void cass_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void cass_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("cass", new cass_entry<CalculationType, Parameters>); + factory.add_to_factory("cass", new cass_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/cc.hpp b/boost/geometry/srs/projections/proj/cc.hpp index c7fc1f20ab..78c3ede008 100644 --- a/boost/geometry/srs/projections/proj/cc.hpp +++ b/boost/geometry/srs/projections/proj/cc.hpp @@ -1,8 +1,4 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_CC_HPP -#define BOOST_GEOMETRY_PROJECTIONS_CC_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_CC_HPP +#define BOOST_GEOMETRY_PROJECTIONS_CC_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -63,36 +62,33 @@ namespace projections namespace detail { namespace cc { - static const double EPS10 = 1.e-10; + static const double epsilon10 = 1.e-10; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_cc_spheroid : public base_t_fi<base_cc_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_cc_spheroid + : public base_t_fi<base_cc_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - inline base_cc_spheroid(const Parameters& par) - : base_t_fi<base_cc_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_cc_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); - if (fabs(fabs(lp_lat) - HALFPI) <= EPS10) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + if (fabs(fabs(lp_lat) - half_pi) <= epsilon10) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } xy_x = lp_lon; xy_y = tan(lp_lat); } // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { lp_lat = atan(xy_y); lp_lon = xy_x; @@ -127,10 +123,10 @@ namespace projections \par Example \image html ex_cc.gif */ - template <typename CalculationType, typename Parameters> - struct cc_spheroid : public detail::cc::base_cc_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct cc_spheroid : public detail::cc::base_cc_spheroid<T, Parameters> { - inline cc_spheroid(const Parameters& par) : detail::cc::base_cc_spheroid<CalculationType, Parameters>(par) + inline cc_spheroid(const Parameters& par) : detail::cc::base_cc_spheroid<T, Parameters>(par) { detail::cc::setup_cc(this->m_par); } @@ -144,20 +140,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::cc, cc_spheroid, cc_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class cc_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class cc_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<cc_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<cc_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void cc_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void cc_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("cc", new cc_entry<CalculationType, Parameters>); + factory.add_to_factory("cc", new cc_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/cea.hpp b/boost/geometry/srs/projections/proj/cea.hpp index b6d8707e08..2d7ba20d3d 100644 --- a/boost/geometry/srs/projections/proj/cea.hpp +++ b/boost/geometry/srs/projections/proj/cea.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_CEA_HPP -#define BOOST_GEOMETRY_PROJECTIONS_CEA_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_CEA_HPP +#define BOOST_GEOMETRY_PROJECTIONS_CEA_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -65,33 +64,29 @@ namespace projections namespace detail { namespace cea { - static const double EPS = 1e-10; + static const double epsilon = 1e-10; template <typename T> struct par_cea { T qp; - T apa[APA_SIZE]; + detail::apa<T> apa; }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_cea_ellipsoid : public base_t_fi<base_cea_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_cea_ellipsoid + : public base_t_fi<base_cea_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_cea<CalculationType> m_proj_parm; + par_cea<T> m_proj_parm; inline base_cea_ellipsoid(const Parameters& par) - : base_t_fi<base_cea_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_cea_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { xy_x = this->m_par.k0 * lp_lon; xy_y = .5 * pj_qsfn(sin(lp_lat), this->m_par.e, this->m_par.one_es) / this->m_par.k0; @@ -99,7 +94,7 @@ namespace projections // INVERSE(e_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { lp_lat = pj_authlat(asin( 2. * xy_y * this->m_par.k0 / this->m_proj_parm.qp), this->m_proj_parm.apa); lp_lon = xy_x / this->m_par.k0; @@ -113,23 +108,19 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_cea_spheroid : public base_t_fi<base_cea_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_cea_spheroid + : public base_t_fi<base_cea_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_cea<CalculationType> m_proj_parm; + par_cea<T> m_proj_parm; inline base_cea_spheroid(const Parameters& par) - : base_t_fi<base_cea_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_cea_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { xy_x = this->m_par.k0 * lp_lon; xy_y = sin(lp_lat) / this->m_par.k0; @@ -137,20 +128,20 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); - CalculationType t; + T t; - if ((t = fabs(xy_y *= this->m_par.k0)) - EPS <= 1.) { + if ((t = fabs(xy_y *= this->m_par.k0)) - epsilon <= 1.) { if (t >= 1.) - lp_lat = xy_y < 0. ? -HALFPI : HALFPI; + lp_lat = xy_y < 0. ? -half_pi : half_pi; else lp_lat = asin(xy_y); lp_lon = xy_x / this->m_par.k0; } else - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); } static inline std::string get_name() @@ -166,17 +157,19 @@ namespace projections { T t = 0; - if (pj_param(par.params, "tlat_ts").i && - (par.k0 = cos(t = pj_param(par.params, "rlat_ts").f)) < 0.) - BOOST_THROW_EXCEPTION( projection_exception(-24) ); - if (par.es) { + if (pj_param_r(par.params, "lat_ts", t)) { + par.k0 = cos(t); + if (par.k0 < 0.) { + BOOST_THROW_EXCEPTION( projection_exception(error_lat_ts_larger_than_90) ); + } + } + if (par.es != 0.0) { t = sin(t); par.k0 /= sqrt(1. - par.es * t * t); par.e = sqrt(par.es); - if (!pj_authset(par.es, proj_parm.apa)) - BOOST_THROW_EXCEPTION( projection_exception(0) ); + proj_parm.apa = pj_authset<T>(par.es); + proj_parm.qp = pj_qsfn(1., par.e, par.one_es); - } else { } } @@ -198,10 +191,10 @@ namespace projections \par Example \image html ex_cea.gif */ - template <typename CalculationType, typename Parameters> - struct cea_ellipsoid : public detail::cea::base_cea_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct cea_ellipsoid : public detail::cea::base_cea_ellipsoid<T, Parameters> { - inline cea_ellipsoid(const Parameters& par) : detail::cea::base_cea_ellipsoid<CalculationType, Parameters>(par) + inline cea_ellipsoid(const Parameters& par) : detail::cea::base_cea_ellipsoid<T, Parameters>(par) { detail::cea::setup_cea(this->m_par, this->m_proj_parm); } @@ -222,10 +215,10 @@ namespace projections \par Example \image html ex_cea.gif */ - template <typename CalculationType, typename Parameters> - struct cea_spheroid : public detail::cea::base_cea_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct cea_spheroid : public detail::cea::base_cea_spheroid<T, Parameters> { - inline cea_spheroid(const Parameters& par) : detail::cea::base_cea_spheroid<CalculationType, Parameters>(par) + inline cea_spheroid(const Parameters& par) : detail::cea::base_cea_spheroid<T, Parameters>(par) { detail::cea::setup_cea(this->m_par, this->m_proj_parm); } @@ -239,23 +232,23 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::cea, cea_spheroid, cea_ellipsoid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class cea_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class cea_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { if (par.es) - return new base_v_fi<cea_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<cea_ellipsoid<T, Parameters>, T, Parameters>(par); else - return new base_v_fi<cea_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<cea_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void cea_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void cea_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("cea", new cea_entry<CalculationType, Parameters>); + factory.add_to_factory("cea", new cea_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/chamb.hpp b/boost/geometry/srs/projections/proj/chamb.hpp index 9fd123bb2e..a2bed492c1 100644 --- a/boost/geometry/srs/projections/proj/chamb.hpp +++ b/boost/geometry/srs/projections/proj/chamb.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_CHAMB_HPP -#define BOOST_GEOMETRY_PROJECTIONS_CHAMB_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_CHAMB_HPP +#define BOOST_GEOMETRY_PROJECTIONS_CHAMB_HPP + #include <boost/geometry/util/math.hpp> #include <cstdio> @@ -65,14 +64,14 @@ namespace projections namespace detail { namespace chamb { - //static const double THIRD = 0.333333333333333333; - static const double TOL = 1e-9; + //static const double third = 0.333333333333333333; + static const double tolerance = 1e-9; // specific for 'chamb' template <typename T> - struct VECT { T r, Az; }; + struct vect_ra { T r, Az; }; template <typename T> - struct XY { T x, y; }; + struct point_xy { T x, y; }; template <typename T> struct par_chamb @@ -80,19 +79,19 @@ namespace projections struct { /* control point data */ T phi, lam; T cosphi, sinphi; - VECT<T> v; - XY<T> p; + vect_ra<T> v; + point_xy<T> p; T Az; } c[3]; - XY<T> p; + point_xy<T> p; T beta_0, beta_1, beta_2; }; + /* distance and azimuth from point 1 to point 2 */ template <typename T> - inline VECT<T> /* distance and azimuth from point 1 to point 2 */ - vect(T const& dphi, T const& c1, T const& s1, T const& c2, T const& s2, T const& dlam) + inline vect_ra<T> vect(T const& dphi, T const& c1, T const& s1, T const& c2, T const& s2, T const& dlam) { - VECT<T> v; + vect_ra<T> v; T cdl, dp, dl; cdl = cos(dlam); @@ -103,43 +102,39 @@ namespace projections dl = sin(.5 * dlam); v.r = 2. * aasin(sqrt(dp * dp + c1 * c2 * dl * dl)); } - if (fabs(v.r) > TOL) + if (fabs(v.r) > tolerance) v.Az = atan2(c2 * sin(dlam), c1 * s2 - s1 * c2 * cdl); else v.r = v.Az = 0.; return v; } + /* law of cosines */ template <typename T> - inline T /* law of cosines */ - lc(T const& b, T const& c, T const& a) + inline T lc(T const& b, T const& c, T const& a) { return aacos(.5 * (b * b + c * c - a * a) / (b * c)); } // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_chamb_spheroid : public base_t_f<base_chamb_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_chamb_spheroid + : public base_t_f<base_chamb_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_chamb<CalculationType> m_proj_parm; + par_chamb<T> m_proj_parm; inline base_chamb_spheroid(const Parameters& par) - : base_t_f<base_chamb_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_f<base_chamb_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType THIRD = detail::THIRD<CalculationType>(); + static const T third = detail::third<T>(); - CalculationType sinphi, cosphi, a; - VECT<CalculationType> v[3]; + T sinphi, cosphi, a; + vect_ra<T> v[3]; int i, j; sinphi = sin(lp_lat); @@ -147,7 +142,7 @@ namespace projections for (i = 0; i < 3; ++i) { /* dist/azimiths from control */ v[i] = vect(lp_lat - this->m_proj_parm.c[i].phi, this->m_proj_parm.c[i].cosphi, this->m_proj_parm.c[i].sinphi, cosphi, sinphi, lp_lon - this->m_proj_parm.c[i].lam); - if ( ! v[i].r) + if (v[i].r == 0.0) break; v[i].Az = adjlon(v[i].Az - this->m_proj_parm.c[i].v.Az); } @@ -173,8 +168,8 @@ namespace projections xy_y += v[i].r * sin(a); } } - xy_x *= THIRD; /* mean of arc intercepts */ - xy_y *= THIRD; + xy_x *= third; /* mean of arc intercepts */ + xy_y *= third; } } @@ -189,16 +184,16 @@ namespace projections template <typename Parameters, typename T> inline void setup_chamb(Parameters& par, par_chamb<T>& proj_parm) { - static const T ONEPI = detail::ONEPI<T>(); + static const T pi = detail::pi<T>(); + + static const std::string lat[3] = {"lat_1", "lat_2", "lat_3"}; + static const std::string lon[3] = {"lon_1", "lon_2", "lon_3"}; int i, j; - char line[10]; for (i = 0; i < 3; ++i) { /* get control point locations */ - (void)sprintf(line, "rlat_%d", i+1); - proj_parm.c[i].phi = pj_param(par.params, line).f; - (void)sprintf(line, "rlon_%d", i+1); - proj_parm.c[i].lam = pj_param(par.params, line).f; + proj_parm.c[i].phi = pj_get_param_r(par.params, lat[i]); + proj_parm.c[i].lam = pj_get_param_r(par.params, lon[i]); proj_parm.c[i].lam = adjlon(proj_parm.c[i].lam - par.lam0); proj_parm.c[i].cosphi = cos(proj_parm.c[i].phi); proj_parm.c[i].sinphi = sin(proj_parm.c[i].phi); @@ -207,17 +202,18 @@ namespace projections j = i == 2 ? 0 : i + 1; proj_parm.c[i].v = vect(proj_parm.c[j].phi - proj_parm.c[i].phi, proj_parm.c[i].cosphi, proj_parm.c[i].sinphi, proj_parm.c[j].cosphi, proj_parm.c[j].sinphi, proj_parm.c[j].lam - proj_parm.c[i].lam); - if (! proj_parm.c[i].v.r) - BOOST_THROW_EXCEPTION( projection_exception(-25) ); + if (proj_parm.c[i].v.r == 0.0) + BOOST_THROW_EXCEPTION( projection_exception(error_control_point_no_dist) ); /* co-linearity problem ignored for now */ } proj_parm.beta_0 = lc(proj_parm.c[0].v.r, proj_parm.c[2].v.r, proj_parm.c[1].v.r); proj_parm.beta_1 = lc(proj_parm.c[0].v.r, proj_parm.c[1].v.r, proj_parm.c[2].v.r); - proj_parm.beta_2 = ONEPI - proj_parm.beta_0; + proj_parm.beta_2 = pi - proj_parm.beta_0; proj_parm.p.y = 2. * (proj_parm.c[0].p.y = proj_parm.c[1].p.y = proj_parm.c[2].v.r * sin(proj_parm.beta_0)); proj_parm.c[2].p.y = 0.; proj_parm.c[0].p.x = - (proj_parm.c[1].p.x = 0.5 * proj_parm.c[0].v.r); proj_parm.p.x = proj_parm.c[2].p.x = proj_parm.c[0].p.x + proj_parm.c[2].v.r * cos(proj_parm.beta_0); + par.es = 0.; } @@ -244,10 +240,10 @@ namespace projections \par Example \image html ex_chamb.gif */ - template <typename CalculationType, typename Parameters> - struct chamb_spheroid : public detail::chamb::base_chamb_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct chamb_spheroid : public detail::chamb::base_chamb_spheroid<T, Parameters> { - inline chamb_spheroid(const Parameters& par) : detail::chamb::base_chamb_spheroid<CalculationType, Parameters>(par) + inline chamb_spheroid(const Parameters& par) : detail::chamb::base_chamb_spheroid<T, Parameters>(par) { detail::chamb::setup_chamb(this->m_par, this->m_proj_parm); } @@ -261,20 +257,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::chamb, chamb_spheroid, chamb_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class chamb_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class chamb_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_f<chamb_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_f<chamb_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void chamb_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void chamb_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("chamb", new chamb_entry<CalculationType, Parameters>); + factory.add_to_factory("chamb", new chamb_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/collg.hpp b/boost/geometry/srs/projections/proj/collg.hpp index 0bc347a305..1dc5b3ce48 100644 --- a/boost/geometry/srs/projections/proj/collg.hpp +++ b/boost/geometry/srs/projections/proj/collg.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_COLLG_HPP -#define BOOST_GEOMETRY_PROJECTIONS_COLLG_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_COLLG_HPP +#define BOOST_GEOMETRY_PROJECTIONS_COLLG_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -65,25 +64,20 @@ namespace projections static const double FXC = 1.12837916709551257390; static const double FYC = 1.77245385090551602729; - static const double ONEEPS = 1.0000001; + static const double one_plus_eps = 1.0000001; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_collg_spheroid : public base_t_fi<base_collg_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_collg_spheroid + : public base_t_fi<base_collg_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_collg_spheroid(const Parameters& par) - : base_t_fi<base_collg_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_collg_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { if ((xy_y = 1. - sin(lp_lat)) <= 0.) xy_y = 0.; @@ -95,15 +89,19 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { + static T const half_pi = detail::half_pi<T>(); + 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) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); - else - lp_lat = lp_lat < 0. ? -geometry::math::half_pi<double>() : geometry::math::half_pi<double>(); + else if (fabs(lp_lat) > one_plus_eps) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } else { + lp_lat = lp_lat < 0. ? -half_pi : half_pi; + } + if ((lp_lon = 1. - sin(lp_lat)) <= 0.) lp_lon = 0.; else @@ -139,10 +137,10 @@ namespace projections \par Example \image html ex_collg.gif */ - template <typename CalculationType, typename Parameters> - struct collg_spheroid : public detail::collg::base_collg_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct collg_spheroid : public detail::collg::base_collg_spheroid<T, Parameters> { - inline collg_spheroid(const Parameters& par) : detail::collg::base_collg_spheroid<CalculationType, Parameters>(par) + inline collg_spheroid(const Parameters& par) : detail::collg::base_collg_spheroid<T, Parameters>(par) { detail::collg::setup_collg(this->m_par); } @@ -156,20 +154,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::collg, collg_spheroid, collg_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class collg_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class collg_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<collg_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<collg_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void collg_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void collg_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("collg", new collg_entry<CalculationType, Parameters>); + factory.add_to_factory("collg", new collg_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/crast.hpp b/boost/geometry/srs/projections/proj/crast.hpp index 4aea886071..5f781f8776 100644 --- a/boost/geometry/srs/projections/proj/crast.hpp +++ b/boost/geometry/srs/projections/proj/crast.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_CRAST_HPP -#define BOOST_GEOMETRY_PROJECTIONS_CRAST_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_CRAST_HPP +#define BOOST_GEOMETRY_PROJECTIONS_CRAST_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -65,41 +64,36 @@ namespace projections static const double RXM = 1.02332670794648848847; static const double YM = 3.06998012383946546542; static const double RYM = 0.32573500793527994772; - //static const double THIRD = 0.333333333333333333; + //static const double third = 0.333333333333333333; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_crast_spheroid : public base_t_fi<base_crast_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_crast_spheroid + : public base_t_fi<base_crast_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_crast_spheroid(const Parameters& par) - : base_t_fi<base_crast_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_crast_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType THIRD = detail::THIRD<CalculationType>(); + static const T third = detail::third<T>(); - lp_lat *= THIRD; + lp_lat *= third; xy_x = XM * lp_lon * (2. * cos(lp_lat + lp_lat) - 1.); xy_y = YM * sin(lp_lat); } // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType THIRD = detail::THIRD<CalculationType>(); + static const T third = detail::third<T>(); lp_lat = 3. * asin(xy_y * RYM); - lp_lon = xy_x * RXM / (2. * cos((lp_lat + lp_lat) * THIRD) - 1); + lp_lon = xy_x * RXM / (2. * cos((lp_lat + lp_lat) * third) - 1); } static inline std::string get_name() @@ -131,10 +125,10 @@ namespace projections \par Example \image html ex_crast.gif */ - template <typename CalculationType, typename Parameters> - struct crast_spheroid : public detail::crast::base_crast_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct crast_spheroid : public detail::crast::base_crast_spheroid<T, Parameters> { - inline crast_spheroid(const Parameters& par) : detail::crast::base_crast_spheroid<CalculationType, Parameters>(par) + inline crast_spheroid(const Parameters& par) : detail::crast::base_crast_spheroid<T, Parameters>(par) { detail::crast::setup_crast(this->m_par); } @@ -148,20 +142,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::crast, crast_spheroid, crast_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class crast_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class crast_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<crast_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<crast_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void crast_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void crast_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("crast", new crast_entry<CalculationType, Parameters>); + factory.add_to_factory("crast", new crast_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/denoy.hpp b/boost/geometry/srs/projections/proj/denoy.hpp index afedae8734..9d54487f6f 100644 --- a/boost/geometry/srs/projections/proj/denoy.hpp +++ b/boost/geometry/srs/projections/proj/denoy.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_DENOY_HPP -#define BOOST_GEOMETRY_PROJECTIONS_DENOY_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_DENOY_HPP +#define BOOST_GEOMETRY_PROJECTIONS_DENOY_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -62,36 +61,31 @@ namespace projections { static const double C0 = 0.95; - //static const double C1 = -.08333333333333333333; - //static const double C3 = .00166666666666666666; + //static const double C1 = -0.08333333333333333333; + //static const double C3 = 0.00166666666666666666; static const double D1 = 0.9; static const double D5 = 0.03; template <typename T> - inline T C1() { return -.0833333333333333333333333333333; } + inline T C1() { return -0.0833333333333333333333333333333; } template <typename T> - inline T C3() { return .0016666666666666666666666666666; } + inline T C3() { return 0.0016666666666666666666666666666; } // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_denoy_spheroid : public base_t_f<base_denoy_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_denoy_spheroid + : public base_t_f<base_denoy_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_denoy_spheroid(const Parameters& par) - : base_t_f<base_denoy_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_f<base_denoy_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType C1 = denoy::C1<CalculationType>(); - static const CalculationType C3 = denoy::C3<CalculationType>(); + static const T C1 = denoy::C1<T>(); + static const T C3 = denoy::C3<T>(); xy_y = lp_lat; xy_x = lp_lon; @@ -111,7 +105,7 @@ namespace projections template <typename Parameters> inline void setup_denoy(Parameters& par) { - par.es = 0.; + par.es = 0.0; } }} // namespace detail::denoy @@ -130,10 +124,10 @@ namespace projections \par Example \image html ex_denoy.gif */ - template <typename CalculationType, typename Parameters> - struct denoy_spheroid : public detail::denoy::base_denoy_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct denoy_spheroid : public detail::denoy::base_denoy_spheroid<T, Parameters> { - inline denoy_spheroid(const Parameters& par) : detail::denoy::base_denoy_spheroid<CalculationType, Parameters>(par) + inline denoy_spheroid(const Parameters& par) : detail::denoy::base_denoy_spheroid<T, Parameters>(par) { detail::denoy::setup_denoy(this->m_par); } @@ -147,20 +141,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::denoy, denoy_spheroid, denoy_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class denoy_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class denoy_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_f<denoy_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_f<denoy_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void denoy_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void denoy_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("denoy", new denoy_entry<CalculationType, Parameters>); + factory.add_to_factory("denoy", new denoy_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/eck1.hpp b/boost/geometry/srs/projections/proj/eck1.hpp index 41f0f6424f..e5ab6e2449 100644 --- a/boost/geometry/srs/projections/proj/eck1.hpp +++ b/boost/geometry/srs/projections/proj/eck1.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_ECK1_HPP -#define BOOST_GEOMETRY_PROJECTIONS_ECK1_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_ECK1_HPP +#define BOOST_GEOMETRY_PROJECTIONS_ECK1_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -65,22 +64,17 @@ namespace projections static const double RP = .31830988618379067154; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_eck1_spheroid : public base_t_fi<base_eck1_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_eck1_spheroid + : public base_t_fi<base_eck1_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_eck1_spheroid(const Parameters& par) - : base_t_fi<base_eck1_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_eck1_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { xy_x = FC * lp_lon * (1. - RP * fabs(lp_lat)); xy_y = FC * lp_lat; @@ -88,7 +82,7 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { lp_lat = xy_y / FC; lp_lon = xy_x / (FC * (1. - RP * fabs(lp_lat))); @@ -123,10 +117,10 @@ namespace projections \par Example \image html ex_eck1.gif */ - template <typename CalculationType, typename Parameters> - struct eck1_spheroid : public detail::eck1::base_eck1_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct eck1_spheroid : public detail::eck1::base_eck1_spheroid<T, Parameters> { - inline eck1_spheroid(const Parameters& par) : detail::eck1::base_eck1_spheroid<CalculationType, Parameters>(par) + inline eck1_spheroid(const Parameters& par) : detail::eck1::base_eck1_spheroid<T, Parameters>(par) { detail::eck1::setup_eck1(this->m_par); } @@ -140,20 +134,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::eck1, eck1_spheroid, eck1_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class eck1_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class eck1_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<eck1_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<eck1_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void eck1_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void eck1_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("eck1", new eck1_entry<CalculationType, Parameters>); + factory.add_to_factory("eck1", new eck1_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/eck2.hpp b/boost/geometry/srs/projections/proj/eck2.hpp index 737057bfcd..fd39735d95 100644 --- a/boost/geometry/srs/projections/proj/eck2.hpp +++ b/boost/geometry/srs/projections/proj/eck2.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_ECK2_HPP -#define BOOST_GEOMETRY_PROJECTIONS_ECK2_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_ECK2_HPP +#define BOOST_GEOMETRY_PROJECTIONS_ECK2_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -66,25 +65,20 @@ namespace projections static const double FXC = 0.46065886596178063902; static const double FYC = 1.44720250911653531871; //static const double C13 = 0.33333333333333333333; - static const double ONEEPS = 1.0000001; + static const double one_plus_eps = 1.0000001; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_eck2_spheroid : public base_t_fi<base_eck2_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_eck2_spheroid + : public base_t_fi<base_eck2_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_eck2_spheroid(const Parameters& par) - : base_t_fi<base_eck2_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_eck2_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { xy_x = FXC * lp_lon * (xy_y = sqrt(4. - 3. * sin(fabs(lp_lat)))); xy_y = FYC * (2. - xy_y); @@ -93,18 +87,18 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); - static const CalculationType C13 = detail::THIRD<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); + static const T C13 = detail::third<T>(); 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) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + if (fabs(lp_lat) > one_plus_eps) + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); else - lp_lat = lp_lat < 0. ? -HALFPI : HALFPI; + lp_lat = lp_lat < 0. ? -half_pi : half_pi; } else lp_lat = asin(lp_lat); if (xy_y < 0) @@ -140,10 +134,10 @@ namespace projections \par Example \image html ex_eck2.gif */ - template <typename CalculationType, typename Parameters> - struct eck2_spheroid : public detail::eck2::base_eck2_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct eck2_spheroid : public detail::eck2::base_eck2_spheroid<T, Parameters> { - inline eck2_spheroid(const Parameters& par) : detail::eck2::base_eck2_spheroid<CalculationType, Parameters>(par) + inline eck2_spheroid(const Parameters& par) : detail::eck2::base_eck2_spheroid<T, Parameters>(par) { detail::eck2::setup_eck2(this->m_par); } @@ -157,20 +151,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::eck2, eck2_spheroid, eck2_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class eck2_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class eck2_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<eck2_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<eck2_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void eck2_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void eck2_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("eck2", new eck2_entry<CalculationType, Parameters>); + factory.add_to_factory("eck2", new eck2_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/eck3.hpp b/boost/geometry/srs/projections/proj/eck3.hpp index dbc1beb625..35933af3fe 100644 --- a/boost/geometry/srs/projections/proj/eck3.hpp +++ b/boost/geometry/srs/projections/proj/eck3.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_ECK3_HPP -#define BOOST_GEOMETRY_PROJECTIONS_ECK3_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_ECK3_HPP +#define BOOST_GEOMETRY_PROJECTIONS_ECK3_HPP + #include <boost/core/ignore_unused.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -54,10 +53,10 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct eck3 {}; - struct putp1 {}; - struct wag6 {}; - struct kav7 {}; + struct eck3 {}; // Eckert III + struct putp1 {}; // Putnins P1 + struct wag6 {}; // Wagner VI + struct kav7 {}; // Kavraisky VII }} //namespace srs::par4 @@ -74,23 +73,19 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_eck3_spheroid : public base_t_fi<base_eck3_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_eck3_spheroid + : public base_t_fi<base_eck3_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_eck3<CalculationType> m_proj_parm; + par_eck3<T> m_proj_parm; inline base_eck3_spheroid(const Parameters& par) - : base_t_fi<base_eck3_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_eck3_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { xy_y = this->m_proj_parm.C_y * lp_lat; xy_x = this->m_proj_parm.C_x * lp_lon * (this->m_proj_parm.A + asqrt(1. - this->m_proj_parm.B * lp_lat * lp_lat)); @@ -98,10 +93,16 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { + T denominator; lp_lat = xy_y / this->m_proj_parm.C_y; - lp_lon = xy_x / (this->m_proj_parm.C_x * (this->m_proj_parm.A + asqrt(1. - this->m_proj_parm.B * lp_lat * lp_lat))); + denominator = (this->m_proj_parm.C_x * (this->m_proj_parm.A + asqrt(1. - this->m_proj_parm.B * lp_lat * lp_lat))); + if ( denominator == 0.0) { + lp_lon = HUGE_VAL; + lp_lat = HUGE_VAL; + } else + lp_lon = xy_x / denominator; } static inline std::string get_name() @@ -111,10 +112,9 @@ namespace projections }; - template <typename Parameters, typename T> - inline void setup(Parameters& par, par_eck3<T>& proj_parm) + template <typename Parameters> + inline void setup(Parameters& par) { - boost::ignore_unused(proj_parm); par.es = 0.; } @@ -123,11 +123,12 @@ namespace projections template <typename Parameters, typename T> inline void setup_eck3(Parameters& par, par_eck3<T>& proj_parm) { - proj_parm.C_x = .42223820031577120149; - proj_parm.C_y = .84447640063154240298; - proj_parm.A = 1.; + proj_parm.C_x = 0.42223820031577120149; + proj_parm.C_y = 0.84447640063154240298; + proj_parm.A = 1.0; proj_parm.B = 0.4052847345693510857755; - setup(par, proj_parm); + + setup(par); } // Putnins P1 @@ -138,7 +139,8 @@ namespace projections proj_parm.C_y = 0.94745; proj_parm.A = -0.5; proj_parm.B = 0.30396355092701331433; - setup(par, proj_parm); + + setup(par); } // Wagner VI @@ -146,21 +148,25 @@ namespace projections inline void setup_wag6(Parameters& par, par_eck3<T>& proj_parm) { proj_parm.C_x = proj_parm.C_y = 0.94745; - proj_parm.A = 0.; + proj_parm.A = 0.0; proj_parm.B = 0.30396355092701331433; - setup(par, proj_parm); + + setup(par); } // Kavraisky VII template <typename Parameters, typename T> inline void setup_kav7(Parameters& par, par_eck3<T>& proj_parm) { - proj_parm.C_x = 0.2632401569273184856851; + /* Defined twice in original code - Using 0.866..., + * but leaving the other one here as a safety measure. + * proj_parm.C_x = 0.2632401569273184856851; */ proj_parm.C_x = 0.8660254037844; - proj_parm.C_y = 1.; - proj_parm.A = 0.; + proj_parm.C_y = 1.0; + proj_parm.A = 0.0; proj_parm.B = 0.30396355092701331433; - setup(par, proj_parm); + + setup(par); } }} // namespace detail::eck3 @@ -178,10 +184,10 @@ namespace projections \par Example \image html ex_eck3.gif */ - template <typename CalculationType, typename Parameters> - struct eck3_spheroid : public detail::eck3::base_eck3_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct eck3_spheroid : public detail::eck3::base_eck3_spheroid<T, Parameters> { - inline eck3_spheroid(const Parameters& par) : detail::eck3::base_eck3_spheroid<CalculationType, Parameters>(par) + inline eck3_spheroid(const Parameters& par) : detail::eck3::base_eck3_spheroid<T, Parameters>(par) { detail::eck3::setup_eck3(this->m_par, this->m_proj_parm); } @@ -199,10 +205,10 @@ namespace projections \par Example \image html ex_putp1.gif */ - template <typename CalculationType, typename Parameters> - struct putp1_spheroid : public detail::eck3::base_eck3_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct putp1_spheroid : public detail::eck3::base_eck3_spheroid<T, Parameters> { - inline putp1_spheroid(const Parameters& par) : detail::eck3::base_eck3_spheroid<CalculationType, Parameters>(par) + inline putp1_spheroid(const Parameters& par) : detail::eck3::base_eck3_spheroid<T, Parameters>(par) { detail::eck3::setup_putp1(this->m_par, this->m_proj_parm); } @@ -220,10 +226,10 @@ namespace projections \par Example \image html ex_wag6.gif */ - template <typename CalculationType, typename Parameters> - struct wag6_spheroid : public detail::eck3::base_eck3_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct wag6_spheroid : public detail::eck3::base_eck3_spheroid<T, Parameters> { - inline wag6_spheroid(const Parameters& par) : detail::eck3::base_eck3_spheroid<CalculationType, Parameters>(par) + inline wag6_spheroid(const Parameters& par) : detail::eck3::base_eck3_spheroid<T, Parameters>(par) { detail::eck3::setup_wag6(this->m_par, this->m_proj_parm); } @@ -241,10 +247,10 @@ namespace projections \par Example \image html ex_kav7.gif */ - template <typename CalculationType, typename Parameters> - struct kav7_spheroid : public detail::eck3::base_eck3_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct kav7_spheroid : public detail::eck3::base_eck3_spheroid<T, Parameters> { - inline kav7_spheroid(const Parameters& par) : detail::eck3::base_eck3_spheroid<CalculationType, Parameters>(par) + inline kav7_spheroid(const Parameters& par) : detail::eck3::base_eck3_spheroid<T, Parameters>(par) { detail::eck3::setup_kav7(this->m_par, this->m_proj_parm); } @@ -261,53 +267,53 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::kav7, kav7_spheroid, kav7_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class eck3_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class eck3_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<eck3_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<eck3_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class putp1_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class putp1_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<putp1_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<putp1_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class wag6_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class wag6_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<wag6_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<wag6_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class kav7_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class kav7_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<kav7_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<kav7_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void eck3_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void eck3_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("eck3", new eck3_entry<CalculationType, Parameters>); - factory.add_to_factory("putp1", new putp1_entry<CalculationType, Parameters>); - factory.add_to_factory("wag6", new wag6_entry<CalculationType, Parameters>); - factory.add_to_factory("kav7", new kav7_entry<CalculationType, Parameters>); + factory.add_to_factory("eck3", new eck3_entry<T, Parameters>); + factory.add_to_factory("putp1", new putp1_entry<T, Parameters>); + factory.add_to_factory("wag6", new wag6_entry<T, Parameters>); + factory.add_to_factory("kav7", new kav7_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/eck4.hpp b/boost/geometry/srs/projections/proj/eck4.hpp index 4307b59439..7c1fc6178d 100644 --- a/boost/geometry/srs/projections/proj/eck4.hpp +++ b/boost/geometry/srs/projections/proj/eck4.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_ECK4_HPP -#define BOOST_GEOMETRY_PROJECTIONS_ECK4_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_ECK4_HPP +#define BOOST_GEOMETRY_PROJECTIONS_ECK4_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -52,7 +51,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct eck4 {}; + struct eck4 {}; // Eckert IV }} //namespace srs::par4 @@ -67,39 +66,34 @@ namespace projections static const double RC_y = .75386330736002178205; static const double C_p = 3.57079632679489661922; static const double RC_p = .28004957675577868795; - static const double EPS = 1e-7; - static const int NITER = 6; + static const double epsilon = 1e-7; + static const int n_iter = 6; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_eck4_spheroid : public base_t_fi<base_eck4_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_eck4_spheroid + : public base_t_fi<base_eck4_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_eck4_spheroid(const Parameters& par) - : base_t_fi<base_eck4_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_eck4_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType p, V, s, c; + T p, V, s, c; int i; p = C_p * sin(lp_lat); V = lp_lat * lp_lat; lp_lat *= 0.895168 + V * ( 0.0218849 + V * 0.00826809 ); - for (i = NITER; i ; --i) { + for (i = n_iter; i ; --i) { c = cos(lp_lat); s = sin(lp_lat); lp_lat -= V = (lp_lat + s * (c + 2.) - p) / (1. + c * (c + 2.) - s * s); - if (fabs(V) < EPS) + if (fabs(V) < epsilon) break; } if (!i) { @@ -113,13 +107,13 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType c; + T c; - lp_lat = aasin(xy_y / C_y); + lp_lat = aasin(xy_y * RC_y); lp_lon = xy_x / (C_x * (1. + (c = cos(lp_lat)))); - lp_lat = aasin((lp_lat + sin(lp_lat) * (c + 2.)) / C_p); + lp_lat = aasin((lp_lat + sin(lp_lat) * (c + 2.)) * RC_p); } static inline std::string get_name() @@ -151,10 +145,10 @@ namespace projections \par Example \image html ex_eck4.gif */ - template <typename CalculationType, typename Parameters> - struct eck4_spheroid : public detail::eck4::base_eck4_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct eck4_spheroid : public detail::eck4::base_eck4_spheroid<T, Parameters> { - inline eck4_spheroid(const Parameters& par) : detail::eck4::base_eck4_spheroid<CalculationType, Parameters>(par) + inline eck4_spheroid(const Parameters& par) : detail::eck4::base_eck4_spheroid<T, Parameters>(par) { detail::eck4::setup_eck4(this->m_par); } @@ -168,20 +162,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::eck4, eck4_spheroid, eck4_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class eck4_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class eck4_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<eck4_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<eck4_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void eck4_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void eck4_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("eck4", new eck4_entry<CalculationType, Parameters>); + factory.add_to_factory("eck4", new eck4_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/eck5.hpp b/boost/geometry/srs/projections/proj/eck5.hpp index bc075702e8..823de91040 100644 --- a/boost/geometry/srs/projections/proj/eck5.hpp +++ b/boost/geometry/srs/projections/proj/eck5.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_ECK5_HPP -#define BOOST_GEOMETRY_PROJECTIONS_ECK5_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_ECK5_HPP +#define BOOST_GEOMETRY_PROJECTIONS_ECK5_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -51,7 +50,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct eck5 {}; + struct eck5 {}; // Eckert V }} //namespace srs::par4 @@ -61,28 +60,23 @@ namespace projections namespace detail { namespace eck5 { - static const double XF = 0.44101277172455148219; + static const double XF = 0.44101277172455148219; static const double RXF = 2.26750802723822639137; - static const double YF = 0.88202554344910296438; + static const double YF = 0.88202554344910296438; static const double RYF = 1.13375401361911319568; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_eck5_spheroid : public base_t_fi<base_eck5_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_eck5_spheroid + : public base_t_fi<base_eck5_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_eck5_spheroid(const Parameters& par) - : base_t_fi<base_eck5_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_eck5_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { xy_x = XF * (1. + cos(lp_lat)) * lp_lon; xy_y = YF * lp_lat; @@ -90,7 +84,7 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { lp_lon = RXF * xy_x / (1. + cos( lp_lat = RYF * xy_y)); } @@ -106,7 +100,7 @@ namespace projections template <typename Parameters> inline void setup_eck5(Parameters& par) { - par.es = 0.; + par.es = 0.0; } }} // namespace detail::eck5 @@ -124,10 +118,10 @@ namespace projections \par Example \image html ex_eck5.gif */ - template <typename CalculationType, typename Parameters> - struct eck5_spheroid : public detail::eck5::base_eck5_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct eck5_spheroid : public detail::eck5::base_eck5_spheroid<T, Parameters> { - inline eck5_spheroid(const Parameters& par) : detail::eck5::base_eck5_spheroid<CalculationType, Parameters>(par) + inline eck5_spheroid(const Parameters& par) : detail::eck5::base_eck5_spheroid<T, Parameters>(par) { detail::eck5::setup_eck5(this->m_par); } @@ -141,20 +135,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::eck5, eck5_spheroid, eck5_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class eck5_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class eck5_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<eck5_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<eck5_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void eck5_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void eck5_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("eck5", new eck5_entry<CalculationType, Parameters>); + factory.add_to_factory("eck5", new eck5_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/eqc.hpp b/boost/geometry/srs/projections/proj/eqc.hpp index 5234ce9b8d..355ab90567 100644 --- a/boost/geometry/srs/projections/proj/eqc.hpp +++ b/boost/geometry/srs/projections/proj/eqc.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_EQC_HPP -#define BOOST_GEOMETRY_PROJECTIONS_EQC_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_EQC_HPP +#define BOOST_GEOMETRY_PROJECTIONS_EQC_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -51,7 +50,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct eqc {}; + struct eqc {}; // Equidistant Cylindrical (Plate Caree) }} //namespace srs::par4 @@ -67,23 +66,19 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_eqc_spheroid : public base_t_fi<base_eqc_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_eqc_spheroid + : public base_t_fi<base_eqc_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_eqc<CalculationType> m_proj_parm; + par_eqc<T> m_proj_parm; inline base_eqc_spheroid(const Parameters& par) - : base_t_fi<base_eqc_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_eqc_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { xy_x = this->m_proj_parm.rc * lp_lon; xy_y = lp_lat - this->m_par.phi0; @@ -91,7 +86,7 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { lp_lon = xy_x / this->m_proj_parm.rc; lp_lat = xy_y + this->m_par.phi0; @@ -108,8 +103,8 @@ namespace projections template <typename Parameters, typename T> inline void setup_eqc(Parameters& par, par_eqc<T>& proj_parm) { - if ((proj_parm.rc = cos(pj_param(par.params, "rlat_ts").f)) <= 0.) - BOOST_THROW_EXCEPTION( projection_exception(-24) ); + if ((proj_parm.rc = cos(pj_get_param_r(par.params, "lat_ts"))) <= 0.) + BOOST_THROW_EXCEPTION( projection_exception(error_lat_ts_larger_than_90) ); par.es = 0.; } @@ -131,10 +126,10 @@ namespace projections \par Example \image html ex_eqc.gif */ - template <typename CalculationType, typename Parameters> - struct eqc_spheroid : public detail::eqc::base_eqc_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct eqc_spheroid : public detail::eqc::base_eqc_spheroid<T, Parameters> { - inline eqc_spheroid(const Parameters& par) : detail::eqc::base_eqc_spheroid<CalculationType, Parameters>(par) + inline eqc_spheroid(const Parameters& par) : detail::eqc::base_eqc_spheroid<T, Parameters>(par) { detail::eqc::setup_eqc(this->m_par, this->m_proj_parm); } @@ -148,20 +143,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::eqc, eqc_spheroid, eqc_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class eqc_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class eqc_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<eqc_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<eqc_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void eqc_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void eqc_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("eqc", new eqc_entry<CalculationType, Parameters>); + factory.add_to_factory("eqc", new eqc_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/eqdc.hpp b/boost/geometry/srs/projections/proj/eqdc.hpp index 1af11338a4..f0c7597cbd 100644 --- a/boost/geometry/srs/projections/proj/eqdc.hpp +++ b/boost/geometry/srs/projections/proj/eqdc.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_EQDC_HPP -#define BOOST_GEOMETRY_PROJECTIONS_EQDC_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_EQDC_HPP +#define BOOST_GEOMETRY_PROJECTIONS_EQDC_HPP + #include <boost/geometry/util/math.hpp> #include <boost/math/special_functions/hypot.hpp> @@ -56,7 +55,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct eqdc {}; + struct eqdc {}; // Equidistant Conic }} //namespace srs::par4 @@ -66,40 +65,37 @@ namespace projections namespace detail { namespace eqdc { - static const double EPS10 = 1.e-10; + static const double epsilon10 = 1.e-10; template <typename T> struct par_eqdc { - T phi1; - T phi2; - T n; - T rho0; - T c; - T en[EN_SIZE]; - int ellips; + T phi1; + T phi2; + T n; + T rho0; + T c; + detail::en<T> en; + bool ellips; }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_eqdc_ellipsoid : public base_t_fi<base_eqdc_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_eqdc_ellipsoid + : public base_t_fi<base_eqdc_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_eqdc<CalculationType> m_proj_parm; + par_eqdc<T> m_proj_parm; inline base_eqdc_ellipsoid(const Parameters& par) - : base_t_fi<base_eqdc_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_eqdc_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) sphere & ellipsoid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType rho = 0.0; + T rho = 0.0; + rho = this->m_proj_parm.c - (this->m_proj_parm.ellips ? pj_mlfn(lp_lat, sin(lp_lat), cos(lp_lat), this->m_proj_parm.en) : lp_lat); xy_x = rho * sin( lp_lon *= this->m_proj_parm.n ); @@ -108,9 +104,12 @@ namespace projections // INVERSE(e_inverse) sphere & ellipsoid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType rho = 0.0; + static T const half_pi = detail::half_pi<T>(); + + T rho = 0.0; + if ((rho = boost::math::hypot(xy_x, xy_y = this->m_proj_parm.rho0 - xy_y)) != 0.0 ) { if (this->m_proj_parm.n < 0.) { rho = -rho; @@ -123,25 +122,10 @@ namespace projections lp_lon = atan2(xy_x, xy_y) / this->m_proj_parm.n; } else { lp_lon = 0.; - lp_lat = this->m_proj_parm.n > 0. ? geometry::math::half_pi<double>() : - geometry::math::half_pi<double>(); + lp_lat = this->m_proj_parm.n > 0. ? half_pi : -half_pi; } } - // SPECIAL(fac) - #ifdef SPECIAL_FACTORS_NOT_CONVERTED - inline void fac(Geographic lp, Factors &fac) const - { - CalculationType sinphi, cosphi; - - sinphi = sin(lp_lat); - cosphi = cos(lp_lat); - this->m_fac.code |= IS_ANAL_HK; - this->m_fac.h = 1.; - this->m_fac.k = this->m_proj_parm.n * (this->m_proj_parm.c - (this->m_proj_parm.ellips ? pj_mlfn(lp_lat, sinphi, - cosphi, this->m_proj_parm.en) : lp_lat)) / pj_msfn(sinphi, cosphi, this->m_par.es); - } - #endif - static inline std::string get_name() { return "eqdc_ellipsoid"; @@ -156,15 +140,17 @@ namespace projections T cosphi, sinphi; int secant; - proj_parm.phi1 = pj_param(par.params, "rlat_1").f; - proj_parm.phi2 = pj_param(par.params, "rlat_2").f; - if (fabs(proj_parm.phi1 + proj_parm.phi2) < EPS10) - BOOST_THROW_EXCEPTION( projection_exception(-21) ); - if (!pj_enfn(par.es, proj_parm.en)) - BOOST_THROW_EXCEPTION( projection_exception(0) ); + proj_parm.phi1 = pj_get_param_r(par.params, "lat_1"); + proj_parm.phi2 = pj_get_param_r(par.params, "lat_2"); + + if (fabs(proj_parm.phi1 + proj_parm.phi2) < epsilon10) + BOOST_THROW_EXCEPTION( projection_exception(error_conic_lat_equal) ); + + proj_parm.en = pj_enfn<T>(par.es); + proj_parm.n = sinphi = sin(proj_parm.phi1); cosphi = cos(proj_parm.phi1); - secant = fabs(proj_parm.phi1 - proj_parm.phi2) >= EPS10; + secant = fabs(proj_parm.phi1 - proj_parm.phi2) >= epsilon10; if( (proj_parm.ellips = (par.es > 0.)) ) { double ml1, m1; @@ -206,10 +192,10 @@ namespace projections \par Example \image html ex_eqdc.gif */ - template <typename CalculationType, typename Parameters> - struct eqdc_ellipsoid : public detail::eqdc::base_eqdc_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct eqdc_ellipsoid : public detail::eqdc::base_eqdc_ellipsoid<T, Parameters> { - inline eqdc_ellipsoid(const Parameters& par) : detail::eqdc::base_eqdc_ellipsoid<CalculationType, Parameters>(par) + inline eqdc_ellipsoid(const Parameters& par) : detail::eqdc::base_eqdc_ellipsoid<T, Parameters>(par) { detail::eqdc::setup_eqdc(this->m_par, this->m_proj_parm); } @@ -223,20 +209,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::eqdc, eqdc_ellipsoid, eqdc_ellipsoid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class eqdc_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class eqdc_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<eqdc_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<eqdc_ellipsoid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void eqdc_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void eqdc_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("eqdc", new eqdc_entry<CalculationType, Parameters>); + factory.add_to_factory("eqdc", new eqdc_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/etmerc.hpp b/boost/geometry/srs/projections/proj/etmerc.hpp index 479c128f11..050aafacca 100644 --- a/boost/geometry/srs/projections/proj/etmerc.hpp +++ b/boost/geometry/srs/projections/proj/etmerc.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_ETMERC_HPP -#define BOOST_GEOMETRY_PROJECTIONS_ETMERC_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -43,12 +39,28 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +/* The code in this file is largly based upon procedures: + * + * Written by: Knud Poder and Karsten Engsager + * + * Based on math from: R.Koenig and K.H. Weise, "Mathematische + * Grundlagen der hoeheren Geodaesie und Kartographie, + * Springer-Verlag, Berlin/Goettingen" Heidelberg, 1951. + * + * Modified and used here by permission of Reference Networks + * Division, Kort og Matrikelstyrelsen (KMS), Copenhagen, Denmark +*/ + +#ifndef BOOST_GEOMETRY_PROJECTIONS_ETMERC_HPP +#define BOOST_GEOMETRY_PROJECTIONS_ETMERC_HPP + #include <boost/math/special_functions/hypot.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> #include <boost/geometry/srs/projections/impl/factory_entry.hpp> +#include <boost/geometry/srs/projections/impl/function_overloads.hpp> namespace boost { namespace geometry { @@ -56,6 +68,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { struct etmerc {}; + struct utm {}; }} //namespace srs::par4 @@ -78,25 +91,8 @@ namespace projections T gtu[6]; /* Constants for geo -> transv. merc. */ }; - /* The code in this file is largly based upon procedures: - * - * Written by: Knud Poder and Karsten Engsager - * - * Based on math from: R.Koenig and K.H. Weise, "Mathematische - * Grundlagen der hoeheren Geodaesie und Kartographie, - * Springer-Verlag, Berlin/Goettingen" Heidelberg, 1951. - * - * Modified and used here by permission of Reference Networks - * Division, Kort og Matrikelstyrelsen (KMS), Copenhagen, Denmark - */ - - - - - template <typename T> - inline T - log1py(T const& x) { /* Compute log(1+x) accurately */ + inline T log1py(T const& x) { /* Compute log(1+x) accurately */ volatile T y = 1 + x, z = y - 1; @@ -108,16 +104,14 @@ namespace projections } template <typename T> - inline T - asinhy(T const& x) { /* Compute asinh(x) accurately */ + inline T asinhy(T const& x) { /* Compute asinh(x) accurately */ T y = fabs(x); /* Enforce odd parity */ y = log1py(y * (1 + y/(boost::math::hypot(1.0, y) + 1))); return x < 0 ? -y : y; } template <typename T> - inline T - gatg(const T *p1, int len_p1, T const& B) { + inline T gatg(const T *p1, int len_p1, T const& B) { const T *p; T h = 0, h1, h2 = 0, cos_2B; @@ -127,9 +121,9 @@ namespace projections return (B + h*sin(2*B)); } + /* Complex Clenshaw summation */ template <typename T> - inline T - clenS(const T *a, int size, T const& arg_r, T const& arg_i, T *R, T *I) { + inline T clenS(const T *a, int size, T const& arg_r, T const& arg_i, T *R, T *I) { T r, i, hr, hr1, hr2, hi, hi1, hi2; T sin_arg_r, cos_arg_r, sinh_arg_i, cosh_arg_i; @@ -157,14 +151,15 @@ namespace projections return(*R); } + /* Real Clenshaw summation */ template <typename T> - inline T - clens(const T *a, int size, T const& arg_r) { + inline T clens(const T *a, int size, T const& arg_r) { T r, hr, hr1, hr2, cos_arg_r; const T* p = a + size; cos_arg_r = cos(arg_r); r = 2*cos_arg_r; + /* summation loop */ for (hr1 = 0, hr = *--p; a - p;) { hr2 = hr1; @@ -175,26 +170,22 @@ namespace projections } // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_etmerc_ellipsoid : public base_t_fi<base_etmerc_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_etmerc_ellipsoid + : public base_t_fi<base_etmerc_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_etmerc<CalculationType> m_proj_parm; + par_etmerc<T> m_proj_parm; inline base_etmerc_ellipsoid(const Parameters& par) - : base_t_fi<base_etmerc_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_etmerc_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) ellipsoid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType sin_Cn, cos_Cn, cos_Ce, sin_Ce, dCn, dCe; - CalculationType Cn = lp_lat, Ce = lp_lon; + T sin_Cn, cos_Cn, cos_Ce, sin_Ce, dCn, dCe; + T Cn = lp_lat, Ce = lp_lon; /* ell. LAT, LNG -> Gaussian LAT, LNG */ Cn = gatg(this->m_proj_parm.cbg, PROJ_ETMERC_ORDER, Cn); @@ -206,8 +197,9 @@ namespace projections Cn = atan2(sin_Cn, cos_Ce*cos_Cn); Ce = atan2(sin_Ce*cos_Cn, boost::math::hypot(sin_Cn, cos_Cn*cos_Ce)); + /* compl. sph. N, E -> ell. norm. N, E */ - Ce = asinhy(tan(Ce)); /* Replaces: Ce = log(tan(FORTPI + Ce*0.5)); */ + Ce = asinhy(tan(Ce)); /* Replaces: Ce = log(tan(fourth_pi + Ce*0.5)); */ Cn += clenS(this->m_proj_parm.gtu, PROJ_ETMERC_ORDER, 2*Cn, 2*Ce, &dCn, &dCe); Ce += dCe; if (fabs(Ce) <= 2.623395162778) { @@ -219,19 +211,20 @@ namespace projections // INVERSE(e_inverse) ellipsoid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType sin_Cn, cos_Cn, cos_Ce, sin_Ce, dCn, dCe; - CalculationType Cn = xy_y, Ce = xy_x; + T sin_Cn, cos_Cn, cos_Ce, sin_Ce, dCn, dCe; + T Cn = xy_y, Ce = xy_x; /* normalize N, E */ Cn = (Cn - this->m_proj_parm.Zb)/this->m_proj_parm.Qn; Ce = Ce/this->m_proj_parm.Qn; + if (fabs(Ce) <= 2.623395162778) { /* 150 degrees */ - /* norm. N, E -> compl. sph. LAT, LNG */ + /* norm. N, E -> compl. sph. LAT, LNG */ Cn += clenS(this->m_proj_parm.utg, PROJ_ETMERC_ORDER, 2*Cn, 2*Ce, &dCn, &dCe); Ce += dCe; - Ce = atan(sinh(Ce)); /* Replaces: Ce = 2*(atan(exp(Ce)) - FORTPI); */ + Ce = atan(sinh(Ce)); /* Replaces: Ce = 2*(atan(exp(Ce)) - fourth_pi); */ /* compl. sph. LAT -> Gaussian LAT, LNG */ sin_Cn = sin(Cn); cos_Cn = cos(Cn); @@ -254,15 +247,17 @@ namespace projections }; - // Extended Transverse Mercator template <typename Parameters, typename T> - inline void setup_etmerc(Parameters& par, par_etmerc<T>& proj_parm) + inline void setup(Parameters& par, par_etmerc<T>& proj_parm) { T f, n, np, Z; - if (par.es <= 0) - BOOST_THROW_EXCEPTION( projection_exception(-34) ); + if (par.es <= 0) { + BOOST_THROW_EXCEPTION( projection_exception(error_ellipsoid_use_required) ); + } + f = par.es / (1 + sqrt(1 - par.es)); /* Replaces: f = 1 - sqrt(1-par.es); */ + /* third flattening */ np = n = f/(2 - f); @@ -270,6 +265,7 @@ namespace projections /* cgb := Gaussian -> Geodetic, KW p190 - 191 (61) - (62) */ /* cbg := Geodetic -> Gaussian, KW p186 - 187 (51) - (52) */ /* PROJ_ETMERC_ORDER = 6th degree : Engsager and Poder: ICC2007 */ + proj_parm.cgb[0] = n*( 2 + n*(-2/3.0 + n*(-2 + n*(116/45.0 + n*(26/45.0 + n*(-2854/675.0 )))))); proj_parm.cbg[0] = n*(-2 + n*( 2/3.0 + n*( 4/3.0 + n*(-82/45.0 + n*(32/45.0 + @@ -326,13 +322,59 @@ namespace projections np *= n; proj_parm.utg[5] = np*(-20648693/638668800.0); proj_parm.gtu[5] = np*(212378941/319334400.0); + /* Gaussian latitude value of the origin latitude */ Z = gatg(proj_parm.cbg, PROJ_ETMERC_ORDER, par.phi0); + /* Origin northing minus true northing at the origin latitude */ /* i.e. true northing = N - proj_parm.Zb */ proj_parm.Zb = - proj_parm.Qn*(Z + clens(proj_parm.gtu, PROJ_ETMERC_ORDER, 2*Z)); } + // Extended Transverse Mercator + template <typename Parameters, typename T> + inline void setup_etmerc(Parameters& par, par_etmerc<T>& proj_parm) + { + setup(par, proj_parm); + } + + // Universal Transverse Mercator (UTM) + template <typename Parameters, typename T> + inline void setup_utm(Parameters& par, par_etmerc<T>& proj_parm) + { + static const T pi = detail::pi<T>(); + + int zone; + + if (par.es == 0.0) { + BOOST_THROW_EXCEPTION( projection_exception(error_ellipsoid_use_required) ); + } + + par.y0 = pj_get_param_b(par.params, "south") ? 10000000. : 0.; + par.x0 = 500000.; + if (pj_param_i(par.params, "zone", zone)) /* zone input ? */ + { + if (zone > 0 && zone <= 60) + --zone; + else { + BOOST_THROW_EXCEPTION( projection_exception(error_invalid_utm_zone) ); + } + } + else /* nearest central meridian input */ + { + zone = int_floor((adjlon(par.lam0) + pi) * 30. / pi); + if (zone < 0) + zone = 0; + else if (zone >= 60) + zone = 59; + } + par.lam0 = (zone + .5) * pi / 30. - pi; + par.k0 = 0.9996; + par.phi0 = 0.; + + setup(par, proj_parm); + } + }} // namespace detail::etmerc #endif // doxygen @@ -351,37 +393,73 @@ namespace projections \par Example \image html ex_etmerc.gif */ - template <typename CalculationType, typename Parameters> - struct etmerc_ellipsoid : public detail::etmerc::base_etmerc_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct etmerc_ellipsoid : public detail::etmerc::base_etmerc_ellipsoid<T, Parameters> { - inline etmerc_ellipsoid(const Parameters& par) : detail::etmerc::base_etmerc_ellipsoid<CalculationType, Parameters>(par) + inline etmerc_ellipsoid(const Parameters& par) : detail::etmerc::base_etmerc_ellipsoid<T, Parameters>(par) { detail::etmerc::setup_etmerc(this->m_par, this->m_proj_parm); } }; + /*! + \brief Universal Transverse Mercator (UTM) projection + \ingroup projections + \tparam Geographic latlong point type + \tparam Cartesian xy point type + \tparam Parameters parameter type + \par Projection characteristics + - Cylindrical + - Spheroid + \par Projection parameters + - zone: UTM Zone (integer) + - south: Denotes southern hemisphere UTM zone (boolean) + \par Example + \image html ex_utm.gif + */ + template <typename T, typename Parameters> + struct utm_ellipsoid : public detail::etmerc::base_etmerc_ellipsoid<T, Parameters> + { + inline utm_ellipsoid(const Parameters& par) : detail::etmerc::base_etmerc_ellipsoid<T, Parameters>(par) + { + detail::etmerc::setup_utm(this->m_par, this->m_proj_parm); + } + }; + #ifndef DOXYGEN_NO_DETAIL namespace detail { // Static projection BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::etmerc, etmerc_ellipsoid, etmerc_ellipsoid) + BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::utm, utm_ellipsoid, utm_ellipsoid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class etmerc_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class etmerc_entry : public detail::factory_entry<T, Parameters> + { + public : + virtual base_v<T, Parameters>* create_new(const Parameters& par) const + { + return new base_v_fi<etmerc_ellipsoid<T, Parameters>, T, Parameters>(par); + } + }; + + template <typename T, typename Parameters> + class utm_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<etmerc_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<utm_ellipsoid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void etmerc_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void etmerc_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("etmerc", new etmerc_entry<CalculationType, Parameters>); + factory.add_to_factory("etmerc", new etmerc_entry<T, Parameters>); + factory.add_to_factory("utm", new utm_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/fahey.hpp b/boost/geometry/srs/projections/proj/fahey.hpp index 8ea43ee94b..8438b5dad3 100644 --- a/boost/geometry/srs/projections/proj/fahey.hpp +++ b/boost/geometry/srs/projections/proj/fahey.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_FAHEY_HPP -#define BOOST_GEOMETRY_PROJECTIONS_FAHEY_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_FAHEY_HPP +#define BOOST_GEOMETRY_PROJECTIONS_FAHEY_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -52,7 +51,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct fahey {}; + struct fahey {}; // Fahey }} //namespace srs::par4 @@ -62,37 +61,34 @@ namespace projections namespace detail { namespace fahey { - static const double TOL = 1e-6; + static const double tolerance = 1e-6; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_fahey_spheroid : public base_t_fi<base_fahey_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_fahey_spheroid + : public base_t_fi<base_fahey_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_fahey_spheroid(const Parameters& par) - : base_t_fi<base_fahey_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_fahey_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - xy_y = 1.819152 * ( xy_x = tan(0.5 * lp_lat) ); + xy_x = tan(0.5 * lp_lat); + xy_y = 1.819152 * xy_x; xy_x = 0.819152 * lp_lon * asqrt(1 - xy_x * xy_x); } // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - lp_lat = 2. * atan(xy_y /= 1.819152); - lp_lon = fabs(xy_y = 1. - xy_y * xy_y) < TOL ? 0. : - xy_x / (0.819152 * sqrt(xy_y)); + xy_y /= 1.819152; + lp_lat = 2. * atan(xy_y); + xy_y = 1. - xy_y * xy_y; + lp_lon = fabs(xy_y) < tolerance ? 0. : xy_x / (0.819152 * sqrt(xy_y)); } static inline std::string get_name() @@ -124,10 +120,10 @@ namespace projections \par Example \image html ex_fahey.gif */ - template <typename CalculationType, typename Parameters> - struct fahey_spheroid : public detail::fahey::base_fahey_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct fahey_spheroid : public detail::fahey::base_fahey_spheroid<T, Parameters> { - inline fahey_spheroid(const Parameters& par) : detail::fahey::base_fahey_spheroid<CalculationType, Parameters>(par) + inline fahey_spheroid(const Parameters& par) : detail::fahey::base_fahey_spheroid<T, Parameters>(par) { detail::fahey::setup_fahey(this->m_par); } @@ -141,20 +137,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::fahey, fahey_spheroid, fahey_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class fahey_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class fahey_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<fahey_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<fahey_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void fahey_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void fahey_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("fahey", new fahey_entry<CalculationType, Parameters>); + factory.add_to_factory("fahey", new fahey_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/fouc_s.hpp b/boost/geometry/srs/projections/proj/fouc_s.hpp index 0f34593161..580bc1804b 100644 --- a/boost/geometry/srs/projections/proj/fouc_s.hpp +++ b/boost/geometry/srs/projections/proj/fouc_s.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_FOUC_S_HPP -#define BOOST_GEOMETRY_PROJECTIONS_FOUC_S_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_FOUC_S_HPP +#define BOOST_GEOMETRY_PROJECTIONS_FOUC_S_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -54,7 +53,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct fouc_s {}; + struct fouc_s {}; // Foucaut Sinusoidal }} //namespace srs::par4 @@ -64,8 +63,8 @@ namespace projections namespace detail { namespace fouc_s { - static const int MAX_ITER = 10; - static const double LOOP_TOL = 1e-7; + static const int max_iter = 10; + static const double loop_tol = 1e-7; template <typename T> struct par_fouc_s @@ -74,25 +73,21 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_fouc_s_spheroid : public base_t_fi<base_fouc_s_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_fouc_s_spheroid + : public base_t_fi<base_fouc_s_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_fouc_s<CalculationType> m_proj_parm; + par_fouc_s<T> m_proj_parm; inline base_fouc_s_spheroid(const Parameters& par) - : base_t_fi<base_fouc_s_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_fouc_s_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType t; + T t; t = cos(lp_lat); xy_x = lp_lon * t / (this->m_proj_parm.n + this->m_proj_parm.n1 * t); @@ -101,21 +96,23 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType V; + static T const half_pi = detail::half_pi<T>(); + + T V; int i; - if (this->m_proj_parm.n) { + if (this->m_proj_parm.n != 0.0) { lp_lat = xy_y; - for (i = MAX_ITER; i ; --i) { + for (i = max_iter; i ; --i) { lp_lat -= V = (this->m_proj_parm.n * lp_lat + this->m_proj_parm.n1 * sin(lp_lat) - xy_y ) / (this->m_proj_parm.n + this->m_proj_parm.n1 * cos(lp_lat)); - if (fabs(V) < LOOP_TOL) + if (fabs(V) < loop_tol) break; } if (!i) - lp_lat = xy_y < 0. ? -geometry::math::half_pi<double>() : geometry::math::half_pi<double>(); + lp_lat = xy_y < 0. ? -half_pi : half_pi; } else lp_lat = aasin(xy_y); V = cos(lp_lat); @@ -133,9 +130,10 @@ namespace projections template <typename Parameters, typename T> inline void setup_fouc_s(Parameters& par, par_fouc_s<T>& proj_parm) { - proj_parm.n = pj_param(par.params, "dn").f; + proj_parm.n = pj_get_param_f(par.params, "n"); if (proj_parm.n < 0. || proj_parm.n > 1.) - BOOST_THROW_EXCEPTION( projection_exception(-99) ); + BOOST_THROW_EXCEPTION( projection_exception(error_n_out_of_range) ); + proj_parm.n1 = 1. - proj_parm.n; par.es = 0; } @@ -157,10 +155,10 @@ namespace projections \par Example \image html ex_fouc_s.gif */ - template <typename CalculationType, typename Parameters> - struct fouc_s_spheroid : public detail::fouc_s::base_fouc_s_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct fouc_s_spheroid : public detail::fouc_s::base_fouc_s_spheroid<T, Parameters> { - inline fouc_s_spheroid(const Parameters& par) : detail::fouc_s::base_fouc_s_spheroid<CalculationType, Parameters>(par) + inline fouc_s_spheroid(const Parameters& par) : detail::fouc_s::base_fouc_s_spheroid<T, Parameters>(par) { detail::fouc_s::setup_fouc_s(this->m_par, this->m_proj_parm); } @@ -174,20 +172,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::fouc_s, fouc_s_spheroid, fouc_s_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class fouc_s_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class fouc_s_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<fouc_s_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<fouc_s_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void fouc_s_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void fouc_s_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("fouc_s", new fouc_s_entry<CalculationType, Parameters>); + factory.add_to_factory("fouc_s", new fouc_s_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/gall.hpp b/boost/geometry/srs/projections/proj/gall.hpp index fc1ad144d7..2c35c60985 100644 --- a/boost/geometry/srs/projections/proj/gall.hpp +++ b/boost/geometry/srs/projections/proj/gall.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_GALL_HPP -#define BOOST_GEOMETRY_PROJECTIONS_GALL_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_GALL_HPP +#define BOOST_GEOMETRY_PROJECTIONS_GALL_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -51,7 +50,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct gall {}; + struct gall {}; // Gall (Gall Stereographic) }} //namespace srs::par4 @@ -67,22 +66,17 @@ namespace projections static const double RXF = 1.41421356237309504880; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_gall_spheroid : public base_t_fi<base_gall_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_gall_spheroid + : public base_t_fi<base_gall_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_gall_spheroid(const Parameters& par) - : base_t_fi<base_gall_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_gall_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { xy_x = XF * lp_lon; xy_y = YF * tan(.5 * lp_lat); @@ -90,7 +84,7 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { lp_lon = RXF * xy_x; lp_lat = 2. * atan(xy_y * RYF); @@ -107,7 +101,7 @@ namespace projections template <typename Parameters> inline void setup_gall(Parameters& par) { - par.es = 0.; + par.es = 0.0; } }} // namespace detail::gall @@ -125,10 +119,10 @@ namespace projections \par Example \image html ex_gall.gif */ - template <typename CalculationType, typename Parameters> - struct gall_spheroid : public detail::gall::base_gall_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct gall_spheroid : public detail::gall::base_gall_spheroid<T, Parameters> { - inline gall_spheroid(const Parameters& par) : detail::gall::base_gall_spheroid<CalculationType, Parameters>(par) + inline gall_spheroid(const Parameters& par) : detail::gall::base_gall_spheroid<T, Parameters>(par) { detail::gall::setup_gall(this->m_par); } @@ -142,20 +136,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::gall, gall_spheroid, gall_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class gall_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class gall_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<gall_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<gall_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void gall_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void gall_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("gall", new gall_entry<CalculationType, Parameters>); + factory.add_to_factory("gall", new gall_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/geocent.hpp b/boost/geometry/srs/projections/proj/geocent.hpp index bfcbb145fa..92fd8e1070 100644 --- a/boost/geometry/srs/projections/proj/geocent.hpp +++ b/boost/geometry/srs/projections/proj/geocent.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_GEOCENT_HPP -#define BOOST_GEOMETRY_PROJECTIONS_GEOCENT_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,13 +15,13 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: // Purpose: Stub projection for geocentric. The transformation isn't -// really done here since this code is 2D. The real transformation -// is handled by pj_transform.c. +// really done here since this code is 2D. The real transformation +// is handled by pj_transform.c. // Author: Frank Warmerdam, warmerdam@pobox.com // Copyright (c) 2002, Frank Warmerdam @@ -47,6 +43,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_GEOCENT_HPP +#define BOOST_GEOMETRY_PROJECTIONS_GEOCENT_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -57,7 +56,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct geocent {}; + struct geocent {}; // Geocentric }} //namespace srs::par4 @@ -68,22 +67,17 @@ namespace projections { // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_geocent_other : public base_t_fi<base_geocent_other<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_geocent_other + : public base_t_fi<base_geocent_other<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_geocent_other(const Parameters& par) - : base_t_fi<base_geocent_other<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_geocent_other<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(forward) // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { xy_x = lp_lon; xy_y = lp_lat; @@ -91,7 +85,7 @@ namespace projections // INVERSE(inverse) // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { lp_lat = xy_y; lp_lon = xy_x; @@ -125,10 +119,10 @@ namespace projections \par Example \image html ex_geocent.gif */ - template <typename CalculationType, typename Parameters> - struct geocent_other : public detail::geocent::base_geocent_other<CalculationType, Parameters> + template <typename T, typename Parameters> + struct geocent_other : public detail::geocent::base_geocent_other<T, Parameters> { - inline geocent_other(const Parameters& par) : detail::geocent::base_geocent_other<CalculationType, Parameters>(par) + inline geocent_other(const Parameters& par) : detail::geocent::base_geocent_other<T, Parameters>(par) { detail::geocent::setup_geocent(this->m_par); } @@ -142,20 +136,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::geocent, geocent_other, geocent_other) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class geocent_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class geocent_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<geocent_other<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<geocent_other<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void geocent_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void geocent_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("geocent", new geocent_entry<CalculationType, Parameters>); + factory.add_to_factory("geocent", new geocent_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/geos.hpp b/boost/geometry/srs/projections/proj/geos.hpp index 798f7f6247..905411f766 100644 --- a/boost/geometry/srs/projections/proj/geos.hpp +++ b/boost/geometry/srs/projections/proj/geos.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_GEOS_HPP -#define BOOST_GEOMETRY_PROJECTIONS_GEOS_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,14 +15,15 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: // Copyright (c) 2004 Gerald I. Evenden // Copyright (c) 2012 Martin Raspaud + // See also (section 4.4.3.2): -// http://www.eumetsat.int/en/area4/msg/news/us_doc/cgms_03_26.pdf +// http://www.eumetsat.int/en/area4/msg/news/us_doc/cgms_03_26.pdf // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), @@ -46,6 +43,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_GEOS_HPP +#define BOOST_GEOMETRY_PROJECTIONS_GEOS_HPP + #include <boost/math/special_functions/hypot.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -58,7 +58,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct geos {}; + struct geos {}; // Geostationary Satellite View }} //namespace srs::par4 @@ -77,87 +77,86 @@ namespace projections T radius_g; T radius_g_1; T C; - std::string sweep_axis; int flip_axis; }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_geos_ellipsoid : public base_t_fi<base_geos_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_geos_ellipsoid + : public base_t_fi<base_geos_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_geos<CalculationType> m_proj_parm; + par_geos<T> m_proj_parm; inline base_geos_ellipsoid(const Parameters& par) - : base_t_fi<base_geos_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_geos_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) ellipsoid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType r, Vx, Vy, Vz, tmp; + T r, Vx, Vy, Vz, tmp; - /* Calculation of geocentric latitude. */ + /* Calculation of geocentric latitude. */ lp_lat = atan (this->m_proj_parm.radius_p2 * tan (lp_lat)); - /* Calculation of the three components of the vector from satellite to - ** position on earth surface (lon,lat).*/ + + /* Calculation of the three components of the vector from satellite to + ** position on earth surface (lon,lat).*/ r = (this->m_proj_parm.radius_p) / boost::math::hypot(this->m_proj_parm.radius_p * cos (lp_lat), sin (lp_lat)); Vx = r * cos (lp_lon) * cos (lp_lat); Vy = r * sin (lp_lon) * cos (lp_lat); 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.) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); - /* Calculation based on view angles from satellite. */ + + /* Check visibility. */ + if (((this->m_proj_parm.radius_g - Vx) * Vx - Vy * Vy - Vz * Vz * this->m_proj_parm.radius_p_inv2) < 0.) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } + + /* Calculation based on view angles from satellite. */ tmp = this->m_proj_parm.radius_g - Vx; - if(this->m_proj_parm.flip_axis) - { - xy_x = this->m_proj_parm.radius_g_1 * atan (Vy / boost::math::hypot (Vz, tmp)); - xy_y = this->m_proj_parm.radius_g_1 * atan (Vz / tmp); - } - else - { - xy_x = this->m_proj_parm.radius_g_1 * atan (Vy / tmp); - xy_y = this->m_proj_parm.radius_g_1 * atan (Vz / boost::math::hypot (Vy, tmp)); - } + + if(this->m_proj_parm.flip_axis) { + xy_x = this->m_proj_parm.radius_g_1 * atan (Vy / boost::math::hypot (Vz, tmp)); + xy_y = this->m_proj_parm.radius_g_1 * atan (Vz / tmp); + } else { + xy_x = this->m_proj_parm.radius_g_1 * atan (Vy / tmp); + xy_y = this->m_proj_parm.radius_g_1 * atan (Vz / boost::math::hypot (Vy, tmp)); + } } // INVERSE(e_inverse) ellipsoid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType Vx, Vy, Vz, a, b, det, k; + T Vx, Vy, Vz, a, b, det, k; - /* Setting three components of vector from satellite to position.*/ + /* Setting three components of vector from satellite to position.*/ Vx = -1.0; - if(this->m_proj_parm.flip_axis) - { - Vz = tan (xy_y / this->m_proj_parm.radius_g_1); - Vy = tan (xy_x / this->m_proj_parm.radius_g_1) * boost::math::hypot(1.0, Vz); - } - else - { - Vy = tan (xy_x / this->m_proj_parm.radius_g_1); - Vz = tan (xy_y / this->m_proj_parm.radius_g_1) * boost::math::hypot(1.0, Vy); - } - /* Calculation of terms in cubic equation and determinant.*/ + + if(this->m_proj_parm.flip_axis) { + Vz = tan (xy_y / this->m_proj_parm.radius_g_1); + Vy = tan (xy_x / this->m_proj_parm.radius_g_1) * boost::math::hypot(1.0, Vz); + } else { + Vy = tan (xy_x / this->m_proj_parm.radius_g_1); + Vz = tan (xy_y / this->m_proj_parm.radius_g_1) * boost::math::hypot(1.0, Vy); + } + + /* Calculation of terms in cubic equation and determinant.*/ 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.) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); - /* Calculation of three components of vector from satellite to position.*/ + if ((det = (b * b) - 4 * a * this->m_proj_parm.C) < 0.) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } + + /* 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; Vy *= k; Vz *= k; - /* Calculation of longitude and latitude.*/ - lp_lon = atan2 (Vy, Vx); + + /* Calculation of longitude and latitude.*/ + lp_lon = atan2 (Vy, Vx); lp_lat = atan (Vz * cos (lp_lon) / Vx); lp_lat = atan (this->m_proj_parm.radius_p_inv2 * tan (lp_lat)); } @@ -170,78 +169,76 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_geos_spheroid : public base_t_fi<base_geos_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_geos_spheroid + : public base_t_fi<base_geos_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_geos<CalculationType> m_proj_parm; + par_geos<T> m_proj_parm; inline base_geos_spheroid(const Parameters& par) - : base_t_fi<base_geos_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_geos_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType Vx, Vy, Vz, tmp; + T Vx, Vy, Vz, tmp; - /* Calculation of the three components of the vector from satellite to - ** position on earth surface (lon,lat).*/ + /* Calculation of the three components of the vector from satellite to + ** position on earth surface (lon,lat).*/ tmp = cos(lp_lat); Vx = cos (lp_lon) * tmp; Vy = sin (lp_lon) * tmp; Vz = sin (lp_lat); - /* Check visibility.*/ + + /* Check visibility.*/ + // TODO: in proj4 5.0.0 this check is not present if (((this->m_proj_parm.radius_g - Vx) * Vx - Vy * Vy - Vz * Vz) < 0.) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); - /* Calculation based on view angles from satellite.*/ + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + + /* Calculation based on view angles from satellite.*/ tmp = this->m_proj_parm.radius_g - Vx; - if(this->m_proj_parm.flip_axis) - { - xy_x = this->m_proj_parm.radius_g_1 * atan(Vy / boost::math::hypot(Vz, tmp)); - xy_y = this->m_proj_parm.radius_g_1 * atan(Vz / tmp); - } - else - { - xy_x = this->m_proj_parm.radius_g_1 * atan(Vy / tmp); - xy_y = this->m_proj_parm.radius_g_1 * atan(Vz / boost::math::hypot(Vy, tmp)); - } + + if(this->m_proj_parm.flip_axis) { + xy_x = this->m_proj_parm.radius_g_1 * atan(Vy / boost::math::hypot(Vz, tmp)); + xy_y = this->m_proj_parm.radius_g_1 * atan(Vz / tmp); + } else { + xy_x = this->m_proj_parm.radius_g_1 * atan(Vy / tmp); + xy_y = this->m_proj_parm.radius_g_1 * atan(Vz / boost::math::hypot(Vy, tmp)); + } } // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType Vx, Vy, Vz, a, b, det, k; + T Vx, Vy, Vz, a, b, det, k; - /* Setting three components of vector from satellite to position.*/ + /* Setting three components of vector from satellite to position.*/ Vx = -1.0; - if(this->m_proj_parm.flip_axis) - { - Vz = tan (xy_y / (this->m_proj_parm.radius_g - 1.0)); - Vy = tan (xy_x / (this->m_proj_parm.radius_g - 1.0)) * sqrt (1.0 + Vz * Vz); - } - else - { - Vy = tan (xy_x / (this->m_proj_parm.radius_g - 1.0)); - Vz = tan (xy_y / (this->m_proj_parm.radius_g - 1.0)) * sqrt (1.0 + Vy * Vy); - } - /* Calculation of terms in cubic equation and determinant.*/ + if(this->m_proj_parm.flip_axis) { + Vz = tan (xy_y / (this->m_proj_parm.radius_g - 1.0)); + Vy = tan (xy_x / (this->m_proj_parm.radius_g - 1.0)) * sqrt (1.0 + Vz * Vz); + } else { + Vy = tan (xy_x / (this->m_proj_parm.radius_g - 1.0)); + Vz = tan (xy_y / (this->m_proj_parm.radius_g - 1.0)) * sqrt (1.0 + Vy * Vy); + } + + /* 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.) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); - /* Calculation of three components of vector from satellite to position.*/ + if ((det = (b * b) - 4 * a * this->m_proj_parm.C) < 0.) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } + + /* 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; Vy *= k; Vz *= k; - /* Calculation of longitude and latitude.*/ + + /* Calculation of longitude and latitude.*/ lp_lon = atan2 (Vy, Vx); lp_lat = atan (Vz * cos (lp_lon) / Vx); } @@ -257,27 +254,31 @@ namespace projections template <typename Parameters, typename T> inline void setup_geos(Parameters& par, par_geos<T>& proj_parm) { - if ((proj_parm.h = pj_param(par.params, "dh").f) <= 0.) - BOOST_THROW_EXCEPTION( projection_exception(-30) ); - if (par.phi0) - BOOST_THROW_EXCEPTION( projection_exception(-46) ); - proj_parm.sweep_axis = pj_param(par.params, "ssweep").s; - if (proj_parm.sweep_axis.empty()) + std::string sweep_axis; + + if ((proj_parm.h = pj_get_param_f(par.params, "h")) <= 0.) + BOOST_THROW_EXCEPTION( projection_exception(error_h_less_than_zero) ); + + if (par.phi0 != 0.0) + BOOST_THROW_EXCEPTION( projection_exception(error_unknown_prime_meridian) ); + + sweep_axis = pj_get_param_s(par.params, "sweep"); + if (sweep_axis.empty()) proj_parm.flip_axis = 0; else { - if (proj_parm.sweep_axis[1] != '\0' || - (proj_parm.sweep_axis[0] != 'x' && - proj_parm.sweep_axis[0] != 'y')) - BOOST_THROW_EXCEPTION( projection_exception(-49) ); - if (proj_parm.sweep_axis[0] == 'x') + if (sweep_axis[1] != '\0' || (sweep_axis[0] != 'x' && sweep_axis[0] != 'y')) + BOOST_THROW_EXCEPTION( projection_exception(error_invalid_sweep_axis) ); + + if (sweep_axis[0] == 'x') proj_parm.flip_axis = 1; else proj_parm.flip_axis = 0; } + proj_parm.radius_g_1 = proj_parm.h / par.a; proj_parm.radius_g = 1. + proj_parm.radius_g_1; proj_parm.C = proj_parm.radius_g * proj_parm.radius_g - 1.0; - if (par.es) { + if (par.es != 0.0) { proj_parm.radius_p = sqrt (par.one_es); proj_parm.radius_p2 = par.one_es; proj_parm.radius_p_inv2 = par.rone_es; @@ -305,10 +306,10 @@ namespace projections \par Example \image html ex_geos.gif */ - template <typename CalculationType, typename Parameters> - struct geos_ellipsoid : public detail::geos::base_geos_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct geos_ellipsoid : public detail::geos::base_geos_ellipsoid<T, Parameters> { - inline geos_ellipsoid(const Parameters& par) : detail::geos::base_geos_ellipsoid<CalculationType, Parameters>(par) + inline geos_ellipsoid(const Parameters& par) : detail::geos::base_geos_ellipsoid<T, Parameters>(par) { detail::geos::setup_geos(this->m_par, this->m_proj_parm); } @@ -330,10 +331,10 @@ namespace projections \par Example \image html ex_geos.gif */ - template <typename CalculationType, typename Parameters> - struct geos_spheroid : public detail::geos::base_geos_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct geos_spheroid : public detail::geos::base_geos_spheroid<T, Parameters> { - inline geos_spheroid(const Parameters& par) : detail::geos::base_geos_spheroid<CalculationType, Parameters>(par) + inline geos_spheroid(const Parameters& par) : detail::geos::base_geos_spheroid<T, Parameters>(par) { detail::geos::setup_geos(this->m_par, this->m_proj_parm); } @@ -347,23 +348,23 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::geos, geos_spheroid, geos_ellipsoid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class geos_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class geos_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { if (par.es) - return new base_v_fi<geos_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<geos_ellipsoid<T, Parameters>, T, Parameters>(par); else - return new base_v_fi<geos_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<geos_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void geos_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void geos_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("geos", new geos_entry<CalculationType, Parameters>); + factory.add_to_factory("geos", new geos_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/gins8.hpp b/boost/geometry/srs/projections/proj/gins8.hpp index f6c0059b07..5cdc933943 100644 --- a/boost/geometry/srs/projections/proj/gins8.hpp +++ b/boost/geometry/srs/projections/proj/gins8.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_GINS8_HPP -#define BOOST_GEOMETRY_PROJECTIONS_GINS8_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_GINS8_HPP +#define BOOST_GEOMETRY_PROJECTIONS_GINS8_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -51,7 +50,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct gins8 {}; + struct gins8 {}; // Ginsburg VIII (TsNIIGAiK) }} //namespace srs::par4 @@ -69,26 +68,21 @@ namespace projections inline T C12() { return 0.083333333333333333333333333333333333; } // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_gins8_spheroid : public base_t_f<base_gins8_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_gins8_spheroid + : public base_t_f<base_gins8_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_gins8_spheroid(const Parameters& par) - : base_t_f<base_gins8_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_f<base_gins8_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType C12 = gins8::C12<CalculationType>(); + static const T C12 = gins8::C12<T>(); - CalculationType t = lp_lat * lp_lat; + T t = lp_lat * lp_lat; xy_y = lp_lat * (1. + t * C12); xy_x = lp_lon * (1. - Cp * t); @@ -126,10 +120,10 @@ namespace projections \par Example \image html ex_gins8.gif */ - template <typename CalculationType, typename Parameters> - struct gins8_spheroid : public detail::gins8::base_gins8_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct gins8_spheroid : public detail::gins8::base_gins8_spheroid<T, Parameters> { - inline gins8_spheroid(const Parameters& par) : detail::gins8::base_gins8_spheroid<CalculationType, Parameters>(par) + inline gins8_spheroid(const Parameters& par) : detail::gins8::base_gins8_spheroid<T, Parameters>(par) { detail::gins8::setup_gins8(this->m_par); } @@ -143,20 +137,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::gins8, gins8_spheroid, gins8_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class gins8_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class gins8_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_f<gins8_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_f<gins8_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void gins8_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void gins8_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("gins8", new gins8_entry<CalculationType, Parameters>); + factory.add_to_factory("gins8", new gins8_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/gn_sinu.hpp b/boost/geometry/srs/projections/proj/gn_sinu.hpp index c41b278255..2a8e82bdc5 100644 --- a/boost/geometry/srs/projections/proj/gn_sinu.hpp +++ b/boost/geometry/srs/projections/proj/gn_sinu.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_GN_SINU_HPP -#define BOOST_GEOMETRY_PROJECTIONS_GN_SINU_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_GN_SINU_HPP +#define BOOST_GEOMETRY_PROJECTIONS_GN_SINU_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -55,10 +54,10 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct gn_sinu {}; - struct sinu {}; - struct eck6 {}; - struct mbtfps {}; + struct gn_sinu {}; // General Sinusoidal Series + struct sinu {}; // Sinusoidal (Sanson-Flamsteed) + struct eck6 {}; // Eckert VI + struct mbtfps {}; // McBryde-Thomas Flat-Polar Sinusoidal }} //namespace srs::par4 @@ -68,39 +67,35 @@ namespace projections namespace detail { namespace gn_sinu { - static const double EPS10 = 1e-10; - static const int MAX_ITER = 8; - static const double LOOP_TOL = 1e-7; + static const double epsilon10 = 1e-10; + static const int max_iter = 8; + static const double loop_tol = 1e-7; template <typename T> struct par_gn_sinu { - T en[EN_SIZE]; + detail::en<T> en; T m, n, C_x, C_y; }; /* Ellipsoidal Sinusoidal only */ // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_gn_sinu_ellipsoid : public base_t_fi<base_gn_sinu_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_gn_sinu_ellipsoid + : public base_t_fi<base_gn_sinu_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_gn_sinu<CalculationType> m_proj_parm; + par_gn_sinu<T> m_proj_parm; inline base_gn_sinu_ellipsoid(const Parameters& par) - : base_t_fi<base_gn_sinu_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_gn_sinu_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) ellipsoid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType s, c; + T s, c; xy_y = pj_mlfn(lp_lat, s = sin(lp_lat), c = cos(lp_lat), this->m_proj_parm.en); xy_x = lp_lon * c / sqrt(1. - this->m_par.es * s * s); @@ -108,19 +103,19 @@ namespace projections // INVERSE(e_inverse) ellipsoid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); - CalculationType s; + T s; - if ((s = fabs(lp_lat = pj_inv_mlfn(xy_y, this->m_par.es, this->m_proj_parm.en))) < HALFPI) { + if ((s = fabs(lp_lat = pj_inv_mlfn(xy_y, this->m_par.es, this->m_proj_parm.en))) < half_pi) { s = sin(lp_lat); lp_lon = xy_x * sqrt(1. - this->m_par.es * s * s) / cos(lp_lat); - } else if ((s - EPS10) < HALFPI) + } else if ((s - epsilon10) < half_pi) lp_lon = 0.; else - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); } /* General spherical sinusoidals */ @@ -132,39 +127,36 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_gn_sinu_spheroid : public base_t_fi<base_gn_sinu_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_gn_sinu_spheroid + : public base_t_fi<base_gn_sinu_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_gn_sinu<CalculationType> m_proj_parm; + par_gn_sinu<T> m_proj_parm; inline base_gn_sinu_spheroid(const Parameters& par) - : base_t_fi<base_gn_sinu_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_gn_sinu_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) sphere // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - if (!this->m_proj_parm.m) + if (this->m_proj_parm.m == 0.0) lp_lat = this->m_proj_parm.n != 1. ? aasin(this->m_proj_parm.n * sin(lp_lat)): lp_lat; else { - CalculationType k, V; + T k, V; int i; k = this->m_proj_parm.n * sin(lp_lat); - for (i = MAX_ITER; i ; --i) { + for (i = max_iter; i ; --i) { lp_lat -= V = (this->m_proj_parm.m * lp_lat + sin(lp_lat) - k) / (this->m_proj_parm.m + cos(lp_lat)); - if (fabs(V) < LOOP_TOL) + if (fabs(V) < loop_tol) break; } - if (!i) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + if (!i) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } } 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; @@ -172,10 +164,10 @@ namespace projections // INVERSE(s_inverse) sphere // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { xy_y /= this->m_proj_parm.C_y; - lp_lat = this->m_proj_parm.m ? aasin((this->m_proj_parm.m * xy_y + sin(xy_y)) / this->m_proj_parm.n) : + lp_lat = (this->m_proj_parm.m != 0.0) ? aasin((this->m_proj_parm.m * xy_y + sin(xy_y)) / this->m_proj_parm.n) : ( this->m_proj_parm.n != 1. ? aasin(sin(xy_y) / this->m_proj_parm.n) : xy_y ); lp_lon = xy_x / (this->m_proj_parm.C_x * (this->m_proj_parm.m + cos(xy_y))); } @@ -191,6 +183,7 @@ namespace projections inline void setup(Parameters& par, par_gn_sinu<T>& proj_parm) { par.es = 0; + proj_parm.C_x = (proj_parm.C_y = sqrt((proj_parm.m + 1.) / proj_parm.n))/(proj_parm.m + 1.); } @@ -199,11 +192,13 @@ namespace projections template <typename Parameters, typename T> inline void setup_gn_sinu(Parameters& par, par_gn_sinu<T>& proj_parm) { - if (pj_param(par.params, "tn").i && pj_param(par.params, "tm").i) { - proj_parm.n = pj_param(par.params, "dn").f; - proj_parm.m = pj_param(par.params, "dm").f; + if (pj_param_f(par.params, "n", proj_parm.n) + && pj_param_f(par.params, "m", proj_parm.m)) { + if (proj_parm.n <= 0 || proj_parm.m < 0) + BOOST_THROW_EXCEPTION( projection_exception(error_invalid_m_or_n) ); } else - BOOST_THROW_EXCEPTION( projection_exception(-99) ); + BOOST_THROW_EXCEPTION( projection_exception(error_invalid_m_or_n) ); + setup(par, proj_parm); } @@ -211,9 +206,10 @@ namespace projections template <typename Parameters, typename T> inline void setup_sinu(Parameters& par, par_gn_sinu<T>& proj_parm) { - if (!pj_enfn(par.es, proj_parm.en)) - BOOST_THROW_EXCEPTION( projection_exception(0) ); - if (par.es) { + proj_parm.en = pj_enfn<T>(par.es); + + if (par.es != 0.0) { + /* empty */ } else { proj_parm.n = 1.; proj_parm.m = 0.; @@ -257,10 +253,10 @@ namespace projections \par Example \image html ex_gn_sinu.gif */ - template <typename CalculationType, typename Parameters> - struct gn_sinu_spheroid : public detail::gn_sinu::base_gn_sinu_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct gn_sinu_spheroid : public detail::gn_sinu::base_gn_sinu_spheroid<T, Parameters> { - inline gn_sinu_spheroid(const Parameters& par) : detail::gn_sinu::base_gn_sinu_spheroid<CalculationType, Parameters>(par) + inline gn_sinu_spheroid(const Parameters& par) : detail::gn_sinu::base_gn_sinu_spheroid<T, Parameters>(par) { detail::gn_sinu::setup_gn_sinu(this->m_par, this->m_proj_parm); } @@ -279,10 +275,10 @@ namespace projections \par Example \image html ex_sinu.gif */ - template <typename CalculationType, typename Parameters> - struct sinu_ellipsoid : public detail::gn_sinu::base_gn_sinu_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct sinu_ellipsoid : public detail::gn_sinu::base_gn_sinu_ellipsoid<T, Parameters> { - inline sinu_ellipsoid(const Parameters& par) : detail::gn_sinu::base_gn_sinu_ellipsoid<CalculationType, Parameters>(par) + inline sinu_ellipsoid(const Parameters& par) : detail::gn_sinu::base_gn_sinu_ellipsoid<T, Parameters>(par) { detail::gn_sinu::setup_sinu(this->m_par, this->m_proj_parm); } @@ -301,10 +297,10 @@ namespace projections \par Example \image html ex_sinu.gif */ - template <typename CalculationType, typename Parameters> - struct sinu_spheroid : public detail::gn_sinu::base_gn_sinu_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct sinu_spheroid : public detail::gn_sinu::base_gn_sinu_spheroid<T, Parameters> { - inline sinu_spheroid(const Parameters& par) : detail::gn_sinu::base_gn_sinu_spheroid<CalculationType, Parameters>(par) + inline sinu_spheroid(const Parameters& par) : detail::gn_sinu::base_gn_sinu_spheroid<T, Parameters>(par) { detail::gn_sinu::setup_sinu(this->m_par, this->m_proj_parm); } @@ -322,10 +318,10 @@ namespace projections \par Example \image html ex_eck6.gif */ - template <typename CalculationType, typename Parameters> - struct eck6_spheroid : public detail::gn_sinu::base_gn_sinu_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct eck6_spheroid : public detail::gn_sinu::base_gn_sinu_spheroid<T, Parameters> { - inline eck6_spheroid(const Parameters& par) : detail::gn_sinu::base_gn_sinu_spheroid<CalculationType, Parameters>(par) + inline eck6_spheroid(const Parameters& par) : detail::gn_sinu::base_gn_sinu_spheroid<T, Parameters>(par) { detail::gn_sinu::setup_eck6(this->m_par, this->m_proj_parm); } @@ -343,10 +339,10 @@ namespace projections \par Example \image html ex_mbtfps.gif */ - template <typename CalculationType, typename Parameters> - struct mbtfps_spheroid : public detail::gn_sinu::base_gn_sinu_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct mbtfps_spheroid : public detail::gn_sinu::base_gn_sinu_spheroid<T, Parameters> { - inline mbtfps_spheroid(const Parameters& par) : detail::gn_sinu::base_gn_sinu_spheroid<CalculationType, Parameters>(par) + inline mbtfps_spheroid(const Parameters& par) : detail::gn_sinu::base_gn_sinu_spheroid<T, Parameters>(par) { detail::gn_sinu::setup_mbtfps(this->m_par, this->m_proj_parm); } @@ -363,56 +359,56 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::mbtfps, mbtfps_spheroid, mbtfps_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class gn_sinu_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class gn_sinu_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<gn_sinu_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<gn_sinu_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class sinu_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class sinu_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { if (par.es) - return new base_v_fi<sinu_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<sinu_ellipsoid<T, Parameters>, T, Parameters>(par); else - return new base_v_fi<sinu_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<sinu_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class eck6_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class eck6_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<eck6_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<eck6_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class mbtfps_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class mbtfps_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<mbtfps_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<mbtfps_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void gn_sinu_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void gn_sinu_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("gn_sinu", new gn_sinu_entry<CalculationType, Parameters>); - factory.add_to_factory("sinu", new sinu_entry<CalculationType, Parameters>); - factory.add_to_factory("eck6", new eck6_entry<CalculationType, Parameters>); - factory.add_to_factory("mbtfps", new mbtfps_entry<CalculationType, Parameters>); + factory.add_to_factory("gn_sinu", new gn_sinu_entry<T, Parameters>); + factory.add_to_factory("sinu", new sinu_entry<T, Parameters>); + factory.add_to_factory("eck6", new eck6_entry<T, Parameters>); + factory.add_to_factory("mbtfps", new mbtfps_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/gnom.hpp b/boost/geometry/srs/projections/proj/gnom.hpp index d691c136b6..9276391a76 100644 --- a/boost/geometry/srs/projections/proj/gnom.hpp +++ b/boost/geometry/srs/projections/proj/gnom.hpp @@ -1,8 +1,4 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_GNOM_HPP -#define BOOST_GEOMETRY_PROJECTIONS_GNOM_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_GNOM_HPP +#define BOOST_GEOMETRY_PROJECTIONS_GNOM_HPP + #include <boost/config.hpp> #include <boost/geometry/util/math.hpp> #include <boost/math/special_functions/hypot.hpp> @@ -65,72 +64,74 @@ namespace projections namespace detail { namespace gnom { - static const double EPS10 = 1.e-10; - static const int N_POLE = 0; - static const int S_POLE = 1; - static const int EQUIT = 2; - static const int OBLIQ = 3; + static const double epsilon10 = 1.e-10; + enum mode_type { + n_pole = 0, + s_pole = 1, + equit = 2, + obliq = 3 + }; template <typename T> struct par_gnom { T sinph0; T cosph0; - int mode; + mode_type mode; }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_gnom_spheroid : public base_t_fi<base_gnom_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_gnom_spheroid + : public base_t_fi<base_gnom_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_gnom<CalculationType> m_proj_parm; + par_gnom<T> m_proj_parm; inline base_gnom_spheroid(const Parameters& par) - : base_t_fi<base_gnom_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_gnom_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType coslam, cosphi, sinphi; + T coslam, cosphi, sinphi; sinphi = sin(lp_lat); cosphi = cos(lp_lat); coslam = cos(lp_lon); + switch (this->m_proj_parm.mode) { - case EQUIT: + case equit: xy_y = cosphi * coslam; break; - case OBLIQ: + case obliq: xy_y = this->m_proj_parm.sinph0 * sinphi + this->m_proj_parm.cosph0 * cosphi * coslam; break; - case S_POLE: + case s_pole: xy_y = - sinphi; break; - case N_POLE: + case n_pole: xy_y = sinphi; break; } - if (xy_y <= EPS10) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + + if (xy_y <= epsilon10) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } + xy_x = (xy_y = 1. / xy_y) * cosphi * sin(lp_lon); switch (this->m_proj_parm.mode) { - case EQUIT: + case equit: xy_y *= sinphi; break; - case OBLIQ: + case obliq: xy_y *= this->m_proj_parm.cosph0 * sinphi - this->m_proj_parm.sinph0 * cosphi * coslam; break; - case N_POLE: + case n_pole: coslam = - coslam; BOOST_FALLTHROUGH; - case S_POLE: + case s_pole: xy_y *= cosphi * coslam; break; } @@ -138,43 +139,44 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); - CalculationType rh, cosz, sinz; + T rh, cosz, sinz; rh = boost::math::hypot(xy_x, xy_y); sinz = sin(lp_lat = atan(rh)); cosz = sqrt(1. - sinz * sinz); - if (fabs(rh) <= EPS10) { + + if (fabs(rh) <= epsilon10) { lp_lat = this->m_par.phi0; lp_lon = 0.; } else { switch (this->m_proj_parm.mode) { - case OBLIQ: + case obliq: lp_lat = cosz * this->m_proj_parm.sinph0 + xy_y * sinz * this->m_proj_parm.cosph0 / rh; if (fabs(lp_lat) >= 1.) - lp_lat = lp_lat > 0. ? HALFPI : -HALFPI; + lp_lat = lp_lat > 0. ? half_pi : -half_pi; else lp_lat = asin(lp_lat); xy_y = (cosz - this->m_proj_parm.sinph0 * sin(lp_lat)) * rh; xy_x *= sinz * this->m_proj_parm.cosph0; break; - case EQUIT: + case equit: lp_lat = xy_y * sinz / rh; if (fabs(lp_lat) >= 1.) - lp_lat = lp_lat > 0. ? HALFPI : -HALFPI; + lp_lat = lp_lat > 0. ? half_pi : -half_pi; else lp_lat = asin(lp_lat); xy_y = cosz * rh; xy_x *= sinz; break; - case S_POLE: - lp_lat -= HALFPI; + case s_pole: + lp_lat -= half_pi; break; - case N_POLE: - lp_lat = HALFPI - lp_lat; + case n_pole: + lp_lat = half_pi - lp_lat; xy_y = -xy_y; break; } @@ -193,17 +195,18 @@ namespace projections template <typename Parameters, typename T> inline void setup_gnom(Parameters& par, par_gnom<T>& proj_parm) { - static const T HALFPI = detail::HALFPI<T>(); - - if (fabs(fabs(par.phi0) - HALFPI) < EPS10) - proj_parm.mode = par.phi0 < 0. ? S_POLE : N_POLE; - else if (fabs(par.phi0) < EPS10) - proj_parm.mode = EQUIT; - else { - proj_parm.mode = OBLIQ; + static const T half_pi = detail::half_pi<T>(); + + if (fabs(fabs(par.phi0) - half_pi) < epsilon10) { + proj_parm.mode = par.phi0 < 0. ? s_pole : n_pole; + } else if (fabs(par.phi0) < epsilon10) { + proj_parm.mode = equit; + } else { + proj_parm.mode = obliq; proj_parm.sinph0 = sin(par.phi0); proj_parm.cosph0 = cos(par.phi0); } + par.es = 0.; } @@ -222,10 +225,10 @@ namespace projections \par Example \image html ex_gnom.gif */ - template <typename CalculationType, typename Parameters> - struct gnom_spheroid : public detail::gnom::base_gnom_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct gnom_spheroid : public detail::gnom::base_gnom_spheroid<T, Parameters> { - inline gnom_spheroid(const Parameters& par) : detail::gnom::base_gnom_spheroid<CalculationType, Parameters>(par) + inline gnom_spheroid(const Parameters& par) : detail::gnom::base_gnom_spheroid<T, Parameters>(par) { detail::gnom::setup_gnom(this->m_par, this->m_proj_parm); } @@ -239,20 +242,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::gnom, gnom_spheroid, gnom_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class gnom_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class gnom_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<gnom_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<gnom_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void gnom_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void gnom_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("gnom", new gnom_entry<CalculationType, Parameters>); + factory.add_to_factory("gnom", new gnom_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/goode.hpp b/boost/geometry/srs/projections/proj/goode.hpp index ef4e5ebeee..014c9328cf 100644 --- a/boost/geometry/srs/projections/proj/goode.hpp +++ b/boost/geometry/srs/projections/proj/goode.hpp @@ -1,8 +1,4 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_GOODE_HPP -#define BOOST_GEOMETRY_PROJECTIONS_GOODE_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_GOODE_HPP +#define BOOST_GEOMETRY_PROJECTIONS_GOODE_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -53,7 +52,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct goode {}; + struct goode {}; // Goode Homolosine }} //namespace srs::par4 @@ -66,66 +65,52 @@ namespace projections static const double Y_COR = 0.05280; static const double PHI_LIM = .71093078197902358062; - template <typename CalculationType, typename Parameters> + // TODO: consider storing references to Parameters instead of copies + template <typename T, typename Par> struct par_goode { - sinu_ellipsoid<CalculationType, Parameters> sinu; - moll_spheroid<CalculationType, Parameters> moll; + sinu_spheroid<T, Par> sinu; + moll_spheroid<T, Par> moll; - par_goode(const Parameters& par) : sinu(par), moll(par) {} + par_goode(Par const& par) : sinu(par), moll(par) {} }; - // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_goode_spheroid : public base_t_fi<base_goode_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Par> + inline void s_forward(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y, + Par const& par, par_goode<T, Par> const& proj_par) { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_goode<CalculationType, Parameters> m_proj_parm; - - inline base_goode_spheroid(const Parameters& par) - : base_t_fi<base_goode_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par), m_proj_parm(par) {} - - // FORWARD(s_forward) spheroid - // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const - { - if (fabs(lp_lat) <= PHI_LIM) - this->m_proj_parm.sinu.fwd(lp_lon, lp_lat, xy_x, xy_y); - else { - this->m_proj_parm.moll.fwd(lp_lon, lp_lat, xy_x, xy_y); - xy_y -= lp_lat >= 0.0 ? Y_COR : -Y_COR; - } - } - - // INVERSE(s_inverse) spheroid - // 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 (fabs(xy_y) <= PHI_LIM) - this->m_proj_parm.sinu.inv(xy_x, xy_y, lp_lon, lp_lat); - else { - xy_y += xy_y >= 0.0 ? Y_COR : -Y_COR; - this->m_proj_parm.moll.inv(xy_x, xy_y, lp_lon, lp_lat); - } + if (fabs(lp_lat) <= PHI_LIM) + proj_par.sinu.fwd(lp_lon, lp_lat, xy_x, xy_y); + else { + proj_par.moll.fwd(lp_lon, lp_lat, xy_x, xy_y); + xy_y -= lp_lat >= 0.0 ? Y_COR : -Y_COR; } + } - static inline std::string get_name() - { - return "goode_spheroid"; + template <typename T, typename Par> + inline void s_inverse(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat, + Par const& par, par_goode<T, Par> const& proj_par) + { + if (fabs(xy_y) <= PHI_LIM) + proj_par.sinu.inv(xy_x, xy_y, lp_lon, lp_lat); + else { + xy_y += xy_y >= 0.0 ? Y_COR : -Y_COR; + proj_par.moll.inv(xy_x, xy_y, lp_lon, lp_lat); } - - }; + } // Goode Homolosine - template <typename CalculationType, typename Parameters> - inline void setup_goode(Parameters& par, par_goode<CalculationType, Parameters>& /*proj_parm*/) + template <typename Par> + inline void setup_goode(Par& par) { par.es = 0.; + + // NOTE: The following explicit initialization of sinu projection + // is not needed because setup_goode() is called before proj_par.sinu + // is constructed and m_par of parent projection is used. + + //proj_par.sinu.m_par.es = 0.; + //detail::gn_sinu::setup_sinu(proj_par.sinu.m_par, proj_par.sinu.m_proj_parm); } }} // namespace detail::goode @@ -143,13 +128,42 @@ namespace projections \par Example \image html ex_goode.gif */ - template <typename CalculationType, typename Parameters> - struct goode_spheroid : public detail::goode::base_goode_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct goode_spheroid : public detail::base_t_fi<goode_spheroid<T, Parameters>, T, Parameters> { - inline goode_spheroid(const Parameters& par) : detail::goode::base_goode_spheroid<CalculationType, Parameters>(par) + detail::goode::par_goode<T, Parameters> m_proj_parm; + + inline goode_spheroid(const Parameters& par) + : detail::base_t_fi<goode_spheroid<T, Parameters>, T, Parameters>(*this, par) + , m_proj_parm(setup(this->m_par)) + {} + + // FORWARD(s_forward) spheroid + // Project coordinates from geographic (lon, lat) to cartesian (x, y) + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - detail::goode::setup_goode(this->m_par, this->m_proj_parm); + detail::goode::s_forward(lp_lon, lp_lat, xy_x, xy_y, this->m_par, this->m_proj_parm); } + + // INVERSE(s_inverse) spheroid + // Project coordinates from cartesian (x, y) to geographic (lon, lat) + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const + { + detail::goode::s_inverse(xy_x, xy_y, lp_lon, lp_lat, this->m_par, this->m_proj_parm); + } + + static inline std::string get_name() + { + return "goode_spheroid"; + } + + private: + static Parameters& setup(Parameters& par) + { + detail::goode::setup_goode(par); + return par; + } + }; #ifndef DOXYGEN_NO_DETAIL @@ -160,20 +174,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::goode, goode_spheroid, goode_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class goode_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class goode_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<goode_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<goode_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void goode_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void goode_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("goode", new goode_entry<CalculationType, Parameters>); + factory.add_to_factory("goode", new goode_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/gstmerc.hpp b/boost/geometry/srs/projections/proj/gstmerc.hpp index 5e3581328e..69751c503c 100644 --- a/boost/geometry/srs/projections/proj/gstmerc.hpp +++ b/boost/geometry/srs/projections/proj/gstmerc.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_GSTMERC_HPP -#define BOOST_GEOMETRY_PROJECTIONS_GSTMERC_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_GSTMERC_HPP +#define BOOST_GEOMETRY_PROJECTIONS_GSTMERC_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -53,7 +52,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct gstmerc {}; + struct gstmerc {}; // Gauss-Schreiber Transverse Mercator (aka Gauss-Laborde Reunion) }} //namespace srs::par4 @@ -75,45 +74,41 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_gstmerc_spheroid : public base_t_fi<base_gstmerc_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_gstmerc_spheroid + : public base_t_fi<base_gstmerc_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_gstmerc<CalculationType> m_proj_parm; + par_gstmerc<T> m_proj_parm; inline base_gstmerc_spheroid(const Parameters& par) - : base_t_fi<base_gstmerc_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_gstmerc_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType L, Ls, sinLs1, Ls1; + T L, Ls, sinLs1, Ls1; + L= this->m_proj_parm.n1*lp_lon; Ls= this->m_proj_parm.c+this->m_proj_parm.n1*log(pj_tsfn(-1.0*lp_lat,-1.0*sin(lp_lat),this->m_par.e)); sinLs1= sin(L)/cosh(Ls); Ls1= log(pj_tsfn(-1.0*asin(sinLs1),0.0,0.0)); xy_x= (this->m_proj_parm.XS + this->m_proj_parm.n2*Ls1)*this->m_par.ra; xy_y= (this->m_proj_parm.YS + this->m_proj_parm.n2*atan(sinh(Ls)/cos(L)))*this->m_par.ra; - /*fprintf(stderr,"fwd:\nL =%16.13f\nLs =%16.13f\nLs1 =%16.13f\nLP(%16.13f,%16.13f)=XY(%16.4f,%16.4f)\n",L,Ls,Ls1,lp_lon+this->m_par.lam0,lp_lat,(xy_x*this->m_par.a + this->m_par.x0)*this->m_par.to_meter,(xy_y*this->m_par.a + this->m_par.y0)*this->m_par.to_meter);*/ } // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType L, LC, sinC; + T L, LC, sinC; + L= atan(sinh((xy_x*this->m_par.a - this->m_proj_parm.XS)/this->m_proj_parm.n2)/cos((xy_y*this->m_par.a - this->m_proj_parm.YS)/this->m_proj_parm.n2)); sinC= sin((xy_y*this->m_par.a - this->m_proj_parm.YS)/this->m_proj_parm.n2)/cosh((xy_x*this->m_par.a - this->m_proj_parm.XS)/this->m_proj_parm.n2); LC= log(pj_tsfn(-1.0*asin(sinC),0.0,0.0)); lp_lon= L/this->m_proj_parm.n1; lp_lat= -1.0*pj_phi2(exp((LC-this->m_proj_parm.c)/this->m_proj_parm.n1),this->m_par.e); - /*fprintf(stderr,"inv:\nL =%16.13f\nsinC =%16.13f\nLC =%16.13f\nXY(%16.4f,%16.4f)=LP(%16.13f,%16.13f)\n",L,sinC,LC,((xy_x/this->m_par.ra)+this->m_par.x0)/this->m_par.to_meter,((xy_y/this->m_par.ra)+this->m_par.y0)/this->m_par.to_meter,lp_lon+this->m_par.lam0,lp_lat);*/ } static inline std::string get_name() @@ -128,14 +123,13 @@ namespace projections inline void setup_gstmerc(Parameters& par, par_gstmerc<T>& proj_parm) { proj_parm.lamc= par.lam0; - proj_parm.n1= sqrt(1.0+par.es*pow(cos(par.phi0),4.0)/(1.0-par.es)); + proj_parm.n1= sqrt(T(1)+par.es*math::pow(cos(par.phi0),4)/(T(1)-par.es)); proj_parm.phic= asin(sin(par.phi0)/proj_parm.n1); - proj_parm.c= log(pj_tsfn(-1.0*proj_parm.phic,0.0,0.0)) - -proj_parm.n1*log(pj_tsfn(-1.0*par.phi0,-1.0*sin(par.phi0),par.e)); + proj_parm.c= log(pj_tsfn(-1.0*proj_parm.phic,0.0,0.0)) + - proj_parm.n1*log(pj_tsfn(-1.0*par.phi0,-1.0*sin(par.phi0),par.e)); proj_parm.n2= par.k0*par.a*sqrt(1.0-par.es)/(1.0-par.es*sin(par.phi0)*sin(par.phi0)); proj_parm.XS= 0;/* -par.x0 */ proj_parm.YS= -1.0*proj_parm.n2*proj_parm.phic;/* -par.y0 */ - /*fprintf(stderr,"a (m) =%16.4f\ne =%16.13f\nl0(rad)=%16.13f\np0(rad)=%16.13f\nk0 =%16.4f\nX0 (m)=%16.4f\nY0 (m)=%16.4f\n\nlC(rad)=%16.13f\npC(rad)=%16.13f\nc =%16.13f\nn1 =%16.13f\nn2 (m) =%16.4f\nXS (m) =%16.4f\nYS (m) =%16.4f\n", par.a, par.e, par.lam0, par.phi0, par.k0, par.x0, par.y0, proj_parm.lamc, proj_parm.phic, proj_parm.c, proj_parm.n1, proj_parm.n2, proj_parm.XS +par.x0, proj_parm.YS + par.y0);*/ } }} // namespace detail::gstmerc @@ -158,10 +152,10 @@ namespace projections \par Example \image html ex_gstmerc.gif */ - template <typename CalculationType, typename Parameters> - struct gstmerc_spheroid : public detail::gstmerc::base_gstmerc_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct gstmerc_spheroid : public detail::gstmerc::base_gstmerc_spheroid<T, Parameters> { - inline gstmerc_spheroid(const Parameters& par) : detail::gstmerc::base_gstmerc_spheroid<CalculationType, Parameters>(par) + inline gstmerc_spheroid(const Parameters& par) : detail::gstmerc::base_gstmerc_spheroid<T, Parameters>(par) { detail::gstmerc::setup_gstmerc(this->m_par, this->m_proj_parm); } @@ -175,20 +169,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::gstmerc, gstmerc_spheroid, gstmerc_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class gstmerc_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class gstmerc_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<gstmerc_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<gstmerc_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void gstmerc_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void gstmerc_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("gstmerc", new gstmerc_entry<CalculationType, Parameters>); + factory.add_to_factory("gstmerc", new gstmerc_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/hammer.hpp b/boost/geometry/srs/projections/proj/hammer.hpp index 58707a1499..9fd5bd34b1 100644 --- a/boost/geometry/srs/projections/proj/hammer.hpp +++ b/boost/geometry/srs/projections/proj/hammer.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_HAMMER_HPP -#define BOOST_GEOMETRY_PROJECTIONS_HAMMER_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_HAMMER_HPP +#define BOOST_GEOMETRY_PROJECTIONS_HAMMER_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -51,7 +50,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct hammer {}; + struct hammer {}; // Hammer & Eckert-Greifendorff }} //namespace srs::par4 @@ -60,7 +59,7 @@ namespace projections #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace hammer { - static const double EPS = 1.0e-10; + static const double epsilon = 1.0e-10; template <typename T> struct par_hammer @@ -70,25 +69,21 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_hammer_spheroid : public base_t_fi<base_hammer_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_hammer_spheroid + : public base_t_fi<base_hammer_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_hammer<CalculationType> m_proj_parm; + par_hammer<T> m_proj_parm; inline base_hammer_spheroid(const Parameters& par) - : base_t_fi<base_hammer_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_hammer_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType cosphi, d; + T cosphi, d; d = sqrt(2./(1. + (cosphi = cos(lp_lat)) * cos(lp_lon *= this->m_proj_parm.w))); xy_x = this->m_proj_parm.m * d * cosphi * sin(lp_lon); @@ -97,15 +92,15 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType z; + T z; z = sqrt(1. - 0.25*this->m_proj_parm.w*this->m_proj_parm.w*xy_x*xy_x - 0.25*xy_y*xy_y); - if (geometry::math::abs(2.*z*z-1.) < EPS) { + if (geometry::math::abs(2.*z*z-1.) < epsilon) { lp_lon = HUGE_VAL; lp_lat = HUGE_VAL; - BOOST_THROW_EXCEPTION( projection_exception(-14) ); + BOOST_THROW_EXCEPTION( projection_exception(error_lat_or_lon_exceed_limit) ); } else { lp_lon = aatan2(this->m_proj_parm.w * xy_x * z,2. * z * z - 1)/this->m_proj_parm.w; lp_lat = aasin(z * xy_y); @@ -123,18 +118,22 @@ namespace projections template <typename Parameters, typename T> inline void setup_hammer(Parameters& par, par_hammer<T>& proj_parm) { - if (pj_param(par.params, "tW").i) { - if ((proj_parm.w = fabs(pj_param(par.params, "dW").f)) <= 0.) - BOOST_THROW_EXCEPTION( projection_exception(-27) ); + T tmp; + + if (pj_param_f(par.params, "W", tmp)) { + if ((proj_parm.w = fabs(tmp)) <= 0.) + BOOST_THROW_EXCEPTION( projection_exception(error_w_or_m_zero_or_less) ); } else proj_parm.w = .5; - if (pj_param(par.params, "tM").i) { - if ((proj_parm.m = fabs(pj_param(par.params, "dM").f)) <= 0.) - BOOST_THROW_EXCEPTION( projection_exception(-27) ); + if (pj_param_f(par.params, "M", tmp)) { + if ((proj_parm.m = fabs(tmp)) <= 0.) + BOOST_THROW_EXCEPTION( projection_exception(error_w_or_m_zero_or_less) ); } else proj_parm.m = 1.; + proj_parm.rm = 1. / proj_parm.m; proj_parm.m /= proj_parm.w; + par.es = 0.; } @@ -157,10 +156,10 @@ namespace projections \par Example \image html ex_hammer.gif */ - template <typename CalculationType, typename Parameters> - struct hammer_spheroid : public detail::hammer::base_hammer_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct hammer_spheroid : public detail::hammer::base_hammer_spheroid<T, Parameters> { - inline hammer_spheroid(const Parameters& par) : detail::hammer::base_hammer_spheroid<CalculationType, Parameters>(par) + inline hammer_spheroid(const Parameters& par) : detail::hammer::base_hammer_spheroid<T, Parameters>(par) { detail::hammer::setup_hammer(this->m_par, this->m_proj_parm); } @@ -174,20 +173,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::hammer, hammer_spheroid, hammer_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class hammer_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class hammer_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<hammer_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<hammer_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void hammer_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void hammer_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("hammer", new hammer_entry<CalculationType, Parameters>); + factory.add_to_factory("hammer", new hammer_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/hatano.hpp b/boost/geometry/srs/projections/proj/hatano.hpp index e37a78196b..8392a2a3ca 100644 --- a/boost/geometry/srs/projections/proj/hatano.hpp +++ b/boost/geometry/srs/projections/proj/hatano.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_HATANO_HPP -#define BOOST_GEOMETRY_PROJECTIONS_HATANO_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_HATANO_HPP +#define BOOST_GEOMETRY_PROJECTIONS_HATANO_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -53,7 +52,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct hatano {}; + struct hatano {}; // Hatano Asymmetrical Equal Area }} //namespace srs::par4 @@ -63,9 +62,9 @@ namespace projections namespace detail { namespace hatano { - static const int NITER = 20; - static const double EPS = 1e-7; - static const double ONETOL = 1.000001; + static const int n_iter = 20; + static const double epsilon = 1e-7; + static const double one_plus_tol = 1.000001; static const double CN_ = 2.67595; static const double CS_ = 2.43763; static const double RCN = 0.37369906014686373063; @@ -78,30 +77,25 @@ namespace projections static const double RXC = 1.17647058823529411764; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_hatano_spheroid : public base_t_fi<base_hatano_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_hatano_spheroid + : public base_t_fi<base_hatano_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_hatano_spheroid(const Parameters& par) - : base_t_fi<base_hatano_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_hatano_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType th1, c; + T th1, c; int i; c = sin(lp_lat) * (lp_lat < 0. ? CS_ : CN_); - for (i = NITER; i; --i) { + for (i = n_iter; i; --i) { lp_lat -= th1 = (lp_lat + sin(lp_lat) - c) / (1. + cos(lp_lat)); - if (fabs(th1) < EPS) break; + if (fabs(th1) < epsilon) break; } xy_x = FXC * lp_lon * cos(lp_lat *= .5); xy_y = sin(lp_lat) * (lp_lat < 0. ? FYCS : FYCN); @@ -109,16 +103,18 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType th; + static T const half_pi = detail::half_pi<T>(); + + T th; th = xy_y * ( xy_y < 0. ? RYCS : RYCN); if (fabs(th) > 1.) { - if (fabs(th) > ONETOL) { - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + if (fabs(th) > one_plus_tol) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); } else { - th = th > 0. ? geometry::math::half_pi<double>() : - geometry::math::half_pi<double>(); + th = th > 0. ? half_pi : - half_pi; } } else { th = asin(th); @@ -128,10 +124,10 @@ namespace projections th += th; lp_lat = (th + sin(th)) * (xy_y < 0. ? RCS : RCN); if (fabs(lp_lat) > 1.) { - if (fabs(lp_lat) > ONETOL) { - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + if (fabs(lp_lat) > one_plus_tol) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); } else { - lp_lat = lp_lat > 0. ? geometry::math::half_pi<double>() : - geometry::math::half_pi<double>(); + lp_lat = lp_lat > 0. ? half_pi : - half_pi; } } else { lp_lat = asin(lp_lat); @@ -167,10 +163,10 @@ namespace projections \par Example \image html ex_hatano.gif */ - template <typename CalculationType, typename Parameters> - struct hatano_spheroid : public detail::hatano::base_hatano_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct hatano_spheroid : public detail::hatano::base_hatano_spheroid<T, Parameters> { - inline hatano_spheroid(const Parameters& par) : detail::hatano::base_hatano_spheroid<CalculationType, Parameters>(par) + inline hatano_spheroid(const Parameters& par) : detail::hatano::base_hatano_spheroid<T, Parameters>(par) { detail::hatano::setup_hatano(this->m_par); } @@ -184,20 +180,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::hatano, hatano_spheroid, hatano_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class hatano_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class hatano_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<hatano_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<hatano_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void hatano_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void hatano_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("hatano", new hatano_entry<CalculationType, Parameters>); + factory.add_to_factory("hatano", new hatano_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/healpix.hpp b/boost/geometry/srs/projections/proj/healpix.hpp index d2f5a8c081..4615448192 100644 --- a/boost/geometry/srs/projections/proj/healpix.hpp +++ b/boost/geometry/srs/projections/proj/healpix.hpp @@ -1,8 +1,4 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_HEALPIX_HPP -#define BOOST_GEOMETRY_PROJECTIONS_HEALPIX_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. @@ -19,16 +15,17 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: // Purpose: Implementation of the HEALPix and rHEALPix projections. -// For background see <http://code.scenzgrid.org/index.php/p/scenzgrid-py/source/tree/master/docs/rhealpix_dggs.pdf>. +// For background see <http://code.scenzgrid.org/index.php/p/scenzgrid-py/source/tree/master/docs/rhealpix_dggs.pdf>. // Authors: Alex Raichev (raichev@cs.auckland.ac.nz) -// Michael Speth (spethm@landcareresearch.co.nz) +// Michael Speth (spethm@landcareresearch.co.nz) // Notes: Raichev implemented these projections in Python and -// Speth translated them into C here. +// Speth translated them into C here. + // Copyright (c) 2001, Thomas Flemming, tf@ttqv.com // Permission is hereby granted, free of charge, to any person obtaining a @@ -49,6 +46,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_HEALPIX_HPP +#define BOOST_GEOMETRY_PROJECTIONS_HEALPIX_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -63,8 +63,8 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct healpix {}; - struct rhealpix {}; + struct healpix {}; // HEALPix + struct rhealpix {}; // rHEALPix }} //namespace srs::par4 @@ -74,7 +74,8 @@ namespace projections namespace detail { namespace healpix { - static const double EPS = 1e-15; + /* Fuzz to handle rounding errors: */ + static const double epsilon = 1e-15; template <typename T> struct par_healpix @@ -82,28 +83,36 @@ namespace projections int north_square; int south_square; T qp; - T apa[APA_SIZE]; + detail::apa<T> apa; }; - /* Matrix for counterclockwise rotation by pi/2: */ - /* Matrix for counterclockwise rotation by pi: */ - /* Matrix for counterclockwise rotation by 3*pi/2: */ - /* Identity matrix */ - /* IDENT, R1, R2, R3, R1 inverse, R2 inverse, R3 inverse:*/ - /* Fuzz to handle rounding errors: */ template <typename T> - struct CapMap + struct cap_map { int cn; /* An integer 0--3 indicating the position of the polar cap. */ T x, y; /* Coordinates of the pole point (point of most extreme latitude on the polar caps). */ - enum Region {north, south, equatorial} region; + enum region_type {north, south, equatorial} region; }; template <typename T> - struct Point + struct point_xy { T x, y; }; - static double rot[7][2][2] = {{{1, 0},{0, 1}}, {{ 0,-1},{ 1, 0}}, {{-1, 0},{ 0,-1}}, {{ 0, 1},{-1, 0}}, {{ 0, 1},{-1, 0}}, {{-1, 0},{ 0,-1}}, {{ 0,-1},{ 1, 0}}}; + + /* IDENT, R1, R2, R3, R1 inverse, R2 inverse, R3 inverse:*/ + static double rot[7][2][2] = { + /* Identity matrix */ + {{1, 0},{0, 1}}, + /* Matrix for counterclockwise rotation by pi/2: */ + {{ 0,-1},{ 1, 0}}, + /* Matrix for counterclockwise rotation by pi: */ + {{-1, 0},{ 0,-1}}, + /* Matrix for counterclockwise rotation by 3*pi/2: */ + {{ 0, 1},{-1, 0}}, + {{ 0, 1},{-1, 0}}, // 3*pi/2 + {{-1, 0},{ 0,-1}}, // pi + {{ 0,-1},{ 1, 0}} // pi/2 + }; /** * Returns the sign of the double. @@ -149,41 +158,41 @@ namespace projections template <typename T> inline int pnpoly(int nvert, T vert[][2], T const& testx, T const& testy) { - int i, c = 0; + int i; int counter = 0; T xinters; - Point<T> p1, p2; + point_xy<T> p1, p2; + /* Check for boundrary cases */ for (i = 0; i < nvert; i++) { if (testx == vert[i][0] && testy == vert[i][1]) { return 1; } } + p1.x = vert[0][0]; p1.y = vert[0][1]; + for (i = 1; i < nvert; i++) { p2.x = vert[i % nvert][0]; p2.y = vert[i % nvert][1]; - if (testy > (std::min)(p1.y, p2.y)) { - if (testy <= (std::max)(p1.y, p2.y)) { - if (testx <= (std::max)(p1.x, p2.x)) { - if (p1.y != p2.y) { - xinters = (testy-p1.y)*(p2.x-p1.x)/(p2.y-p1.y)+p1.x; - if (p1.x == p2.x || testx <= xinters) { - counter++; - } - } - } - } + if (testy > (std::min)(p1.y, p2.y) && + testy <= (std::max)(p1.y, p2.y) && + testx <= (std::max)(p1.x, p2.x) && + p1.y != p2.y) + { + xinters = (testy-p1.y)*(p2.x-p1.x)/(p2.y-p1.y)+p1.x; + if (p1.x == p2.x || testx <= xinters) + counter++; } p1 = p2; } + if (counter % 2 == 0) { return 0; } else { return 1; } - return c; } /** * Return 1 if (x, y) lies in (the interior or boundary of) the image of the @@ -195,45 +204,49 @@ namespace projections template <typename T> inline int in_image(T const& x, T const& y, int proj, int north_square, int south_square) { - static const T ONEPI = detail::ONEPI<T>(); + static const T pi = detail::pi<T>(); + static const T half_pi = detail::half_pi<T>(); + static const T fourth_pi = detail::fourth_pi<T>(); if (proj == 0) { T healpixVertsJit[][2] = { - {-1.0*ONEPI- EPS, ONEPI/4.0}, - {-3.0*ONEPI/4.0, ONEPI/2.0 + EPS}, - {-1.0*ONEPI/2.0, ONEPI/4.0 + EPS}, - {-1.0*ONEPI/4.0, ONEPI/2.0 + EPS}, - {0.0, ONEPI/4.0 + EPS}, - {ONEPI/4.0, ONEPI/2.0 + EPS}, - {ONEPI/2.0, ONEPI/4.0 + EPS}, - {3.0*ONEPI/4.0, ONEPI/2.0 + EPS}, - {ONEPI+ EPS, ONEPI/4.0}, - {ONEPI+ EPS, -1.0*ONEPI/4.0}, - {3.0*ONEPI/4.0, -1.0*ONEPI/2.0 - EPS}, - {ONEPI/2.0, -1.0*ONEPI/4.0 - EPS}, - {ONEPI/4.0, -1.0*ONEPI/2.0 - EPS}, - {0.0, -1.0*ONEPI/4.0 - EPS}, - {-1.0*ONEPI/4.0, -1.0*ONEPI/2.0 - EPS}, - {-1.0*ONEPI/2.0, -1.0*ONEPI/4.0 - EPS}, - {-3.0*ONEPI/4.0, -1.0*ONEPI/2.0 - EPS}, - {-1.0*ONEPI - EPS, -1.0*ONEPI/4.0} + {-pi - epsilon, fourth_pi}, + {-3.0*fourth_pi, half_pi + epsilon}, + {-half_pi, fourth_pi + epsilon}, + {-fourth_pi, half_pi + epsilon}, + {0.0, fourth_pi + epsilon}, + {fourth_pi, half_pi + epsilon}, + {half_pi, fourth_pi + epsilon}, + {3.0*fourth_pi, half_pi + epsilon}, + {pi + epsilon, fourth_pi}, + {pi + epsilon, -fourth_pi}, + {3.0*fourth_pi, -half_pi - epsilon}, + {half_pi, -fourth_pi - epsilon}, + {fourth_pi, -half_pi - epsilon}, + {0.0, -fourth_pi - epsilon}, + {-fourth_pi, -half_pi - epsilon}, + {-half_pi, -fourth_pi - epsilon}, + {-3.0*fourth_pi, -half_pi - epsilon}, + {-pi - epsilon, -fourth_pi} }; return pnpoly((int)sizeof(healpixVertsJit)/ sizeof(healpixVertsJit[0]), healpixVertsJit, x, y); } else { T rhealpixVertsJit[][2] = { - {-1.0*ONEPI - EPS, ONEPI/4.0 + EPS}, - {-1.0*ONEPI + north_square*ONEPI/2.0- EPS, ONEPI/4.0 + EPS}, - {-1.0*ONEPI + north_square*ONEPI/2.0- EPS, 3*ONEPI/4.0 + EPS}, - {-1.0*ONEPI + (north_square + 1.0)*ONEPI/2.0 + EPS, 3*ONEPI/4.0 + EPS}, - {-1.0*ONEPI + (north_square + 1.0)*ONEPI/2.0 + EPS, ONEPI/4.0 + EPS}, - {ONEPI + EPS, ONEPI/4.0 + EPS}, - {ONEPI + EPS, -1.0*ONEPI/4.0 - EPS}, - {-1.0*ONEPI + (south_square + 1.0)*ONEPI/2.0 + EPS, -1.0*ONEPI/4.0 - EPS}, - {-1.0*ONEPI + (south_square + 1.0)*ONEPI/2.0 + EPS, -3.0*ONEPI/4.0 - EPS}, - {-1.0*ONEPI + south_square*ONEPI/2.0 - EPS, -3.0*ONEPI/4.0 - EPS}, - {-1.0*ONEPI + south_square*ONEPI/2.0 - EPS, -1.0*ONEPI/4.0 - EPS}, - {-1.0*ONEPI - EPS, -1.0*ONEPI/4.0 - EPS}}; + {-pi - epsilon, fourth_pi + epsilon}, + {-pi + north_square*half_pi - epsilon, fourth_pi + epsilon}, + {-pi + north_square*half_pi - epsilon, 3.0*fourth_pi + epsilon}, + {-pi + (north_square + 1.0)*half_pi + epsilon, 3.0*fourth_pi + epsilon}, + {-pi + (north_square + 1.0)*half_pi + epsilon, fourth_pi + epsilon}, + {pi + epsilon, fourth_pi + epsilon}, + {pi + epsilon, -fourth_pi - epsilon}, + {-pi + (south_square + 1.0)*half_pi + epsilon, -fourth_pi - epsilon}, + {-pi + (south_square + 1.0)*half_pi + epsilon, -3.0*fourth_pi - epsilon}, + {-pi + south_square*half_pi - epsilon, -3.0*fourth_pi - epsilon}, + {-pi + south_square*half_pi - epsilon, -fourth_pi - epsilon}, + {-pi - epsilon, -fourth_pi - epsilon} + }; + return pnpoly((int)sizeof(rhealpixVertsJit)/ sizeof(rhealpixVertsJit[0]), rhealpixVertsJit, x, y); } @@ -251,10 +264,12 @@ namespace projections T q = pj_qsfn(sin(alpha), par.e, 1.0 - par.es); T qp = proj_parm.qp; T ratio = q/qp; - if (fabsl(ratio) > 1) { + + if (math::abs(ratio) > 1) { /* Rounding error. */ ratio = pj_sign(ratio); } + return asin(ratio); } else { /* Approximation to inverse authalic latitude. */ @@ -268,7 +283,9 @@ namespace projections template <typename T> inline void healpix_sphere(T const& lp_lam, T const& lp_phi, T& xy_x, T& xy_y) { - static const T ONEPI = detail::ONEPI<T>(); + static const T pi = detail::pi<T>(); + static const T half_pi = detail::half_pi<T>(); + static const T fourth_pi = detail::fourth_pi<T>(); T lam = lp_lam; T phi = lp_phi; @@ -277,17 +294,17 @@ namespace projections /* equatorial region */ if ( fabsl(phi) <= phi0) { xy_x = lam; - xy_y = 3.0*ONEPI/8.0*sin(phi); + xy_y = 3.0*pi/8.0*sin(phi); } else { T lamc; - T sigma = sqrt(3.0*(1 - fabsl(sin(phi)))); - T cn = floor(2*lam / ONEPI + 2); + T sigma = sqrt(3.0*(1 - math::abs(sin(phi)))); + T cn = floor(2*lam / pi + 2); if (cn >= 4) { cn = 3; } - lamc = -3*ONEPI/4 + (ONEPI/2)*cn; + lamc = -3*fourth_pi + half_pi*cn; xy_x = lamc + (lam - lamc)*sigma; - xy_y = pj_sign(phi)*ONEPI/4*(2 - sigma); + xy_y = pj_sign(phi)*fourth_pi*(2 - sigma); } return; } @@ -297,28 +314,31 @@ namespace projections template <typename T> inline void healpix_sphere_inverse(T const& xy_x, T const& xy_y, T& lp_lam, T& lp_phi) { - static const T ONEPI = detail::ONEPI<T>(); + static const T pi = detail::pi<T>(); + static const T half_pi = detail::half_pi<T>(); + static const T fourth_pi = detail::fourth_pi<T>(); T x = xy_x; T y = xy_y; - T y0 = ONEPI/4.0; + T y0 = fourth_pi; + /* Equatorial region. */ - if (fabsl(y) <= y0) { + if (math::abs(y) <= y0) { lp_lam = x; - lp_phi = asin(8.0*y/(3.0*ONEPI)); - } else if (fabsl(y) < ONEPI/2.0) { - T cn = floor(2.0*x/ONEPI + 2.0); + lp_phi = asin(8.0*y/(3.0*pi)); + } else if (fabsl(y) < half_pi) { + T cn = floor(2.0*x/pi + 2.0); T xc, tau; if (cn >= 4) { cn = 3; } - xc = -3.0*ONEPI/4.0 + (ONEPI/2.0)*cn; - tau = 2.0 - 4.0*fabsl(y)/ONEPI; + xc = -3.0*fourth_pi + (half_pi)*cn; + tau = 2.0 - 4.0*fabsl(y)/pi; lp_lam = xc + (x - xc)/tau; - lp_phi = pj_sign(y)*asin(1.0 - pow(tau , 2.0)/3.0); + lp_phi = pj_sign(y)*asin(1.0 - math::pow(tau, 2)/3.0); } else { - lp_lam = -1.0*ONEPI; - lp_phi = pj_sign(y)*ONEPI/2.0; + lp_lam = -1.0*pi; + lp_phi = pj_sign(y)*half_pi; } return; } @@ -351,8 +371,8 @@ namespace projections * b is a 2 x 1 matrix. * @param ret holds a*b. **/ - template <typename T> - inline void dot_product(T a[2][2], T b[2], T *ret) + template <typename T1, typename T2> + inline void dot_product(T1 a[2][2], T2 b[2], T2 *ret) { int i, j; int length = 2; @@ -372,89 +392,88 @@ namespace projections * (north_square, south_square)-rHEALPix projection of the unit sphere. **/ template <typename T> - inline CapMap<T> get_cap(T x, T const& y, int north_square, int south_square, + inline cap_map<T> get_cap(T x, T const& y, int north_square, int south_square, int inverse) { - static const T ONEPI = detail::ONEPI<T>(); + static const T pi = detail::pi<T>(); + static const T half_pi = detail::half_pi<T>(); + static const T fourth_pi = detail::fourth_pi<T>(); - CapMap<T> capmap; + cap_map<T> capmap; T c; capmap.x = x; capmap.y = y; if (inverse == 0) { - if (y > ONEPI/4.0) { - capmap.region = CapMap<T>::north; - c = ONEPI/2.0; - } else if (y < -1*ONEPI/4.0) { - capmap.region = CapMap<T>::south; - c = -1*ONEPI/2.0; + if (y > fourth_pi) { + capmap.region = cap_map<T>::north; + c = half_pi; + } else if (y < -fourth_pi) { + capmap.region = cap_map<T>::south; + c = -half_pi; } else { - capmap.region = CapMap<T>::equatorial; + capmap.region = cap_map<T>::equatorial; capmap.cn = 0; return capmap; } /* polar region */ - if (x < -1*ONEPI/2.0) { + if (x < -half_pi) { capmap.cn = 0; - capmap.x = (-1*3.0*ONEPI/4.0); + capmap.x = (-3.0*fourth_pi); capmap.y = c; - } else if (x >= -1*ONEPI/2.0 && x < 0) { + } else if (x >= -half_pi && x < 0) { capmap.cn = 1; - capmap.x = -1*ONEPI/4.0; + capmap.x = -fourth_pi; capmap.y = c; - } else if (x >= 0 && x < ONEPI/2.0) { + } else if (x >= 0 && x < half_pi) { capmap.cn = 2; - capmap.x = ONEPI/4.0; + capmap.x = fourth_pi; capmap.y = c; } else { capmap.cn = 3; - capmap.x = 3.0*ONEPI/4.0; + capmap.x = 3.0*fourth_pi; capmap.y = c; } - return capmap; } else { - T eps; - if (y > ONEPI/4.0) { - capmap.region = CapMap<T>::north; - capmap.x = (-3.0*ONEPI/4.0 + north_square*ONEPI/2.0); - capmap.y = ONEPI/2.0; - x = x - north_square*ONEPI/2.0; - } else if (y < -1*ONEPI/4.0) { - capmap.region = CapMap<T>::south; - capmap.x = (-3.0*ONEPI/4.0 + south_square*ONEPI/2); - capmap.y = -1*ONEPI/2.0; - x = x - south_square*ONEPI/2.0; + if (y > fourth_pi) { + capmap.region = cap_map<T>::north; + capmap.x = (-3.0*fourth_pi + north_square*half_pi); + capmap.y = half_pi; + x = x - north_square*half_pi; + } else if (y < -fourth_pi) { + capmap.region = cap_map<T>::south; + capmap.x = (-3.0*fourth_pi + south_square*pi/2); + capmap.y = -half_pi; + x = x - south_square*half_pi; } else { - capmap.region = CapMap<T>::equatorial; + capmap.region = cap_map<T>::equatorial; capmap.cn = 0; return capmap; } /* Polar Region, find the HEALPix polar cap number that x, y moves to when rHEALPix polar square is disassembled. */ - eps = 1e-15; /* Kludge. Fuzz to avoid some rounding errors. */ - if (capmap.region == CapMap<T>::north) { - if (y >= -1*x - ONEPI/4.0 - eps && y < x + 5.0*ONEPI/4.0 - eps) { + if (capmap.region == cap_map<T>::north) { + if (y >= -x - fourth_pi - epsilon && y < x + 5.0*fourth_pi - epsilon) { capmap.cn = (north_square + 1) % 4; - } else if (y > -1*x -1*ONEPI/4.0 + eps && y >= x + 5.0*ONEPI/4.0 - eps) { + } else if (y > -x -fourth_pi + epsilon && y >= x + 5.0*fourth_pi - epsilon) { capmap.cn = (north_square + 2) % 4; - } else if (y <= -1*x -1*ONEPI/4.0 + eps && y > x + 5.0*ONEPI/4.0 + eps) { + } else if (y <= -x -fourth_pi + epsilon && y > x + 5.0*fourth_pi + epsilon) { capmap.cn = (north_square + 3) % 4; } else { capmap.cn = north_square; } - } else if (capmap.region == CapMap<T>::south) { - if (y <= x + ONEPI/4.0 + eps && y > -1*x - 5.0*ONEPI/4 + eps) { + } else if (capmap.region == cap_map<T>::south) { + if (y <= x + fourth_pi + epsilon && y > -x - 5.0*fourth_pi + epsilon) { capmap.cn = (south_square + 1) % 4; - } else if (y < x + ONEPI/4.0 - eps && y <= -1*x - 5.0*ONEPI/4.0 + eps) { + } else if (y < x + fourth_pi - epsilon && y <= -x - 5.0*fourth_pi + epsilon) { capmap.cn = (south_square + 2) % 4; - } else if (y >= x + ONEPI/4.0 - eps && y < -1*x - 5.0*ONEPI/4.0 - eps) { + } else if (y >= x + fourth_pi - epsilon && y < -x - 5.0*fourth_pi - epsilon) { capmap.cn = (south_square + 3) % 4; } else { capmap.cn = south_square; } } - return capmap; } + return capmap; } /** * Rearrange point (x, y) in the HEALPix projection by @@ -469,95 +488,84 @@ namespace projections inline void combine_caps(T& xy_x, T& xy_y, int north_square, int south_square, int inverse) { - static const T ONEPI = detail::ONEPI<T>(); + static const T half_pi = detail::half_pi<T>(); + static const T fourth_pi = detail::fourth_pi<T>(); T v[2]; - T a[2]; + T c[2]; T vector[2]; T v_min_c[2]; T ret_dot[2]; - CapMap<T> capmap = get_cap(xy_x, xy_y, north_square, south_square, inverse); - if (capmap.region == CapMap<T>::equatorial) { + const double (*tmpRot)[2]; + int pole = 0; + + cap_map<T> capmap = get_cap(xy_x, xy_y, north_square, south_square, inverse); + if (capmap.region == cap_map<T>::equatorial) { xy_x = capmap.x; xy_y = capmap.y; return; } - v[0] = xy_x; - v[1] = xy_y; + + v[0] = xy_x; v[1] = xy_y; + c[0] = capmap.x; c[1] = capmap.y; + if (inverse == 0) { /* Rotate (xy_x, xy_y) about its polar cap tip and then translate it to north_square or south_square. */ - int pole = 0; - T (*tmpRot)[2]; - T c[2] = {capmap.x, capmap.y}; - if (capmap.region == CapMap<T>::north) { + + if (capmap.region == cap_map<T>::north) { pole = north_square; - a[0] = (-3.0*ONEPI/4.0 + pole*ONEPI/2); - a[1] = (ONEPI/2.0 + pole*0); tmpRot = rot[get_rotate_index(capmap.cn - pole)]; - vector_sub(v, c, v_min_c); - dot_product(tmpRot, v_min_c, ret_dot); - vector_add(ret_dot, a, vector); } else { pole = south_square; - a[0] = (-3.0*ONEPI/4.0 + pole*ONEPI/2); - a[1] = (ONEPI/-2.0 + pole*0); tmpRot = rot[get_rotate_index(-1*(capmap.cn - pole))]; - vector_sub(v, c, v_min_c); - dot_product(tmpRot, v_min_c, ret_dot); - vector_add(ret_dot, a, vector); } - xy_x = vector[0]; - xy_y = vector[1]; - return; } else { /* Inverse function. Unrotate (xy_x, xy_y) and then translate it back. */ - int pole = 0; - T (*tmpRot)[2]; - T c[2] = {capmap.x, capmap.y}; + /* disassemble */ - if (capmap.region == CapMap<T>::north) { + if (capmap.region == cap_map<T>::north) { pole = north_square; - a[0] = (-3.0*ONEPI/4.0 + capmap.cn*ONEPI/2); - a[1] = (ONEPI/2.0 + capmap.cn*0); tmpRot = rot[get_rotate_index(-1*(capmap.cn - pole))]; - vector_sub(v, c, v_min_c); - dot_product(tmpRot, v_min_c, ret_dot); - vector_add(ret_dot, a, vector); } else { pole = south_square; - a[0] = (-3.0*ONEPI/4.0 + capmap.cn*ONEPI/2); - a[1] = (ONEPI/-2.0 + capmap.cn*0); tmpRot = rot[get_rotate_index(capmap.cn - pole)]; - vector_sub(v, c, v_min_c); - dot_product(tmpRot, v_min_c, ret_dot); - vector_add(ret_dot, a, vector); } - xy_x = vector[0]; - xy_y = vector[1]; - return; } + + vector_sub(v, c, v_min_c); + dot_product(tmpRot, v_min_c, ret_dot); + + { + T a[2]; + /* Workaround cppcheck git issue */ + T* pa = a; + // TODO: in proj4 5.0.0 this line is used instead + //pa[0] = -3.0*fourth_pi + ((inverse == 0) ? 0 : capmap.cn) *half_pi; + pa[0] = -3.0*fourth_pi + ((inverse == 0) ? pole : capmap.cn) *half_pi; + pa[1] = half_pi; + vector_add(ret_dot, a, vector); + } + + xy_x = vector[0]; + xy_y = vector[1]; } // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_healpix_ellipsoid : public base_t_fi<base_healpix_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_healpix_ellipsoid + : public base_t_fi<base_healpix_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_healpix<CalculationType> m_proj_parm; + par_healpix<T> m_proj_parm; inline base_healpix_ellipsoid(const Parameters& par) - : base_t_fi<base_healpix_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_healpix_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_healpix_forward) ellipsoid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { lp_lat = auth_lat(this->params(), m_proj_parm, lp_lat, 0); return healpix_sphere(lp_lon, lp_lat, xy_x, xy_y); @@ -565,13 +573,13 @@ namespace projections // INVERSE(e_healpix_inverse) ellipsoid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { /* Check whether (x, y) lies in the HEALPix image. */ if (in_image(xy_x, xy_y, 0, 0, 0) == 0) { lp_lon = HUGE_VAL; lp_lat = HUGE_VAL; - BOOST_THROW_EXCEPTION( projection_exception(-15) ); + BOOST_THROW_EXCEPTION( projection_exception(error_invalid_x_or_y) ); } healpix_sphere_inverse(xy_x, xy_y, lp_lon, lp_lat); lp_lat = auth_lat(this->params(), m_proj_parm, lp_lat, 1); @@ -585,36 +593,32 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_healpix_spheroid : public base_t_fi<base_healpix_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_healpix_spheroid + : public base_t_fi<base_healpix_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_healpix<CalculationType> m_proj_parm; + par_healpix<T> m_proj_parm; inline base_healpix_spheroid(const Parameters& par) - : base_t_fi<base_healpix_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_healpix_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_healpix_forward) sphere // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { return healpix_sphere(lp_lon, lp_lat, xy_x, xy_y); } // INVERSE(s_healpix_inverse) sphere // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { /* Check whether (x, y) lies in the HEALPix image */ if (in_image(xy_x, xy_y, 0, 0, 0) == 0) { lp_lon = HUGE_VAL; lp_lat = HUGE_VAL; - BOOST_THROW_EXCEPTION( projection_exception(-15) ); + BOOST_THROW_EXCEPTION( projection_exception(error_invalid_x_or_y) ); } return healpix_sphere_inverse(xy_x, xy_y, lp_lon, lp_lat); } @@ -627,23 +631,19 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_rhealpix_ellipsoid : public base_t_fi<base_rhealpix_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_rhealpix_ellipsoid + : public base_t_fi<base_rhealpix_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_healpix<CalculationType> m_proj_parm; + par_healpix<T> m_proj_parm; inline base_rhealpix_ellipsoid(const Parameters& par) - : base_t_fi<base_rhealpix_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_rhealpix_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_rhealpix_forward) ellipsoid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { lp_lat = auth_lat(this->params(), m_proj_parm, lp_lat, 0); healpix_sphere(lp_lon, lp_lat, xy_x, xy_y); @@ -652,13 +652,13 @@ namespace projections // INVERSE(e_rhealpix_inverse) ellipsoid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { /* Check whether (x, y) lies in the rHEALPix image. */ if (in_image(xy_x, xy_y, 1, this->m_proj_parm.north_square, this->m_proj_parm.south_square) == 0) { lp_lon = HUGE_VAL; lp_lat = HUGE_VAL; - BOOST_THROW_EXCEPTION( projection_exception(-15) ); + BOOST_THROW_EXCEPTION( projection_exception(error_invalid_x_or_y) ); } combine_caps(xy_x, xy_y, this->m_proj_parm.north_square, this->m_proj_parm.south_square, 1); healpix_sphere_inverse(xy_x, xy_y, lp_lon, lp_lat); @@ -673,23 +673,19 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_rhealpix_spheroid : public base_t_fi<base_rhealpix_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_rhealpix_spheroid + : public base_t_fi<base_rhealpix_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_healpix<CalculationType> m_proj_parm; + par_healpix<T> m_proj_parm; inline base_rhealpix_spheroid(const Parameters& par) - : base_t_fi<base_rhealpix_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_rhealpix_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_rhealpix_forward) sphere // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { healpix_sphere(lp_lon, lp_lat, xy_x, xy_y); combine_caps(xy_x, xy_y, this->m_proj_parm.north_square, this->m_proj_parm.south_square, 0); @@ -697,13 +693,13 @@ namespace projections // INVERSE(s_rhealpix_inverse) sphere // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { /* Check whether (x, y) lies in the rHEALPix image. */ if (in_image(xy_x, xy_y, 1, this->m_proj_parm.north_square, this->m_proj_parm.south_square) == 0) { lp_lon = HUGE_VAL; lp_lat = HUGE_VAL; - BOOST_THROW_EXCEPTION( projection_exception(-15) ); + BOOST_THROW_EXCEPTION( projection_exception(error_invalid_x_or_y) ); } combine_caps(xy_x, xy_y, this->m_proj_parm.north_square, this->m_proj_parm.south_square, 1); return healpix_sphere_inverse(xy_x, xy_y, lp_lon, lp_lat); @@ -720,11 +716,11 @@ namespace projections template <typename Parameters, typename T> inline void setup_healpix(Parameters& par, par_healpix<T>& proj_parm) { - if (par.es) { - pj_authset(par.es, proj_parm.apa); /* For auth_lat(). */ + if (par.es != 0.0) { + proj_parm.apa = pj_authset<T>(par.es); /* For auth_lat(). */ proj_parm.qp = pj_qsfn(1.0, par.e, par.one_es); /* For auth_lat(). */ par.a = par.a*sqrt(0.5*proj_parm.qp); /* Set par.a to authalic radius. */ - par.ra = 1.0/par.a; + pj_calc_ellipsoid_params(par, par.a, par.es); /* Ensure we have a consistent parameter set */ } else { } } @@ -733,19 +729,21 @@ namespace projections template <typename Parameters, typename T> inline void setup_rhealpix(Parameters& par, par_healpix<T>& proj_parm) { - proj_parm.north_square = pj_param(par.params,"inorth_square").i; - proj_parm.south_square = pj_param(par.params,"isouth_square").i; + proj_parm.north_square = pj_get_param_i(par.params, "north_square"); + proj_parm.south_square = pj_get_param_i(par.params, "south_square"); /* Check for valid north_square and south_square inputs. */ if (proj_parm.north_square < 0 || proj_parm.north_square > 3) { - BOOST_THROW_EXCEPTION( projection_exception(-47) ); + BOOST_THROW_EXCEPTION( projection_exception(error_axis) ); } if (proj_parm.south_square < 0 || proj_parm.south_square > 3) { - BOOST_THROW_EXCEPTION( projection_exception(-47) ); + BOOST_THROW_EXCEPTION( projection_exception(error_axis) ); } - if (par.es) { - pj_authset(par.es, proj_parm.apa); /* For auth_lat(). */ + if (par.es != 0.0) { + proj_parm.apa = pj_authset<T>(par.es); /* For auth_lat(). */ proj_parm.qp = pj_qsfn(1.0, par.e, par.one_es); /* For auth_lat(). */ par.a = par.a*sqrt(0.5*proj_parm.qp); /* Set par.a to authalic radius. */ + // TODO: why not the same as in healpix? + //pj_calc_ellipsoid_params(par, par.a, par.es); par.ra = 1.0/par.a; } else { } @@ -766,10 +764,10 @@ namespace projections \par Example \image html ex_healpix.gif */ - template <typename CalculationType, typename Parameters> - struct healpix_ellipsoid : public detail::healpix::base_healpix_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct healpix_ellipsoid : public detail::healpix::base_healpix_ellipsoid<T, Parameters> { - inline healpix_ellipsoid(const Parameters& par) : detail::healpix::base_healpix_ellipsoid<CalculationType, Parameters>(par) + inline healpix_ellipsoid(const Parameters& par) : detail::healpix::base_healpix_ellipsoid<T, Parameters>(par) { detail::healpix::setup_healpix(this->m_par, this->m_proj_parm); } @@ -787,10 +785,10 @@ namespace projections \par Example \image html ex_healpix.gif */ - template <typename CalculationType, typename Parameters> - struct healpix_spheroid : public detail::healpix::base_healpix_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct healpix_spheroid : public detail::healpix::base_healpix_spheroid<T, Parameters> { - inline healpix_spheroid(const Parameters& par) : detail::healpix::base_healpix_spheroid<CalculationType, Parameters>(par) + inline healpix_spheroid(const Parameters& par) : detail::healpix::base_healpix_spheroid<T, Parameters>(par) { detail::healpix::setup_healpix(this->m_par, this->m_proj_parm); } @@ -811,10 +809,10 @@ namespace projections \par Example \image html ex_rhealpix.gif */ - template <typename CalculationType, typename Parameters> - struct rhealpix_ellipsoid : public detail::healpix::base_rhealpix_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct rhealpix_ellipsoid : public detail::healpix::base_rhealpix_ellipsoid<T, Parameters> { - inline rhealpix_ellipsoid(const Parameters& par) : detail::healpix::base_rhealpix_ellipsoid<CalculationType, Parameters>(par) + inline rhealpix_ellipsoid(const Parameters& par) : detail::healpix::base_rhealpix_ellipsoid<T, Parameters>(par) { detail::healpix::setup_rhealpix(this->m_par, this->m_proj_parm); } @@ -835,10 +833,10 @@ namespace projections \par Example \image html ex_rhealpix.gif */ - template <typename CalculationType, typename Parameters> - struct rhealpix_spheroid : public detail::healpix::base_rhealpix_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct rhealpix_spheroid : public detail::healpix::base_rhealpix_spheroid<T, Parameters> { - inline rhealpix_spheroid(const Parameters& par) : detail::healpix::base_rhealpix_spheroid<CalculationType, Parameters>(par) + inline rhealpix_spheroid(const Parameters& par) : detail::healpix::base_rhealpix_spheroid<T, Parameters>(par) { detail::healpix::setup_rhealpix(this->m_par, this->m_proj_parm); } @@ -853,37 +851,37 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::rhealpix, rhealpix_spheroid, rhealpix_ellipsoid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class healpix_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class healpix_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { if (par.es) - return new base_v_fi<healpix_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<healpix_ellipsoid<T, Parameters>, T, Parameters>(par); else - return new base_v_fi<healpix_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<healpix_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class rhealpix_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class rhealpix_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { if (par.es) - return new base_v_fi<rhealpix_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<rhealpix_ellipsoid<T, Parameters>, T, Parameters>(par); else - return new base_v_fi<rhealpix_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<rhealpix_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void healpix_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void healpix_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("healpix", new healpix_entry<CalculationType, Parameters>); - factory.add_to_factory("rhealpix", new rhealpix_entry<CalculationType, Parameters>); + factory.add_to_factory("healpix", new healpix_entry<T, Parameters>); + factory.add_to_factory("rhealpix", new rhealpix_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/igh.hpp b/boost/geometry/srs/projections/proj/igh.hpp index 219f74239e..6661863c91 100644 --- a/boost/geometry/srs/projections/proj/igh.hpp +++ b/boost/geometry/srs/projections/proj/igh.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_IGH_HPP -#define BOOST_GEOMETRY_PROJECTIONS_IGH_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_IGH_HPP +#define BOOST_GEOMETRY_PROJECTIONS_IGH_HPP + #include <boost/geometry/util/math.hpp> #include <boost/shared_ptr.hpp> @@ -56,7 +55,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct igh {}; + struct igh {}; // Interrupted Goode Homolosine }} //namespace srs::par4 @@ -65,16 +64,18 @@ namespace projections #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace igh { - - template <typename CalculationType, typename Parameters> + // TODO: consider replacing dynamically created projections + // with member objects + template <typename T, typename Parameters> struct par_igh { - boost::shared_ptr<base_v<CalculationType, Parameters> > pj[12]; - CalculationType dy0; + boost::shared_ptr<base_v<T, Parameters> > pj[12]; + T dy0; }; + /* 40d 44' 11.8" [degrees] */ template <typename T> - inline T d4044118() { return (T(40) + T(44)/T(60.) + T(11.8)/T(3600.)) * geometry::math::d2r<T>(); } // 40d 44' 11.8" [degrees] + inline T d4044118() { return (T(40) + T(44)/T(60.) + T(11.8)/T(3600.)) * geometry::math::d2r<T>(); } template <typename T> inline T d10() { return T(10) * geometry::math::d2r<T>(); } @@ -101,15 +102,18 @@ namespace projections template <typename T> inline T d180() { return T(180) * geometry::math::d2r<T>(); } - static const double EPSLN = 1.e-10; // allow a little 'slack' on zone edge positions + static const double epsilon = 1.e-10; // allow a little 'slack' on zone edge positions // Converted from #define SETUP(n, proj, x_0, y_0, lon_0) - template <template <typename, typename> class Entry, typename Parameters, typename CalculationType> - inline void do_setup(int n, Parameters const& par, par_igh<CalculationType, Parameters>& proj_parm, - CalculationType const& x_0, CalculationType const& y_0, - CalculationType const& lon_0) + template <template <typename, typename> class Entry, typename Parameters, typename T> + inline void do_setup(int n, Parameters const& par, par_igh<T, Parameters>& proj_parm, + T const& x_0, T const& y_0, + T const& lon_0) { - Entry<CalculationType, Parameters> entry; + // NOTE: in the original proj4 these projections are initialized + // with zeroed parameters which could be done here as well instead + // of initializing with parent projection's parameters. + Entry<T, Parameters> entry; proj_parm.pj[n-1].reset(entry.create_new(par)); proj_parm.pj[n-1]->mutable_params().x0 = x_0; proj_parm.pj[n-1]->mutable_params().y0 = y_0; @@ -117,29 +121,25 @@ namespace projections } // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_igh_spheroid : public base_t_fi<base_igh_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_igh_spheroid + : public base_t_fi<base_igh_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_igh<CalculationType, Parameters> m_proj_parm; + par_igh<T, Parameters> m_proj_parm; inline base_igh_spheroid(const Parameters& par) - : base_t_fi<base_igh_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_igh_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType d4044118 = igh::d4044118<CalculationType>(); - static const CalculationType d20 = igh::d20<CalculationType>(); - static const CalculationType d40 = igh::d40<CalculationType>(); - static const CalculationType d80 = igh::d80<CalculationType>(); - static const CalculationType d100 = igh::d100<CalculationType>(); + static const T d4044118 = igh::d4044118<T>(); + static const T d20 = igh::d20<T>(); + static const T d40 = igh::d40<T>(); + static const T d80 = igh::d80<T>(); + static const T d100 = igh::d100<T>(); int z; if (lp_lat >= d4044118) { // 1|2 @@ -169,26 +169,26 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType d4044118 = igh::d4044118<CalculationType>(); - static const CalculationType d10 = igh::d10<CalculationType>(); - static const CalculationType d20 = igh::d20<CalculationType>(); - static const CalculationType d40 = igh::d40<CalculationType>(); - static const CalculationType d50 = igh::d50<CalculationType>(); - static const CalculationType d60 = igh::d60<CalculationType>(); - static const CalculationType d80 = igh::d80<CalculationType>(); - static const CalculationType d90 = igh::d90<CalculationType>(); - static const CalculationType d100 = igh::d100<CalculationType>(); - static const CalculationType d160 = igh::d160<CalculationType>(); - static const CalculationType d180 = igh::d180<CalculationType>(); - - static const CalculationType c2 = 2.0; + static const T d4044118 = igh::d4044118<T>(); + static const T d10 = igh::d10<T>(); + static const T d20 = igh::d20<T>(); + static const T d40 = igh::d40<T>(); + static const T d50 = igh::d50<T>(); + static const T d60 = igh::d60<T>(); + static const T d80 = igh::d80<T>(); + static const T d90 = igh::d90<T>(); + static const T d100 = igh::d100<T>(); + static const T d160 = igh::d160<T>(); + static const T d180 = igh::d180<T>(); + + static const T c2 = 2.0; - const CalculationType y90 = this->m_proj_parm.dy0 + sqrt(c2); // lt=90 corresponds to y=y0+sqrt(2.0) + const T y90 = this->m_proj_parm.dy0 + sqrt(c2); // lt=90 corresponds to y=y0+sqrt(2.0) int z = 0; - if (xy_y > y90+EPSLN || xy_y < -y90+EPSLN) // 0 + if (xy_y > y90+epsilon || xy_y < -y90+epsilon) // 0 z = 0; else if (xy_y >= d4044118) // 1|2 z = (xy_x <= -d40? 1: 2); @@ -217,24 +217,24 @@ namespace projections lp_lon += this->m_proj_parm.pj[z-1]->params().lam0; switch (z) { - case 1: ok = (lp_lon >= -d180-EPSLN && lp_lon <= -d40+EPSLN) || - ((lp_lon >= -d40-EPSLN && lp_lon <= -d10+EPSLN) && - (lp_lat >= d60-EPSLN && lp_lat <= d90+EPSLN)); break; - case 2: ok = (lp_lon >= -d40-EPSLN && lp_lon <= d180+EPSLN) || - ((lp_lon >= -d180-EPSLN && lp_lon <= -d160+EPSLN) && - (lp_lat >= d50-EPSLN && lp_lat <= d90+EPSLN)) || - ((lp_lon >= -d50-EPSLN && lp_lon <= -d40+EPSLN) && - (lp_lat >= d60-EPSLN && lp_lat <= d90+EPSLN)); break; - case 3: ok = (lp_lon >= -d180-EPSLN && lp_lon <= -d40+EPSLN); break; - case 4: ok = (lp_lon >= -d40-EPSLN && lp_lon <= d180+EPSLN); break; - case 5: ok = (lp_lon >= -d180-EPSLN && lp_lon <= -d100+EPSLN); break; - case 6: ok = (lp_lon >= -d100-EPSLN && lp_lon <= -d20+EPSLN); break; - case 7: ok = (lp_lon >= -d20-EPSLN && lp_lon <= d80+EPSLN); break; - case 8: ok = (lp_lon >= d80-EPSLN && lp_lon <= d180+EPSLN); break; - case 9: ok = (lp_lon >= -d180-EPSLN && lp_lon <= -d100+EPSLN); break; - case 10: ok = (lp_lon >= -d100-EPSLN && lp_lon <= -d20+EPSLN); break; - case 11: ok = (lp_lon >= -d20-EPSLN && lp_lon <= d80+EPSLN); break; - case 12: ok = (lp_lon >= d80-EPSLN && lp_lon <= d180+EPSLN); break; + case 1: ok = (lp_lon >= -d180-epsilon && lp_lon <= -d40+epsilon) || + ((lp_lon >= -d40-epsilon && lp_lon <= -d10+epsilon) && + (lp_lat >= d60-epsilon && lp_lat <= d90+epsilon)); break; + case 2: ok = (lp_lon >= -d40-epsilon && lp_lon <= d180+epsilon) || + ((lp_lon >= -d180-epsilon && lp_lon <= -d160+epsilon) && + (lp_lat >= d50-epsilon && lp_lat <= d90+epsilon)) || + ((lp_lon >= -d50-epsilon && lp_lon <= -d40+epsilon) && + (lp_lat >= d60-epsilon && lp_lat <= d90+epsilon)); break; + case 3: ok = (lp_lon >= -d180-epsilon && lp_lon <= -d40+epsilon); break; + case 4: ok = (lp_lon >= -d40-epsilon && lp_lon <= d180+epsilon); break; + case 5: ok = (lp_lon >= -d180-epsilon && lp_lon <= -d100+epsilon); break; + case 6: ok = (lp_lon >= -d100-epsilon && lp_lon <= -d20+epsilon); break; + case 7: ok = (lp_lon >= -d20-epsilon && lp_lon <= d80+epsilon); break; + case 8: ok = (lp_lon >= d80-epsilon && lp_lon <= d180+epsilon); break; + case 9: ok = (lp_lon >= -d180-epsilon && lp_lon <= -d100+epsilon); break; + case 10: ok = (lp_lon >= -d100-epsilon && lp_lon <= -d20+epsilon); break; + case 11: ok = (lp_lon >= -d20-epsilon && lp_lon <= d80+epsilon); break; + case 12: ok = (lp_lon >= d80-epsilon && lp_lon <= d180+epsilon); break; } z = (!ok? 0: z); // projectable? @@ -252,17 +252,17 @@ namespace projections }; // Interrupted Goode Homolosine - template <typename CalculationType, typename Parameters> - inline void setup_igh(Parameters& par, par_igh<CalculationType, Parameters>& proj_parm) + template <typename T, typename Parameters> + inline void setup_igh(Parameters& par, par_igh<T, Parameters>& proj_parm) { - static const CalculationType d0 = 0; - static const CalculationType d4044118 = igh::d4044118<CalculationType>(); - static const CalculationType d20 = igh::d20<CalculationType>(); - static const CalculationType d30 = igh::d30<CalculationType>(); - static const CalculationType d60 = igh::d60<CalculationType>(); - static const CalculationType d100 = igh::d100<CalculationType>(); - static const CalculationType d140 = igh::d140<CalculationType>(); - static const CalculationType d160 = igh::d160<CalculationType>(); + static const T d0 = 0; + static const T d4044118 = igh::d4044118<T>(); + static const T d20 = igh::d20<T>(); + static const T d30 = igh::d30<T>(); + static const T d60 = igh::d60<T>(); + static const T d100 = igh::d100<T>(); + static const T d140 = igh::d140<T>(); + static const T d160 = igh::d160<T>(); /* Zones: @@ -283,11 +283,17 @@ namespace projections +-------+--------+-----------+-----------+ -180 -100 -20 80 180 */ - - - CalculationType lp_lam = 0, lp_phi = d4044118; - CalculationType xy1_x, xy1_y; - CalculationType xy3_x, xy3_y; + + T lp_lam = 0, lp_phi = d4044118; + T xy1_x, xy1_y; + T xy3_x, xy3_y; + + // IMPORTANT: Force spherical sinu projection + // This is required because unlike in the original proj4 here + // parameters are used to initialize underlying projections. + // In the original code zeroed parameters are passed which + // could be done here as well though. + par.es = 0.; // sinusoidal zones do_setup<sinu_entry>(3, par, proj_parm, -d100, d0, -d100); @@ -315,7 +321,8 @@ namespace projections do_setup<moll_entry>(11, par, proj_parm, d20, -proj_parm.dy0, d20); do_setup<moll_entry>(12, par, proj_parm, d140, -proj_parm.dy0, d140); - par.es = 0.; + // Already done before + //par.es = 0.; } }} // namespace detail::igh @@ -333,10 +340,10 @@ namespace projections \par Example \image html ex_igh.gif */ - template <typename CalculationType, typename Parameters> - struct igh_spheroid : public detail::igh::base_igh_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct igh_spheroid : public detail::igh::base_igh_spheroid<T, Parameters> { - inline igh_spheroid(const Parameters& par) : detail::igh::base_igh_spheroid<CalculationType, Parameters>(par) + inline igh_spheroid(const Parameters& par) : detail::igh::base_igh_spheroid<T, Parameters>(par) { detail::igh::setup_igh(this->m_par, this->m_proj_parm); } @@ -350,20 +357,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::igh, igh_spheroid, igh_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class igh_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class igh_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<igh_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<igh_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void igh_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void igh_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("igh", new igh_entry<CalculationType, Parameters>); + factory.add_to_factory("igh", new igh_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/imw_p.hpp b/boost/geometry/srs/projections/proj/imw_p.hpp index 1a7fe9e915..78bd10d63b 100644 --- a/boost/geometry/srs/projections/proj/imw_p.hpp +++ b/boost/geometry/srs/projections/proj/imw_p.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_IMW_P_HPP -#define BOOST_GEOMETRY_PROJECTIONS_IMW_P_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_IMW_P_HPP +#define BOOST_GEOMETRY_PROJECTIONS_IMW_P_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -54,7 +53,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct imw_p {}; + struct imw_p {}; // International Map of the World Polyconic }} //namespace srs::par4 @@ -64,19 +63,25 @@ namespace projections namespace detail { namespace imw_p { - static const double TOL = 1e-10; - static const double EPS = 1e-10; + static const double tolerance = 1e-10; + static const double epsilon = 1e-10; template <typename T> - struct XY { T x, y; }; // specific for IMW_P + struct point_xy { T x, y; }; // specific for IMW_P + + enum mode_type { + none_is_zero = 0, /* phi_1 and phi_2 != 0 */ + phi_1_is_zero = 1, /* phi_1 = 0 */ + phi_2_is_zero = -1 /* phi_2 = 0 */ + }; template <typename T> struct par_imw_p { T P, Pp, Q, Qp, R_1, R_2, sphi_1, sphi_2, C2; T phi_1, phi_2, lam_1; - T en[EN_SIZE]; - int mode; /* = 0, phi_1 and phi_2 != 0, = 1, phi_1 = 0, = -1 phi_2 = 0 */ + detail::en<T> en; + mode_type mode; }; template <typename Parameters, typename T> @@ -85,25 +90,25 @@ namespace projections { int err = 0; - if (!pj_param(par.params, "tlat_1").i || - !pj_param(par.params, "tlat_2").i) { + if (!pj_param_r(par.params, "lat_1", proj_parm.phi_1) || + !pj_param_r(par.params, "lat_2", proj_parm.phi_2)) { err = -41; } else { - proj_parm.phi_1 = pj_param(par.params, "rlat_1").f; - proj_parm.phi_2 = pj_param(par.params, "rlat_2").f; + //proj_parm.phi_1 = pj_get_param_r(par.params, "lat_1"); // set above + //proj_parm.phi_2 = pj_get_param_r(par.params, "lat_2"); // set above *del = 0.5 * (proj_parm.phi_2 - proj_parm.phi_1); *sig = 0.5 * (proj_parm.phi_2 + proj_parm.phi_1); - err = (fabs(*del) < EPS || fabs(*sig) < EPS) ? -42 : 0; + err = (fabs(*del) < epsilon || fabs(*sig) < epsilon) ? -42 : 0; } return err; } template <typename Parameters, typename T> - inline XY<T> + inline point_xy<T> loc_for(T const& lp_lam, T const& lp_phi, Parameters const& par, par_imw_p<T> const& proj_parm, T *yc) { - XY<T> xy; + point_xy<T> xy; - if (! lp_phi) { + if (lp_phi == 0.0) { xy.x = lp_lam; xy.y = 0.; } else { @@ -117,7 +122,7 @@ namespace projections C = sqrt(R * R - xa * xa); if (lp_phi < 0.) C = - C; C += ya - R; - if (proj_parm.mode < 0) { + if (proj_parm.mode == phi_2_is_zero) { xb = lp_lam; yb = proj_parm.C2; } else { @@ -125,7 +130,7 @@ namespace projections xb = proj_parm.R_2 * sin(t); yb = proj_parm.C2 + proj_parm.R_2 * (1. - cos(t)); } - if (proj_parm.mode > 0) { + if (proj_parm.mode == phi_1_is_zero) { xc = lp_lam; *yc = 0.; } else { @@ -160,35 +165,33 @@ namespace projections } // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_imw_p_ellipsoid : public base_t_fi<base_imw_p_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_imw_p_ellipsoid + : public base_t_fi<base_imw_p_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_imw_p<CalculationType> m_proj_parm; + par_imw_p<T> m_proj_parm; inline base_imw_p_ellipsoid(const Parameters& par) - : base_t_fi<base_imw_p_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_imw_p_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) ellipsoid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType yc = 0; - XY<CalculationType> xy = loc_for(lp_lon, lp_lat, this->m_par, m_proj_parm, &yc); + T yc = 0; + point_xy<T> xy = loc_for(lp_lon, lp_lat, this->m_par, m_proj_parm, &yc); xy_x = xy.x; xy_y = xy.y; } // INVERSE(e_inverse) ellipsoid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - XY<CalculationType> t; - CalculationType yc = 0; + point_xy<T> t; + T yc = 0.0; + int i = 0; + const int n_max_iter = 1000; /* Arbitrarily choosen number... */ lp_lat = this->m_proj_parm.phi_2; lp_lon = xy_x / cos(lp_lat); @@ -196,7 +199,14 @@ namespace projections t = loc_for(lp_lon, lp_lat, this->m_par, m_proj_parm, &yc); lp_lat = ((lp_lat - this->m_proj_parm.phi_1) * (xy_y - yc) / (t.y - yc)) + this->m_proj_parm.phi_1; lp_lon = lp_lon * xy_x / t.x; - } while (fabs(t.x - xy_x) > TOL || fabs(t.y - xy_y) > TOL); + i++; + } while (i < n_max_iter && + (fabs(t.x - xy_x) > tolerance || fabs(t.y - xy_y) > tolerance)); + + if( i == n_max_iter ) + { + lp_lon = lp_lat = HUGE_VAL; + } } static inline std::string get_name() @@ -211,36 +221,37 @@ namespace projections inline void setup_imw_p(Parameters& par, par_imw_p<T>& proj_parm) { T del, sig, s, t, x1, x2, T2, y1, m1, m2, y2; - int i; + int err; - if (!pj_enfn(par.es, proj_parm.en)) - BOOST_THROW_EXCEPTION( projection_exception(0) ); - if( (i = phi12(par, proj_parm, &del, &sig)) != 0) - BOOST_THROW_EXCEPTION( projection_exception(i) ); + proj_parm.en = pj_enfn<T>(par.es); + if( (err = phi12(par, proj_parm, &del, &sig)) != 0) + BOOST_THROW_EXCEPTION( projection_exception(err) ); if (proj_parm.phi_2 < proj_parm.phi_1) { /* make sure proj_parm.phi_1 most southerly */ del = proj_parm.phi_1; proj_parm.phi_1 = proj_parm.phi_2; proj_parm.phi_2 = del; } - if (pj_param(par.params, "tlon_1").i) - proj_parm.lam_1 = pj_param(par.params, "rlon_1").f; - else { /* use predefined based upon latitude */ + if (pj_param_r(par.params, "lon_1", proj_parm.lam_1)) { + /* empty */ + } else { /* use predefined based upon latitude */ sig = fabs(sig * geometry::math::r2d<T>()); - if (sig <= 60) sig = 2.; + if (sig <= 60) sig = 2.; else if (sig <= 76) sig = 4.; else sig = 8.; proj_parm.lam_1 = sig * geometry::math::d2r<T>(); } - proj_parm.mode = 0; - if (proj_parm.phi_1) xy(par, proj_parm, proj_parm.phi_1, &x1, &y1, &proj_parm.sphi_1, &proj_parm.R_1); + proj_parm.mode = none_is_zero; + if (proj_parm.phi_1 != 0.0) + xy(par, proj_parm, proj_parm.phi_1, &x1, &y1, &proj_parm.sphi_1, &proj_parm.R_1); else { - proj_parm.mode = 1; + proj_parm.mode = phi_1_is_zero; y1 = 0.; x1 = proj_parm.lam_1; } - if (proj_parm.phi_2) xy(par, proj_parm, proj_parm.phi_2, &x2, &T2, &proj_parm.sphi_2, &proj_parm.R_2); + if (proj_parm.phi_2 != 0.0) + xy(par, proj_parm, proj_parm.phi_2, &x2, &T2, &proj_parm.sphi_2, &proj_parm.R_2); else { - proj_parm.mode = -1; + proj_parm.mode = phi_2_is_zero; T2 = 0.; x2 = proj_parm.lam_1; } @@ -276,10 +287,10 @@ namespace projections \par Example \image html ex_imw_p.gif */ - template <typename CalculationType, typename Parameters> - struct imw_p_ellipsoid : public detail::imw_p::base_imw_p_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct imw_p_ellipsoid : public detail::imw_p::base_imw_p_ellipsoid<T, Parameters> { - inline imw_p_ellipsoid(const Parameters& par) : detail::imw_p::base_imw_p_ellipsoid<CalculationType, Parameters>(par) + inline imw_p_ellipsoid(const Parameters& par) : detail::imw_p::base_imw_p_ellipsoid<T, Parameters>(par) { detail::imw_p::setup_imw_p(this->m_par, this->m_proj_parm); } @@ -293,20 +304,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::imw_p, imw_p_ellipsoid, imw_p_ellipsoid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class imw_p_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class imw_p_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<imw_p_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<imw_p_ellipsoid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void imw_p_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void imw_p_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("imw_p", new imw_p_entry<CalculationType, Parameters>); + factory.add_to_factory("imw_p", new imw_p_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/isea.hpp b/boost/geometry/srs/projections/proj/isea.hpp index 4cffbc430f..6ae803b65e 100644 --- a/boost/geometry/srs/projections/proj/isea.hpp +++ b/boost/geometry/srs/projections/proj/isea.hpp @@ -1,8 +1,4 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_ISEA_HPP -#define BOOST_GEOMETRY_PROJECTIONS_ISEA_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -44,6 +40,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_ISEA_HPP +#define BOOST_GEOMETRY_PROJECTIONS_ISEA_HPP + #include <sstream> #include <boost/core/ignore_unused.hpp> @@ -68,48 +67,42 @@ namespace projections #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace isea { + static const double epsilon = std::numeric_limits<double>::epsilon(); - static const double E = 52.62263186; - static const double F = 10.81231696; - //static const double DEG60 = 1.04719755119659774614; - //static const double DEG120 = 2.09439510239319549229; - //static const double DEG72 = 1.25663706143591729537; - //static const double DEG90 = 1.57079632679489661922; - //static const double DEG144 = 2.51327412287183459075; - //static const double DEG36 = 0.62831853071795864768; - //static const double DEG108 = 1.88495559215387594306; - //static const double DEG180 = geometry::math::pi<double>(); - static const double ISEA_SCALE = 0.8301572857837594396028083; - static const double V_LAT = 0.46364760899944494524; - static const double E_RAD = 0.91843818702186776133; - static const double F_RAD = 0.18871053072122403508; - static const double TABLE_G = 0.6615845383; - static const double TABLE_H = 0.1909830056; - static const double RPRIME = 0.91038328153090290025; - static const double PRECISION = 0.0000000000005; - static const double ISEA_STD_LAT = 1.01722196792335072101; - static const double ISEA_STD_LON = .19634954084936207740; + /* sqrt(5)/M_PI */ + static const double isea_scale = 0.8301572857837594396028083; + /* 26.565051177 degrees */ + static const double v_lat = 0.46364760899944494524; + /* 52.62263186 */ + static const double e_rad = 0.91843818702186776133; + /* 10.81231696 */ + static const double f_rad = 0.18871053072122403508; + /* R tan(g) sin(60) */ + static const double table_g = 0.6615845383; + /* H = 0.25 R tan g = */ + static const double table_h = 0.1909830056; + //static const double RPRIME = 0.91038328153090290025; + static const double isea_std_lat = 1.01722196792335072101; + static const double isea_std_lon = .19634954084936207740; template <typename T> - inline T DEG30() { return T(30) * geometry::math::d2r<T>(); } - template <typename T> - inline T DEG60() { return T(60) * geometry::math::d2r<T>(); } + inline T deg30_rad() { return T(30) * geometry::math::d2r<T>(); } template <typename T> - inline T DEG120() { return T(120) * geometry::math::d2r<T>(); } + inline T deg120_rad() { return T(120) * geometry::math::d2r<T>(); } template <typename T> - inline T DEG72() { return T(72) * geometry::math::d2r<T>(); } + inline T deg72_rad() { return T(72) * geometry::math::d2r<T>(); } template <typename T> - inline T DEG90() { return geometry::math::half_pi<T>(); } + inline T deg90_rad() { return geometry::math::half_pi<T>(); } template <typename T> - inline T DEG144() { return T(144) * geometry::math::d2r<T>(); } + inline T deg144_rad() { return T(144) * geometry::math::d2r<T>(); } template <typename T> - inline T DEG36() { return T(36) * geometry::math::d2r<T>(); } + inline T deg36_rad() { return T(36) * geometry::math::d2r<T>(); } template <typename T> - inline T DEG108() { return T(108) * geometry::math::d2r<T>(); } + inline T deg108_rad() { return T(108) * geometry::math::d2r<T>(); } template <typename T> - inline T DEG180() { return geometry::math::pi<T>(); } + inline T deg180_rad() { return geometry::math::pi<T>(); } - inline bool DOWNTRI(int tri) { return (((tri - 1) / 5) % 2 == 1); } + inline bool downtri(int tri) { return (((tri - 1) / 5) % 2 == 1); } /* * Proj 4 provides its own entry points into @@ -155,14 +148,16 @@ namespace projections template <typename T> inline - int hexbin2(T const& width, T x, T y, - int *i, int *j) { + int hexbin2(T const& width, T x, T y, int *i, int *j) + { T z, rx, ry, rz; T abs_dx, abs_dy, abs_dz; int ix, iy, iz, s; struct hex h; - x = x / cos(DEG30<T>()); /* rotated X coord */ + static const T cos_deg30 = cos(deg30_rad<T>()); + + x = x / cos_deg30; /* rotated X coord */ y = y - x / 2.0; /* adjustment for rotated X */ /* adjust for actual hexwidth */ @@ -201,28 +196,30 @@ namespace projections hex_xy(&h); *i = h.x; *j = h.y; - return ix * 100 + iy; + return ix * 100 + iy; } - enum isea_poly { ISEA_NONE, ISEA_ICOSAHEDRON = 20 }; - enum isea_topology { ISEA_HEXAGON=6, ISEA_TRIANGLE=3, ISEA_DIAMOND=4 }; - enum isea_address_form { ISEA_GEO, ISEA_Q2DI, ISEA_SEQNUM, ISEA_INTERLEAVE, - ISEA_PLANE, ISEA_Q2DD, ISEA_PROJTRI, ISEA_VERTEX2DD, ISEA_HEX + //enum isea_poly { isea_none = 0, isea_icosahedron = 20 }; + //enum isea_topology { isea_hexagon=6, isea_triangle=3, isea_diamond=4 }; + enum isea_address_form { + isea_addr_geo, isea_addr_q2di, isea_addr_seqnum, + isea_addr_interleave, isea_addr_plane, isea_addr_q2dd, + isea_addr_projtri, isea_addr_vertex2dd, isea_addr_hex }; template <typename T> struct isea_dgg { - int polyhedron; /* ignored, icosahedron */ - T o_lat, o_lon, o_az; /* orientation, radians */ - int pole; /* true if standard snyder */ - int topology; /* ignored, hexagon */ - int aperture; /* valid values depend on partitioning method */ - int resolution; - T radius; /* radius of the earth in meters, ignored 1.0 */ - int output; /* an isea_address_form */ - int triangle; /* triangle of last transformed point */ - int quad; /* quad of last transformed point */ - unsigned long serial; + //isea_poly polyhedron; /* ignored, icosahedron */ + T o_lat, o_lon, o_az; /* orientation, radians */ + int pole; /* true if standard snyder */ + //isea_topology topology; /* ignored, hexagon */ + int aperture; /* valid values depend on partitioning method */ + int resolution; + T radius; /* radius of the earth in meters, ignored 1.0 */ + isea_address_form output; /* an isea_address_form */ + int triangle; /* triangle of last transformed point */ + int quad; /* quad of last transformed point */ + unsigned long serial; }; template <typename T> @@ -245,10 +242,10 @@ namespace projections /* ENDINC */ enum snyder_polyhedron { - SNYDER_POLY_HEXAGON, SNYDER_POLY_PENTAGON, - SNYDER_POLY_TETRAHEDRON, SNYDER_POLY_CUBE, - SNYDER_POLY_OCTAHEDRON, SNYDER_POLY_DODECAHEDRON, - SNYDER_POLY_ICOSAHEDRON + snyder_poly_hexagon = 0, snyder_poly_pentagon = 1, + snyder_poly_tetrahedron = 2, snyder_poly_cube = 3, + snyder_poly_octahedron = 4, snyder_poly_dodecahedron = 5, + snyder_poly_icosahedron = 6 }; template <typename T> @@ -271,29 +268,23 @@ namespace projections }; return result; } - - - /* sqrt(5)/M_PI */ - - /* 26.565051177 degrees */ - - + template <typename T> inline const isea_geo<T> * vertex() { static isea_geo<T> result[] = { - {0.0, DEG90<T>()}, - {DEG180<T>(), V_LAT}, - {-DEG108<T>(), V_LAT}, - {-DEG36<T>(), V_LAT}, - {DEG36<T>(), V_LAT}, - {DEG108<T>(), V_LAT}, - {-DEG144<T>(), -V_LAT}, - {-DEG72<T>(), -V_LAT}, - {0.0, -V_LAT}, - {DEG72<T>(), -V_LAT}, - {DEG144<T>(), -V_LAT}, - {0.0, -DEG90<T>()} + { 0.0, deg90_rad<T>()}, + { deg180_rad<T>(), v_lat}, + {-deg108_rad<T>(), v_lat}, + {-deg36_rad<T>(), v_lat}, + { deg36_rad<T>(), v_lat}, + { deg108_rad<T>(), v_lat}, + {-deg144_rad<T>(), -v_lat}, + {-deg72_rad<T>(), -v_lat}, + { 0.0, -v_lat}, + { deg72_rad<T>(), -v_lat}, + { deg144_rad<T>(), -v_lat}, + { 0.0, -deg90_rad<T>()} }; return result; } @@ -302,36 +293,32 @@ namespace projections static int tri_v1[] = {0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 2, 3, 4, 5, 1, 11, 11, 11, 11, 11}; - /* 52.62263186 */ - - /* 10.81231696 */ - /* triangle Centers */ template <typename T> inline const isea_geo<T> * icostriangles() { static isea_geo<T> result[] = { - {0.0, 0.0}, - {-DEG144<T>(), E_RAD}, - {-DEG72<T>(), E_RAD}, - {0.0, E_RAD}, - {DEG72<T>(), E_RAD}, - {DEG144<T>(), E_RAD}, - {-DEG144<T>(), F_RAD}, - {-DEG72<T>(), F_RAD}, - {0.0, F_RAD}, - {DEG72<T>(), F_RAD}, - {DEG144<T>(), F_RAD}, - {-DEG108<T>(), -F_RAD}, - {-DEG36<T>(), -F_RAD}, - {DEG36<T>(), -F_RAD}, - {DEG108<T>(), -F_RAD}, - {DEG180<T>(), -F_RAD}, - {-DEG108<T>(), -E_RAD}, - {-DEG36<T>(), -E_RAD}, - {DEG36<T>(), -E_RAD}, - {DEG108<T>(), -E_RAD}, - {DEG180<T>(), -E_RAD}, + { 0.0, 0.0}, + {-deg144_rad<T>(), e_rad}, + {-deg72_rad<T>(), e_rad}, + { 0.0, e_rad}, + { deg72_rad<T>(), e_rad}, + { deg144_rad<T>(), e_rad}, + {-deg144_rad<T>(), f_rad}, + {-deg72_rad<T>(), f_rad}, + { 0.0, f_rad}, + { deg72_rad<T>(), f_rad}, + { deg144_rad<T>(), f_rad}, + {-deg108_rad<T>(), -f_rad}, + {-deg36_rad<T>(), -f_rad}, + { deg36_rad<T>(), -f_rad}, + { deg108_rad<T>(), -f_rad}, + { deg180_rad<T>(), -f_rad}, + {-deg108_rad<T>(), -e_rad}, + {-deg36_rad<T>(), -e_rad}, + { deg36_rad<T>(), -e_rad}, + { deg108_rad<T>(), -e_rad}, + { deg180_rad<T>(), -e_rad}, }; return result; } @@ -355,11 +342,6 @@ namespace projections return adj; } - /* R tan(g) sin(60) */ - - /* H = 0.25 R tan g = */ - - template <typename T> inline isea_pt<T> isea_triangle_xy(int triangle) { @@ -368,22 +350,22 @@ namespace projections triangle = (triangle - 1) % 20; - c.x = TABLE_G * ((triangle % 5) - 2) * 2.0; + c.x = table_g * ((triangle % 5) - 2) * 2.0; if (triangle > 9) { - c.x += TABLE_G; + c.x += table_g; } switch (triangle / 5) { case 0: - c.y = 5.0 * TABLE_H; + c.y = 5.0 * table_h; break; case 1: - c.y = TABLE_H; + c.y = table_h; break; case 2: - c.y = -TABLE_H; + c.y = -table_h; break; case 3: - c.y = -5.0 * TABLE_H; + c.y = -5.0 * table_h; break; default: /* should be impossible */ @@ -412,6 +394,9 @@ namespace projections template <typename T> inline int isea_snyder_forward(isea_geo<T> * ll, isea_pt<T> * out) { + static T const two_pi = detail::two_pi<T>(); + static T const d2r = geometry::math::d2r<T>(); + int i; /* @@ -450,10 +435,10 @@ namespace projections */ /* TODO put these constants in as radians to begin with */ - c = constants<T>()[SNYDER_POLY_ICOSAHEDRON]; - theta = c.theta * geometry::math::d2r<T>(); - g = c.g * geometry::math::d2r<T>(); - G = c.G * geometry::math::d2r<T>(); + c = constants<T>()[snyder_poly_icosahedron]; + theta = c.theta * d2r; + g = c.g * d2r; + G = c.G * d2r; for (i = 1; i <= 20; i++) { T z; @@ -462,23 +447,15 @@ namespace projections center = icostriangles<T>()[i]; /* step 1 */ - #if 0 - z = sph_distance(center.lon, center.lat, ll->lon, ll->lat); - #else z = acos(sin(center.lat) * sin(ll->lat) + cos(center.lat) * cos(ll->lat) * cos(ll->lon - center.lon)); - #endif /* not on this triangle */ if (z > g + 0.000005) { /* TODO DBL_EPSILON */ continue; } - Az = sph_azimuth(ll->lon, ll->lat, center.lon, center.lat); - Az = atan2(cos(ll->lat) * sin(ll->lon - center.lon), - cos(center.lat) * sin(ll->lat) - - sin(center.lat) * cos(ll->lat) * cos(ll->lon - center.lon) - ); + Az = sph_azimuth(center.lon, center.lat, ll->lon, ll->lat); /* step 2 */ @@ -490,7 +467,7 @@ namespace projections /* TODO I don't know why we do this. It's not in snyder */ /* maybe because we should have picked a better vertex */ if (Az < 0.0) { - Az += geometry::math::two_pi<T>(); + Az += two_pi; } /* * adjust Az for the point to fall within the range of 0 to @@ -503,11 +480,11 @@ namespace projections Az_adjust_multiples = 0; while (Az < 0.0) { - Az += DEG120<T>(); + Az += deg120_rad<T>(); Az_adjust_multiples--; } - while (Az > DEG120<T>() + DBL_EPSILON) { - Az -= DEG120<T>(); + while (Az > deg120_rad<T>() + epsilon) { + Az -= deg120_rad<T>(); Az_adjust_multiples++; } @@ -536,8 +513,8 @@ namespace projections H = acos(sin(Az) * sin(G) * cos(g) - cos(Az) * cos(G)); /* eq 7 */ - /* Ag = (Az + G + H - DEG180) * M_PI * R * R / DEG180; */ - Ag = Az + G + H - DEG180<T>(); + /* Ag = (Az + G + H - deg180_rad) * M_PI * R * R / deg180_rad; */ + Ag = Az + G + H - deg180_rad<T>(); /* eq 8 */ Azprime = atan2(2.0 * Ag, Rprime * Rprime * tan_g * tan_g - 2.0 * Ag * cot_theta); @@ -557,7 +534,7 @@ namespace projections * 2 to Azprime */ - Azprime += DEG120<T>() * Az_adjust_multiples; + Azprime += deg120_rad<T>() * Az_adjust_multiples; /* calculate rectangular coordinates */ @@ -612,6 +589,9 @@ namespace projections template <typename T> inline isea_geo<T> snyder_ctran(isea_geo<T> * np, isea_geo<T> * pt) { + static T const pi = detail::pi<T>(); + static T const two_pi = detail::two_pi<T>(); + isea_geo<T> npt; T alpha, phi, lambda, lambda0, beta, lambdap, phip; T sin_phip; @@ -640,11 +620,11 @@ namespace projections /* normalize longitude */ /* TODO can we just do a modulus ? */ - lambdap = fmod(lambdap, geometry::math::two_pi<T>()); - while (lambdap > geometry::math::pi<T>()) - lambdap -= geometry::math::two_pi<T>(); - while (lambdap < -geometry::math::pi<T>()) - lambdap += geometry::math::two_pi<T>(); + lambdap = fmod(lambdap, two_pi); + while (lambdap > pi) + lambdap -= two_pi; + while (lambdap < -pi) + lambdap += two_pi; phip = asin(sin_phip); @@ -657,25 +637,28 @@ namespace projections template <typename T> inline isea_geo<T> isea_ctran(isea_geo<T> * np, isea_geo<T> * pt, T const& lon0) { + static T const pi = detail::pi<T>(); + static T const two_pi = detail::two_pi<T>(); + isea_geo<T> npt; - np->lon += geometry::math::pi<T>(); + np->lon += pi; npt = snyder_ctran(np, pt); - np->lon -= geometry::math::pi<T>(); + np->lon -= pi; - npt.lon -= (geometry::math::pi<T>() - lon0 + np->lon); + npt.lon -= (pi - lon0 + np->lon); /* * snyder is down tri 3, isea is along side of tri1 from vertex 0 to * vertex 1 these are 180 degrees apart */ - npt.lon += geometry::math::pi<T>(); + npt.lon += pi; /* normalize longitude */ - npt.lon = fmod(npt.lon, geometry::math::two_pi<T>()); - while (npt.lon > geometry::math::pi<T>()) - npt.lon -= geometry::math::two_pi<T>(); - while (npt.lon < -geometry::math::pi<T>()) - npt.lon += geometry::math::two_pi<T>(); + npt.lon = fmod(npt.lon, two_pi); + while (npt.lon > pi) + npt.lon -= two_pi; + while (npt.lon < -pi) + npt.lon += two_pi; return npt; } @@ -690,14 +673,14 @@ namespace projections if (!g) return 0; - g->polyhedron = 20; - g->o_lat = ISEA_STD_LAT; - g->o_lon = ISEA_STD_LON; + //g->polyhedron = isea_icosahedron; + g->o_lat = isea_std_lat; + g->o_lon = isea_std_lon; g->o_az = 0.0; g->aperture = 4; g->resolution = 6; g->radius = 1.0; - g->topology = 6; + //g->topology = isea_hexagon; return 1; } @@ -707,8 +690,8 @@ namespace projections { if (!g) return 0; - g->o_lat = ISEA_STD_LAT; - g->o_lon = ISEA_STD_LON; + g->o_lat = isea_std_lat; + g->o_lon = isea_std_lon; g->o_az = 0.0; return 1; } @@ -716,9 +699,11 @@ namespace projections template <typename T> inline int isea_orient_pole(isea_dgg<T> * g) { + static T const half_pi = detail::half_pi<T>(); + if (!g) return 0; - g->o_lat = geometry::math::half_pi<T>(); + g->o_lat = half_pi; g->o_lon = 0.0; g->o_az = 0; return 1; @@ -748,13 +733,16 @@ namespace projections template <typename T> inline void isea_rotate(isea_pt<T> * pt, T const& degrees) { + static T const d2r = geometry::math::d2r<T>(); + static T const two_pi = detail::two_pi<T>(); + T rad; T x, y; - rad = -degrees * geometry::math::d2r<T>(); - while (rad >= geometry::math::two_pi<T>()) rad -= geometry::math::two_pi<T>(); - while (rad <= -geometry::math::two_pi<T>()) rad += geometry::math::two_pi<T>(); + rad = -degrees * d2r; + while (rad >= two_pi) rad -= two_pi; + while (rad <= -two_pi) rad += two_pi; x = pt->x * cos(rad) + pt->y * sin(rad); y = -pt->x * sin(rad) + pt->y * cos(rad); @@ -768,7 +756,7 @@ namespace projections { isea_pt<T> tc; /* center of triangle */ - if (DOWNTRI(tri)) { + if (downtri(tri)) { isea_rotate(pt, 180.0); } tc = isea_triangle_xy<T>(tri); @@ -787,7 +775,6 @@ namespace projections int downtri, quad; downtri = (((tri - 1) / 5) % 2 == 1); - boost::ignore_unused(downtri); quad = ((tri - 1) % 5) + ((tri - 1) / 10) * 5 + 1; isea_rotate(pt, downtri ? 240.0 : 60.0); @@ -802,6 +789,8 @@ namespace projections template <typename T> inline int isea_dddi_ap3odd(isea_dgg<T> *g, int quad, isea_pt<T> *pt, isea_pt<T> *di) { + static T const pi = detail::pi<T>(); + isea_pt<T> v; T hexwidth; T sidelength; /* in hexes */ @@ -810,10 +799,10 @@ namespace projections hex h; /* This is the number of hexes from apex to base of a triangle */ - sidelength = (pow(2.0, g->resolution) + 1.0) / 2.0; + sidelength = (math::pow(T(2), g->resolution) + T(1)) / T(2); /* apex to base is cos(30deg) */ - hexwidth = cos(geometry::math::pi<T>() / 6.0) / sidelength; + hexwidth = cos(pi / 6.0) / sidelength; /* TODO I think sidelength is always x.5, so * (int)sidelength * 2 + 1 might be just as good @@ -890,7 +879,7 @@ namespace projections } /* todo might want to do this as an iterated loop */ if (g->aperture >0) { - sidelength = (int) (pow(T(g->aperture), T(g->resolution / 2.0)) + 0.5); + sidelength = (int) (math::pow(T(g->aperture), T(g->resolution / T(2))) + T(0.5)); } else { sidelength = g->resolution; } @@ -976,19 +965,19 @@ namespace projections return g->serial; } /* hexes in a quad */ - hexes = (int) (pow(T(g->aperture), T(g->resolution)) + 0.5); + hexes = (int) (math::pow(T(g->aperture), T(g->resolution)) + T(0.5)); if (quad == 11) { g->serial = 1 + 10 * hexes + 1; return g->serial; } if (g->aperture == 3 && g->resolution % 2 == 1) { - height = (int) (pow(T(g->aperture), T((g->resolution - 1) / 2.0))); + height = (int) (math::pow(T(g->aperture), T((g->resolution - 1) / T(2)))); sn = ((int) di->x) * height; sn += ((int) di->y) / height; sn += (quad - 1) * hexes; sn += 2; } else { - sidelength = (int) (pow(T(g->aperture), T(g->resolution / 2.0)) + 0.5); + sidelength = (int) (math::pow(T(g->aperture), T(g->resolution / T(2))) + T(0.5)); sn = (int) ((quad - 1) * hexes + sidelength * di->x + di->y + 2); } @@ -1068,47 +1057,44 @@ namespace projections template <typename T> inline isea_pt<T> isea_forward(isea_dgg<T> *g, isea_geo<T> *in) { - int tri, downtri; + int tri; isea_pt<T> out, coord; tri = isea_transform(g, in, &out); - downtri = (((tri - 1) / 5) % 2 == 1); - boost::ignore_unused(downtri); - - if (g->output == ISEA_PLANE) { + if (g->output == isea_addr_plane) { isea_tri_plane(tri, &out, g->radius); return out; } /* convert to isea standard triangle size */ - out.x = out.x / g->radius * ISEA_SCALE; - out.y = out.y / g->radius * ISEA_SCALE; + out.x = out.x / g->radius * isea_scale; + out.y = out.y / g->radius * isea_scale; out.x += 0.5; out.y += 2.0 * .14433756729740644112; switch (g->output) { - case ISEA_PROJTRI: + case isea_addr_projtri: /* nothing to do, already in projected triangle */ break; - case ISEA_VERTEX2DD: + case isea_addr_vertex2dd: g->quad = isea_ptdd(tri, &out); break; - case ISEA_Q2DD: + case isea_addr_q2dd: /* Same as above, we just don't print as much */ g->quad = isea_ptdd(tri, &out); break; - case ISEA_Q2DI: + case isea_addr_q2di: g->quad = isea_ptdi(g, tri, &out, &coord); return coord; break; - case ISEA_SEQNUM: + case isea_addr_seqnum: isea_ptdi(g, tri, &out, &coord); /* disn will set g->serial */ isea_disn(g, g->quad, &coord); return coord; break; - case ISEA_HEX: + case isea_addr_hex: isea_hex(g, tri, &out, &coord); return coord; break; @@ -1127,31 +1113,27 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_isea_spheroid : public base_t_f<base_isea_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_isea_spheroid + : public base_t_f<base_isea_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_isea<CalculationType> m_proj_parm; + par_isea<T> m_proj_parm; inline base_isea_spheroid(const Parameters& par) - : base_t_f<base_isea_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_f<base_isea_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - isea_pt<CalculationType> out; - isea_geo<CalculationType> in; + isea_pt<T> out; + isea_geo<T> in; in.lon = lp_lon; in.lat = lp_lat; - isea_dgg<CalculationType> copy = this->m_proj_parm.dgg; + isea_dgg<T> copy = this->m_proj_parm.dgg; out = isea_forward(©, &in); xy_x = out.x; @@ -1171,74 +1153,63 @@ namespace projections { std::string opt; - isea_grid_init(&proj_parm.dgg); + isea_grid_init(&proj_parm.dgg); - proj_parm.dgg.output = ISEA_PLANE; + proj_parm.dgg.output = isea_addr_plane; /* proj_parm.dgg.radius = par.a; / * otherwise defaults to 1 */ /* calling library will scale, I think */ - opt = pj_param(par.params, "sorient").s; + opt = pj_get_param_s(par.params, "orient"); if (! opt.empty()) { if (opt == std::string("isea")) { isea_orient_isea(&proj_parm.dgg); } else if (opt == std::string("pole")) { isea_orient_pole(&proj_parm.dgg); } else { - BOOST_THROW_EXCEPTION( projection_exception(-34) ); + BOOST_THROW_EXCEPTION( projection_exception(error_ellipsoid_use_required) ); } } - if (pj_param(par.params, "tazi").i) { - proj_parm.dgg.o_az = pj_param(par.params, "razi").f; - } - - if (pj_param(par.params, "tlon_0").i) { - proj_parm.dgg.o_lon = pj_param(par.params, "rlon_0").f; - } - - if (pj_param(par.params, "tlat_0").i) { - proj_parm.dgg.o_lat = pj_param(par.params, "rlat_0").f; - } - - if (pj_param(par.params, "taperture").i) { - proj_parm.dgg.aperture = pj_param(par.params, "iaperture").i; - } - - if (pj_param(par.params, "tresolution").i) { - proj_parm.dgg.resolution = pj_param(par.params, "iresolution").i; - } - - opt = pj_param(par.params, "smode").s; + pj_param_r(par.params, "azi", proj_parm.dgg.o_az); + pj_param_r(par.params, "lon_0", proj_parm.dgg.o_lon); + pj_param_r(par.params, "lat_0", proj_parm.dgg.o_lat); + // TODO: this parameter is set below second time + pj_param_i(par.params, "aperture", proj_parm.dgg.aperture); + // TODO: this parameter is set below second time + pj_param_i(par.params, "resolution", proj_parm.dgg.resolution); + + opt = pj_get_param_s(par.params, "mode"); if (! opt.empty()) { if (opt == std::string("plane")) { - proj_parm.dgg.output = ISEA_PLANE; + proj_parm.dgg.output = isea_addr_plane; } else if (opt == std::string("di")) { - proj_parm.dgg.output = ISEA_Q2DI; + proj_parm.dgg.output = isea_addr_q2di; } else if (opt == std::string("dd")) { - proj_parm.dgg.output = ISEA_Q2DD; + proj_parm.dgg.output = isea_addr_q2dd; } else if (opt == std::string("hex")) { - proj_parm.dgg.output = ISEA_HEX; + proj_parm.dgg.output = isea_addr_hex; } else { /* TODO verify error code. Possibly eliminate magic */ - BOOST_THROW_EXCEPTION( projection_exception(-34) ); + BOOST_THROW_EXCEPTION( projection_exception(error_ellipsoid_use_required) ); } } - if (pj_param(par.params, "trescale").i) { - proj_parm.dgg.radius = ISEA_SCALE; + // TODO: pj_param_exists -> pj_get_param_b ? + if (pj_param_exists(par.params, "rescale")) { + proj_parm.dgg.radius = isea_scale; } - if (pj_param(par.params, "tresolution").i) { - proj_parm.dgg.resolution = pj_param(par.params, "iresolution").i; + if (pj_param_i(par.params, "resolution", proj_parm.dgg.resolution)) { + /* empty */ } else { proj_parm.dgg.resolution = 4; } - if (pj_param(par.params, "taperture").i) { - proj_parm.dgg.aperture = pj_param(par.params, "iaperture").i; + if (pj_param_i(par.params, "aperture", proj_parm.dgg.aperture)) { + /* empty */ } else { proj_parm.dgg.aperture = 3; } @@ -1267,10 +1238,10 @@ namespace projections \par Example \image html ex_isea.gif */ - template <typename CalculationType, typename Parameters> - struct isea_spheroid : public detail::isea::base_isea_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct isea_spheroid : public detail::isea::base_isea_spheroid<T, Parameters> { - inline isea_spheroid(const Parameters& par) : detail::isea::base_isea_spheroid<CalculationType, Parameters>(par) + inline isea_spheroid(const Parameters& par) : detail::isea::base_isea_spheroid<T, Parameters>(par) { detail::isea::setup_isea(this->m_par, this->m_proj_parm); } @@ -1284,20 +1255,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::isea, isea_spheroid, isea_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class isea_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class isea_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_f<isea_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_f<isea_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void isea_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void isea_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("isea", new isea_entry<CalculationType, Parameters>); + factory.add_to_factory("isea", new isea_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/krovak.hpp b/boost/geometry/srs/projections/proj/krovak.hpp index 09c24772ed..a008f181db 100644 --- a/boost/geometry/srs/projections/proj/krovak.hpp +++ b/boost/geometry/srs/projections/proj/krovak.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_KROVAK_HPP -#define BOOST_GEOMETRY_PROJECTIONS_KROVAK_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,12 +15,12 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: // Purpose: Implementation of the krovak (Krovak) projection. -// Definition: http://www.ihsenergy.com/epsg/guid7.html#1.4.3 +// Definition: http://www.ihsenergy.com/epsg/guid7.html#1.4.3 // Author: Thomas Flemming, tf@ttqv.com // Copyright (c) 2001, Thomas Flemming, tf@ttqv.com @@ -46,6 +42,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_KROVAK_HPP +#define BOOST_GEOMETRY_PROJECTIONS_KROVAK_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -56,7 +55,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct krovak {}; + struct krovak {}; // Krovak }} //namespace srs::par4 @@ -65,10 +64,23 @@ namespace projections #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace krovak { + static double epsilon = 1e-15; + static double S45 = 0.785398163397448; /* 45 deg */ + static double S90 = 1.570796326794896; /* 90 deg */ + static double UQ = 1.04216856380474; /* DU(2, 59, 42, 42.69689) */ + static double S0 = 1.37008346281555; /* Latitude of pseudo standard parallel 78deg 30'00" N */ + /* Not sure at all of the appropriate number for max_iter... */ + static int max_iter = 100; + template <typename T> struct par_krovak { - T C_x; + T alpha; + T k; + T n; + T rho0; + T ad; + int czech; }; /** @@ -95,164 +107,81 @@ namespace projections **/ // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_krovak_ellipsoid : public base_t_fi<base_krovak_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_krovak_ellipsoid + : public base_t_fi<base_krovak_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_krovak<CalculationType> m_proj_parm; + par_krovak<T> m_proj_parm; inline base_krovak_ellipsoid(const Parameters& par) - : base_t_fi<base_krovak_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_krovak_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) ellipsoid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - /* calculate xy from lat/lon */ - - /* Constants, identical to inverse transform function */ - CalculationType s45, s90, e2, e, alfa, uq, u0, g, k, k1, n0, ro0, ad, a, s0, n; - CalculationType gfi, u, fi0, deltav, s, d, eps, ro; - - - s45 = 0.785398163397448; /* 45 DEG */ - s90 = 2 * s45; - fi0 = this->m_par.phi0; /* Latitude of projection centre 49 DEG 30' */ - - /* Ellipsoid is used as Parameter in for.c and inv.c, therefore a must - be set to 1 here. - Ellipsoid Bessel 1841 a = 6377397.155m 1/f = 299.1528128, - e2=0.006674372230614; - */ - a = 1; /* 6377397.155; */ - /* e2 = this->m_par.es;*/ /* 0.006674372230614; */ - e2 = 0.006674372230614; - e = sqrt(e2); - - alfa = sqrt(1. + (e2 * pow(cos(fi0), 4)) / (1. - e2)); + T gfi, u, deltav, s, d, eps, rho; - uq = 1.04216856380474; /* DU(2, 59, 42, 42.69689) */ - u0 = asin(sin(fi0) / alfa); - g = pow( (1. + e * sin(fi0)) / (1. - e * sin(fi0)) , alfa * e / 2. ); + gfi = math::pow( (T(1) + this->m_par.e * sin(lp_lat)) / (T(1) - this->m_par.e * sin(lp_lat)), this->m_proj_parm.alpha * this->m_par.e / T(2)); - k = tan( u0 / 2. + s45) / pow (tan(fi0 / 2. + s45) , alfa) * g; + u = 2. * (atan(this->m_proj_parm.k * math::pow( tan(lp_lat / T(2) + S45), this->m_proj_parm.alpha) / gfi)-S45); + deltav = -lp_lon * this->m_proj_parm.alpha; - k1 = this->m_par.k0; - n0 = a * sqrt(1. - e2) / (1. - e2 * pow(sin(fi0), 2)); - s0 = 1.37008346281555; /* Latitude of pseudo standard parallel 78 DEG 30'00" N */ - n = sin(s0); - ro0 = k1 * n0 / tan(s0); - ad = s90 - uq; - - /* Transformation */ - - gfi =pow ( ((1. + e * sin(lp_lat)) / - (1. - e * sin(lp_lat))) , (alfa * e / 2.)); + s = asin(cos(this->m_proj_parm.ad) * sin(u) + sin(this->m_proj_parm.ad) * cos(u) * cos(deltav)); + d = asin(cos(u) * sin(deltav) / cos(s)); - u= 2. * (atan(k * pow( tan(lp_lat / 2. + s45), alfa) / gfi)-s45); + eps = this->m_proj_parm.n * d; + rho = this->m_proj_parm.rho0 * math::pow(tan(S0 / T(2) + S45) , this->m_proj_parm.n) / math::pow(tan(s / T(2) + S45) , this->m_proj_parm.n); - deltav = - lp_lon * alfa; + xy_y = rho * cos(eps); + xy_x = rho * sin(eps); - s = asin(cos(ad) * sin(u) + sin(ad) * cos(u) * cos(deltav)); - d = asin(cos(u) * sin(deltav) / cos(s)); - eps = n * d; - ro = ro0 * pow(tan(s0 / 2. + s45) , n) / pow(tan(s / 2. + s45) , n) ; - - /* x and y are reverted! */ - xy_y = ro * cos(eps) / a; - xy_x = ro * sin(eps) / a; - - if( !pj_param(this->m_par.params, "tczech").i ) - { - xy_y *= -1.0; - xy_x *= -1.0; - } + xy_y *= this->m_proj_parm.czech; + xy_x *= this->m_proj_parm.czech; } // INVERSE(e_inverse) ellipsoid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - /* calculate lat/lon from xy */ - - /* Constants, identisch wie in der Umkehrfunktion */ - CalculationType s45, s90, fi0, e2, e, alfa, uq, u0, g, k, k1, n0, ro0, ad, a, s0, n; - CalculationType u, deltav, s, d, eps, ro, fi1, xy0; - int ok; - - s45 = 0.785398163397448; /* 45 DEG */ - s90 = 2 * s45; - fi0 = this->m_par.phi0; /* Latitude of projection centre 49 DEG 30' */ - - - /* Ellipsoid is used as Parameter in for.c and inv.c, therefore a must - be set to 1 here. - Ellipsoid Bessel 1841 a = 6377397.155m 1/f = 299.1528128, - e2=0.006674372230614; - */ - a = 1; /* 6377397.155; */ - /* e2 = this->m_par.es; */ /* 0.006674372230614; */ - e2 = 0.006674372230614; - e = sqrt(e2); - - alfa = sqrt(1. + (e2 * pow(cos(fi0), 4)) / (1. - e2)); - uq = 1.04216856380474; /* DU(2, 59, 42, 42.69689) */ - u0 = asin(sin(fi0) / alfa); - g = pow( (1. + e * sin(fi0)) / (1. - e * sin(fi0)) , alfa * e / 2. ); - - k = tan( u0 / 2. + s45) / pow (tan(fi0 / 2. + s45) , alfa) * g; - - k1 = this->m_par.k0; - n0 = a * sqrt(1. - e2) / (1. - e2 * pow(sin(fi0), 2)); - s0 = 1.37008346281555; /* Latitude of pseudo standard parallel 78 DEG 30'00" N */ - n = sin(s0); - ro0 = k1 * n0 / tan(s0); - ad = s90 - uq; - - - /* Transformation */ - /* revert y, x*/ - xy0=xy_x; - xy_x=xy_y; - xy_y=xy0; - - if( !pj_param(this->m_par.params, "tczech").i ) - { - xy_x *= -1.0; - xy_y *= -1.0; - } - - ro = sqrt(xy_x * xy_x + xy_y * xy_y); + T u, deltav, s, d, eps, rho, fi1, xy0; + int i; + + // TODO: replace with std::swap() + xy0 = xy_x; + xy_x = xy_y; + xy_y = xy0; + + xy_x *= this->m_proj_parm.czech; + xy_y *= this->m_proj_parm.czech; + + rho = sqrt(xy_x * xy_x + xy_y * xy_y); eps = atan2(xy_y, xy_x); - d = eps / sin(s0); - s = 2. * (atan( pow(ro0 / ro, 1. / n) * tan(s0 / 2. + s45)) - s45); - u = asin(cos(ad) * sin(s) - sin(ad) * cos(s) * cos(d)); - deltav = asin(cos(s) * sin(d) / cos(u)); + d = eps / sin(S0); + s = T(2) * (atan(math::pow(this->m_proj_parm.rho0 / rho, T(1) / this->m_proj_parm.n) * tan(S0 / T(2) + S45)) - S45); - lp_lon = this->m_par.lam0 - deltav / alfa; + u = asin(cos(this->m_proj_parm.ad) * sin(s) - sin(this->m_proj_parm.ad) * cos(s) * cos(d)); + deltav = asin(cos(s) * sin(d) / cos(u)); - /* ITERATION FOR lp_lat */ - fi1 = u; + lp_lon = this->m_par.lam0 - deltav / this->m_proj_parm.alpha; - ok = 0; - do - { - lp_lat = 2. * ( atan( pow( k, -1. / alfa) * - pow( tan(u / 2. + s45) , 1. / alfa) * - pow( (1. + e * sin(fi1)) / (1. - e * sin(fi1)) , e / 2.) - ) - s45); + /* ITERATION FOR lp_lat */ + fi1 = u; - if (fabs(fi1 - lp_lat) < 0.000000000000001) ok=1; - fi1 = lp_lat; + for (i = max_iter; i ; --i) { + lp_lat = T(2) * ( atan( math::pow( this->m_proj_parm.k, T(-1) / this->m_proj_parm.alpha) * + math::pow( tan(u / T(2) + S45) , T(1) / this->m_proj_parm.alpha) * + math::pow( (T(1) + this->m_par.e * sin(fi1)) / (T(1) - this->m_par.e * sin(fi1)) , this->m_par.e / T(2)) + ) - S45); - } - while (ok==0); + if (fabs(fi1 - lp_lat) < epsilon) + break; + fi1 = lp_lat; + } + if( i == 0 ) + BOOST_THROW_EXCEPTION( projection_exception(error_non_convergent) ); lp_lon -= this->m_par.lam0; } @@ -268,32 +197,39 @@ namespace projections template <typename Parameters, typename T> inline void setup_krovak(Parameters& par, par_krovak<T>& proj_parm) { - T ts; - /* read some Parameters, - * here Latitude Truescale */ - - ts = pj_param(par.params, "rlat_ts").f; - proj_parm.C_x = ts; + T u0, n0, g; /* we want Bessel as fixed ellipsoid */ par.a = 6377397.155; par.e = sqrt(par.es = 0.006674372230614); - /* if latitude of projection center is not set, use 49d30'N */ - if (!pj_param(par.params, "tlat_0").i) - par.phi0 = 0.863937979737193; - - /* if center long is not set use 42d30'E of Ferro - 17d40' for Ferro */ - /* that will correspond to using longitudes relative to greenwich */ - /* as input and output, instead of lat/long relative to Ferro */ - if (!pj_param(par.params, "tlon_0").i) - par.lam0 = 0.7417649320975901 - 0.308341501185665; - - /* if scale not set default to 0.9999 */ - if (!pj_param(par.params, "tk").i) - par.k0 = 0.9999; - - /* always the same */ + /* if latitude of projection center is not set, use 49d30'N */ + if (!pj_param_exists(par.params, "lat_0")) + par.phi0 = 0.863937979737193; + + /* if center long is not set use 42d30'E of Ferro - 17d40' for Ferro */ + /* that will correspond to using longitudes relative to greenwich */ + /* as input and output, instead of lat/long relative to Ferro */ + if (!pj_param_exists(par.params, "lon_0")) + par.lam0 = 0.7417649320975901 - 0.308341501185665; + + /* if scale not set default to 0.9999 */ + if (!pj_param_exists(par.params, "k")) + par.k0 = 0.9999; + + proj_parm.czech = 1; + if( !pj_param_exists(par.params, "czech") ) + proj_parm.czech = -1; + + /* Set up shared parameters between forward and inverse */ + proj_parm.alpha = sqrt(T(1) + (par.es * math::pow(cos(par.phi0), 4)) / (T(1) - par.es)); + u0 = asin(sin(par.phi0) / proj_parm.alpha); + g = math::pow( (T(1) + par.e * sin(par.phi0)) / (T(1) - par.e * sin(par.phi0)) , proj_parm.alpha * par.e / T(2) ); + proj_parm.k = tan( u0 / 2. + S45) / math::pow(tan(par.phi0 / T(2) + S45) , proj_parm.alpha) * g; + n0 = sqrt(T(1) - par.es) / (T(1) - par.es * math::pow(sin(par.phi0), 2)); + proj_parm.n = sin(S0); + proj_parm.rho0 = par.k0 * n0 / tan(S0); + proj_parm.ad = S90 - UQ; } }} // namespace detail::krovak @@ -316,10 +252,10 @@ namespace projections \par Example \image html ex_krovak.gif */ - template <typename CalculationType, typename Parameters> - struct krovak_ellipsoid : public detail::krovak::base_krovak_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct krovak_ellipsoid : public detail::krovak::base_krovak_ellipsoid<T, Parameters> { - inline krovak_ellipsoid(const Parameters& par) : detail::krovak::base_krovak_ellipsoid<CalculationType, Parameters>(par) + inline krovak_ellipsoid(const Parameters& par) : detail::krovak::base_krovak_ellipsoid<T, Parameters>(par) { detail::krovak::setup_krovak(this->m_par, this->m_proj_parm); } @@ -333,20 +269,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::krovak, krovak_ellipsoid, krovak_ellipsoid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class krovak_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class krovak_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<krovak_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<krovak_ellipsoid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void krovak_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void krovak_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("krovak", new krovak_entry<CalculationType, Parameters>); + factory.add_to_factory("krovak", new krovak_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/labrd.hpp b/boost/geometry/srs/projections/proj/labrd.hpp index 0a51689308..32a15e2781 100644 --- a/boost/geometry/srs/projections/proj/labrd.hpp +++ b/boost/geometry/srs/projections/proj/labrd.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_LABRD_HPP -#define BOOST_GEOMETRY_PROJECTIONS_LABRD_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_LABRD_HPP +#define BOOST_GEOMETRY_PROJECTIONS_LABRD_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -51,7 +50,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct labrd {}; + struct labrd {}; // Laborde }} //namespace srs::par4 @@ -60,7 +59,7 @@ namespace projections #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace labrd { - static const double EPS = 1.e-10; + static const double epsilon = 1.e-10; template <typename T> struct par_labrd @@ -70,33 +69,29 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_labrd_ellipsoid : public base_t_fi<base_labrd_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_labrd_ellipsoid + : public base_t_fi<base_labrd_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_labrd<CalculationType> m_proj_parm; + par_labrd<T> m_proj_parm; inline base_labrd_ellipsoid(const Parameters& par) - : base_t_fi<base_labrd_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_labrd_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType FORTPI = detail::FORTPI<CalculationType>(); + static const T fourth_pi = detail::fourth_pi<T>(); - CalculationType V1, V2, ps, sinps, cosps, sinps2, cosps2, I1, I2, I3, I4, I5, I6, - x2, y2, t; + T V1, V2, ps, sinps, cosps, sinps2, cosps2; + T I1, I2, I3, I4, I5, I6, x2, y2, t; - V1 = this->m_proj_parm.A * log( tan(FORTPI + .5 * lp_lat) ); + V1 = this->m_proj_parm.A * log( tan(fourth_pi + .5 * lp_lat) ); t = this->m_par.e * sin(lp_lat); V2 = .5 * this->m_par.e * this->m_proj_parm.A * log ((1. + t)/(1. - t)); - ps = 2. * (atan(exp(V1 - V2 + this->m_proj_parm.C)) - FORTPI); + ps = 2. * (atan(exp(V1 - V2 + this->m_proj_parm.C)) - fourth_pi); I1 = ps - this->m_proj_parm.p0s; cosps = cos(ps); cosps2 = cosps * cosps; sinps = sin(ps); sinps2 = sinps * sinps; @@ -120,12 +115,15 @@ namespace projections // INVERSE(e_inverse) ellipsoid & spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType FORTPI = detail::FORTPI<CalculationType>(); + static const T fourth_pi = detail::fourth_pi<T>(); - CalculationType x2, y2, V1, V2, V3, V4, t, t2, ps, pe, tpe, s, - I7, I8, I9, I10, I11, d, Re; + /* t = 0.0 optimization is to avoid a false positive cppcheck warning */ + /* (cppcheck git beaf29c15867984aa3c2a15cf15bd7576ccde2b3). Might no */ + /* longer be necessary with later versions. */ + T x2, y2, V1, V2, V3, V4, t = 0.0, t2, ps, pe, tpe, s; + T I7, I8, I9, I10, I11, d, Re; int i; x2 = xy_x * xy_x; @@ -138,20 +136,17 @@ namespace projections xy_y += this->m_proj_parm.Cb * V1 - this->m_proj_parm.Ca * V2 - this->m_proj_parm.Cd * V3 + this->m_proj_parm.Cc * V4; ps = this->m_proj_parm.p0s + xy_y / this->m_proj_parm.kRg; pe = ps + this->m_par.phi0 - this->m_proj_parm.p0s; + for ( i = 20; i; --i) { - V1 = this->m_proj_parm.A * log(tan(FORTPI + .5 * pe)); + V1 = this->m_proj_parm.A * log(tan(fourth_pi + .5 * pe)); tpe = this->m_par.e * sin(pe); V2 = .5 * this->m_par.e * this->m_proj_parm.A * log((1. + tpe)/(1. - tpe)); - t = ps - 2. * (atan(exp(V1 - V2 + this->m_proj_parm.C)) - FORTPI); + t = ps - 2. * (atan(exp(V1 - V2 + this->m_proj_parm.C)) - fourth_pi); pe += t; - if (fabs(t) < EPS) + if (fabs(t) < epsilon) break; } - /* - if (!i) { - } else { - } - */ + t = this->m_par.e * sin(pe); t = 1. - t * t; Re = this->m_par.one_es / ( t * sqrt(t) ); @@ -182,12 +177,12 @@ namespace projections template <typename Parameters, typename T> inline void setup_labrd(Parameters& par, par_labrd<T>& proj_parm) { - static const T FORTPI = detail::FORTPI<T>(); + static const T fourth_pi = detail::fourth_pi<T>(); T Az, sinp, R, N, t; - proj_parm.rot = pj_param(par.params, "bno_rot").i == 0; - Az = pj_param(par.params, "razi").f; + proj_parm.rot = pj_get_param_b(par.params, "no_rot"); + Az = pj_get_param_r(par.params, "azi"); sinp = sin(par.phi0); t = 1. - par.es * sinp * sinp; N = 1. / sqrt(t); @@ -197,8 +192,8 @@ namespace projections proj_parm.A = sinp / sin(proj_parm.p0s); t = par.e * sinp; proj_parm.C = .5 * par.e * proj_parm.A * log((1. + t)/(1. - t)) + - - proj_parm.A * log( tan(FORTPI + .5 * par.phi0)) - + log( tan(FORTPI + .5 * proj_parm.p0s)); + - proj_parm.A * log( tan(fourth_pi + .5 * par.phi0)) + + log( tan(fourth_pi + .5 * proj_parm.p0s)); t = Az + Az; proj_parm.Ca = (1. - cos(t)) * ( proj_parm.Cb = 1. / (12. * proj_parm.kRg * proj_parm.kRg) ); proj_parm.Cb *= sin(t); @@ -225,10 +220,10 @@ namespace projections \par Example \image html ex_labrd.gif */ - template <typename CalculationType, typename Parameters> - struct labrd_ellipsoid : public detail::labrd::base_labrd_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct labrd_ellipsoid : public detail::labrd::base_labrd_ellipsoid<T, Parameters> { - inline labrd_ellipsoid(const Parameters& par) : detail::labrd::base_labrd_ellipsoid<CalculationType, Parameters>(par) + inline labrd_ellipsoid(const Parameters& par) : detail::labrd::base_labrd_ellipsoid<T, Parameters>(par) { detail::labrd::setup_labrd(this->m_par, this->m_proj_parm); } @@ -242,20 +237,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::labrd, labrd_ellipsoid, labrd_ellipsoid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class labrd_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class labrd_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<labrd_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<labrd_ellipsoid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void labrd_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void labrd_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("labrd", new labrd_entry<CalculationType, Parameters>); + factory.add_to_factory("labrd", new labrd_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/laea.hpp b/boost/geometry/srs/projections/proj/laea.hpp index 757d2b7ff0..6d5a948672 100644 --- a/boost/geometry/srs/projections/proj/laea.hpp +++ b/boost/geometry/srs/projections/proj/laea.hpp @@ -1,8 +1,4 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_LAEA_HPP -#define BOOST_GEOMETRY_PROJECTIONS_LAEA_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_LAEA_HPP +#define BOOST_GEOMETRY_PROJECTIONS_LAEA_HPP + #include <boost/config.hpp> #include <boost/geometry/util/math.hpp> #include <boost/math/special_functions/hypot.hpp> @@ -66,13 +65,14 @@ namespace projections #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace laea { - static const double EPS10 = 1.e-10; - static const int NITER = 20; - static const double CONV = 1.e-10; - static const int N_POLE = 0; - static const int S_POLE = 1; - static const int EQUIT = 2; - static const int OBLIQ = 3; + static const double epsilon10 = 1.e-10; + + enum mode_type { + n_pole = 0, + s_pole = 1, + equit = 2, + obliq = 3 + }; template <typename T> struct par_laea @@ -85,75 +85,77 @@ namespace projections T qp; T dd; T rq; - T apa[APA_SIZE]; - int mode; + detail::apa<T> apa; + mode_type mode; }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_laea_ellipsoid : public base_t_fi<base_laea_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_laea_ellipsoid + : public base_t_fi<base_laea_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_laea<CalculationType> m_proj_parm; + par_laea<T> m_proj_parm; inline base_laea_ellipsoid(const Parameters& par) - : base_t_fi<base_laea_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_laea_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) ellipsoid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); - CalculationType coslam, sinlam, sinphi, q, sinb=0.0, cosb=0.0, b=0.0; + T coslam, sinlam, sinphi, q, sinb=0.0, cosb=0.0, b=0.0; coslam = cos(lp_lon); sinlam = sin(lp_lon); sinphi = sin(lp_lat); q = pj_qsfn(sinphi, this->m_par.e, this->m_par.one_es); - if (this->m_proj_parm.mode == OBLIQ || this->m_proj_parm.mode == EQUIT) { + + if (this->m_proj_parm.mode == obliq || this->m_proj_parm.mode == equit) { sinb = q / this->m_proj_parm.qp; cosb = sqrt(1. - sinb * sinb); } + switch (this->m_proj_parm.mode) { - case OBLIQ: + case obliq: b = 1. + this->m_proj_parm.sinb1 * sinb + this->m_proj_parm.cosb1 * cosb * coslam; break; - case EQUIT: + case equit: b = 1. + cosb * coslam; break; - case N_POLE: - b = HALFPI + lp_lat; + case n_pole: + b = half_pi + lp_lat; q = this->m_proj_parm.qp - q; break; - case S_POLE: - b = lp_lat - HALFPI; + case s_pole: + b = lp_lat - half_pi; q = this->m_proj_parm.qp + q; break; } - if (fabs(b) < EPS10) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + if (fabs(b) < epsilon10) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } + switch (this->m_proj_parm.mode) { - case OBLIQ: - xy_y = this->m_proj_parm.ymf * ( b = sqrt(2. / b) ) - * (this->m_proj_parm.cosb1 * sinb - this->m_proj_parm.sinb1 * cosb * coslam); + case obliq: + b = sqrt(2. / b); + xy_y = this->m_proj_parm.ymf * b * (this->m_proj_parm.cosb1 * sinb - this->m_proj_parm.sinb1 * cosb * coslam); goto eqcon; break; - case EQUIT: - xy_y = (b = sqrt(2. / (1. + cosb * coslam))) * sinb * this->m_proj_parm.ymf; + case equit: + b = sqrt(2. / (1. + cosb * coslam)); + xy_y = b * sinb * this->m_proj_parm.ymf; eqcon: xy_x = this->m_proj_parm.xmf * b * cosb * sinlam; break; - case N_POLE: - case S_POLE: + case n_pole: + case s_pole: if (q >= 0.) { - xy_x = (b = sqrt(q)) * sinlam; - xy_y = coslam * (this->m_proj_parm.mode == S_POLE ? b : -b); + b = sqrt(q); + xy_x = b * sinlam; + xy_y = coslam * (this->m_proj_parm.mode == s_pole ? b : -b); } else xy_x = xy_y = 0.; break; @@ -162,42 +164,45 @@ namespace projections // INVERSE(e_inverse) ellipsoid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType cCe, sCe, q, rho, ab=0.0; + T cCe, sCe, q, rho, ab=0.0; switch (this->m_proj_parm.mode) { - case EQUIT: - case OBLIQ: - if ((rho = boost::math::hypot(xy_x /= this->m_proj_parm.dd, xy_y *= this->m_proj_parm.dd)) < EPS10) { + case equit: + case obliq: + xy_x /= this->m_proj_parm.dd; + xy_y *= this->m_proj_parm.dd; + rho = boost::math::hypot(xy_x, xy_y); + if (rho < epsilon10) { lp_lon = 0.; lp_lat = this->m_par.phi0; return; } - cCe = cos(sCe = 2. * asin(.5 * rho / this->m_proj_parm.rq)); - xy_x *= (sCe = sin(sCe)); - if (this->m_proj_parm.mode == OBLIQ) { - q = this->m_proj_parm.qp * (ab = cCe * this->m_proj_parm.sinb1 + xy_y * sCe * this->m_proj_parm.cosb1 / rho); + sCe = 2. * asin(.5 * rho / this->m_proj_parm.rq); + cCe = cos(sCe); + sCe = sin(sCe); + xy_x *= sCe; + if (this->m_proj_parm.mode == obliq) { + ab = cCe * this->m_proj_parm.sinb1 + xy_y * sCe * this->m_proj_parm.cosb1 / rho; xy_y = rho * this->m_proj_parm.cosb1 * cCe - xy_y * this->m_proj_parm.sinb1 * sCe; } else { - q = this->m_proj_parm.qp * (ab = xy_y * sCe / rho); + ab = xy_y * sCe / rho; xy_y = rho * cCe; } break; - case N_POLE: + case n_pole: xy_y = -xy_y; BOOST_FALLTHROUGH; - case S_POLE: - if (!(q = (xy_x * xy_x + xy_y * xy_y)) ) { + case s_pole: + q = (xy_x * xy_x + xy_y * xy_y); + if (q == 0.0) { lp_lon = 0.; lp_lat = this->m_par.phi0; return; } - /* - q = this->m_proj_parm.qp - q; - */ ab = 1. - q / this->m_proj_parm.qp; - if (this->m_proj_parm.mode == S_POLE) + if (this->m_proj_parm.mode == s_pole) ab = - ab; break; } @@ -213,52 +218,51 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_laea_spheroid : public base_t_fi<base_laea_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_laea_spheroid + : public base_t_fi<base_laea_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_laea<CalculationType> m_proj_parm; + par_laea<T> m_proj_parm; inline base_laea_spheroid(const Parameters& par) - : base_t_fi<base_laea_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_laea_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType FORTPI = detail::FORTPI<CalculationType>(); + static const T fourth_pi = detail::fourth_pi<T>(); - CalculationType coslam, cosphi, sinphi; + T coslam, cosphi, sinphi; sinphi = sin(lp_lat); cosphi = cos(lp_lat); coslam = cos(lp_lon); switch (this->m_proj_parm.mode) { - case EQUIT: + case equit: xy_y = 1. + cosphi * coslam; goto oblcon; - case OBLIQ: + case obliq: xy_y = 1. + this->m_proj_parm.sinb1 * sinphi + this->m_proj_parm.cosb1 * cosphi * coslam; oblcon: - if (xy_y <= EPS10) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); - xy_x = (xy_y = sqrt(2. / xy_y)) * cosphi * sin(lp_lon); - xy_y *= this->m_proj_parm.mode == EQUIT ? sinphi : + if (xy_y <= epsilon10) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } + xy_y = sqrt(2. / xy_y); + xy_x = 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; break; - case N_POLE: + case n_pole: coslam = -coslam; BOOST_FALLTHROUGH; - case S_POLE: - if (fabs(lp_lat + this->m_par.phi0) < EPS10) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); - xy_y = FORTPI - lp_lat * .5; - xy_y = 2. * (this->m_proj_parm.mode == S_POLE ? cos(xy_y) : sin(xy_y)); + case s_pole: + if (fabs(lp_lat + this->m_par.phi0) < epsilon10) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } + xy_y = fourth_pi - 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); xy_y *= coslam; break; @@ -267,41 +271,42 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); - CalculationType cosz=0.0, rh, sinz=0.0; + T cosz=0.0, rh, sinz=0.0; rh = boost::math::hypot(xy_x, xy_y); - if ((lp_lat = rh * .5 ) > 1.) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + if ((lp_lat = rh * .5 ) > 1.) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } lp_lat = 2. * asin(lp_lat); - if (this->m_proj_parm.mode == OBLIQ || this->m_proj_parm.mode == EQUIT) { + if (this->m_proj_parm.mode == obliq || this->m_proj_parm.mode == equit) { sinz = sin(lp_lat); cosz = cos(lp_lat); } switch (this->m_proj_parm.mode) { - case EQUIT: - lp_lat = fabs(rh) <= EPS10 ? 0. : asin(xy_y * sinz / rh); + case equit: + lp_lat = fabs(rh) <= epsilon10 ? 0. : asin(xy_y * sinz / rh); xy_x *= sinz; xy_y = cosz * rh; break; - case OBLIQ: - lp_lat = fabs(rh) <= EPS10 ? this->m_par.phi0 : + case obliq: + lp_lat = fabs(rh) <= epsilon10 ? this->m_par.phi0 : asin(cosz * this->m_proj_parm.sinb1 + xy_y * sinz * this->m_proj_parm.cosb1 / rh); xy_x *= sinz * this->m_proj_parm.cosb1; xy_y = (cosz - sin(lp_lat) * this->m_proj_parm.sinb1) * rh; break; - case N_POLE: + case n_pole: xy_y = -xy_y; - lp_lat = HALFPI - lp_lat; + lp_lat = half_pi - lp_lat; break; - case S_POLE: - lp_lat -= HALFPI; + case s_pole: + lp_lat -= half_pi; break; } - lp_lon = (xy_y == 0. && (this->m_proj_parm.mode == EQUIT || this->m_proj_parm.mode == OBLIQ)) ? + lp_lon = (xy_y == 0. && (this->m_proj_parm.mode == equit || this->m_proj_parm.mode == obliq)) ? 0. : atan2(xy_x, xy_y); } @@ -316,34 +321,35 @@ namespace projections template <typename Parameters, typename T> inline void setup_laea(Parameters& par, par_laea<T>& proj_parm) { - static const T HALFPI = detail::HALFPI<T>(); + static const T half_pi = detail::half_pi<T>(); T t; - if (fabs((t = fabs(par.phi0)) - HALFPI) < EPS10) - proj_parm.mode = par.phi0 < 0. ? S_POLE : N_POLE; - else if (fabs(t) < EPS10) - proj_parm.mode = EQUIT; + t = fabs(par.phi0); + if (fabs(t - half_pi) < epsilon10) + proj_parm.mode = par.phi0 < 0. ? s_pole : n_pole; + else if (fabs(t) < epsilon10) + proj_parm.mode = equit; else - proj_parm.mode = OBLIQ; - if (par.es) { + proj_parm.mode = obliq; + if (par.es != 0.0) { double sinphi; par.e = sqrt(par.es); proj_parm.qp = pj_qsfn(1., par.e, par.one_es); proj_parm.mmf = .5 / (1. - par.es); - pj_authset(par.es, proj_parm.apa); + proj_parm.apa = pj_authset<T>(par.es); switch (proj_parm.mode) { - case N_POLE: - case S_POLE: + case n_pole: + case s_pole: proj_parm.dd = 1.; break; - case EQUIT: + case equit: proj_parm.dd = 1. / (proj_parm.rq = sqrt(.5 * proj_parm.qp)); proj_parm.xmf = 1.; proj_parm.ymf = .5 * proj_parm.qp; break; - case OBLIQ: + case obliq: proj_parm.rq = sqrt(.5 * proj_parm.qp); sinphi = sin(par.phi0); proj_parm.sinb1 = pj_qsfn(sinphi, par.e, par.one_es) / proj_parm.qp; @@ -355,7 +361,7 @@ namespace projections break; } } else { - if (proj_parm.mode == OBLIQ) { + if (proj_parm.mode == obliq) { proj_parm.sinb1 = sin(par.phi0); proj_parm.cosb1 = cos(par.phi0); } @@ -378,10 +384,10 @@ namespace projections \par Example \image html ex_laea.gif */ - template <typename CalculationType, typename Parameters> - struct laea_ellipsoid : public detail::laea::base_laea_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct laea_ellipsoid : public detail::laea::base_laea_ellipsoid<T, Parameters> { - inline laea_ellipsoid(const Parameters& par) : detail::laea::base_laea_ellipsoid<CalculationType, Parameters>(par) + inline laea_ellipsoid(const Parameters& par) : detail::laea::base_laea_ellipsoid<T, Parameters>(par) { detail::laea::setup_laea(this->m_par, this->m_proj_parm); } @@ -400,10 +406,10 @@ namespace projections \par Example \image html ex_laea.gif */ - template <typename CalculationType, typename Parameters> - struct laea_spheroid : public detail::laea::base_laea_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct laea_spheroid : public detail::laea::base_laea_spheroid<T, Parameters> { - inline laea_spheroid(const Parameters& par) : detail::laea::base_laea_spheroid<CalculationType, Parameters>(par) + inline laea_spheroid(const Parameters& par) : detail::laea::base_laea_spheroid<T, Parameters>(par) { detail::laea::setup_laea(this->m_par, this->m_proj_parm); } @@ -417,23 +423,23 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::laea, laea_spheroid, laea_ellipsoid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class laea_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class laea_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { if (par.es) - return new base_v_fi<laea_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<laea_ellipsoid<T, Parameters>, T, Parameters>(par); else - return new base_v_fi<laea_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<laea_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void laea_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void laea_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("laea", new laea_entry<CalculationType, Parameters>); + factory.add_to_factory("laea", new laea_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/lagrng.hpp b/boost/geometry/srs/projections/proj/lagrng.hpp index 8ed5c1389e..6cedef717f 100644 --- a/boost/geometry/srs/projections/proj/lagrng.hpp +++ b/boost/geometry/srs/projections/proj/lagrng.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_LAGRNG_HPP -#define BOOST_GEOMETRY_PROJECTIONS_LAGRNG_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_LAGRNG_HPP +#define BOOST_GEOMETRY_PROJECTIONS_LAGRNG_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -53,7 +52,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct lagrng {}; + struct lagrng {}; // Lagrange }} //namespace srs::par4 @@ -63,47 +62,44 @@ namespace projections namespace detail { namespace lagrng { - static const double TOL = 1e-10; + static const double tolerance = 1e-10; template <typename T> struct par_lagrng { - T hrw; - T rw; T a1; + T rw; + T hrw; }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_lagrng_spheroid : public base_t_f<base_lagrng_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_lagrng_spheroid + : public base_t_f<base_lagrng_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_lagrng<CalculationType> m_proj_parm; + par_lagrng<T> m_proj_parm; inline base_lagrng_spheroid(const Parameters& par) - : base_t_f<base_lagrng_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_f<base_lagrng_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); - CalculationType v, c; + T v, c; - if (fabs(fabs(lp_lat) - HALFPI) < TOL) { + if (fabs(fabs(lp_lat) - half_pi) < tolerance) { xy_x = 0; xy_y = lp_lat < 0 ? -2. : 2.; } else { 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) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + v = this->m_proj_parm.a1 * math::pow((T(1) + lp_lat)/(T(1) - lp_lat), this->m_proj_parm.hrw); + if ((c = 0.5 * (v + 1./v) + cos(lp_lon *= this->m_proj_parm.rw)) < tolerance) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } xy_x = 2. * sin(lp_lon) / c; xy_y = (v - 1./v) / c; } @@ -122,13 +118,18 @@ namespace projections { T phi1; - if ((proj_parm.rw = pj_param(par.params, "dW").f) <= 0) - BOOST_THROW_EXCEPTION( projection_exception(-27) ); - proj_parm.hrw = 0.5 * (proj_parm.rw = 1. / proj_parm.rw); - phi1 = pj_param(par.params, "rlat_1").f; - if (fabs(fabs(phi1 = sin(phi1)) - 1.) < TOL) - BOOST_THROW_EXCEPTION( projection_exception(-22) ); - proj_parm.a1 = pow((1. - phi1)/(1. + phi1), proj_parm.hrw); + proj_parm.rw = pj_get_param_f(par.params, "W"); + if (proj_parm.rw <= 0) + BOOST_THROW_EXCEPTION( projection_exception(error_w_or_m_zero_or_less) ); + + proj_parm.rw = 1. / proj_parm.rw; + proj_parm.hrw = 0.5 * proj_parm.rw; + phi1 = pj_get_param_r(par.params, "lat_1"); + if (fabs(fabs(phi1 = sin(phi1)) - 1.) < tolerance) + BOOST_THROW_EXCEPTION( projection_exception(error_lat_larger_than_90) ); + + proj_parm.a1 = math::pow((T(1) - phi1)/(T(1) + phi1), proj_parm.hrw); + par.es = 0.; } @@ -151,10 +152,10 @@ namespace projections \par Example \image html ex_lagrng.gif */ - template <typename CalculationType, typename Parameters> - struct lagrng_spheroid : public detail::lagrng::base_lagrng_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct lagrng_spheroid : public detail::lagrng::base_lagrng_spheroid<T, Parameters> { - inline lagrng_spheroid(const Parameters& par) : detail::lagrng::base_lagrng_spheroid<CalculationType, Parameters>(par) + inline lagrng_spheroid(const Parameters& par) : detail::lagrng::base_lagrng_spheroid<T, Parameters>(par) { detail::lagrng::setup_lagrng(this->m_par, this->m_proj_parm); } @@ -168,20 +169,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::lagrng, lagrng_spheroid, lagrng_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class lagrng_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class lagrng_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_f<lagrng_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_f<lagrng_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void lagrng_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void lagrng_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("lagrng", new lagrng_entry<CalculationType, Parameters>); + factory.add_to_factory("lagrng", new lagrng_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/larr.hpp b/boost/geometry/srs/projections/proj/larr.hpp index 2b2735c0dd..84fbafac62 100644 --- a/boost/geometry/srs/projections/proj/larr.hpp +++ b/boost/geometry/srs/projections/proj/larr.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_LARR_HPP -#define BOOST_GEOMETRY_PROJECTIONS_LARR_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_LARR_HPP +#define BOOST_GEOMETRY_PROJECTIONS_LARR_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -51,7 +50,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct larr {}; + struct larr {}; // Larrivee }} //namespace srs::par4 @@ -61,33 +60,23 @@ namespace projections namespace detail { namespace larr { - //static const double SIXTH = .16666666666666666; - - template <typename T> - inline T SIXTH() { return .16666666666666666666666666666666; } - // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_larr_spheroid : public base_t_f<base_larr_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_larr_spheroid + : public base_t_f<base_larr_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_larr_spheroid(const Parameters& par) - : base_t_f<base_larr_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_f<base_larr_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) sphere // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType SIXTH = larr::SIXTH<CalculationType>(); + static const T sixth = detail::sixth<T>(); xy_x = 0.5 * lp_lon * (1. + sqrt(cos(lp_lat))); - xy_y = lp_lat / (cos(0.5 * lp_lat) * cos(SIXTH * lp_lon)); + xy_y = lp_lat / (cos(0.5 * lp_lat) * cos(sixth * lp_lon)); } static inline std::string get_name() @@ -120,10 +109,10 @@ namespace projections \par Example \image html ex_larr.gif */ - template <typename CalculationType, typename Parameters> - struct larr_spheroid : public detail::larr::base_larr_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct larr_spheroid : public detail::larr::base_larr_spheroid<T, Parameters> { - inline larr_spheroid(const Parameters& par) : detail::larr::base_larr_spheroid<CalculationType, Parameters>(par) + inline larr_spheroid(const Parameters& par) : detail::larr::base_larr_spheroid<T, Parameters>(par) { detail::larr::setup_larr(this->m_par); } @@ -137,20 +126,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::larr, larr_spheroid, larr_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class larr_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class larr_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_f<larr_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_f<larr_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void larr_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void larr_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("larr", new larr_entry<CalculationType, Parameters>); + factory.add_to_factory("larr", new larr_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/lask.hpp b/boost/geometry/srs/projections/proj/lask.hpp index 9ee1a95efe..3f06533bf2 100644 --- a/boost/geometry/srs/projections/proj/lask.hpp +++ b/boost/geometry/srs/projections/proj/lask.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_LASK_HPP -#define BOOST_GEOMETRY_PROJECTIONS_LASK_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_LASK_HPP +#define BOOST_GEOMETRY_PROJECTIONS_LASK_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -51,7 +50,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct lask {}; + struct lask {}; // Laskowski }} //namespace srs::par4 @@ -73,30 +72,25 @@ namespace projections static const double b05 = -0.0491032; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_lask_spheroid : public base_t_f<base_lask_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_lask_spheroid + : public base_t_f<base_lask_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - - inline base_lask_spheroid(const Parameters& par) - : base_t_f<base_lask_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + inline base_lask_spheroid(const Parameters& par) + : base_t_f<base_lask_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) sphere // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType l2, p2; + T l2, p2; l2 = lp_lon * lp_lon; p2 = lp_lat * lp_lat; xy_x = lp_lon * (a10 + p2 * (a12 + l2 * a32 + p2 * a14)); xy_y = lp_lat * (b01 + l2 * (b21 + p2 * b23 + l2 * b41) + - p2 * (b03 + p2 * b05)); + p2 * (b03 + p2 * b05)); } static inline std::string get_name() @@ -129,10 +123,10 @@ namespace projections \par Example \image html ex_lask.gif */ - template <typename CalculationType, typename Parameters> - struct lask_spheroid : public detail::lask::base_lask_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct lask_spheroid : public detail::lask::base_lask_spheroid<T, Parameters> { - inline lask_spheroid(const Parameters& par) : detail::lask::base_lask_spheroid<CalculationType, Parameters>(par) + inline lask_spheroid(const Parameters& par) : detail::lask::base_lask_spheroid<T, Parameters>(par) { detail::lask::setup_lask(this->m_par); } @@ -146,20 +140,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::lask, lask_spheroid, lask_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class lask_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class lask_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_f<lask_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_f<lask_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void lask_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void lask_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("lask", new lask_entry<CalculationType, Parameters>); + factory.add_to_factory("lask", new lask_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/latlong.hpp b/boost/geometry/srs/projections/proj/latlong.hpp index e806381f2d..4c2d00a805 100644 --- a/boost/geometry/srs/projections/proj/latlong.hpp +++ b/boost/geometry/srs/projections/proj/latlong.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_LATLONG_HPP -#define BOOST_GEOMETRY_PROJECTIONS_LATLONG_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,13 +15,13 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: // Purpose: Stub projection implementation for lat/long coordinates. We -// don't actually change the coordinates, but we want proj=latlong -// to act sort of like a projection. +// don't actually change the coordinates, but we want proj=latlong +// to act sort of like a projection. // Author: Frank Warmerdam, warmerdam@pobox.com // Copyright (c) 2000, Frank Warmerdam @@ -47,6 +43,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_LATLONG_HPP +#define BOOST_GEOMETRY_PROJECTIONS_LATLONG_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -58,10 +57,10 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct lonlat {}; - struct latlon {}; - struct latlong {}; - struct longlat {}; + struct lonlat {}; // Lat/long (Geodetic) + struct latlon {}; // Lat/long (Geodetic alias) + struct latlong {}; // Lat/long (Geodetic alias) + struct longlat {}; // Lat/long (Geodetic alias) }} //namespace srs::par4 @@ -74,33 +73,32 @@ namespace projections /* very loosely based upon DMA code by Bradford W. Drew */ // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_latlong_other : public base_t_fi<base_latlong_other<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_latlong_other + : public base_t_fi<base_latlong_other<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_latlong_other(const Parameters& par) - : base_t_fi<base_latlong_other<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_latlong_other<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(forward) // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - xy_x = lp_lon / this->m_par.a; - xy_y = lp_lat / this->m_par.a; + // TODO: in the original code a is not used + // different mechanism is probably used instead + xy_x = lp_lon / this->m_par.a; + xy_y = lp_lat / this->m_par.a; } // INVERSE(inverse) // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - lp_lat = xy_y * this->m_par.a; - lp_lon = xy_x * this->m_par.a; + // TODO: in the original code a is not used + // different mechanism is probably used instead + lp_lat = xy_y * this->m_par.a; + lp_lon = xy_x * this->m_par.a; } static inline std::string get_name() @@ -158,10 +156,10 @@ namespace projections \par Example \image html ex_lonlat.gif */ - template <typename CalculationType, typename Parameters> - struct lonlat_other : public detail::latlong::base_latlong_other<CalculationType, Parameters> + template <typename T, typename Parameters> + struct lonlat_other : public detail::latlong::base_latlong_other<T, Parameters> { - inline lonlat_other(const Parameters& par) : detail::latlong::base_latlong_other<CalculationType, Parameters>(par) + inline lonlat_other(const Parameters& par) : detail::latlong::base_latlong_other<T, Parameters>(par) { detail::latlong::setup_lonlat(this->m_par); } @@ -176,10 +174,10 @@ namespace projections \par Example \image html ex_latlon.gif */ - template <typename CalculationType, typename Parameters> - struct latlon_other : public detail::latlong::base_latlong_other<CalculationType, Parameters> + template <typename T, typename Parameters> + struct latlon_other : public detail::latlong::base_latlong_other<T, Parameters> { - inline latlon_other(const Parameters& par) : detail::latlong::base_latlong_other<CalculationType, Parameters>(par) + inline latlon_other(const Parameters& par) : detail::latlong::base_latlong_other<T, Parameters>(par) { detail::latlong::setup_latlon(this->m_par); } @@ -194,10 +192,10 @@ namespace projections \par Example \image html ex_latlong.gif */ - template <typename CalculationType, typename Parameters> - struct latlong_other : public detail::latlong::base_latlong_other<CalculationType, Parameters> + template <typename T, typename Parameters> + struct latlong_other : public detail::latlong::base_latlong_other<T, Parameters> { - inline latlong_other(const Parameters& par) : detail::latlong::base_latlong_other<CalculationType, Parameters>(par) + inline latlong_other(const Parameters& par) : detail::latlong::base_latlong_other<T, Parameters>(par) { detail::latlong::setup_latlong(this->m_par); } @@ -212,10 +210,10 @@ namespace projections \par Example \image html ex_longlat.gif */ - template <typename CalculationType, typename Parameters> - struct longlat_other : public detail::latlong::base_latlong_other<CalculationType, Parameters> + template <typename T, typename Parameters> + struct longlat_other : public detail::latlong::base_latlong_other<T, Parameters> { - inline longlat_other(const Parameters& par) : detail::latlong::base_latlong_other<CalculationType, Parameters>(par) + inline longlat_other(const Parameters& par) : detail::latlong::base_latlong_other<T, Parameters>(par) { detail::latlong::setup_longlat(this->m_par); } @@ -232,53 +230,53 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::longlat, longlat_other, longlat_other) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class lonlat_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class lonlat_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<lonlat_other<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<lonlat_other<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class latlon_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class latlon_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<latlon_other<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<latlon_other<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class latlong_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class latlong_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<latlong_other<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<latlong_other<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class longlat_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class longlat_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<longlat_other<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<longlat_other<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void latlong_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void latlong_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("lonlat", new lonlat_entry<CalculationType, Parameters>); - factory.add_to_factory("latlon", new latlon_entry<CalculationType, Parameters>); - factory.add_to_factory("latlong", new latlong_entry<CalculationType, Parameters>); - factory.add_to_factory("longlat", new longlat_entry<CalculationType, Parameters>); + factory.add_to_factory("lonlat", new lonlat_entry<T, Parameters>); + factory.add_to_factory("latlon", new latlon_entry<T, Parameters>); + factory.add_to_factory("latlong", new latlong_entry<T, Parameters>); + factory.add_to_factory("longlat", new longlat_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/lcc.hpp b/boost/geometry/srs/projections/proj/lcc.hpp index 609c08491c..f8fdd015ea 100644 --- a/boost/geometry/srs/projections/proj/lcc.hpp +++ b/boost/geometry/srs/projections/proj/lcc.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_LCC_HPP -#define BOOST_GEOMETRY_PROJECTIONS_LCC_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_LCC_HPP +#define BOOST_GEOMETRY_PROJECTIONS_LCC_HPP + #include <boost/geometry/util/math.hpp> #include <boost/math/special_functions/hypot.hpp> @@ -58,7 +57,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct lcc {}; + struct lcc {}; // Lambert Conformal Conic }} //namespace srs::par4 @@ -67,7 +66,7 @@ namespace projections #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace lcc { - static const double EPS10 = 1.e-10; + static const double epsilon10 = 1.e-10; template <typename T> struct par_lcc @@ -81,88 +80,73 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_lcc_ellipsoid : public base_t_fi<base_lcc_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_lcc_ellipsoid + : public base_t_fi<base_lcc_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_lcc<CalculationType> m_proj_parm; + par_lcc<T> m_proj_parm; inline base_lcc_ellipsoid(const Parameters& par) - : base_t_fi<base_lcc_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_lcc_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) ellipsoid & spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType FORTPI = detail::FORTPI<CalculationType>(); - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T fourth_pi = detail::fourth_pi<T>(); + static const T half_pi = detail::half_pi<T>(); + + T rho; - CalculationType rho; - if (fabs(fabs(lp_lat) - HALFPI) < EPS10) { - if ((lp_lat * this->m_proj_parm.n) <= 0.) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + if (fabs(fabs(lp_lat) - half_pi) < epsilon10) { + if ((lp_lat * this->m_proj_parm.n) <= 0.) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } rho = 0.; - } else - rho = this->m_proj_parm.c * (this->m_proj_parm.ellips ? pow(pj_tsfn(lp_lat, sin(lp_lat), - this->m_par.e), this->m_proj_parm.n) : pow(tan(FORTPI + .5 * lp_lat), -this->m_proj_parm.n)); - xy_x = this->m_par.k0 * (rho * sin( lp_lon *= this->m_proj_parm.n ) ); + } else { + rho = this->m_proj_parm.c * (this->m_proj_parm.ellips + ? math::pow(pj_tsfn(lp_lat, sin(lp_lat), this->m_par.e), this->m_proj_parm.n) + : math::pow(tan(fourth_pi + T(0.5) * lp_lat), -this->m_proj_parm.n)); + } + lp_lon *= this->m_proj_parm.n; + xy_x = this->m_par.k0 * (rho * sin( lp_lon) ); xy_y = this->m_par.k0 * (this->m_proj_parm.rho0 - rho * cos(lp_lon) ); } // INVERSE(e_inverse) ellipsoid & spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); + + T rho; - CalculationType rho; xy_x /= this->m_par.k0; xy_y /= this->m_par.k0; - if( (rho = boost::math::hypot(xy_x, xy_y = this->m_proj_parm.rho0 - xy_y)) != 0.0) { + + xy_y = this->m_proj_parm.rho0 - xy_y; + rho = boost::math::hypot(xy_x, xy_y); + if(rho != 0.0) { if (this->m_proj_parm.n < 0.) { rho = -rho; xy_x = -xy_x; xy_y = -xy_y; } 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) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + lp_lat = pj_phi2(math::pow(rho / this->m_proj_parm.c, T(1)/this->m_proj_parm.n), this->m_par.e); + if (lp_lat == HUGE_VAL) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } } else - lp_lat = 2. * atan(pow(this->m_proj_parm.c / rho, 1./this->m_proj_parm.n)) - HALFPI; + lp_lat = 2. * atan(math::pow(this->m_proj_parm.c / rho, T(1)/this->m_proj_parm.n)) - half_pi; lp_lon = atan2(xy_x, xy_y) / this->m_proj_parm.n; } else { lp_lon = 0.; - lp_lat = this->m_proj_parm.n > 0. ? HALFPI : -HALFPI; + lp_lat = this->m_proj_parm.n > 0. ? half_pi : -half_pi; } } - // SPECIAL(fac) - #ifdef SPECIAL_FACTORS_NOT_CONVERTED - inline void fac(Geographic lp, Factors &fac) const - { - static const CalculationType FORTPI = detail::FORTPI<CalculationType>(); - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); - - CalculationType rho; - if (fabs(fabs(lp_lat) - HALFPI) < EPS10) { - if ((lp_lat * this->m_proj_parm.n) <= 0.) return; - rho = 0.; - } else - rho = this->m_proj_parm.c * (this->m_proj_parm.ellips ? pow(pj_tsfn(lp_lat, sin(lp_lat), - this->m_par.e), this->m_proj_parm.n) : pow(tan(FORTPI + .5 * lp_lat), -this->m_proj_parm.n)); - this->m_fac.code |= IS_ANAL_HK + IS_ANAL_CONV; - this->m_fac.k = this->m_fac.h = this->m_par.k0 * this->m_proj_parm.n * rho / - pj_msfn(sin(lp_lat), cos(lp_lat), this->m_par.es); - this->m_fac.conv = - this->m_proj_parm.n * lp_lon; - } - #endif - static inline std::string get_name() { return "lcc_ellipsoid"; @@ -174,25 +158,26 @@ namespace projections template <typename Parameters, typename T> inline void setup_lcc(Parameters& par, par_lcc<T>& proj_parm) { - static const T FORTPI = detail::FORTPI<T>(); - static const T HALFPI = detail::HALFPI<T>(); + static const T fourth_pi = detail::fourth_pi<T>(); + static const T half_pi = detail::half_pi<T>(); T cosphi, sinphi; int secant; - proj_parm.phi1 = pj_param(par.params, "rlat_1").f; - if (pj_param(par.params, "tlat_2").i) - proj_parm.phi2 = pj_param(par.params, "rlat_2").f; - else { + proj_parm.phi1 = pj_get_param_r(par.params, "lat_1"); + if (pj_param_r(par.params, "lat_2", proj_parm.phi2)) { + /* empty */ + } else { proj_parm.phi2 = proj_parm.phi1; - if (!pj_param(par.params, "tlat_0").i) + if (!pj_param_exists(par.params, "lat_0")) par.phi0 = proj_parm.phi1; } - if (fabs(proj_parm.phi1 + proj_parm.phi2) < EPS10) - BOOST_THROW_EXCEPTION( projection_exception(-21) ); + if (fabs(proj_parm.phi1 + proj_parm.phi2) < epsilon10) + BOOST_THROW_EXCEPTION( projection_exception(error_conic_lat_equal) ); + proj_parm.n = sinphi = sin(proj_parm.phi1); cosphi = cos(proj_parm.phi1); - secant = fabs(proj_parm.phi1 - proj_parm.phi2) >= EPS10; + secant = fabs(proj_parm.phi1 - proj_parm.phi2) >= epsilon10; if( (proj_parm.ellips = (par.es != 0.)) ) { double ml1, m1; @@ -200,21 +185,21 @@ namespace projections m1 = pj_msfn(sinphi, cosphi, par.es); ml1 = pj_tsfn(proj_parm.phi1, sinphi, par.e); if (secant) { /* secant cone */ - proj_parm.n = log(m1 / - pj_msfn(sinphi = sin(proj_parm.phi2), cos(proj_parm.phi2), par.es)); + sinphi = sin(proj_parm.phi2); + proj_parm.n = log(m1 / pj_msfn(sinphi, cos(proj_parm.phi2), par.es)); proj_parm.n /= log(ml1 / pj_tsfn(proj_parm.phi2, sinphi, par.e)); } - proj_parm.c = (proj_parm.rho0 = m1 * pow(ml1, -proj_parm.n) / proj_parm.n); - proj_parm.rho0 *= (fabs(fabs(par.phi0) - HALFPI) < EPS10) ? 0. : - pow(pj_tsfn(par.phi0, sin(par.phi0), par.e), proj_parm.n); + proj_parm.c = (proj_parm.rho0 = m1 * math::pow(ml1, -proj_parm.n) / proj_parm.n); + proj_parm.rho0 *= (fabs(fabs(par.phi0) - half_pi) < epsilon10) ? T(0) : + math::pow(pj_tsfn(par.phi0, sin(par.phi0), par.e), proj_parm.n); } else { if (secant) proj_parm.n = log(cosphi / cos(proj_parm.phi2)) / - log(tan(FORTPI + .5 * proj_parm.phi2) / - tan(FORTPI + .5 * proj_parm.phi1)); - proj_parm.c = cosphi * pow(tan(FORTPI + .5 * proj_parm.phi1), proj_parm.n) / proj_parm.n; - proj_parm.rho0 = (fabs(fabs(par.phi0) - HALFPI) < EPS10) ? 0. : - proj_parm.c * pow(tan(FORTPI + .5 * par.phi0), -proj_parm.n); + log(tan(fourth_pi + .5 * proj_parm.phi2) / + tan(fourth_pi + .5 * proj_parm.phi1)); + proj_parm.c = cosphi * math::pow(tan(fourth_pi + T(0.5) * proj_parm.phi1), proj_parm.n) / proj_parm.n; + proj_parm.rho0 = (fabs(fabs(par.phi0) - half_pi) < epsilon10) ? 0. : + proj_parm.c * math::pow(tan(fourth_pi + T(0.5) * par.phi0), -proj_parm.n); } } @@ -238,10 +223,10 @@ namespace projections \par Example \image html ex_lcc.gif */ - template <typename CalculationType, typename Parameters> - struct lcc_ellipsoid : public detail::lcc::base_lcc_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct lcc_ellipsoid : public detail::lcc::base_lcc_ellipsoid<T, Parameters> { - inline lcc_ellipsoid(const Parameters& par) : detail::lcc::base_lcc_ellipsoid<CalculationType, Parameters>(par) + inline lcc_ellipsoid(const Parameters& par) : detail::lcc::base_lcc_ellipsoid<T, Parameters>(par) { detail::lcc::setup_lcc(this->m_par, this->m_proj_parm); } @@ -255,20 +240,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::lcc, lcc_ellipsoid, lcc_ellipsoid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class lcc_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class lcc_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<lcc_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<lcc_ellipsoid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void lcc_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void lcc_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("lcc", new lcc_entry<CalculationType, Parameters>); + factory.add_to_factory("lcc", new lcc_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/lcca.hpp b/boost/geometry/srs/projections/proj/lcca.hpp index a1a2069d8f..ddbdfdb0d1 100644 --- a/boost/geometry/srs/projections/proj/lcca.hpp +++ b/boost/geometry/srs/projections/proj/lcca.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_LCCA_HPP -#define BOOST_GEOMETRY_PROJECTIONS_LCCA_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,7 +37,55 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -#include <boost/core/ignore_unused.hpp> +/***************************************************************************** + + Lambert Conformal Conic Alternative + ----------------------------------- + + This is Gerald Evenden's 2003 implementation of an alternative + "almost" LCC, which has been in use historically, but which + should NOT be used for new projects - i.e: use this implementation + if you need interoperability with old data represented in this + projection, but not in any other case. + + The code was originally discussed on the PROJ.4 mailing list in + a thread archived over at + + http://lists.maptools.org/pipermail/proj/2003-March/000644.html + + It was discussed again in the thread starting at + + http://lists.maptools.org/pipermail/proj/2017-October/007828.html + and continuing at + http://lists.maptools.org/pipermail/proj/2017-November/007831.html + + which prompted Clifford J. Mugnier to add these clarifying notes: + + The French Army Truncated Cubic Lambert (partially conformal) Conic + projection is the Legal system for the projection in France between + the late 1800s and 1948 when the French Legislature changed the law + to recognize the fully conformal version. + + It was (might still be in one or two North African prior French + Colonies) used in North Africa in Algeria, Tunisia, & Morocco, as + well as in Syria during the Levant. + + Last time I have seen it used was about 30+ years ago in + Algeria when it was used to define Lease Block boundaries for + Petroleum Exploration & Production. + + (signed) + + Clifford J. Mugnier, c.p., c.m.s. + Chief of Geodesy + LSU Center for GeoInformatics + Dept. of Civil Engineering + LOUISIANA STATE UNIVERSITY + +*****************************************************************************/ + +#ifndef BOOST_GEOMETRY_PROJECTIONS_LCCA_HPP +#define BOOST_GEOMETRY_PROJECTIONS_LCCA_HPP #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> @@ -64,13 +108,13 @@ namespace projections namespace detail { namespace lcca { - static const int MAX_ITER = 10; - static const double DEL_TOL = 1e-12; + static const int max_iter = 10; + static const double del_tol = 1e-12; template <typename T> struct par_lcca { - T en[EN_SIZE]; + detail::en<T> en; T r0, l, M0; T C; }; @@ -88,25 +132,21 @@ namespace projections } // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_lcca_ellipsoid : public base_t_fi<base_lcca_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_lcca_ellipsoid + : public base_t_fi<base_lcca_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_lcca<CalculationType> m_proj_parm; + par_lcca<T> m_proj_parm; inline base_lcca_ellipsoid(const Parameters& par) - : base_t_fi<base_lcca_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_lcca_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) ellipsoid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType S, r, dr; + T S, r, dr; S = pj_mlfn(lp_lat, sin(lp_lat), cos(lp_lat), this->m_proj_parm.en) - this->m_proj_parm.M0; dr = fS(S, this->m_proj_parm.C); @@ -117,9 +157,9 @@ namespace projections // INVERSE(e_inverse) ellipsoid & spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType theta, dr, S, dif; + T theta, dr, S, dif; int i; xy_x /= this->m_par.k0; @@ -128,12 +168,13 @@ namespace projections dr = xy_y - xy_x * tan(0.5 * theta); lp_lon = theta / this->m_proj_parm.l; S = dr; - for (i = MAX_ITER; i ; --i) { + for (i = max_iter; i ; --i) { S -= (dif = (fS(S, this->m_proj_parm.C) - dr) / fSp(S, this->m_proj_parm.C)); - if (fabs(dif) < DEL_TOL) break; + if (fabs(dif) < del_tol) break; + } + if (!i) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); } - if (!i) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); lp_lat = pj_inv_mlfn(S + this->m_proj_parm.M0, this->m_par.es, this->m_proj_parm.en); } @@ -148,14 +189,13 @@ namespace projections template <typename Parameters, typename T> inline void setup_lcca(Parameters& par, par_lcca<T>& proj_parm) { - T s2p0, N0, R0, tan0, tan20; - - if (!pj_enfn(par.es, proj_parm.en)) - BOOST_THROW_EXCEPTION( projection_exception(0) ); - if (!pj_param(par.params, "tlat_0").i) - BOOST_THROW_EXCEPTION( projection_exception(50) ); - if (par.phi0 == 0.) - BOOST_THROW_EXCEPTION( projection_exception(51) ); + T s2p0, N0, R0, tan0; + + proj_parm.en = pj_enfn<T>(par.es); + + if (par.phi0 == 0.) { + BOOST_THROW_EXCEPTION( projection_exception(error_lat_0_is_zero) ); + } proj_parm.l = sin(par.phi0); proj_parm.M0 = pj_mlfn(par.phi0, proj_parm.l, cos(par.phi0), proj_parm.en); s2p0 = proj_parm.l * proj_parm.l; @@ -163,10 +203,8 @@ namespace projections N0 = sqrt(R0); R0 *= par.one_es * N0; tan0 = tan(par.phi0); - tan20 = tan0 * tan0; proj_parm.r0 = N0 / tan0; proj_parm.C = 1. / (6. * R0 * N0); - boost::ignore_unused(tan20); } }} // namespace detail::lcca @@ -187,10 +225,10 @@ namespace projections \par Example \image html ex_lcca.gif */ - template <typename CalculationType, typename Parameters> - struct lcca_ellipsoid : public detail::lcca::base_lcca_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct lcca_ellipsoid : public detail::lcca::base_lcca_ellipsoid<T, Parameters> { - inline lcca_ellipsoid(const Parameters& par) : detail::lcca::base_lcca_ellipsoid<CalculationType, Parameters>(par) + inline lcca_ellipsoid(const Parameters& par) : detail::lcca::base_lcca_ellipsoid<T, Parameters>(par) { detail::lcca::setup_lcca(this->m_par, this->m_proj_parm); } @@ -204,20 +242,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::lcca, lcca_ellipsoid, lcca_ellipsoid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class lcca_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class lcca_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<lcca_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<lcca_ellipsoid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void lcca_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void lcca_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("lcca", new lcca_entry<CalculationType, Parameters>); + factory.add_to_factory("lcca", new lcca_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/loxim.hpp b/boost/geometry/srs/projections/proj/loxim.hpp index f88eb4ca6e..badac3c765 100644 --- a/boost/geometry/srs/projections/proj/loxim.hpp +++ b/boost/geometry/srs/projections/proj/loxim.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_LOXIM_HPP -#define BOOST_GEOMETRY_PROJECTIONS_LOXIM_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_LOXIM_HPP +#define BOOST_GEOMETRY_PROJECTIONS_LOXIM_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -53,7 +52,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct loxim {}; + struct loxim {}; // Loximuthal }} //namespace srs::par4 @@ -62,7 +61,7 @@ namespace projections #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace loxim { - static const double EPS = 1e-8; + static const double epsilon = 1e-8; template <typename T> struct par_loxim @@ -73,33 +72,29 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_loxim_spheroid : public base_t_fi<base_loxim_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_loxim_spheroid + : public base_t_fi<base_loxim_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_loxim<CalculationType> m_proj_parm; + par_loxim<T> m_proj_parm; inline base_loxim_spheroid(const Parameters& par) - : base_t_fi<base_loxim_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_loxim_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType FORTPI = detail::FORTPI<CalculationType>(); - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T fourth_pi = detail::fourth_pi<T>(); + static const T half_pi = detail::half_pi<T>(); xy_y = lp_lat - this->m_proj_parm.phi1; - if (fabs(xy_y) < EPS) + if (fabs(xy_y) < epsilon) xy_x = lp_lon * this->m_proj_parm.cosphi1; else { - xy_x = FORTPI + 0.5 * lp_lat; - if (fabs(xy_x) < EPS || fabs(fabs(xy_x) - HALFPI) < EPS) + xy_x = fourth_pi + 0.5 * lp_lat; + if (fabs(xy_x) < epsilon || fabs(fabs(xy_x) - half_pi) < epsilon) xy_x = 0.; else xy_x = lp_lon * xy_y / log( tan(xy_x) / this->m_proj_parm.tanphi1 ); @@ -108,20 +103,21 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType FORTPI = detail::FORTPI<CalculationType>(); - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T fourth_pi = detail::fourth_pi<T>(); + static const T half_pi = detail::half_pi<T>(); lp_lat = xy_y + this->m_proj_parm.phi1; - if (fabs(xy_y) < EPS) + if (fabs(xy_y) < epsilon) { lp_lon = xy_x / this->m_proj_parm.cosphi1; - else - if (fabs( lp_lon = FORTPI + 0.5 * lp_lat ) < EPS || - fabs(fabs(lp_lon) - HALFPI) < EPS) + } else { + lp_lon = fourth_pi + 0.5 * lp_lat; + if (fabs(lp_lon) < epsilon || fabs(fabs(lp_lon) - half_pi) < epsilon) lp_lon = 0.; else lp_lon = xy_x * log( tan(lp_lon) / this->m_proj_parm.tanphi1 ) / xy_y ; + } } static inline std::string get_name() @@ -135,12 +131,15 @@ namespace projections template <typename Parameters, typename T> inline void setup_loxim(Parameters& par, par_loxim<T>& proj_parm) { - static const T FORTPI = detail::FORTPI<T>(); + static const T fourth_pi = detail::fourth_pi<T>(); + + proj_parm.phi1 = pj_get_param_r(par.params, "lat_1"); + proj_parm.cosphi1 = cos(proj_parm.phi1); + if (proj_parm.cosphi1 < epsilon) + BOOST_THROW_EXCEPTION( projection_exception(error_lat_larger_than_90) ); + + proj_parm.tanphi1 = tan(fourth_pi + 0.5 * proj_parm.phi1); - proj_parm.phi1 = pj_param(par.params, "rlat_1").f; - if ((proj_parm.cosphi1 = cos(proj_parm.phi1)) < EPS) - BOOST_THROW_EXCEPTION( projection_exception(-22) ); - proj_parm.tanphi1 = tan(FORTPI + 0.5 * proj_parm.phi1); par.es = 0.; } @@ -161,10 +160,10 @@ namespace projections \par Example \image html ex_loxim.gif */ - template <typename CalculationType, typename Parameters> - struct loxim_spheroid : public detail::loxim::base_loxim_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct loxim_spheroid : public detail::loxim::base_loxim_spheroid<T, Parameters> { - inline loxim_spheroid(const Parameters& par) : detail::loxim::base_loxim_spheroid<CalculationType, Parameters>(par) + inline loxim_spheroid(const Parameters& par) : detail::loxim::base_loxim_spheroid<T, Parameters>(par) { detail::loxim::setup_loxim(this->m_par, this->m_proj_parm); } @@ -178,20 +177,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::loxim, loxim_spheroid, loxim_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class loxim_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class loxim_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<loxim_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<loxim_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void loxim_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void loxim_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("loxim", new loxim_entry<CalculationType, Parameters>); + factory.add_to_factory("loxim", new loxim_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/lsat.hpp b/boost/geometry/srs/projections/proj/lsat.hpp index d305339d5b..6ed729f75c 100644 --- a/boost/geometry/srs/projections/proj/lsat.hpp +++ b/boost/geometry/srs/projections/proj/lsat.hpp @@ -1,8 +1,4 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_LSAT_HPP -#define BOOST_GEOMETRY_PROJECTIONS_LSAT_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_LSAT_HPP +#define BOOST_GEOMETRY_PROJECTIONS_LSAT_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -54,7 +53,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct lsat {}; + struct lsat {}; // Space oblique for LANDSAT }} //namespace srs::par4 @@ -63,9 +62,7 @@ namespace projections #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace lsat { - static const double TOL = 1e-7; - //static const double PI_HALFPI = 4.71238898038468985766; - //static const double TWOPI_HALFPI = 7.85398163397448309610; + static const double tolerance = 1e-7; template <typename T> struct par_lsat @@ -79,18 +76,21 @@ namespace projections inline void seraz0(T lam, T const& mult, par_lsat<T>& proj_parm) { - T sdsq, h, s, fc, sd, sq, d__1; + T sdsq, h, s, fc, sd, sq, d__1 = 0; lam *= geometry::math::d2r<T>(); sd = sin(lam); sdsq = sd * sd; - s = proj_parm.p22 * proj_parm.sa * cos(lam) * sqrt((1. + proj_parm.t * sdsq) / (( - 1. + proj_parm.w * sdsq) * (1. + proj_parm.q * sdsq))); + s = proj_parm.p22 * proj_parm.sa * cos(lam) * sqrt((1. + proj_parm.t * sdsq) + / ((1. + proj_parm.w * sdsq) * (1. + proj_parm.q * sdsq))); + d__1 = 1. + proj_parm.q * sdsq; - h = sqrt((1. + proj_parm.q * sdsq) / (1. + proj_parm.w * sdsq)) * ((1. + - proj_parm.w * sdsq) / (d__1 * d__1) - proj_parm.p22 * proj_parm.ca); + h = sqrt((1. + proj_parm.q * sdsq) / (1. + proj_parm.w * sdsq)) * ((1. + proj_parm.w * sdsq) + / (d__1 * d__1) - proj_parm.p22 * proj_parm.ca); + sq = sqrt(proj_parm.xj * proj_parm.xj + s * s); - proj_parm.b += fc = mult * (h * proj_parm.xj - s * s) / sq; + fc = mult * (h * proj_parm.xj - s * s) / sq; + proj_parm.b += fc; proj_parm.a2 += fc * cos(lam + lam); proj_parm.a4 += fc * cos(lam * 4.); fc = mult * s * (h + proj_parm.xj) / sq; @@ -99,68 +99,73 @@ namespace projections } // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_lsat_ellipsoid : public base_t_fi<base_lsat_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_lsat_ellipsoid + : public base_t_fi<base_lsat_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_lsat<CalculationType> m_proj_parm; + par_lsat<T> m_proj_parm; inline base_lsat_ellipsoid(const Parameters& par) - : base_t_fi<base_lsat_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_lsat_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) ellipsoid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType FORTPI = detail::FORTPI<CalculationType>(); - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); - static const CalculationType PI_HALFPI = detail::PI_HALFPI<CalculationType>(); - static const CalculationType TWOPI_HALFPI = detail::TWOPI_HALFPI<CalculationType>(); + static const T fourth_pi = detail::fourth_pi<T>(); + static const T half_pi = detail::half_pi<T>(); + static const T one_and_half_pi = detail::one_and_half_pi<T>(); + static const T two_and_half_pi = detail::two_and_half_pi<T>(); int l, nn; - CalculationType lamt, xlam, sdsq, c, d, s, lamdp, phidp, lampp, tanph, - lamtp, cl, sd, sp, fac, sav, tanphi; - - if (lp_lat > HALFPI) - lp_lat = HALFPI; - else if (lp_lat < -HALFPI) - lp_lat = -HALFPI; - lampp = lp_lat >= 0. ? HALFPI : PI_HALFPI; + T lamt = 0.0, xlam, sdsq, c, d, s, lamdp = 0.0, phidp, lampp, tanph; + T lamtp, cl, sd, sp, sav, tanphi; + + if (lp_lat > half_pi) + lp_lat = half_pi; + else if (lp_lat < -half_pi) + lp_lat = -half_pi; + + if (lp_lat >= 0. ) + lampp = half_pi; + else + lampp = one_and_half_pi; tanphi = tan(lp_lat); for (nn = 0;;) { + T fac; sav = lampp; lamtp = lp_lon + this->m_proj_parm.p22 * lampp; cl = cos(lamtp); - if (fabs(cl) < TOL) - lamtp -= TOL; - fac = lampp - sin(lampp) * (cl < 0. ? -HALFPI : HALFPI); + if (fabs(cl) < tolerance) + lamtp -= tolerance; + if( cl < 0 ) + fac = lampp + sin(lampp) * half_pi; + else + fac = lampp - sin(lampp) * half_pi; for (l = 50; l; --l) { lamt = lp_lon + this->m_proj_parm.p22 * sav; - if (fabs(c = cos(lamt)) < TOL) - lamt -= TOL; + c = cos(lamt); + if (fabs(c) < tolerance) + lamt -= tolerance; xlam = (this->m_par.one_es * tanphi * this->m_proj_parm.sa + sin(lamt) * this->m_proj_parm.ca) / c; lamdp = atan(xlam) + fac; - if (fabs(fabs(sav) - fabs(lamdp)) < TOL) + if (fabs(fabs(sav) - fabs(lamdp)) < tolerance) break; sav = lamdp; } if (!l || ++nn >= 3 || (lamdp > this->m_proj_parm.rlm && lamdp < this->m_proj_parm.rlm2)) break; if (lamdp <= this->m_proj_parm.rlm) - lampp = TWOPI_HALFPI; + lampp = two_and_half_pi; else if (lamdp >= this->m_proj_parm.rlm2) - lampp = HALFPI; + lampp = half_pi; } if (l) { sp = sin(lp_lat); phidp = aasin((this->m_par.one_es * this->m_proj_parm.ca * sp - this->m_proj_parm.sa * cos(lp_lat) * sin(lamt)) / sqrt(1. - this->m_par.es * sp * sp)); - tanph = log(tan(FORTPI + .5 * phidp)); + tanph = log(tan(fourth_pi + .5 * phidp)); sd = sin(lamdp); sdsq = sd * sd; s = this->m_proj_parm.p22 * this->m_proj_parm.sa * cos(lamdp) * sqrt((1. + this->m_proj_parm.t * sdsq) @@ -175,13 +180,13 @@ namespace projections // INVERSE(e_inverse) ellipsoid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType FORTPI = detail::FORTPI<CalculationType>(); - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T fourth_pi = detail::fourth_pi<T>(); + static const T half_pi = detail::half_pi<T>(); int nn; - CalculationType lamt, sdsq, s, lamdp, phidp, sppsq, dd, sd, sl, fac, scl, sav, spp; + T lamt, sdsq, s, lamdp, phidp, sppsq, dd, sd, sl, fac, scl, sav, spp; lamdp = xy_x / this->m_proj_parm.b; nn = 50; @@ -195,14 +200,14 @@ namespace projections 2. * lamdp) - this->m_proj_parm.a4 * sin(lamdp * 4.) - s / this->m_proj_parm.xj * ( this->m_proj_parm.c1 * sin(lamdp) + this->m_proj_parm.c3 * sin(lamdp * 3.)); lamdp /= this->m_proj_parm.b; - } while (fabs(lamdp - sav) >= TOL && --nn); + } while (fabs(lamdp - sav) >= tolerance && --nn); sl = sin(lamdp); fac = exp(sqrt(1. + s * s / this->m_proj_parm.xj / this->m_proj_parm.xj) * (xy_y - this->m_proj_parm.c1 * sl - this->m_proj_parm.c3 * sin(lamdp * 3.))); - phidp = 2. * (atan(fac) - FORTPI); + phidp = 2. * (atan(fac) - fourth_pi); dd = sl * sl; - if (fabs(cos(lamdp)) < TOL) - lamdp -= TOL; + if (fabs(cos(lamdp)) < tolerance) + lamdp -= tolerance; spp = sin(phidp); sppsq = spp * spp; lamt = atan(((1. - sppsq * this->m_par.rone_es) * tan(lamdp) * @@ -211,9 +216,9 @@ namespace projections * (1. + this->m_proj_parm.u))); sl = lamt >= 0. ? 1. : -1.; scl = cos(lamdp) >= 0. ? 1. : -1; - lamt -= HALFPI * (1. - scl) * sl; + lamt -= half_pi * (1. - scl) * sl; lp_lon = lamt - this->m_proj_parm.p22 * lamdp; - if (fabs(this->m_proj_parm.sa) < TOL) + if (fabs(this->m_proj_parm.sa) < tolerance) lp_lat = aasin(spp / sqrt(this->m_par.one_es * this->m_par.one_es + this->m_par.es * sppsq)); else lp_lat = atan((tan(lamdp) * cos(lamt) - this->m_proj_parm.ca * sin(lamt)) / @@ -231,23 +236,29 @@ namespace projections template <typename Parameters, typename T> inline void setup_lsat(Parameters& par, par_lsat<T>& proj_parm) { + static T const d2r = geometry::math::d2r<T>(); + static T const pi = detail::pi<T>(); + static T const two_pi = detail::two_pi<T>(); + int land, path; T lam, alf, esc, ess; - land = pj_param(par.params, "ilsat").i; + land = pj_get_param_i(par.params, "lsat"); if (land <= 0 || land > 5) - BOOST_THROW_EXCEPTION( projection_exception(-28) ); - path = pj_param(par.params, "ipath").i; + BOOST_THROW_EXCEPTION( projection_exception(error_lsat_not_in_range) ); + + path = pj_get_param_i(par.params, "path"); if (path <= 0 || path > (land <= 3 ? 251 : 233)) - BOOST_THROW_EXCEPTION( projection_exception(-29) ); + BOOST_THROW_EXCEPTION( projection_exception(error_path_not_in_range) ); + if (land <= 3) { - par.lam0 = geometry::math::d2r<T>() * 128.87 - geometry::math::two_pi<T>() / 251. * path; + par.lam0 = d2r * 128.87 - two_pi / 251. * path; proj_parm.p22 = 103.2669323; - alf = geometry::math::d2r<T>() * 99.092; + alf = d2r * 99.092; } else { - par.lam0 = geometry::math::d2r<T>() * 129.3 - geometry::math::two_pi<T>() / 233. * path; + par.lam0 = d2r * 129.3 - two_pi / 233. * path; proj_parm.p22 = 98.8841202; - alf = geometry::math::d2r<T>() * 98.2; + alf = d2r * 98.2; } proj_parm.p22 /= 1440.; proj_parm.sa = sin(alf); @@ -262,8 +273,8 @@ namespace projections proj_parm.t = ess * (2. - par.es) * par.rone_es * par.rone_es; proj_parm.u = esc * par.rone_es; proj_parm.xj = par.one_es * par.one_es * par.one_es; - proj_parm.rlm = geometry::math::pi<T>() * (1. / 248. + .5161290322580645); - proj_parm.rlm2 = proj_parm.rlm + geometry::math::two_pi<T>(); + proj_parm.rlm = pi * (1. / 248. + .5161290322580645); + proj_parm.rlm2 = proj_parm.rlm + two_pi; proj_parm.a2 = proj_parm.a4 = proj_parm.b = proj_parm.c1 = proj_parm.c3 = 0.; seraz0(0., 1., proj_parm); for (lam = 9.; lam <= 81.0001; lam += 18.) @@ -297,10 +308,10 @@ namespace projections \par Example \image html ex_lsat.gif */ - template <typename CalculationType, typename Parameters> - struct lsat_ellipsoid : public detail::lsat::base_lsat_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct lsat_ellipsoid : public detail::lsat::base_lsat_ellipsoid<T, Parameters> { - inline lsat_ellipsoid(const Parameters& par) : detail::lsat::base_lsat_ellipsoid<CalculationType, Parameters>(par) + inline lsat_ellipsoid(const Parameters& par) : detail::lsat::base_lsat_ellipsoid<T, Parameters>(par) { detail::lsat::setup_lsat(this->m_par, this->m_proj_parm); } @@ -314,20 +325,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::lsat, lsat_ellipsoid, lsat_ellipsoid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class lsat_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class lsat_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<lsat_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<lsat_ellipsoid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void lsat_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void lsat_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("lsat", new lsat_entry<CalculationType, Parameters>); + factory.add_to_factory("lsat", new lsat_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/mbt_fps.hpp b/boost/geometry/srs/projections/proj/mbt_fps.hpp index 3823725f1c..130590f8e5 100644 --- a/boost/geometry/srs/projections/proj/mbt_fps.hpp +++ b/boost/geometry/srs/projections/proj/mbt_fps.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_MBT_FPS_HPP -#define BOOST_GEOMETRY_PROJECTIONS_MBT_FPS_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_MBT_FPS_HPP +#define BOOST_GEOMETRY_PROJECTIONS_MBT_FPS_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -52,7 +51,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct mbt_fps {}; + struct mbt_fps {}; // McBryde-Thomas Flat-Pole Sine (No. 2) }} //namespace srs::par4 @@ -62,8 +61,8 @@ namespace projections namespace detail { namespace mbt_fps { - static const int MAX_ITER = 10; - static const double LOOP_TOL = 1e-7; + static const int max_iter = 10; + static const double loop_tol = 1e-7; static const double C1 = 0.45503; static const double C2 = 1.36509; static const double C3 = 1.41546; @@ -72,37 +71,32 @@ namespace projections //static const double C1_2 = 0.33333333333333333333333333; template <typename T> - inline T C1_2() { return detail::THIRD<T>(); } + inline T C1_2() { return detail::third<T>(); } // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_mbt_fps_spheroid : public base_t_fi<base_mbt_fps_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_mbt_fps_spheroid + : public base_t_fi<base_mbt_fps_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_mbt_fps_spheroid(const Parameters& par) - : base_t_fi<base_mbt_fps_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_mbt_fps_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType C1_2 = mbt_fps::C1_2<CalculationType>(); + static const T C1_2 = mbt_fps::C1_2<T>(); - CalculationType k, V, t; + T k, V, t; int i; k = C3 * sin(lp_lat); - for (i = MAX_ITER; i ; --i) { + for (i = max_iter; i ; --i) { t = lp_lat / C2; lp_lat -= V = (C1 * sin(t) + sin(lp_lat) - k) / (C1_2 * cos(t) + cos(lp_lat)); - if (fabs(V) < LOOP_TOL) + if (fabs(V) < loop_tol) break; } t = lp_lat / C2; @@ -112,9 +106,9 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType t; + T t; lp_lat = C2 * (t = aasin(xy_y / C_y)); lp_lon = xy_x / (C_x * (1. + 3. * cos(lp_lat)/cos(t))); @@ -150,10 +144,10 @@ namespace projections \par Example \image html ex_mbt_fps.gif */ - template <typename CalculationType, typename Parameters> - struct mbt_fps_spheroid : public detail::mbt_fps::base_mbt_fps_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct mbt_fps_spheroid : public detail::mbt_fps::base_mbt_fps_spheroid<T, Parameters> { - inline mbt_fps_spheroid(const Parameters& par) : detail::mbt_fps::base_mbt_fps_spheroid<CalculationType, Parameters>(par) + inline mbt_fps_spheroid(const Parameters& par) : detail::mbt_fps::base_mbt_fps_spheroid<T, Parameters>(par) { detail::mbt_fps::setup_mbt_fps(this->m_par); } @@ -167,20 +161,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::mbt_fps, mbt_fps_spheroid, mbt_fps_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class mbt_fps_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class mbt_fps_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<mbt_fps_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<mbt_fps_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void mbt_fps_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void mbt_fps_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("mbt_fps", new mbt_fps_entry<CalculationType, Parameters>); + factory.add_to_factory("mbt_fps", new mbt_fps_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/mbtfpp.hpp b/boost/geometry/srs/projections/proj/mbtfpp.hpp index 123d1e4b02..cd09fdf181 100644 --- a/boost/geometry/srs/projections/proj/mbtfpp.hpp +++ b/boost/geometry/srs/projections/proj/mbtfpp.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_MBTFPP_HPP -#define BOOST_GEOMETRY_PROJECTIONS_MBTFPP_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_MBTFPP_HPP +#define BOOST_GEOMETRY_PROJECTIONS_MBTFPP_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -53,7 +52,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct mbtfpp {}; + struct mbtfpp {}; // McBride-Thomas Flat-Polar Parabolic }} //namespace srs::par4 @@ -68,33 +67,23 @@ namespace projections static const double FYC = 3.40168025708304504493; //static const double C23 = .66666666666666666666; //static const double C13 = .33333333333333333333; - static const double ONEEPS = 1.0000001; - - template <typename T> - inline T C23() { return detail::TWOTHIRD<T>(); } - template <typename T> - inline T C13() { return detail::THIRD<T>(); } + static const double one_plus_eps = 1.0000001; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_mbtfpp_spheroid : public base_t_fi<base_mbtfpp_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_mbtfpp_spheroid + : public base_t_fi<base_mbtfpp_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_mbtfpp_spheroid(const Parameters& par) - : base_t_fi<base_mbtfpp_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_mbtfpp_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType C23 = mbtfpp::C23<CalculationType>(); - static const CalculationType C13 = mbtfpp::C13<CalculationType>(); + static const T C23 = detail::two_thirds<T>(); + static const T C13 = detail::third<T>(); lp_lat = asin(CS_ * sin(lp_lat)); xy_x = FXC * lp_lon * (2. * cos(C23 * lp_lat) - 1.); @@ -103,25 +92,28 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); - static const CalculationType C23 = mbtfpp::C23<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); + static const T C23 = detail::two_thirds<T>(); lp_lat = xy_y / FYC; if (fabs(lp_lat) >= 1.) { - if (fabs(lp_lat) > ONEEPS) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); - else - lp_lat = (lp_lat < 0.) ? -HALFPI : HALFPI; + if (fabs(lp_lat) > one_plus_eps) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } else { + lp_lat = (lp_lat < 0.) ? -half_pi : half_pi; + } } 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) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); - else - lp_lat = (lp_lat < 0.) ? -HALFPI : HALFPI; + if (fabs(lp_lat) > one_plus_eps) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } else { + lp_lat = (lp_lat < 0.) ? -half_pi : half_pi; + } } else lp_lat = asin(lp_lat); } @@ -155,10 +147,10 @@ namespace projections \par Example \image html ex_mbtfpp.gif */ - template <typename CalculationType, typename Parameters> - struct mbtfpp_spheroid : public detail::mbtfpp::base_mbtfpp_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct mbtfpp_spheroid : public detail::mbtfpp::base_mbtfpp_spheroid<T, Parameters> { - inline mbtfpp_spheroid(const Parameters& par) : detail::mbtfpp::base_mbtfpp_spheroid<CalculationType, Parameters>(par) + inline mbtfpp_spheroid(const Parameters& par) : detail::mbtfpp::base_mbtfpp_spheroid<T, Parameters>(par) { detail::mbtfpp::setup_mbtfpp(this->m_par); } @@ -172,20 +164,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::mbtfpp, mbtfpp_spheroid, mbtfpp_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class mbtfpp_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class mbtfpp_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<mbtfpp_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<mbtfpp_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void mbtfpp_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void mbtfpp_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("mbtfpp", new mbtfpp_entry<CalculationType, Parameters>); + factory.add_to_factory("mbtfpp", new mbtfpp_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/mbtfpq.hpp b/boost/geometry/srs/projections/proj/mbtfpq.hpp index b4eeb34d5a..4d7858c020 100644 --- a/boost/geometry/srs/projections/proj/mbtfpq.hpp +++ b/boost/geometry/srs/projections/proj/mbtfpq.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_MBTFPQ_HPP -#define BOOST_GEOMETRY_PROJECTIONS_MBTFPQ_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_MBTFPQ_HPP +#define BOOST_GEOMETRY_PROJECTIONS_MBTFPQ_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -53,7 +52,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct mbtfpq {}; + struct mbtfpq {}; // McBryde-Thomas Flat-Polar Quartic }} //namespace srs::par4 @@ -63,9 +62,9 @@ namespace projections namespace detail { namespace mbtfpq { - static const int NITER = 20; - static const double EPS = 1e-7; - static const double ONETOL = 1.000001; + static const int n_iter = 20; + static const double epsilon = 1e-7; + static const double one_plus_tol = 1.000001; static const double C = 1.70710678118654752440; static const double RC = 0.58578643762690495119; static const double FYC = 1.87475828462269495505; @@ -74,31 +73,26 @@ namespace projections static const double RXC = 3.20041258076506210122; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_mbtfpq_spheroid : public base_t_fi<base_mbtfpq_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_mbtfpq_spheroid + : public base_t_fi<base_mbtfpq_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_mbtfpq_spheroid(const Parameters& par) - : base_t_fi<base_mbtfpq_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_mbtfpq_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType th1, c; + T th1, c; int i; c = C * sin(lp_lat); - for (i = NITER; i; --i) { + for (i = n_iter; i; --i) { lp_lat -= th1 = (sin(.5*lp_lat) + sin(lp_lat) - c) / (.5*cos(.5*lp_lat) + cos(lp_lat)); - if (fabs(th1) < EPS) break; + if (fabs(th1) < epsilon) break; } xy_x = FXC * lp_lon * (1.0 + 2. * cos(lp_lat)/cos(0.5 * lp_lat)); xy_y = FYC * sin(0.5 * lp_lat); @@ -106,31 +100,31 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType ONEPI = detail::ONEPI<CalculationType>(); - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T pi = detail::pi<T>(); + static const T half_pi = detail::half_pi<T>(); - CalculationType t; + T t; lp_lat = RYC * xy_y; if (fabs(lp_lat) > 1.) { - if (fabs(lp_lat) > ONETOL) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); - else if (lp_lat < 0.) { - t = -1.; lp_lat = -ONEPI; + if (fabs(lp_lat) > one_plus_tol) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } else if (lp_lat < 0.) { + t = -1.; lp_lat = -pi; } else { - t = 1.; lp_lat = ONEPI; + t = 1.; lp_lat = pi; } } else lp_lat = 2. * asin(t = lp_lat); 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) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); - else - lp_lat = lp_lat < 0. ? -HALFPI : HALFPI; + if (fabs(lp_lat) > one_plus_tol) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } else + lp_lat = lp_lat < 0. ? -half_pi : half_pi; else lp_lat = asin(lp_lat); } @@ -164,10 +158,10 @@ namespace projections \par Example \image html ex_mbtfpq.gif */ - template <typename CalculationType, typename Parameters> - struct mbtfpq_spheroid : public detail::mbtfpq::base_mbtfpq_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct mbtfpq_spheroid : public detail::mbtfpq::base_mbtfpq_spheroid<T, Parameters> { - inline mbtfpq_spheroid(const Parameters& par) : detail::mbtfpq::base_mbtfpq_spheroid<CalculationType, Parameters>(par) + inline mbtfpq_spheroid(const Parameters& par) : detail::mbtfpq::base_mbtfpq_spheroid<T, Parameters>(par) { detail::mbtfpq::setup_mbtfpq(this->m_par); } @@ -181,20 +175,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::mbtfpq, mbtfpq_spheroid, mbtfpq_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class mbtfpq_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class mbtfpq_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<mbtfpq_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<mbtfpq_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void mbtfpq_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void mbtfpq_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("mbtfpq", new mbtfpq_entry<CalculationType, Parameters>); + factory.add_to_factory("mbtfpq", new mbtfpq_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/merc.hpp b/boost/geometry/srs/projections/proj/merc.hpp index ac34aee33e..74449f64c8 100644 --- a/boost/geometry/srs/projections/proj/merc.hpp +++ b/boost/geometry/srs/projections/proj/merc.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_MERC_HPP -#define BOOST_GEOMETRY_PROJECTIONS_MERC_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_MERC_HPP +#define BOOST_GEOMETRY_PROJECTIONS_MERC_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -56,7 +55,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct merc {}; + struct merc {}; // Mercator }} //namespace srs::par4 @@ -66,40 +65,37 @@ namespace projections namespace detail { namespace merc { - static const double EPS10 = 1.e-10; + static const double epsilon10 = 1.e-10; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_merc_ellipsoid : public base_t_fi<base_merc_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_merc_ellipsoid + : public base_t_fi<base_merc_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_merc_ellipsoid(const Parameters& par) - : base_t_fi<base_merc_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_merc_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) ellipsoid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); - if (fabs(fabs(lp_lat) - HALFPI) <= EPS10) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + if (fabs(fabs(lp_lat) - half_pi) <= epsilon10) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } 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)); } // INVERSE(e_inverse) ellipsoid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - if ((lp_lat = pj_phi2(exp(- xy_y / this->m_par.k0), this->m_par.e)) == HUGE_VAL) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + if ((lp_lat = pj_phi2(exp(- xy_y / this->m_par.k0), this->m_par.e)) == HUGE_VAL) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } lp_lon = xy_x / this->m_par.k0; } @@ -111,39 +107,35 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_merc_spheroid : public base_t_fi<base_merc_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_merc_spheroid + : public base_t_fi<base_merc_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_merc_spheroid(const Parameters& par) - : base_t_fi<base_merc_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_merc_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); - static const CalculationType FORTPI = detail::FORTPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); + static const T fourth_pi = detail::fourth_pi<T>(); - if (fabs(fabs(lp_lat) - HALFPI) <= EPS10) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + if (fabs(fabs(lp_lat) - half_pi) <= epsilon10) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } xy_x = this->m_par.k0 * lp_lon; - xy_y = this->m_par.k0 * log(tan(FORTPI + .5 * lp_lat)); + xy_y = this->m_par.k0 * log(tan(fourth_pi + .5 * lp_lat)); } // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); - lp_lat = HALFPI - 2. * atan(exp(-xy_y / this->m_par.k0)); + lp_lat = half_pi - 2. * atan(exp(-xy_y / this->m_par.k0)); lp_lon = xy_x / this->m_par.k0; } @@ -159,17 +151,17 @@ namespace projections inline void setup_merc(Parameters& par) { typedef typename Parameters::type calc_t; - static const calc_t HALFPI = detail::HALFPI<calc_t>(); + static const calc_t half_pi = detail::half_pi<calc_t>(); calc_t phits=0.0; int is_phits; - if( (is_phits = pj_param(par.params, "tlat_ts").i) ) { - phits = fabs(pj_param(par.params, "rlat_ts").f); - if (phits >= HALFPI) - BOOST_THROW_EXCEPTION( projection_exception(-24) ); + if( (is_phits = pj_param_r(par.params, "lat_ts", phits)) ) { + phits = fabs(phits); + if (phits >= half_pi) + BOOST_THROW_EXCEPTION( projection_exception(error_lat_ts_larger_than_90) ); } - if (par.es) { /* ellipsoid */ + if (par.es != 0.0) { /* ellipsoid */ if (is_phits) par.k0 = pj_msfn(sin(phits), cos(phits), par.es); } else { /* sphere */ @@ -196,10 +188,10 @@ namespace projections \par Example \image html ex_merc.gif */ - template <typename CalculationType, typename Parameters> - struct merc_ellipsoid : public detail::merc::base_merc_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct merc_ellipsoid : public detail::merc::base_merc_ellipsoid<T, Parameters> { - inline merc_ellipsoid(const Parameters& par) : detail::merc::base_merc_ellipsoid<CalculationType, Parameters>(par) + inline merc_ellipsoid(const Parameters& par) : detail::merc::base_merc_ellipsoid<T, Parameters>(par) { detail::merc::setup_merc(this->m_par); } @@ -220,10 +212,10 @@ namespace projections \par Example \image html ex_merc.gif */ - template <typename CalculationType, typename Parameters> - struct merc_spheroid : public detail::merc::base_merc_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct merc_spheroid : public detail::merc::base_merc_spheroid<T, Parameters> { - inline merc_spheroid(const Parameters& par) : detail::merc::base_merc_spheroid<CalculationType, Parameters>(par) + inline merc_spheroid(const Parameters& par) : detail::merc::base_merc_spheroid<T, Parameters>(par) { detail::merc::setup_merc(this->m_par); } @@ -237,23 +229,23 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::merc, merc_spheroid, merc_ellipsoid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class merc_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class merc_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { if (par.es) - return new base_v_fi<merc_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<merc_ellipsoid<T, Parameters>, T, Parameters>(par); else - return new base_v_fi<merc_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<merc_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void merc_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void merc_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("merc", new merc_entry<CalculationType, Parameters>); + factory.add_to_factory("merc", new merc_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/mill.hpp b/boost/geometry/srs/projections/proj/mill.hpp index 1d3d4a01d2..9c73f1b21c 100644 --- a/boost/geometry/srs/projections/proj/mill.hpp +++ b/boost/geometry/srs/projections/proj/mill.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_MILL_HPP -#define BOOST_GEOMETRY_PROJECTIONS_MILL_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_MILL_HPP +#define BOOST_GEOMETRY_PROJECTIONS_MILL_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -51,7 +50,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct mill {}; + struct mill {}; // Miller Cylindrical }} //namespace srs::par4 @@ -61,37 +60,32 @@ namespace projections namespace detail { namespace mill { // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_mill_spheroid : public base_t_fi<base_mill_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_mill_spheroid + : public base_t_fi<base_mill_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_mill_spheroid(const Parameters& par) - : base_t_fi<base_mill_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_mill_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType FORTPI = detail::FORTPI<CalculationType>(); + static const T fourth_pi = detail::fourth_pi<T>(); xy_x = lp_lon; - xy_y = log(tan(FORTPI + lp_lat * .4)) * 1.25; + xy_y = log(tan(fourth_pi + lp_lat * .4)) * 1.25; } // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType FORTPI = detail::FORTPI<CalculationType>(); + static const T fourth_pi = detail::fourth_pi<T>(); lp_lon = xy_x; - lp_lat = 2.5 * (atan(exp(.8 * xy_y)) - FORTPI); + lp_lat = 2.5 * (atan(exp(.8 * xy_y)) - fourth_pi); } static inline std::string get_name() @@ -123,10 +117,10 @@ namespace projections \par Example \image html ex_mill.gif */ - template <typename CalculationType, typename Parameters> - struct mill_spheroid : public detail::mill::base_mill_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct mill_spheroid : public detail::mill::base_mill_spheroid<T, Parameters> { - inline mill_spheroid(const Parameters& par) : detail::mill::base_mill_spheroid<CalculationType, Parameters>(par) + inline mill_spheroid(const Parameters& par) : detail::mill::base_mill_spheroid<T, Parameters>(par) { detail::mill::setup_mill(this->m_par); } @@ -140,20 +134,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::mill, mill_spheroid, mill_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class mill_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class mill_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<mill_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<mill_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void mill_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void mill_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("mill", new mill_entry<CalculationType, Parameters>); + factory.add_to_factory("mill", new mill_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/mod_ster.hpp b/boost/geometry/srs/projections/proj/mod_ster.hpp index 8a50a275f9..ca33adcdbd 100644 --- a/boost/geometry/srs/projections/proj/mod_ster.hpp +++ b/boost/geometry/srs/projections/proj/mod_ster.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_MOD_STER_HPP -#define BOOST_GEOMETRY_PROJECTIONS_MOD_STER_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_MOD_STER_HPP +#define BOOST_GEOMETRY_PROJECTIONS_MOD_STER_HPP + #include <boost/geometry/util/math.hpp> #include <boost/math/special_functions/hypot.hpp> @@ -56,11 +55,11 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct mil_os {}; - struct lee_os {}; - struct gs48 {}; - struct alsk {}; - struct gs50 {}; + struct mil_os {}; // Miller Oblated Stereographic + struct lee_os {}; // Lee Oblated Stereographic + struct gs48 {}; // Mod. Stereographic of 48 U.S. + struct alsk {}; // Mod. Stereographic of Alaska + struct gs50 {}; // Mod. Stereographic of 50 U.S. }} //namespace srs::par4 @@ -70,12 +69,12 @@ namespace projections namespace detail { namespace mod_ster { - static const double EPSLN = 1e-10; + static const double epsilon = 1e-12; template <typename T> struct par_mod_ster { - COMPLEX<T> *zcoeff; + pj_complex<T> *zcoeff; T cchio, schio; int n; }; @@ -83,34 +82,30 @@ namespace projections /* based upon Snyder and Linck, USGS-NMD */ // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_mod_ster_ellipsoid : public base_t_fi<base_mod_ster_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_mod_ster_ellipsoid + : public base_t_fi<base_mod_ster_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_mod_ster<CalculationType> m_proj_parm; + par_mod_ster<T> m_proj_parm; inline base_mod_ster_ellipsoid(const Parameters& par) - : base_t_fi<base_mod_ster_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_mod_ster_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) ellipsoid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); - CalculationType sinlon, coslon, esphi, chi, schi, cchi, s; - COMPLEX<CalculationType> p; + T sinlon, coslon, esphi, chi, schi, cchi, s; + pj_complex<T> p; sinlon = sin(lp_lon); coslon = cos(lp_lon); esphi = this->m_par.e * sin(lp_lat); - chi = 2. * atan(tan((HALFPI + lp_lat) * .5) * - pow((1. - esphi) / (1. + esphi), this->m_par.e * .5)) - HALFPI; + chi = 2. * atan(tan((half_pi + lp_lat) * .5) * + math::pow((T(1) - esphi) / (T(1) + esphi), this->m_par.e * T(0.5))) - half_pi; schi = sin(chi); cchi = cos(chi); s = 2. / (1. + this->m_proj_parm.schio * schi + this->m_proj_parm.cchio * cchi * coslon); @@ -123,13 +118,13 @@ namespace projections // INVERSE(e_inverse) ellipsoid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); int nn; - COMPLEX<CalculationType> p, fxy, fpxy, dp; - CalculationType den, rh = 0, z, sinz = 0, cosz = 0, chi, phi = 0, dphi, esphi; + pj_complex<T> p, fxy, fpxy, dp; + T den, rh = 0, z, sinz = 0, cosz = 0, chi, phi = 0, dphi, esphi; p.r = xy_x; p.i = xy_y; @@ -142,7 +137,7 @@ namespace projections dp.i = -(fxy.i * fpxy.r - fxy.r * fpxy.i) / den; p.r += dp.r; p.i += dp.i; - if ((fabs(dp.r) + fabs(dp.i)) <= EPSLN) + if ((fabs(dp.r) + fabs(dp.i)) <= epsilon) break; } if (nn) { @@ -151,7 +146,11 @@ namespace projections sinz = sin(z); cosz = cos(z); lp_lon = this->m_par.lam0; - if (fabs(rh) <= EPSLN) { + if (fabs(rh) <= epsilon) { + /* if we end up here input coordinates were (0,0). + * pj_inv() adds P->lam0 to lp.lam, this way we are + * sure to get the correct offset */ + lp_lon = 0.0; lp_lat = this->m_par.phi0; return; } @@ -159,10 +158,10 @@ namespace projections phi = chi; for (nn = 20; nn ;--nn) { esphi = this->m_par.e * sin(phi); - dphi = 2. * atan(tan((HALFPI + chi) * .5) * - pow((1. + esphi) / (1. - esphi), this->m_par.e * .5)) - HALFPI - phi; + dphi = 2. * atan(tan((half_pi + chi) * .5) * + math::pow((T(1) + esphi) / (T(1) - esphi), this->m_par.e * T(0.5))) - half_pi - phi; phi += dphi; - if (fabs(dphi) <= EPSLN) + if (fabs(dphi) <= epsilon) break; } } @@ -184,12 +183,14 @@ namespace projections template <typename Parameters, typename T> inline void setup(Parameters& par, par_mod_ster<T>& proj_parm) /* general initialization */ { + static T const half_pi = detail::half_pi<T>(); + T esphi, chio; - if (par.es) { + if (par.es != 0.0) { esphi = par.e * sin(par.phi0); - chio = 2. * atan(tan((geometry::math::half_pi<T>() + par.phi0) * .5) * - pow((1. - esphi) / (1. + esphi), par.e * .5)) - geometry::math::half_pi<T>(); + chio = 2. * atan(tan((half_pi + par.phi0) * .5) * + math::pow((T(1) - esphi) / (T(1) + esphi), par.e * T(0.5))) - half_pi; } else chio = par.phi0; proj_parm.schio = sin(chio); @@ -197,41 +198,45 @@ namespace projections } - // Miller Oblated Stereographic + /* Miller Oblated Stereographic */ template <typename Parameters, typename T> inline void setup_mil_os(Parameters& par, par_mod_ster<T>& proj_parm) { - static COMPLEX<T> /* Miller Oblated Stereographic */ - AB[] = { - {0.924500, 0.}, - {0., 0.}, - {0.019430, 0.} - }; + static const T d2r = geometry::math::d2r<T>(); + + static pj_complex<T> AB[] = { + {0.924500, 0.}, + {0., 0.}, + {0.019430, 0.} + }; proj_parm.n = 2; - par.lam0 = geometry::math::d2r<T>() * 20.; - par.phi0 = geometry::math::d2r<T>() * 18.; + par.lam0 = d2r * 20.; + par.phi0 = d2r * 18.; proj_parm.zcoeff = AB; par.es = 0.; + setup(par, proj_parm); } - // Lee Oblated Stereographic + /* Lee Oblated Stereographic */ template <typename Parameters, typename T> inline void setup_lee_os(Parameters& par, par_mod_ster<T>& proj_parm) { - static COMPLEX<T> /* Lee Oblated Stereographic */ - AB[] = { - {0.721316, 0.}, - {0., 0.}, - {-0.0088162, -0.00617325} - }; + static const T d2r = geometry::math::d2r<T>(); + + static pj_complex<T> AB[] = { + { 0.721316, 0.}, + { 0., 0.}, + {-0.0088162, -0.00617325} + }; proj_parm.n = 2; - par.lam0 = geometry::math::d2r<T>() * -165.; - par.phi0 = geometry::math::d2r<T>() * -10.; + par.lam0 = d2r * -165.; + par.phi0 = d2r * -10.; proj_parm.zcoeff = AB; par.es = 0.; + setup(par, proj_parm); } @@ -239,21 +244,23 @@ namespace projections template <typename Parameters, typename T> inline void setup_gs48(Parameters& par, par_mod_ster<T>& proj_parm) { - static COMPLEX<T> /* 48 United States */ - AB[] = { - {0.98879, 0.}, - {0., 0.}, - {-0.050909, 0.}, - {0., 0.}, - {0.075528, 0.} - }; + static const T d2r = geometry::math::d2r<T>(); + + static pj_complex<T> AB[] = { /* 48 United States */ + { 0.98879, 0.}, + { 0., 0.}, + {-0.050909, 0.}, + { 0., 0.}, + { 0.075528, 0.} + }; proj_parm.n = 4; - par.lam0 = geometry::math::d2r<T>() * -96.; - par.phi0 = geometry::math::d2r<T>() * -39.; + par.lam0 = d2r * -96.; + par.phi0 = d2r * -39.; proj_parm.zcoeff = AB; par.es = 0.; par.a = 6370997.; + setup(par, proj_parm); } @@ -261,27 +268,30 @@ namespace projections template <typename Parameters, typename T> inline void setup_alsk(Parameters& par, par_mod_ster<T>& proj_parm) { - static COMPLEX<T> - ABe[] = { /* Alaska ellipsoid */ - {.9945303, 0.}, - {.0052083, -.0027404}, - {.0072721, .0048181}, - {-.0151089, -.1932526}, - {.0642675, -.1381226}, - {.3582802, -.2884586}}, - ABs[] = { /* Alaska sphere */ - {.9972523, 0.}, - {.0052513, -.0041175}, - {.0074606, .0048125}, - {-.0153783, -.1968253}, - {.0636871, -.1408027}, - {.3660976, -.2937382} - }; + static const T d2r = geometry::math::d2r<T>(); + + static pj_complex<T> ABe[] = { /* Alaska ellipsoid */ + { .9945303, 0.}, + { .0052083, -.0027404}, + { .0072721, .0048181}, + {-.0151089, -.1932526}, + { .0642675, -.1381226}, + { .3582802, -.2884586} + }; + + static pj_complex<T> ABs[] = { /* Alaska sphere */ + { .9972523, 0.}, + { .0052513, -.0041175}, + { .0074606, .0048125}, + {-.0153783, -.1968253}, + { .0636871, -.1408027}, + { .3660976, -.2937382} + }; proj_parm.n = 5; - par.lam0 = geometry::math::d2r<T>() * -152.; - par.phi0 = geometry::math::d2r<T>() * 64.; - if (par.es) { /* fixed ellipsoid/sphere */ + par.lam0 = d2r * -152.; + par.phi0 = d2r * 64.; + if (par.es != 0.0) { /* fixed ellipsoid/sphere */ proj_parm.zcoeff = ABe; par.a = 6378206.4; par.e = sqrt(par.es = 0.00676866); @@ -289,6 +299,7 @@ namespace projections proj_parm.zcoeff = ABs; par.a = 6370997.; } + setup(par, proj_parm); } @@ -296,36 +307,37 @@ namespace projections template <typename Parameters, typename T> inline void setup_gs50(Parameters& par, par_mod_ster<T>& proj_parm) { - static COMPLEX<T> - ABe[] = { /* GS50 ellipsoid */ - {.9827497, 0.}, - {.0210669, .0053804}, - {-.1031415, -.0571664}, - {-.0323337, -.0322847}, - {.0502303, .1211983}, - {.0251805, .0895678}, - {-.0012315, -.1416121}, - {.0072202, -.1317091}, - {-.0194029, .0759677}, - {-.0210072, .0834037} - }, - ABs[] = { /* GS50 sphere */ - {.9842990, 0.}, - {.0211642, .0037608}, - {-.1036018, -.0575102}, - {-.0329095, -.0320119}, - {.0499471, .1223335}, - {.0260460, .0899805}, - {.0007388, -.1435792}, - {.0075848, -.1334108}, - {-.0216473, .0776645}, - {-.0225161, .0853673} - }; + static const T d2r = geometry::math::d2r<T>(); + + static pj_complex<T> ABe[] = { /* GS50 ellipsoid */ + { .9827497, 0.}, + { .0210669, .0053804}, + {-.1031415, -.0571664}, + {-.0323337, -.0322847}, + { .0502303, .1211983}, + { .0251805, .0895678}, + {-.0012315, -.1416121}, + { .0072202, -.1317091}, + {-.0194029, .0759677}, + {-.0210072, .0834037} + }; + static pj_complex<T> ABs[] = { /* GS50 sphere */ + { .9842990, 0.}, + { .0211642, .0037608}, + {-.1036018, -.0575102}, + {-.0329095, -.0320119}, + { .0499471, .1223335}, + { .0260460, .0899805}, + { .0007388, -.1435792}, + { .0075848, -.1334108}, + {-.0216473, .0776645}, + {-.0225161, .0853673} + }; proj_parm.n = 9; - par.lam0 = geometry::math::d2r<T>() * -120.; - par.phi0 = geometry::math::d2r<T>() * 45.; - if (par.es) { /* fixed ellipsoid/sphere */ + par.lam0 = d2r * -120.; + par.phi0 = d2r * 45.; + if (par.es != 0.0) { /* fixed ellipsoid/sphere */ proj_parm.zcoeff = ABe; par.a = 6378206.4; par.e = sqrt(par.es = 0.00676866); @@ -333,6 +345,7 @@ namespace projections proj_parm.zcoeff = ABs; par.a = 6370997.; } + setup(par, proj_parm); } @@ -350,10 +363,10 @@ namespace projections \par Example \image html ex_mil_os.gif */ - template <typename CalculationType, typename Parameters> - struct mil_os_ellipsoid : public detail::mod_ster::base_mod_ster_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct mil_os_ellipsoid : public detail::mod_ster::base_mod_ster_ellipsoid<T, Parameters> { - inline mil_os_ellipsoid(const Parameters& par) : detail::mod_ster::base_mod_ster_ellipsoid<CalculationType, Parameters>(par) + inline mil_os_ellipsoid(const Parameters& par) : detail::mod_ster::base_mod_ster_ellipsoid<T, Parameters>(par) { detail::mod_ster::setup_mil_os(this->m_par, this->m_proj_parm); } @@ -370,10 +383,10 @@ namespace projections \par Example \image html ex_lee_os.gif */ - template <typename CalculationType, typename Parameters> - struct lee_os_ellipsoid : public detail::mod_ster::base_mod_ster_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct lee_os_ellipsoid : public detail::mod_ster::base_mod_ster_ellipsoid<T, Parameters> { - inline lee_os_ellipsoid(const Parameters& par) : detail::mod_ster::base_mod_ster_ellipsoid<CalculationType, Parameters>(par) + inline lee_os_ellipsoid(const Parameters& par) : detail::mod_ster::base_mod_ster_ellipsoid<T, Parameters>(par) { detail::mod_ster::setup_lee_os(this->m_par, this->m_proj_parm); } @@ -390,10 +403,10 @@ namespace projections \par Example \image html ex_gs48.gif */ - template <typename CalculationType, typename Parameters> - struct gs48_ellipsoid : public detail::mod_ster::base_mod_ster_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct gs48_ellipsoid : public detail::mod_ster::base_mod_ster_ellipsoid<T, Parameters> { - inline gs48_ellipsoid(const Parameters& par) : detail::mod_ster::base_mod_ster_ellipsoid<CalculationType, Parameters>(par) + inline gs48_ellipsoid(const Parameters& par) : detail::mod_ster::base_mod_ster_ellipsoid<T, Parameters>(par) { detail::mod_ster::setup_gs48(this->m_par, this->m_proj_parm); } @@ -410,10 +423,10 @@ namespace projections \par Example \image html ex_alsk.gif */ - template <typename CalculationType, typename Parameters> - struct alsk_ellipsoid : public detail::mod_ster::base_mod_ster_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct alsk_ellipsoid : public detail::mod_ster::base_mod_ster_ellipsoid<T, Parameters> { - inline alsk_ellipsoid(const Parameters& par) : detail::mod_ster::base_mod_ster_ellipsoid<CalculationType, Parameters>(par) + inline alsk_ellipsoid(const Parameters& par) : detail::mod_ster::base_mod_ster_ellipsoid<T, Parameters>(par) { detail::mod_ster::setup_alsk(this->m_par, this->m_proj_parm); } @@ -430,10 +443,10 @@ namespace projections \par Example \image html ex_gs50.gif */ - template <typename CalculationType, typename Parameters> - struct gs50_ellipsoid : public detail::mod_ster::base_mod_ster_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct gs50_ellipsoid : public detail::mod_ster::base_mod_ster_ellipsoid<T, Parameters> { - inline gs50_ellipsoid(const Parameters& par) : detail::mod_ster::base_mod_ster_ellipsoid<CalculationType, Parameters>(par) + inline gs50_ellipsoid(const Parameters& par) : detail::mod_ster::base_mod_ster_ellipsoid<T, Parameters>(par) { detail::mod_ster::setup_gs50(this->m_par, this->m_proj_parm); } @@ -451,64 +464,64 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::gs50, gs50_ellipsoid, gs50_ellipsoid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class mil_os_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class mil_os_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<mil_os_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<mil_os_ellipsoid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class lee_os_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class lee_os_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<lee_os_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<lee_os_ellipsoid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class gs48_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class gs48_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<gs48_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<gs48_ellipsoid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class alsk_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class alsk_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<alsk_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<alsk_ellipsoid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class gs50_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class gs50_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<gs50_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<gs50_ellipsoid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void mod_ster_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void mod_ster_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("mil_os", new mil_os_entry<CalculationType, Parameters>); - factory.add_to_factory("lee_os", new lee_os_entry<CalculationType, Parameters>); - factory.add_to_factory("gs48", new gs48_entry<CalculationType, Parameters>); - factory.add_to_factory("alsk", new alsk_entry<CalculationType, Parameters>); - factory.add_to_factory("gs50", new gs50_entry<CalculationType, Parameters>); + factory.add_to_factory("mil_os", new mil_os_entry<T, Parameters>); + factory.add_to_factory("lee_os", new lee_os_entry<T, Parameters>); + factory.add_to_factory("gs48", new gs48_entry<T, Parameters>); + factory.add_to_factory("alsk", new alsk_entry<T, Parameters>); + factory.add_to_factory("gs50", new gs50_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/moll.hpp b/boost/geometry/srs/projections/proj/moll.hpp index 6f02c7dea0..deceb3401e 100644 --- a/boost/geometry/srs/projections/proj/moll.hpp +++ b/boost/geometry/srs/projections/proj/moll.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_MOLL_HPP -#define BOOST_GEOMETRY_PROJECTIONS_MOLL_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_MOLL_HPP +#define BOOST_GEOMETRY_PROJECTIONS_MOLL_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -54,9 +53,9 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct moll {}; - struct wag4 {}; - struct wag5 {}; + struct moll {}; // Mollweide + struct wag4 {}; // Wagner IV + struct wag5 {}; // Wagner V }} //namespace srs::par4 @@ -66,8 +65,8 @@ namespace projections namespace detail { namespace moll { - static const int MAX_ITER = 10; - static const double LOOP_TOL = 1e-7; + static const int max_iter = 10; + static const double loop_tol = 1e-7; template <typename T> struct par_moll @@ -76,38 +75,34 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_moll_spheroid : public base_t_fi<base_moll_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_moll_spheroid + : public base_t_fi<base_moll_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_moll<CalculationType> m_proj_parm; + par_moll<T> m_proj_parm; inline base_moll_spheroid(const Parameters& par) - : base_t_fi<base_moll_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_moll_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); - CalculationType k, V; + T k, V; int i; k = this->m_proj_parm.C_p * sin(lp_lat); - for (i = MAX_ITER; i ; --i) { + for (i = max_iter; i ; --i) { lp_lat -= V = (lp_lat + sin(lp_lat) - k) / (1. + cos(lp_lat)); - if (fabs(V) < LOOP_TOL) + if (fabs(V) < loop_tol) break; } if (!i) - lp_lat = (lp_lat < 0.) ? -HALFPI : HALFPI; + lp_lat = (lp_lat < 0.) ? -half_pi : half_pi; else lp_lat *= 0.5; xy_x = this->m_proj_parm.C_x * lp_lon * cos(lp_lat); @@ -116,12 +111,18 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { + static const T pi = detail::pi<T>(); + lp_lat = aasin(xy_y / this->m_proj_parm.C_y); lp_lon = xy_x / (this->m_proj_parm.C_x * cos(lp_lat)); - lp_lat += lp_lat; - lp_lat = aasin((lp_lat + sin(lp_lat)) / this->m_proj_parm.C_p); + if (fabs(lp_lon) < pi) { + lp_lat += lp_lat; + lp_lat = aasin((lp_lat + sin(lp_lat)) / this->m_proj_parm.C_p); + } else { + lp_lon = lp_lat = HUGE_VAL; + } } static inline std::string get_name() @@ -139,6 +140,7 @@ namespace projections par.es = 0; sp = sin(p); r = sqrt(geometry::math::two_pi<T>() * sp / (p2 + sin(p2))); + proj_parm.C_x = 2. * r / geometry::math::pi<T>(); proj_parm.C_y = r / sp; proj_parm.C_p = p2 + sin(p2); @@ -184,10 +186,10 @@ namespace projections \par Example \image html ex_moll.gif */ - template <typename CalculationType, typename Parameters> - struct moll_spheroid : public detail::moll::base_moll_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct moll_spheroid : public detail::moll::base_moll_spheroid<T, Parameters> { - inline moll_spheroid(const Parameters& par) : detail::moll::base_moll_spheroid<CalculationType, Parameters>(par) + inline moll_spheroid(const Parameters& par) : detail::moll::base_moll_spheroid<T, Parameters>(par) { detail::moll::setup_moll(this->m_par, this->m_proj_parm); } @@ -205,10 +207,10 @@ namespace projections \par Example \image html ex_wag4.gif */ - template <typename CalculationType, typename Parameters> - struct wag4_spheroid : public detail::moll::base_moll_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct wag4_spheroid : public detail::moll::base_moll_spheroid<T, Parameters> { - inline wag4_spheroid(const Parameters& par) : detail::moll::base_moll_spheroid<CalculationType, Parameters>(par) + inline wag4_spheroid(const Parameters& par) : detail::moll::base_moll_spheroid<T, Parameters>(par) { detail::moll::setup_wag4(this->m_par, this->m_proj_parm); } @@ -226,10 +228,10 @@ namespace projections \par Example \image html ex_wag5.gif */ - template <typename CalculationType, typename Parameters> - struct wag5_spheroid : public detail::moll::base_moll_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct wag5_spheroid : public detail::moll::base_moll_spheroid<T, Parameters> { - inline wag5_spheroid(const Parameters& par) : detail::moll::base_moll_spheroid<CalculationType, Parameters>(par) + inline wag5_spheroid(const Parameters& par) : detail::moll::base_moll_spheroid<T, Parameters>(par) { detail::moll::setup_wag5(this->m_par, this->m_proj_parm); } @@ -245,42 +247,42 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::wag5, wag5_spheroid, wag5_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class moll_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class moll_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<moll_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<moll_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class wag4_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class wag4_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<wag4_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<wag4_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class wag5_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class wag5_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<wag5_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<wag5_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void moll_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void moll_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("moll", new moll_entry<CalculationType, Parameters>); - factory.add_to_factory("wag4", new wag4_entry<CalculationType, Parameters>); - factory.add_to_factory("wag5", new wag5_entry<CalculationType, Parameters>); + factory.add_to_factory("moll", new moll_entry<T, Parameters>); + factory.add_to_factory("wag4", new wag4_entry<T, Parameters>); + factory.add_to_factory("wag5", new wag5_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/natearth.hpp b/boost/geometry/srs/projections/proj/natearth.hpp index dcd259d9d1..47da25b9e2 100644 --- a/boost/geometry/srs/projections/proj/natearth.hpp +++ b/boost/geometry/srs/projections/proj/natearth.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_NATEARTH_HPP -#define BOOST_GEOMETRY_PROJECTIONS_NATEARTH_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,23 +15,10 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: -// The Natural Earth projection was designed by Tom Patterson, US National Park -// Service, in 2007, using Flex Projector. The shape of the original projection -// was defined at every 5 degrees and piece-wise cubic spline interpolation was -// used to compute the complete graticule. -// The code here uses polynomial functions instead of cubic splines and -// is therefore much simpler to program. The polynomial approximation was -// developed by Bojan Savric, in collaboration with Tom Patterson and Bernhard -// Jenny, Institute of Cartography, ETH Zurich. It slightly deviates from -// Patterson's original projection by adding additional curvature to meridians -// where they meet the horizontal pole line. This improvement is by intention -// and designed in collaboration with Tom Patterson. -// Port to PROJ.4 by Bernhard Jenny, 6 June 2011 - // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation @@ -54,6 +37,22 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +// The Natural Earth projection was designed by Tom Patterson, US National Park +// Service, in 2007, using Flex Projector. The shape of the original projection +// was defined at every 5 degrees and piece-wise cubic spline interpolation was +// used to compute the complete graticule. +// The code here uses polynomial functions instead of cubic splines and +// is therefore much simpler to program. The polynomial approximation was +// developed by Bojan Savric, in collaboration with Tom Patterson and Bernhard +// Jenny, Institute of Cartography, ETH Zurich. It slightly deviates from +// Patterson's original projection by adding additional curvature to meridians +// where they meet the horizontal pole line. This improvement is by intention +// and designed in collaboration with Tom Patterson. +// Port to PROJ.4 by Bernhard Jenny, 6 June 2011 + +#ifndef BOOST_GEOMETRY_PROJECTIONS_NATEARTH_HPP +#define BOOST_GEOMETRY_PROJECTIONS_NATEARTH_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -64,7 +63,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct natearth {}; + struct natearth {}; // Natural Earth }} //namespace srs::par4 @@ -89,31 +88,28 @@ namespace projections static const double C2 = (7 * B2); static const double C3 = (9 * B3); static const double C4 = (11 * B4); - static const double EPS = 1e-11; - //static const double MAX_Y = (0.8707 * 0.52 * geometry::math::pi<double>()); + static const double epsilon = 1e-11; template <typename T> - inline T MAX_Y() { return (0.8707 * 0.52 * detail::ONEPI<T>()); } + inline T max_y() { return (0.8707 * 0.52 * detail::pi<T>()); } + + /* Not sure at all of the appropriate number for max_iter... */ + static const int max_iter = 100; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_natearth_spheroid : public base_t_fi<base_natearth_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_natearth_spheroid + : public base_t_fi<base_natearth_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_natearth_spheroid(const Parameters& par) - : base_t_fi<base_natearth_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_natearth_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType phi2, phi4; + T phi2, phi4; phi2 = lp_lat * lp_lat; phi4 = phi2 * phi2; @@ -123,31 +119,34 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType MAX_Y = natearth::MAX_Y<CalculationType>(); + static const T max_y = natearth::max_y<T>(); - CalculationType yc, tol, y2, y4, f, fder; + T yc, tol, y2, y4, f, fder; + int i; /* make sure y is inside valid range */ - if (xy_y > MAX_Y) { - xy_y = MAX_Y; - } else if (xy_y < -MAX_Y) { - xy_y = -MAX_Y; + if (xy_y > max_y) { + xy_y = max_y; + } else if (xy_y < -max_y) { + xy_y = -max_y; } /* latitude */ yc = xy_y; - for (;;) { /* Newton-Raphson */ + for (i = max_iter; i ; --i) { /* Newton-Raphson */ y2 = yc * yc; y4 = y2 * y2; f = (yc * (B0 + y2 * (B1 + y4 * (B2 + B3 * y2 + B4 * y4)))) - xy_y; fder = C0 + y2 * (C1 + y4 * (C2 + C3 * y2 + C4 * y4)); yc -= tol = f / fder; - if (fabs(tol) < EPS) { + if (fabs(tol) < epsilon) { break; } } + if( i == 0 ) + BOOST_THROW_EXCEPTION( projection_exception(error_non_convergent) ); lp_lat = yc; /* longitude */ @@ -184,10 +183,10 @@ namespace projections \par Example \image html ex_natearth.gif */ - template <typename CalculationType, typename Parameters> - struct natearth_spheroid : public detail::natearth::base_natearth_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct natearth_spheroid : public detail::natearth::base_natearth_spheroid<T, Parameters> { - inline natearth_spheroid(const Parameters& par) : detail::natearth::base_natearth_spheroid<CalculationType, Parameters>(par) + inline natearth_spheroid(const Parameters& par) : detail::natearth::base_natearth_spheroid<T, Parameters>(par) { detail::natearth::setup_natearth(this->m_par); } @@ -201,20 +200,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::natearth, natearth_spheroid, natearth_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class natearth_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class natearth_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<natearth_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<natearth_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void natearth_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void natearth_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("natearth", new natearth_entry<CalculationType, Parameters>); + factory.add_to_factory("natearth", new natearth_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/nell.hpp b/boost/geometry/srs/projections/proj/nell.hpp index 351a4101f7..fcb0e18b17 100644 --- a/boost/geometry/srs/projections/proj/nell.hpp +++ b/boost/geometry/srs/projections/proj/nell.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_NELL_HPP -#define BOOST_GEOMETRY_PROJECTIONS_NELL_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_NELL_HPP +#define BOOST_GEOMETRY_PROJECTIONS_NELL_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -52,7 +51,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct nell {}; + struct nell {}; // Nell }} //namespace srs::par4 @@ -62,37 +61,32 @@ namespace projections namespace detail { namespace nell { - static const int MAX_ITER = 10; - static const double LOOP_TOL = 1e-7; + static const int max_iter = 10; + static const double loop_tol = 1e-7; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_nell_spheroid : public base_t_fi<base_nell_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_nell_spheroid + : public base_t_fi<base_nell_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_nell_spheroid(const Parameters& par) - : base_t_fi<base_nell_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_nell_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType k, V; + T k, V; int i; k = 2. * sin(lp_lat); V = lp_lat * lp_lat; lp_lat *= 1.00371 + V * (-0.0935382 + V * -0.011412); - for (i = MAX_ITER; i ; --i) { + for (i = max_iter; i ; --i) { lp_lat -= V = (lp_lat + sin(lp_lat) - k) / (1. + cos(lp_lat)); - if (fabs(V) < LOOP_TOL) + if (fabs(V) < loop_tol) break; } xy_x = 0.5 * lp_lon * (1. + cos(lp_lat)); @@ -101,7 +95,7 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { lp_lon = 2. * xy_x / (1. + cos(xy_y)); lp_lat = aasin(0.5 * (xy_y + sin(xy_y))); @@ -136,10 +130,10 @@ namespace projections \par Example \image html ex_nell.gif */ - template <typename CalculationType, typename Parameters> - struct nell_spheroid : public detail::nell::base_nell_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct nell_spheroid : public detail::nell::base_nell_spheroid<T, Parameters> { - inline nell_spheroid(const Parameters& par) : detail::nell::base_nell_spheroid<CalculationType, Parameters>(par) + inline nell_spheroid(const Parameters& par) : detail::nell::base_nell_spheroid<T, Parameters>(par) { detail::nell::setup_nell(this->m_par); } @@ -153,20 +147,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::nell, nell_spheroid, nell_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class nell_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class nell_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<nell_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<nell_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void nell_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void nell_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("nell", new nell_entry<CalculationType, Parameters>); + factory.add_to_factory("nell", new nell_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/nell_h.hpp b/boost/geometry/srs/projections/proj/nell_h.hpp index 05de9e263e..73f0018ac6 100644 --- a/boost/geometry/srs/projections/proj/nell_h.hpp +++ b/boost/geometry/srs/projections/proj/nell_h.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_NELL_H_HPP -#define BOOST_GEOMETRY_PROJECTIONS_NELL_H_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_NELL_H_HPP +#define BOOST_GEOMETRY_PROJECTIONS_NELL_H_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -53,7 +52,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct nell_h {}; + struct nell_h {}; // Nell-Hammer }} //namespace srs::par4 @@ -63,26 +62,21 @@ namespace projections namespace detail { namespace nell_h { - static const int NITER = 9; - static const double EPS = 1e-7; + static const int n_iter = 9; + static const double epsilon = 1e-7; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_nell_h_spheroid : public base_t_fi<base_nell_h_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_nell_h_spheroid + : public base_t_fi<base_nell_h_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_nell_h_spheroid(const Parameters& par) - : base_t_fi<base_nell_h_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_nell_h_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { xy_x = 0.5 * lp_lon * (1. + cos(lp_lat)); xy_y = 2.0 * (lp_lat - tan(0.5 *lp_lat)); @@ -90,22 +84,22 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); - CalculationType V, c, p; + T V, c, p; int i; p = 0.5 * xy_y; - for (i = NITER; i ; --i) { + for (i = n_iter; i ; --i) { c = cos(0.5 * lp_lat); lp_lat -= V = (lp_lat - tan(lp_lat/2) - p)/(1. - 0.5/(c*c)); - if (fabs(V) < EPS) + if (fabs(V) < epsilon) break; } if (!i) { - lp_lat = p < 0. ? -HALFPI : HALFPI; + lp_lat = p < 0. ? -half_pi : half_pi; lp_lon = 2. * xy_x; } else lp_lon = 2. * xy_x / (1. + cos(lp_lat)); @@ -140,10 +134,10 @@ namespace projections \par Example \image html ex_nell_h.gif */ - template <typename CalculationType, typename Parameters> - struct nell_h_spheroid : public detail::nell_h::base_nell_h_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct nell_h_spheroid : public detail::nell_h::base_nell_h_spheroid<T, Parameters> { - inline nell_h_spheroid(const Parameters& par) : detail::nell_h::base_nell_h_spheroid<CalculationType, Parameters>(par) + inline nell_h_spheroid(const Parameters& par) : detail::nell_h::base_nell_h_spheroid<T, Parameters>(par) { detail::nell_h::setup_nell_h(this->m_par); } @@ -157,20 +151,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::nell_h, nell_h_spheroid, nell_h_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class nell_h_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class nell_h_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<nell_h_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<nell_h_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void nell_h_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void nell_h_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("nell_h", new nell_h_entry<CalculationType, Parameters>); + factory.add_to_factory("nell_h", new nell_h_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/nocol.hpp b/boost/geometry/srs/projections/proj/nocol.hpp index ef2e95a843..01e428c6d4 100644 --- a/boost/geometry/srs/projections/proj/nocol.hpp +++ b/boost/geometry/srs/projections/proj/nocol.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_NOCOL_HPP -#define BOOST_GEOMETRY_PROJECTIONS_NOCOL_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_NOCOL_HPP +#define BOOST_GEOMETRY_PROJECTIONS_NOCOL_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -53,7 +52,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct nicol {}; + struct nicol {}; // Nicolosi Globular }} //namespace srs::par4 @@ -63,45 +62,40 @@ namespace projections namespace detail { namespace nocol { - static const double EPS = 1e-10; + static const double epsilon = 1e-10; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_nocol_spheroid : public base_t_f<base_nocol_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_nocol_spheroid + : public base_t_f<base_nocol_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_nocol_spheroid(const Parameters& par) - : base_t_f<base_nocol_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_f<base_nocol_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); - if (fabs(lp_lon) < EPS) { + if (fabs(lp_lon) < epsilon) { xy_x = 0; xy_y = lp_lat; - } else if (fabs(lp_lat) < EPS) { + } else if (fabs(lp_lat) < epsilon) { xy_x = lp_lon; xy_y = 0.; - } else if (fabs(fabs(lp_lon) - HALFPI) < EPS) { + } else if (fabs(fabs(lp_lon) - half_pi) < epsilon) { xy_x = lp_lon * cos(lp_lat); - xy_y = HALFPI * sin(lp_lat); - } else if (fabs(fabs(lp_lat) - HALFPI) < EPS) { + xy_y = half_pi * sin(lp_lat); + } else if (fabs(fabs(lp_lat) - half_pi) < epsilon) { xy_x = 0; xy_y = lp_lat; } else { - CalculationType tb, c, d, m, n, r2, sp; + T tb, c, d, m, n, r2, sp; - tb = HALFPI / lp_lon - lp_lon / HALFPI; - c = lp_lat / HALFPI; + tb = half_pi / lp_lon - lp_lon / half_pi; + c = lp_lat / half_pi; d = (1 - c * c)/((sp = sin(lp_lat)) - c); r2 = tb / d; r2 *= r2; @@ -109,10 +103,10 @@ namespace projections n = (sp / r2 + 0.5 * d)/(1. + 1./r2); xy_x = cos(lp_lat); xy_x = sqrt(m * m + xy_x * xy_x / (1. + r2)); - xy_x = HALFPI * ( m + (lp_lon < 0. ? -xy_x : xy_x)); + xy_x = half_pi * ( m + (lp_lon < 0. ? -xy_x : xy_x)); xy_y = sqrt(n * n - (sp * sp / r2 + d * sp - 1.) / (1. + 1./r2)); - xy_y = HALFPI * ( n + (lp_lat < 0. ? xy_y : -xy_y )); + xy_y = half_pi * ( n + (lp_lat < 0. ? xy_y : -xy_y )); } } @@ -146,10 +140,10 @@ namespace projections \par Example \image html ex_nicol.gif */ - template <typename CalculationType, typename Parameters> - struct nicol_spheroid : public detail::nocol::base_nocol_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct nicol_spheroid : public detail::nocol::base_nocol_spheroid<T, Parameters> { - inline nicol_spheroid(const Parameters& par) : detail::nocol::base_nocol_spheroid<CalculationType, Parameters>(par) + inline nicol_spheroid(const Parameters& par) : detail::nocol::base_nocol_spheroid<T, Parameters>(par) { detail::nocol::setup_nicol(this->m_par); } @@ -163,20 +157,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::nicol, nicol_spheroid, nicol_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class nicol_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class nicol_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_f<nicol_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_f<nicol_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void nocol_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void nocol_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("nicol", new nicol_entry<CalculationType, Parameters>); + factory.add_to_factory("nicol", new nicol_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/nsper.hpp b/boost/geometry/srs/projections/proj/nsper.hpp index 85576bf963..2910ee6203 100644 --- a/boost/geometry/srs/projections/proj/nsper.hpp +++ b/boost/geometry/srs/projections/proj/nsper.hpp @@ -1,8 +1,4 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_NSPER_HPP -#define BOOST_GEOMETRY_PROJECTIONS_NSPER_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_NSPER_HPP +#define BOOST_GEOMETRY_PROJECTIONS_NSPER_HPP + #include <boost/config.hpp> #include <boost/geometry/util/math.hpp> #include <boost/math/special_functions/hypot.hpp> @@ -55,8 +54,8 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct nsper {}; - struct tpers {}; + struct nsper {}; // Near-sided perspective + struct tpers {}; // Tilted perspective }} //namespace srs::par4 @@ -66,11 +65,13 @@ namespace projections namespace detail { namespace nsper { - static const double EPS10 = 1.e-10; - static const int N_POLE = 0; - static const int S_POLE = 1; - static const int EQUIT = 2; - static const int OBLIQ = 3; + static const double epsilon10 = 1.e-10; + enum mode_type { + n_pole = 0, + s_pole = 1, + equit = 2, + obliq = 3 + }; template <typename T> struct par_nsper @@ -87,69 +88,66 @@ namespace projections T sg; T sw; T cw; - int mode; + mode_type mode; int tilt; }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_nsper_spheroid : public base_t_fi<base_nsper_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_nsper_spheroid + : public base_t_fi<base_nsper_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_nsper<CalculationType> m_proj_parm; + par_nsper<T> m_proj_parm; inline base_nsper_spheroid(const Parameters& par) - : base_t_fi<base_nsper_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_nsper_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType coslam, cosphi, sinphi; + T coslam, cosphi, sinphi; sinphi = sin(lp_lat); cosphi = cos(lp_lat); coslam = cos(lp_lon); switch (this->m_proj_parm.mode) { - case OBLIQ: + case obliq: xy_y = this->m_proj_parm.sinph0 * sinphi + this->m_proj_parm.cosph0 * cosphi * coslam; break; - case EQUIT: + case equit: xy_y = cosphi * coslam; break; - case S_POLE: + case s_pole: xy_y = - sinphi; break; - case N_POLE: + case n_pole: xy_y = sinphi; break; } - if (xy_y < this->m_proj_parm.rp) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + if (xy_y < this->m_proj_parm.rp) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } 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) { - case OBLIQ: + case obliq: xy_y *= (this->m_proj_parm.cosph0 * sinphi - this->m_proj_parm.sinph0 * cosphi * coslam); break; - case EQUIT: + case equit: xy_y *= sinphi; break; - case N_POLE: + case n_pole: coslam = - coslam; BOOST_FALLTHROUGH; - case S_POLE: + case s_pole: xy_y *= cosphi * coslam; break; } if (this->m_proj_parm.tilt) { - CalculationType yt, ba; + T yt, ba; yt = xy_y * this->m_proj_parm.cg + xy_x * this->m_proj_parm.sg; ba = 1. / (yt * this->m_proj_parm.sw * this->m_proj_parm.h + this->m_proj_parm.cw); @@ -160,12 +158,12 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType rh, cosz, sinz; + T rh, cosz, sinz; if (this->m_proj_parm.tilt) { - CalculationType bm, bq, yt; + T bm, bq, yt; yt = 1./(this->m_proj_parm.pn1 - xy_y * this->m_proj_parm.sw); bm = this->m_proj_parm.pn1 * xy_x * yt; @@ -174,30 +172,31 @@ 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.) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + if ((sinz = 1. - rh * rh * this->m_proj_parm.pfact) < 0.) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } 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) { + if (fabs(rh) <= epsilon10) { lp_lon = 0.; lp_lat = this->m_par.phi0; } else { switch (this->m_proj_parm.mode) { - case OBLIQ: + case obliq: lp_lat = asin(cosz * this->m_proj_parm.sinph0 + xy_y * sinz * this->m_proj_parm.cosph0 / rh); xy_y = (cosz - this->m_proj_parm.sinph0 * sin(lp_lat)) * rh; xy_x *= sinz * this->m_proj_parm.cosph0; break; - case EQUIT: + case equit: lp_lat = asin(xy_y * sinz / rh); xy_y = cosz * rh; xy_x *= sinz; break; - case N_POLE: + case n_pole: lp_lat = asin(cosz); xy_y = -xy_y; break; - case S_POLE: + case s_pole: lp_lat = - asin(cosz); break; } @@ -215,14 +214,15 @@ namespace projections template <typename Parameters, typename T> inline void setup(Parameters& par, par_nsper<T>& proj_parm) { - if ((proj_parm.height = pj_param(par.params, "dh").f) <= 0.) - BOOST_THROW_EXCEPTION( projection_exception(-30) ); - if (fabs(fabs(par.phi0) - geometry::math::half_pi<T>()) < EPS10) - proj_parm.mode = par.phi0 < 0. ? S_POLE : N_POLE; - else if (fabs(par.phi0) < EPS10) - proj_parm.mode = EQUIT; + if ((proj_parm.height = pj_get_param_f(par.params, "h")) <= 0.) + BOOST_THROW_EXCEPTION( projection_exception(error_h_less_than_zero) ); + + if (fabs(fabs(par.phi0) - geometry::math::half_pi<T>()) < epsilon10) + proj_parm.mode = par.phi0 < 0. ? s_pole : n_pole; + else if (fabs(par.phi0) < epsilon10) + proj_parm.mode = equit; else { - proj_parm.mode = OBLIQ; + proj_parm.mode = obliq; proj_parm.sinph0 = sin(par.phi0); proj_parm.cosph0 = cos(par.phi0); } @@ -240,6 +240,7 @@ namespace projections inline void setup_nsper(Parameters& par, par_nsper<T>& proj_parm) { proj_parm.tilt = 0; + setup(par, proj_parm); } @@ -249,11 +250,12 @@ namespace projections { T omega, gamma; - omega = pj_param(par.params, "dtilt").f * geometry::math::d2r<T>(); - gamma = pj_param(par.params, "dazi").f * geometry::math::d2r<T>(); + omega = pj_get_param_r(par.params, "tilt"); + gamma = pj_get_param_r(par.params, "azi"); proj_parm.tilt = 1; proj_parm.cg = cos(gamma); proj_parm.sg = sin(gamma); proj_parm.cw = cos(omega); proj_parm.sw = sin(omega); + setup(par, proj_parm); } @@ -274,10 +276,10 @@ namespace projections \par Example \image html ex_nsper.gif */ - template <typename CalculationType, typename Parameters> - struct nsper_spheroid : public detail::nsper::base_nsper_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct nsper_spheroid : public detail::nsper::base_nsper_spheroid<T, Parameters> { - inline nsper_spheroid(const Parameters& par) : detail::nsper::base_nsper_spheroid<CalculationType, Parameters>(par) + inline nsper_spheroid(const Parameters& par) : detail::nsper::base_nsper_spheroid<T, Parameters>(par) { detail::nsper::setup_nsper(this->m_par, this->m_proj_parm); } @@ -299,10 +301,10 @@ namespace projections \par Example \image html ex_tpers.gif */ - template <typename CalculationType, typename Parameters> - struct tpers_spheroid : public detail::nsper::base_nsper_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct tpers_spheroid : public detail::nsper::base_nsper_spheroid<T, Parameters> { - inline tpers_spheroid(const Parameters& par) : detail::nsper::base_nsper_spheroid<CalculationType, Parameters>(par) + inline tpers_spheroid(const Parameters& par) : detail::nsper::base_nsper_spheroid<T, Parameters>(par) { detail::nsper::setup_tpers(this->m_par, this->m_proj_parm); } @@ -317,31 +319,31 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::tpers, tpers_spheroid, tpers_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class nsper_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class nsper_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<nsper_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<nsper_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class tpers_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class tpers_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<tpers_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<tpers_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void nsper_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void nsper_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("nsper", new nsper_entry<CalculationType, Parameters>); - factory.add_to_factory("tpers", new tpers_entry<CalculationType, Parameters>); + factory.add_to_factory("nsper", new nsper_entry<T, Parameters>); + factory.add_to_factory("tpers", new tpers_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/nzmg.hpp b/boost/geometry/srs/projections/proj/nzmg.hpp index 067eece27a..2806e1a2d2 100644 --- a/boost/geometry/srs/projections/proj/nzmg.hpp +++ b/boost/geometry/srs/projections/proj/nzmg.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_NZMG_HPP -#define BOOST_GEOMETRY_PROJECTIONS_NZMG_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,12 +15,12 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: // Purpose: Implementation of the nzmg (New Zealand Map Grid) projection. -// Very loosely based upon DMA code by Bradford W. Drew +// Very loosely based upon DMA code by Bradford W. Drew // Author: Gerald Evenden // Copyright (c) 1995, Gerald Evenden @@ -46,6 +42,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_NZMG_HPP +#define BOOST_GEOMETRY_PROJECTIONS_NZMG_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -59,7 +58,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct nzmg {}; + struct nzmg {}; // New Zealand Map Grid }} //namespace srs::par4 @@ -69,22 +68,20 @@ namespace projections namespace detail { namespace nzmg { - static const double EPSLN = 1e-10; - //static const double SEC5_TO_RAD = 0.4848136811095359935899141023; - //static const double RAD_TO_SEC5 = 2.062648062470963551564733573; + static const double epsilon = 1e-10; static const int Nbf = 5; static const int Ntpsi = 9; static const int Ntphi = 8; template <typename T> - inline T SEC5_TO_RAD() { return 0.4848136811095359935899141023; } + inline T sec5_to_rad() { return 0.4848136811095359935899141023; } template <typename T> - inline T RAD_TO_SEC5() { return 2.062648062470963551564733573; } + inline T rad_to_sec5() { return 2.062648062470963551564733573; } template <typename T> - inline const COMPLEX<T> * bf() + inline const pj_complex<T> * bf() { - static const COMPLEX<T> result[] = { + static const pj_complex<T> result[] = { {.7557853228, 0.0}, {.249204646, .003371507}, {-.001541739, .041058560}, @@ -98,80 +95,76 @@ namespace projections template <typename T> inline const T * tphi() { - static const T result[] = { 1.5627014243, .5185406398, -.03333098, -.1052906, -.0368594, - .007317, .01220, .00394, -.0013 }; + static const T result[] = { 1.5627014243, .5185406398, -.03333098, + -.1052906, -.0368594, .007317, + .01220, .00394, -.0013 }; return result; } template <typename T> inline const T * tpsi() { static const T result[] = { .6399175073, -.1358797613, .063294409, -.02526853, .0117879, - -.0055161, .0026906, -.001333, .00067, -.00034 }; + -.0055161, .0026906, -.001333, .00067, -.00034 }; return result; } // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_nzmg_ellipsoid : public base_t_fi<base_nzmg_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_nzmg_ellipsoid + : public base_t_fi<base_nzmg_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_nzmg_ellipsoid(const Parameters& par) - : base_t_fi<base_nzmg_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_nzmg_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) ellipsoid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType RAD_TO_SEC5 = nzmg::RAD_TO_SEC5<CalculationType>(); + static const T rad_to_sec5 = nzmg::rad_to_sec5<T>(); - COMPLEX<CalculationType> p; - const CalculationType * C; + pj_complex<T> p; + const T * C; int i; - lp_lat = (lp_lat - this->m_par.phi0) * RAD_TO_SEC5; - for (p.r = *(C = tpsi<CalculationType>() + (i = Ntpsi)); i ; --i) + lp_lat = (lp_lat - this->m_par.phi0) * rad_to_sec5; + for (p.r = *(C = tpsi<T>() + (i = Ntpsi)); i ; --i) p.r = *--C + lp_lat * p.r; p.r *= lp_lat; p.i = lp_lon; - p = pj_zpoly1(p, bf<CalculationType>(), Nbf); + p = pj_zpoly1(p, bf<T>(), Nbf); xy_x = p.i; xy_y = p.r; } // INVERSE(e_inverse) ellipsoid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType SEC5_TO_RAD = nzmg::SEC5_TO_RAD<CalculationType>(); + static const T sec5_to_rad = nzmg::sec5_to_rad<T>(); int nn, i; - COMPLEX<CalculationType> p, f, fp, dp; - CalculationType den; - const CalculationType* C; + pj_complex<T> p, f, fp, dp; + T den; + const T* C; p.r = xy_y; p.i = xy_x; for (nn = 20; nn ;--nn) { - f = pj_zpolyd1(p, bf<CalculationType>(), Nbf, &fp); + f = pj_zpolyd1(p, bf<T>(), Nbf, &fp); f.r -= xy_y; f.i -= xy_x; den = fp.r * fp.r + fp.i * fp.i; p.r += dp.r = -(f.r * fp.r + f.i * fp.i) / den; p.i += dp.i = -(f.i * fp.r - f.r * fp.i) / den; - if ((fabs(dp.r) + fabs(dp.i)) <= EPSLN) + if ((fabs(dp.r) + fabs(dp.i)) <= epsilon) break; } if (nn) { lp_lon = p.i; - for (lp_lat = *(C = tphi<CalculationType>() + (i = Ntphi)); i ; --i) + for (lp_lat = *(C = tphi<T>() + (i = Ntphi)); i ; --i) lp_lat = *--C + p.r * lp_lat; - lp_lat = this->m_par.phi0 + p.r * lp_lat * SEC5_TO_RAD; + lp_lat = this->m_par.phi0 + p.r * lp_lat * sec5_to_rad; } else lp_lon = lp_lat = HUGE_VAL; } @@ -188,11 +181,12 @@ namespace projections inline void setup_nzmg(Parameters& par) { typedef typename Parameters::type calc_t; + static const calc_t d2r = geometry::math::d2r<calc_t>(); /* force to International major axis */ par.ra = 1. / (par.a = 6378388.0); - par.lam0 = geometry::math::d2r<calc_t>() * 173.; - par.phi0 = geometry::math::d2r<calc_t>() * -41.; + par.lam0 = 173. * d2r; + par.phi0 = -41. * d2r; par.x0 = 2510000.; par.y0 = 6023150.; } @@ -211,10 +205,10 @@ namespace projections \par Example \image html ex_nzmg.gif */ - template <typename CalculationType, typename Parameters> - struct nzmg_ellipsoid : public detail::nzmg::base_nzmg_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct nzmg_ellipsoid : public detail::nzmg::base_nzmg_ellipsoid<T, Parameters> { - inline nzmg_ellipsoid(const Parameters& par) : detail::nzmg::base_nzmg_ellipsoid<CalculationType, Parameters>(par) + inline nzmg_ellipsoid(const Parameters& par) : detail::nzmg::base_nzmg_ellipsoid<T, Parameters>(par) { detail::nzmg::setup_nzmg(this->m_par); } @@ -228,20 +222,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::nzmg, nzmg_ellipsoid, nzmg_ellipsoid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class nzmg_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class nzmg_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<nzmg_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<nzmg_ellipsoid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void nzmg_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void nzmg_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("nzmg", new nzmg_entry<CalculationType, Parameters>); + factory.add_to_factory("nzmg", new nzmg_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/ob_tran.hpp b/boost/geometry/srs/projections/proj/ob_tran.hpp index ae74cc27d2..dd6df24def 100644 --- a/boost/geometry/srs/projections/proj/ob_tran.hpp +++ b/boost/geometry/srs/projections/proj/ob_tran.hpp @@ -1,8 +1,4 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_OB_TRAN_HPP -#define BOOST_GEOMETRY_PROJECTIONS_OB_TRAN_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_OB_TRAN_HPP +#define BOOST_GEOMETRY_PROJECTIONS_OB_TRAN_HPP + #include <boost/geometry/util/math.hpp> #include <boost/shared_ptr.hpp> @@ -57,7 +56,7 @@ namespace srs { namespace par4 { //struct ob_tran_oblique {}; //struct ob_tran_transverse {}; - struct ob_tran {}; + struct ob_tran {}; // General Oblique Transformation }} //namespace srs::par4 @@ -67,36 +66,32 @@ namespace projections namespace detail { // fwd declaration needed below - template <typename CalculationType> - inline detail::base_v<CalculationType, parameters<CalculationType> >* - create_new(parameters<CalculationType> const& parameters); + template <typename T> + inline detail::base_v<T, parameters<T> >* + create_new(parameters<T> const& parameters); } // namespace detail namespace detail { namespace ob_tran { - static const double TOL = 1e-10; + static const double tolerance = 1e-10; template <typename Parameters> inline Parameters o_proj_parameters(Parameters const& par) { - Parameters pj; + /* copy existing header into new */ + Parameters pj = par; /* get name of projection to be translated */ - pj.name = pj_param(par.params, "so_proj").s; - /* copy existing header into new */ - pj.params = par.params; - pj.over = par.over; - pj.geoc = par.geoc; - pj.a = par.a; - pj.es = par.es; - pj.ra = par.ra; - pj.lam0 = par.lam0; - pj.phi0 = par.phi0; - pj.x0 = par.x0; - pj.y0 = par.y0; - pj.k0 = par.k0; + pj.name = pj_get_param_s(par.params, "o_proj"); + if (pj.name.empty()) + BOOST_THROW_EXCEPTION( projection_exception(error_no_rotation_proj) ); + + /* avoid endless recursion */ + if( pj.name == "ob_tran") + BOOST_THROW_EXCEPTION( projection_exception(error_failed_to_find_proj) ); + /* force spherical earth */ pj.one_es = pj.rone_es = 1.; pj.es = pj.e = 0.; @@ -104,47 +99,50 @@ namespace projections return pj; } - template <typename CalculationType, typename Parameters> + template <typename T, typename Parameters> struct par_ob_tran { par_ob_tran(Parameters const& par) : link(projections::detail::create_new(o_proj_parameters(par))) { if (! link.get()) - BOOST_THROW_EXCEPTION( projection_exception(-26) ); + BOOST_THROW_EXCEPTION( projection_exception(error_unknown_projection_id) ); } - template <typename T> inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { link->fwd(lp_lon, lp_lat, xy_x, xy_y); } - template <typename T> inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { link->inv(xy_x, xy_y, lp_lon, lp_lat); } - boost::shared_ptr<base_v<CalculationType, Parameters> > link; - CalculationType lamp; - CalculationType cphip, sphip; + boost::shared_ptr<base_v<T, Parameters> > link; + T lamp; + T cphip, sphip; }; - template <typename StaticParameters, typename CalculationType, typename Parameters> + template <typename StaticParameters, typename T, typename Parameters> struct par_ob_tran_static { + // this metafunction handles static error handling typedef typename srs::par4::detail::pick_o_proj_tag < StaticParameters >::type o_proj_tag; + /* avoid endless recursion */ + static const bool is_o_proj_not_ob_tran = ! boost::is_same<o_proj_tag, srs::par4::ob_tran>::value; + BOOST_MPL_ASSERT_MSG((is_o_proj_not_ob_tran), INVALID_O_PROJ_PARAMETER, (StaticParameters)); + typedef typename projections::detail::static_projection_type < o_proj_tag, srs_sphere_tag, // force spherical StaticParameters, - CalculationType, + T, Parameters >::type projection_type; @@ -152,21 +150,19 @@ namespace projections : link(o_proj_parameters(par)) {} - template <typename T> inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { link.fwd(lp_lon, lp_lat, xy_x, xy_y); } - template <typename T> inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { link.inv(xy_x, xy_y, lp_lon, lp_lat); } projection_type link; - CalculationType lamp; - CalculationType cphip, sphip; + T lamp; + T cphip, sphip; }; template <typename T, typename Par> @@ -209,6 +205,7 @@ namespace projections coslam = cos(lp_lon); lp_lon = adjlon(aatan2(cosphi * sin(lp_lon), sin(lp_lat)) + proj_parm.lamp); lp_lat = aasin(- cosphi * coslam); + proj_parm.fwd(lp_lon, lp_lat, xy_x, xy_y); } @@ -227,92 +224,92 @@ namespace projections } // General Oblique Transformation - template <typename CalculationType, typename Parameters, typename ProjParameters> - inline CalculationType setup_ob_tran(Parameters & par, ProjParameters& proj_parm) + template <typename T, typename Parameters, typename ProjParameters> + inline T setup_ob_tran(Parameters & par, ProjParameters& proj_parm) { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); - CalculationType phip; + T phip, alpha; par.es = 0.; /* force to spherical */ // proj_parm.link should be created at this point - if (pj_param(par.params, "to_alpha").i) { - CalculationType lamc, phic, alpha; - - lamc = pj_param(par.params, "ro_lon_c").f; - phic = pj_param(par.params, "ro_lat_c").f; - alpha = pj_param(par.params, "ro_alpha").f; - /* - if (fabs(phic) <= TOL || - fabs(fabs(phic) - HALFPI) <= TOL || - fabs(fabs(alpha) - HALFPI) <= TOL) - */ - if (fabs(fabs(phic) - HALFPI) <= TOL) - BOOST_THROW_EXCEPTION( projection_exception(-32) ); + if (pj_param_r(par.params, "o_alpha", alpha)) { + T lamc, phic; + + lamc = pj_get_param_r(par.params, "o_lon_c"); + phic = pj_get_param_r(par.params, "o_lat_c"); + //alpha = pj_get_param_r(par.params, "o_alpha"); + + if (fabs(fabs(phic) - half_pi) <= tolerance) + BOOST_THROW_EXCEPTION( projection_exception(error_lat_0_or_alpha_eq_90) ); + proj_parm.lamp = lamc + aatan2(-cos(alpha), -sin(alpha) * sin(phic)); phip = aasin(cos(phic) * sin(alpha)); - } else if (pj_param(par.params, "to_lat_p").i) { /* specified new pole */ - proj_parm.lamp = pj_param(par.params, "ro_lon_p").f; - phip = pj_param(par.params, "ro_lat_p").f; + } else if (pj_param_r(par.params, "o_lat_p", phip)) { /* specified new pole */ + proj_parm.lamp = pj_get_param_r(par.params, "o_lon_p"); + //phip = pj_param_r(par.params, "o_lat_p"); } else { /* specified new "equator" points */ - CalculationType lam1, lam2, phi1, phi2, con; - - lam1 = pj_param(par.params, "ro_lon_1").f; - phi1 = pj_param(par.params, "ro_lat_1").f; - lam2 = pj_param(par.params, "ro_lon_2").f; - phi2 = pj_param(par.params, "ro_lat_2").f; - if (fabs(phi1 - phi2) <= TOL || - (con = fabs(phi1)) <= TOL || - fabs(con - HALFPI) <= TOL || - fabs(fabs(phi2) - HALFPI) <= TOL) - BOOST_THROW_EXCEPTION( projection_exception(-33) ); + T lam1, lam2, phi1, phi2, con; + + lam1 = pj_get_param_r(par.params, "o_lon_1"); + phi1 = pj_get_param_r(par.params, "o_lat_1"); + lam2 = pj_get_param_r(par.params, "o_lon_2"); + phi2 = pj_get_param_r(par.params, "o_lat_2"); + if (fabs(phi1 - phi2) <= tolerance || (con = fabs(phi1)) <= tolerance || + fabs(con - half_pi) <= tolerance || fabs(fabs(phi2) - half_pi) <= tolerance) + BOOST_THROW_EXCEPTION( projection_exception(error_lat_1_or_2_zero_or_90) ); + proj_parm.lamp = atan2(cos(phi1) * sin(phi2) * cos(lam1) - sin(phi1) * cos(phi2) * cos(lam2), sin(phi1) * cos(phi2) * sin(lam2) - cos(phi1) * sin(phi2) * sin(lam1)); phip = atan(-cos(proj_parm.lamp - lam1) / tan(phi1)); } - if (fabs(phip) > TOL) { /* oblique */ + + if (fabs(phip) > tolerance) { /* oblique */ proj_parm.cphip = cos(phip); proj_parm.sphip = sin(phip); } else { /* transverse */ } + + // TODO: + /* Support some rather speculative test cases, where the rotated projection */ + /* is actually latlong. We do not want scaling in that case... */ + //if (proj_parm.link...mutable_parameters().right==PJ_IO_UNITS_ANGULAR) + // par.right = PJ_IO_UNITS_PROJECTED; + // return phip to choose model return phip; } // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_ob_tran_oblique : public base_t_fi<base_ob_tran_oblique<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_ob_tran_oblique + : public base_t_fi<base_ob_tran_oblique<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_ob_tran<CalculationType, Parameters> m_proj_parm; + par_ob_tran<T, Parameters> m_proj_parm; inline base_ob_tran_oblique(Parameters const& par, - par_ob_tran<CalculationType, Parameters> const& proj_parm) + par_ob_tran<T, Parameters> const& proj_parm) : base_t_fi < - base_ob_tran_oblique<CalculationType, Parameters>, CalculationType, Parameters + base_ob_tran_oblique<T, Parameters>, T, Parameters >(*this, par) , m_proj_parm(proj_parm) {} // FORWARD(o_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { o_forward(lp_lon, lp_lat, xy_x, xy_y, this->m_proj_parm); } // INVERSE(o_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { o_inverse(xy_x, xy_y, lp_lon, lp_lat, this->m_proj_parm); } @@ -325,35 +322,31 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_ob_tran_transverse : public base_t_fi<base_ob_tran_transverse<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_ob_tran_transverse + : public base_t_fi<base_ob_tran_transverse<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_ob_tran<CalculationType, Parameters> m_proj_parm; + par_ob_tran<T, Parameters> m_proj_parm; inline base_ob_tran_transverse(Parameters const& par, - par_ob_tran<CalculationType, Parameters> const& proj_parm) + par_ob_tran<T, Parameters> const& proj_parm) : base_t_fi < - base_ob_tran_transverse<CalculationType, Parameters>, CalculationType, Parameters + base_ob_tran_transverse<T, Parameters>, T, Parameters >(*this, par) , m_proj_parm(proj_parm) {} // FORWARD(t_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { t_forward(lp_lon, lp_lat, xy_x, xy_y, this->m_proj_parm); } // INVERSE(t_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { t_inverse(xy_x, xy_y, lp_lon, lp_lat, this->m_proj_parm); } @@ -366,25 +359,21 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename StaticParameters, typename CalculationType, typename Parameters> - struct base_ob_tran_static : public base_t_fi<base_ob_tran_static<StaticParameters, CalculationType, Parameters>, - CalculationType, Parameters> + template <typename StaticParameters, typename T, typename Parameters> + struct base_ob_tran_static + : public base_t_fi<base_ob_tran_static<StaticParameters, T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_ob_tran_static<StaticParameters, CalculationType, Parameters> m_proj_parm; + par_ob_tran_static<StaticParameters, T, Parameters> m_proj_parm; bool m_is_oblique; inline base_ob_tran_static(Parameters const& par) - : base_t_fi<base_ob_tran_static<StaticParameters, CalculationType, Parameters>, CalculationType, Parameters>(*this, par) + : base_t_fi<base_ob_tran_static<StaticParameters, T, Parameters>, T, Parameters>(*this, par) , m_proj_parm(par) {} // FORWARD(o_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { if (m_is_oblique) { o_forward(lp_lon, lp_lat, xy_x, xy_y, this->m_proj_parm); @@ -395,7 +384,7 @@ namespace projections // INVERSE(o_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { if (m_is_oblique) { o_inverse(xy_x, xy_y, lp_lon, lp_lat, this->m_proj_parm); @@ -439,12 +428,12 @@ namespace projections \par Example \image html ex_ob_tran.gif */ - template <typename CalculationType, typename Parameters> - struct ob_tran_oblique : public detail::ob_tran::base_ob_tran_oblique<CalculationType, Parameters> + template <typename T, typename Parameters> + struct ob_tran_oblique : public detail::ob_tran::base_ob_tran_oblique<T, Parameters> { inline ob_tran_oblique(Parameters const& par, - detail::ob_tran::par_ob_tran<CalculationType, Parameters> const& proj_parm) - : detail::ob_tran::base_ob_tran_oblique<CalculationType, Parameters>(par, proj_parm) + detail::ob_tran::par_ob_tran<T, Parameters> const& proj_parm) + : detail::ob_tran::base_ob_tran_oblique<T, Parameters>(par, proj_parm) { // already done //detail::ob_tran::setup_ob_tran(this->m_par, this->m_proj_parm); @@ -476,12 +465,12 @@ namespace projections \par Example \image html ex_ob_tran.gif */ - template <typename CalculationType, typename Parameters> - struct ob_tran_transverse : public detail::ob_tran::base_ob_tran_transverse<CalculationType, Parameters> + template <typename T, typename Parameters> + struct ob_tran_transverse : public detail::ob_tran::base_ob_tran_transverse<T, Parameters> { inline ob_tran_transverse(Parameters const& par, - detail::ob_tran::par_ob_tran<CalculationType, Parameters> const& proj_parm) - : detail::ob_tran::base_ob_tran_transverse<CalculationType, Parameters>(par, proj_parm) + detail::ob_tran::par_ob_tran<T, Parameters> const& proj_parm) + : detail::ob_tran::base_ob_tran_transverse<T, Parameters>(par, proj_parm) { // already done //detail::ob_tran::setup_ob_tran(this->m_par, this->m_proj_parm); @@ -513,14 +502,14 @@ namespace projections \par Example \image html ex_ob_tran.gif */ - template <typename StaticParameters, typename CalculationType, typename Parameters> - struct ob_tran_static : public detail::ob_tran::base_ob_tran_static<StaticParameters, CalculationType, Parameters> + template <typename StaticParameters, typename T, typename Parameters> + struct ob_tran_static : public detail::ob_tran::base_ob_tran_static<StaticParameters, T, Parameters> { inline ob_tran_static(const Parameters& par) - : detail::ob_tran::base_ob_tran_static<StaticParameters, CalculationType, Parameters>(par) + : detail::ob_tran::base_ob_tran_static<StaticParameters, T, Parameters>(par) { - CalculationType phip = detail::ob_tran::setup_ob_tran<CalculationType>(this->m_par, this->m_proj_parm); - this->m_is_oblique = fabs(phip) > detail::ob_tran::TOL; + T phip = detail::ob_tran::setup_ob_tran<T>(this->m_par, this->m_proj_parm); + this->m_is_oblique = fabs(phip) > detail::ob_tran::tolerance; } }; @@ -541,27 +530,27 @@ namespace projections }; // Factory entry(s) - template <typename CalculationType, typename Parameters> - class ob_tran_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class ob_tran_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { Parameters params = par; - detail::ob_tran::par_ob_tran<CalculationType, Parameters> proj_parm(params); - CalculationType phip = detail::ob_tran::setup_ob_tran<CalculationType>(params, proj_parm); + detail::ob_tran::par_ob_tran<T, Parameters> proj_parm(params); + T phip = detail::ob_tran::setup_ob_tran<T>(params, proj_parm); - if (fabs(phip) > detail::ob_tran::TOL) - return new base_v_fi<ob_tran_oblique<CalculationType, Parameters>, CalculationType, Parameters>(params, proj_parm); + if (fabs(phip) > detail::ob_tran::tolerance) + return new base_v_fi<ob_tran_oblique<T, Parameters>, T, Parameters>(params, proj_parm); else - return new base_v_fi<ob_tran_transverse<CalculationType, Parameters>, CalculationType, Parameters>(params, proj_parm); + return new base_v_fi<ob_tran_transverse<T, Parameters>, T, Parameters>(params, proj_parm); } }; - template <typename CalculationType, typename Parameters> - inline void ob_tran_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void ob_tran_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("ob_tran", new ob_tran_entry<CalculationType, Parameters>); + factory.add_to_factory("ob_tran", new ob_tran_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/ocea.hpp b/boost/geometry/srs/projections/proj/ocea.hpp index 4b8da5be6e..f8dd4c4ed1 100644 --- a/boost/geometry/srs/projections/proj/ocea.hpp +++ b/boost/geometry/srs/projections/proj/ocea.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_OCEA_HPP -#define BOOST_GEOMETRY_PROJECTIONS_OCEA_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_OCEA_HPP +#define BOOST_GEOMETRY_PROJECTIONS_OCEA_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -53,7 +52,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct ocea {}; + struct ocea {}; // Oblique Cylindrical Equal Area }} //namespace srs::par4 @@ -74,45 +73,38 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_ocea_spheroid : public base_t_fi<base_ocea_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_ocea_spheroid + : public base_t_fi<base_ocea_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_ocea<CalculationType> m_proj_parm; + par_ocea<T> m_proj_parm; inline base_ocea_spheroid(const Parameters& par) - : base_t_fi<base_ocea_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_ocea_spheroid<T, Parameters>, + T, Parameters>(*this, par) {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType ONEPI = detail::ONEPI<CalculationType>(); + static const T pi = detail::pi<T>(); - CalculationType t; + T t; xy_y = sin(lp_lon); - /* - xy_x = atan2((tan(lp_lat) * this->m_proj_parm.cosphi + this->m_proj_parm.sinphi * xy_y) , cos(lp_lon)); - */ t = cos(lp_lon); xy_x = atan((tan(lp_lat) * this->m_proj_parm.cosphi + this->m_proj_parm.sinphi * xy_y) / t); if (t < 0.) - xy_x += ONEPI; + xy_x += pi; xy_x *= this->m_proj_parm.rtk; xy_y = this->m_proj_parm.rok * (this->m_proj_parm.sinphi * sin(lp_lat) - this->m_proj_parm.cosphi * cos(lp_lat) * xy_y); } // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType t, s; + T t, s; xy_y /= this->m_proj_parm.rok; xy_x /= this->m_proj_parm.rtk; @@ -133,31 +125,42 @@ namespace projections template <typename Parameters, typename T> inline void setup_ocea(Parameters& par, par_ocea<T>& proj_parm) { - static const T HALFPI = detail::HALFPI<T>(); + static const T half_pi = detail::half_pi<T>(); T phi_0=0.0, phi_1, phi_2, lam_1, lam_2, lonz, alpha; proj_parm.rok = 1. / par.k0; proj_parm.rtk = par.k0; - if ( pj_param(par.params, "talpha").i) { - alpha = pj_param(par.params, "ralpha").f; - lonz = pj_param(par.params, "rlonc").f; + /*If the keyword "alpha" is found in the sentence then use 1point+1azimuth*/ + if ( pj_param_r(par.params, "alpha", alpha)) { + /*Define Pole of oblique transformation from 1 point & 1 azimuth*/ + //alpha = pj_get_param_r(par.params, "alpha"); // set above + lonz = pj_get_param_r(par.params, "lonc"); + /*Equation 9-8 page 80 (http://pubs.usgs.gov/pp/1395/report.pdf)*/ proj_parm.singam = atan(-cos(alpha)/(-sin(phi_0) * sin(alpha))) + lonz; + /*Equation 9-7 page 80 (http://pubs.usgs.gov/pp/1395/report.pdf)*/ proj_parm.sinphi = asin(cos(phi_0) * sin(alpha)); + /*If the keyword "alpha" is NOT found in the sentence then use 2points*/ } else { - phi_1 = pj_param(par.params, "rlat_1").f; - phi_2 = pj_param(par.params, "rlat_2").f; - lam_1 = pj_param(par.params, "rlon_1").f; - lam_2 = pj_param(par.params, "rlon_2").f; + /*Define Pole of oblique transformation from 2 points*/ + phi_1 = pj_get_param_r(par.params, "lat_1"); + phi_2 = pj_get_param_r(par.params, "lat_2"); + lam_1 = pj_get_param_r(par.params, "lon_1"); + lam_2 = pj_get_param_r(par.params, "lon_2"); + /*Equation 9-1 page 80 (http://pubs.usgs.gov/pp/1395/report.pdf)*/ proj_parm.singam = atan2(cos(phi_1) * sin(phi_2) * cos(lam_1) - sin(phi_1) * cos(phi_2) * cos(lam_2), sin(phi_1) * cos(phi_2) * sin(lam_2) - cos(phi_1) * sin(phi_2) * sin(lam_1) ); - if (lam_1 == -HALFPI) + + /* take care of P->lam0 wrap-around when +lam_1=-90*/ + if (lam_1 == -half_pi) proj_parm.singam = -proj_parm.singam; + + /*Equation 9-2 page 80 (http://pubs.usgs.gov/pp/1395/report.pdf)*/ proj_parm.sinphi = atan(-cos(proj_parm.singam - lam_1) / tan(phi_1)); } - par.lam0 = proj_parm.singam + HALFPI; + par.lam0 = proj_parm.singam + half_pi; proj_parm.cosphi = cos(proj_parm.sinphi); proj_parm.sinphi = sin(proj_parm.sinphi); proj_parm.cosgam = cos(proj_parm.singam); @@ -187,10 +190,10 @@ namespace projections \par Example \image html ex_ocea.gif */ - template <typename CalculationType, typename Parameters> - struct ocea_spheroid : public detail::ocea::base_ocea_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct ocea_spheroid : public detail::ocea::base_ocea_spheroid<T, Parameters> { - inline ocea_spheroid(const Parameters& par) : detail::ocea::base_ocea_spheroid<CalculationType, Parameters>(par) + inline ocea_spheroid(const Parameters& par) : detail::ocea::base_ocea_spheroid<T, Parameters>(par) { detail::ocea::setup_ocea(this->m_par, this->m_proj_parm); } @@ -204,20 +207,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::ocea, ocea_spheroid, ocea_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class ocea_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class ocea_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<ocea_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<ocea_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void ocea_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void ocea_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("ocea", new ocea_entry<CalculationType, Parameters>); + factory.add_to_factory("ocea", new ocea_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/oea.hpp b/boost/geometry/srs/projections/proj/oea.hpp index 469a41a2d5..24840ea1d6 100644 --- a/boost/geometry/srs/projections/proj/oea.hpp +++ b/boost/geometry/srs/projections/proj/oea.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_OEA_HPP -#define BOOST_GEOMETRY_PROJECTIONS_OEA_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_OEA_HPP +#define BOOST_GEOMETRY_PROJECTIONS_OEA_HPP + #include <boost/math/special_functions/hypot.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -54,7 +53,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct oea {}; + struct oea {}; // Oblated Equal Area }} //namespace srs::par4 @@ -73,25 +72,21 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_oea_spheroid : public base_t_fi<base_oea_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_oea_spheroid + : public base_t_fi<base_oea_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_oea<CalculationType> m_proj_parm; + par_oea<T> m_proj_parm; inline base_oea_spheroid(const Parameters& par) - : base_t_fi<base_oea_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_oea_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) sphere // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType Az, M, N, cp, sp, cl, shz; + T Az, M, N, cp, sp, cl, shz; cp = cos(lp_lat); sp = sin(lp_lat); @@ -106,9 +101,9 @@ namespace projections // INVERSE(s_inverse) sphere // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType N, M, xp, yp, z, Az, cz, sz, cAz; + T N, M, xp, yp, z, Az, cz, sz, cAz; N = this->m_proj_parm.hn * aasin(xy_y * this->m_proj_parm.rn); M = this->m_proj_parm.hm * aasin(xy_x * this->m_proj_parm.rm * cos(N * this->m_proj_parm.two_r_n) / cos(N)); @@ -134,11 +129,11 @@ namespace projections template <typename Parameters, typename T> inline void setup_oea(Parameters& par, par_oea<T>& proj_parm) { - if (((proj_parm.n = pj_param(par.params, "dn").f) <= 0.) || - ((proj_parm.m = pj_param(par.params, "dm").f) <= 0.)) - BOOST_THROW_EXCEPTION( projection_exception(-39) ); - else { - proj_parm.theta = pj_param(par.params, "rtheta").f; + if (((proj_parm.n = pj_get_param_f(par.params, "n")) <= 0.) || + ((proj_parm.m = pj_get_param_f(par.params, "m")) <= 0.)) { + BOOST_THROW_EXCEPTION( projection_exception(error_invalid_m_or_n) ); + } else { + proj_parm.theta = pj_get_param_r(par.params, "theta"); proj_parm.sp0 = sin(par.phi0); proj_parm.cp0 = cos(par.phi0); proj_parm.rn = 1./ proj_parm.n; @@ -170,10 +165,10 @@ namespace projections \par Example \image html ex_oea.gif */ - template <typename CalculationType, typename Parameters> - struct oea_spheroid : public detail::oea::base_oea_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct oea_spheroid : public detail::oea::base_oea_spheroid<T, Parameters> { - inline oea_spheroid(const Parameters& par) : detail::oea::base_oea_spheroid<CalculationType, Parameters>(par) + inline oea_spheroid(const Parameters& par) : detail::oea::base_oea_spheroid<T, Parameters>(par) { detail::oea::setup_oea(this->m_par, this->m_proj_parm); } @@ -187,20 +182,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::oea, oea_spheroid, oea_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class oea_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class oea_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<oea_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<oea_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void oea_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void oea_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("oea", new oea_entry<CalculationType, Parameters>); + factory.add_to_factory("oea", new oea_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/omerc.hpp b/boost/geometry/srs/projections/proj/omerc.hpp index 4da6871d13..a4448d182d 100644 --- a/boost/geometry/srs/projections/proj/omerc.hpp +++ b/boost/geometry/srs/projections/proj/omerc.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_OMERC_HPP -#define BOOST_GEOMETRY_PROJECTIONS_OMERC_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -43,6 +39,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_OMERC_HPP +#define BOOST_GEOMETRY_PROJECTIONS_OMERC_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -57,7 +56,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct omerc {}; + struct omerc {}; // Oblique Mercator }} //namespace srs::par4 @@ -66,9 +65,6 @@ namespace projections #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace omerc { - static const double TOL = 1.e-7; - static const double EPS = 1.e-10; - template <typename T> struct par_omerc { @@ -77,45 +73,45 @@ namespace projections int no_rot; }; + static const double tolerance = 1.e-7; + static const double epsilon = 1.e-10; + // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_omerc_ellipsoid : public base_t_fi<base_omerc_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_omerc_ellipsoid + : public base_t_fi<base_omerc_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_omerc<CalculationType> m_proj_parm; + par_omerc<T> m_proj_parm; inline base_omerc_ellipsoid(const Parameters& par) - : base_t_fi<base_omerc_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_omerc_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) ellipsoid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); - CalculationType Q, S, T, U, V, temp, u, v; + T s, t, U, V, W, temp, u, v; - if (fabs(fabs(lp_lat) - HALFPI) > EPS) { - Q = this->m_proj_parm.E / pow(pj_tsfn(lp_lat, sin(lp_lat), this->m_par.e), this->m_proj_parm.B); - temp = 1. / Q; - S = .5 * (Q - temp); - T = .5 * (Q + temp); + if (fabs(fabs(lp_lat) - half_pi) > epsilon) { + W = this->m_proj_parm.E / math::pow(pj_tsfn(lp_lat, sin(lp_lat), this->m_par.e), this->m_proj_parm.B); + temp = 1. / W; + s = .5 * (W - temp); + t = .5 * (W + temp); 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) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + U = (s * this->m_proj_parm.singam - V * this->m_proj_parm.cosgam) / t; + if (fabs(fabs(U) - 1.0) < epsilon) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } 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) { - u = this->m_proj_parm.A * lp_lon; - } else { - u = this->m_proj_parm.ArB * atan2((S * this->m_proj_parm.cosgam + V * this->m_proj_parm.singam), temp); - } + if(fabs(temp) < tolerance) { + u = this->m_proj_parm.A * lp_lon; + } else { + u = this->m_proj_parm.ArB * atan2((s * this->m_proj_parm.cosgam + V * this->m_proj_parm.singam), temp); + } } else { v = lp_lat > 0 ? this->m_proj_parm.v_pole_n : this->m_proj_parm.v_pole_s; u = this->m_proj_parm.ArB * lp_lat; @@ -132,11 +128,11 @@ namespace projections // INVERSE(e_inverse) ellipsoid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); - CalculationType u, v, Qp, Sp, Tp, Vp, Up; + T u, v, Qp, Sp, Tp, Vp, Up; if (this->m_proj_parm.no_rot) { v = xy_y; @@ -150,13 +146,14 @@ namespace projections Tp = .5 * (Qp + 1. / Qp); Vp = sin(this->m_proj_parm.BrA * u); Up = (Vp * this->m_proj_parm.cosgam + Sp * this->m_proj_parm.singam) / Tp; - if (fabs(fabs(Up) - 1.) < EPS) { + if (fabs(fabs(Up) - 1.) < epsilon) { lp_lon = 0.; - lp_lat = Up < 0. ? -HALFPI : HALFPI; + lp_lat = Up < 0. ? -half_pi : half_pi; } 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) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + if ((lp_lat = pj_phi2(math::pow(lp_lat, T(1) / this->m_proj_parm.B), this->m_par.e)) == HUGE_VAL) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } 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)); } @@ -173,47 +170,46 @@ namespace projections template <typename Parameters, typename T> inline void setup_omerc(Parameters& par, par_omerc<T>& proj_parm) { - static const T FORTPI = detail::FORTPI<T>(); - static const T HALFPI = detail::HALFPI<T>(); - static const T ONEPI = detail::ONEPI<T>(); - static const T TWOPI = detail::TWOPI<T>(); + static const T fourth_pi = detail::fourth_pi<T>(); + static const T half_pi = detail::half_pi<T>(); + static const T pi = detail::pi<T>(); + static const T two_pi = detail::two_pi<T>(); T con, com, cosph0, D, F, H, L, sinph0, p, J, gamma=0, - gamma0, lamc=0, lam1=0, lam2=0, phi1=0, phi2=0, alpha_c=0.0; + gamma0, lamc=0, lam1=0, lam2=0, phi1=0, phi2=0, alpha_c=0; int alp, gam, no_off = 0; - proj_parm.no_rot = pj_param(par.params, "tno_rot").i; - if ((alp = pj_param(par.params, "talpha").i) != 0) - alpha_c = pj_param(par.params, "ralpha").f; - if ((gam = pj_param(par.params, "tgamma").i) != 0) - gamma = pj_param(par.params, "rgamma").f; + proj_parm.no_rot = pj_get_param_b(par.params, "no_rot"); + alp = pj_param_r(par.params, "alpha", alpha_c); + gam = pj_param_r(par.params, "gamma", gamma); if (alp || gam) { - lamc = pj_param(par.params, "rlonc").f; - no_off = - /* For libproj4 compatability */ - pj_param(par.params, "tno_off").i - /* for backward compatibility */ - || pj_param(par.params, "tno_uoff").i; - if( no_off ) - { - /* Mark the parameter as used, so that the pj_get_def() return them */ - pj_param(par.params, "sno_uoff"); - pj_param(par.params, "sno_off"); - } + lamc = pj_get_param_r(par.params, "lonc"); + // NOTE: This is not needed in Boost.Geometry + //no_off = + // /* For libproj4 compatability */ + // pj_param_exists(par.params, "no_off") + // /* for backward compatibility */ + // || pj_param_exists(par.params, "no_uoff"); + //if( no_off ) + //{ + // /* Mark the parameter as used, so that the pj_get_def() return them */ + // pj_get_param_s(par.params, "no_uoff"); + // pj_get_param_s(par.params, "no_off"); + //} } else { - lam1 = pj_param(par.params, "rlon_1").f; - phi1 = pj_param(par.params, "rlat_1").f; - lam2 = pj_param(par.params, "rlon_2").f; - phi2 = pj_param(par.params, "rlat_2").f; - if (fabs(phi1 - phi2) <= TOL || - (con = fabs(phi1)) <= TOL || - fabs(con - HALFPI) <= TOL || - fabs(fabs(par.phi0) - HALFPI) <= TOL || - fabs(fabs(phi2) - HALFPI) <= TOL) - BOOST_THROW_EXCEPTION( projection_exception(-33) ); + lam1 = pj_get_param_r(par.params, "lon_1"); + phi1 = pj_get_param_r(par.params, "lat_1"); + lam2 = pj_get_param_r(par.params, "lon_2"); + phi2 = pj_get_param_r(par.params, "lat_2"); + if (fabs(phi1 - phi2) <= tolerance || + (con = fabs(phi1)) <= tolerance || + fabs(con - half_pi) <= tolerance || + fabs(fabs(par.phi0) - half_pi) <= tolerance || + fabs(fabs(phi2) - half_pi) <= tolerance) + BOOST_THROW_EXCEPTION( projection_exception(error_lat_0_or_alpha_eq_90) ); } com = sqrt(par.one_es); - if (fabs(par.phi0) > EPS) { + if (fabs(par.phi0) > epsilon) { sinph0 = sin(par.phi0); cosph0 = cos(par.phi0); con = 1. - par.es * sinph0 * sinph0; @@ -229,7 +225,7 @@ namespace projections F = -F; } proj_parm.E = F += D; - proj_parm.E *= pow(pj_tsfn(par.phi0, sinph0, par.e), proj_parm.B); + proj_parm.E *= math::pow(pj_tsfn(par.phi0, sinph0, par.e), proj_parm.B); } else { proj_parm.B = 1. / com; proj_parm.A = par.k0; @@ -237,33 +233,29 @@ namespace projections } if (alp || gam) { if (alp) { - gamma0 = asin(sin(alpha_c) / D); + gamma0 = aasin(sin(alpha_c) / D); if (!gam) gamma = alpha_c; } else - alpha_c = asin(D*sin(gamma0 = gamma)); - if ((con = fabs(alpha_c)) <= TOL || - fabs(con - ONEPI) <= TOL || - fabs(fabs(par.phi0) - HALFPI) <= TOL) - BOOST_THROW_EXCEPTION( projection_exception(-32) ); - par.lam0 = lamc - asin(.5 * (F - 1. / F) * + alpha_c = aasin(D*sin(gamma0 = gamma)); + par.lam0 = lamc - aasin(.5 * (F - 1. / F) * tan(gamma0)) / proj_parm.B; } else { - H = pow(pj_tsfn(phi1, sin(phi1), par.e), proj_parm.B); - L = pow(pj_tsfn(phi2, sin(phi2), par.e), proj_parm.B); + H = math::pow(pj_tsfn(phi1, sin(phi1), par.e), proj_parm.B); + L = math::pow(pj_tsfn(phi2, sin(phi2), par.e), proj_parm.B); F = proj_parm.E / H; p = (L - H) / (L + H); J = proj_parm.E * proj_parm.E; J = (J - L * H) / (J + L * H); - if ((con = lam1 - lam2) < -ONEPI) - lam2 -= TWOPI; - else if (con > ONEPI) - lam2 += TWOPI; + if ((con = lam1 - lam2) < -pi) + lam2 -= two_pi; + else if (con > pi) + lam2 += two_pi; par.lam0 = adjlon(.5 * (lam1 + lam2) - atan( J * tan(.5 * proj_parm.B * (lam1 - lam2)) / p) / proj_parm.B); gamma0 = atan(2. * sin(proj_parm.B * adjlon(lam1 - par.lam0)) / (F - 1. / F)); - gamma = alpha_c = asin(D * sin(gamma0)); + gamma = alpha_c = aasin(D * sin(gamma0)); } proj_parm.singam = sin(gamma0); proj_parm.cosgam = cos(gamma0); @@ -274,13 +266,13 @@ namespace projections if (no_off) proj_parm.u_0 = 0; else { - proj_parm.u_0 = fabs(proj_parm.ArB * atan2(sqrt(D * D - 1.), cos(alpha_c))); + proj_parm.u_0 = fabs(proj_parm.ArB * atan(sqrt(D * D - 1.) / cos(alpha_c))); if (par.phi0 < 0.) proj_parm.u_0 = - proj_parm.u_0; } F = 0.5 * gamma0; - proj_parm.v_pole_n = proj_parm.ArB * log(tan(FORTPI - F)); - proj_parm.v_pole_s = proj_parm.ArB * log(tan(FORTPI + F)); + proj_parm.v_pole_n = proj_parm.ArB * log(tan(fourth_pi - F)); + proj_parm.v_pole_s = proj_parm.ArB * log(tan(fourth_pi + F)); } }} // namespace detail::omerc @@ -310,10 +302,10 @@ namespace projections \par Example \image html ex_omerc.gif */ - template <typename CalculationType, typename Parameters> - struct omerc_ellipsoid : public detail::omerc::base_omerc_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct omerc_ellipsoid : public detail::omerc::base_omerc_ellipsoid<T, Parameters> { - inline omerc_ellipsoid(const Parameters& par) : detail::omerc::base_omerc_ellipsoid<CalculationType, Parameters>(par) + inline omerc_ellipsoid(const Parameters& par) : detail::omerc::base_omerc_ellipsoid<T, Parameters>(par) { detail::omerc::setup_omerc(this->m_par, this->m_proj_parm); } @@ -327,20 +319,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::omerc, omerc_ellipsoid, omerc_ellipsoid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class omerc_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class omerc_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<omerc_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<omerc_ellipsoid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void omerc_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void omerc_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("omerc", new omerc_entry<CalculationType, Parameters>); + factory.add_to_factory("omerc", new omerc_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/ortho.hpp b/boost/geometry/srs/projections/proj/ortho.hpp index 4510f9dab9..370af50f70 100644 --- a/boost/geometry/srs/projections/proj/ortho.hpp +++ b/boost/geometry/srs/projections/proj/ortho.hpp @@ -1,8 +1,4 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_ORTHO_HPP -#define BOOST_GEOMETRY_PROJECTIONS_ORTHO_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_ORTHO_HPP +#define BOOST_GEOMETRY_PROJECTIONS_ORTHO_HPP + #include <boost/config.hpp> #include <boost/geometry/util/math.hpp> #include <boost/math/special_functions/hypot.hpp> @@ -55,7 +54,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct ortho {}; + struct ortho {}; // Orthographic }} //namespace srs::par4 @@ -65,63 +64,65 @@ namespace projections namespace detail { namespace ortho { - static const double EPS10 = 1.e-10; - static const int N_POLE = 0; - static const int S_POLE = 1; - static const int EQUIT = 2; - static const int OBLIQ = 3; + enum mode_type { + n_pole = 0, + s_pole = 1, + equit = 2, + obliq = 3 + }; template <typename T> struct par_ortho { T sinph0; T cosph0; - int mode; + mode_type mode; }; + static const double epsilon10 = 1.e-10; + // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_ortho_spheroid : public base_t_fi<base_ortho_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_ortho_spheroid + : public base_t_fi<base_ortho_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_ortho<CalculationType> m_proj_parm; + par_ortho<T> m_proj_parm; inline base_ortho_spheroid(const Parameters& par) - : base_t_fi<base_ortho_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_ortho_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); - CalculationType coslam, cosphi, sinphi; + T coslam, cosphi, sinphi; cosphi = cos(lp_lat); coslam = cos(lp_lon); switch (this->m_proj_parm.mode) { - case EQUIT: - if (cosphi * coslam < - EPS10) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + case equit: + if (cosphi * coslam < - epsilon10) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } xy_y = sin(lp_lat); break; - case OBLIQ: + case obliq: if (this->m_proj_parm.sinph0 * (sinphi = sin(lp_lat)) + - this->m_proj_parm.cosph0 * cosphi * coslam < - EPS10) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + this->m_proj_parm.cosph0 * cosphi * coslam < - epsilon10) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } xy_y = this->m_proj_parm.cosph0 * sinphi - this->m_proj_parm.sinph0 * cosphi * coslam; break; - case N_POLE: + case n_pole: coslam = - coslam; BOOST_FALLTHROUGH; - case S_POLE: - if (fabs(lp_lat - this->m_par.phi0) - EPS10 > HALFPI) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + case s_pole: + if (fabs(lp_lat - this->m_par.phi0) - epsilon10 > half_pi) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } xy_y = cosphi * coslam; break; } @@ -130,48 +131,49 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); - CalculationType rh, cosc, sinc; + T rh, cosc, sinc; if ((sinc = (rh = boost::math::hypot(xy_x, xy_y))) > 1.) { - if ((sinc - 1.) > EPS10) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + if ((sinc - 1.) > epsilon10) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } sinc = 1.; } cosc = sqrt(1. - sinc * sinc); /* in this range OK */ - if (fabs(rh) <= EPS10) { + if (fabs(rh) <= epsilon10) { lp_lat = this->m_par.phi0; lp_lon = 0.0; } else { switch (this->m_proj_parm.mode) { - case N_POLE: + case n_pole: xy_y = -xy_y; lp_lat = acos(sinc); break; - case S_POLE: + case s_pole: lp_lat = - acos(sinc); break; - case EQUIT: + case equit: lp_lat = xy_y * sinc / rh; xy_x *= sinc; xy_y = cosc * rh; goto sinchk; - case OBLIQ: + case obliq: lp_lat = cosc * this->m_proj_parm.sinph0 + xy_y * sinc * this->m_proj_parm.cosph0 /rh; xy_y = (cosc - this->m_proj_parm.sinph0 * lp_lat) * rh; xy_x *= sinc * this->m_proj_parm.cosph0; sinchk: if (fabs(lp_lat) >= 1.) - lp_lat = lp_lat < 0. ? -HALFPI : HALFPI; + lp_lat = lp_lat < 0. ? -half_pi : half_pi; else lp_lat = asin(lp_lat); break; } - lp_lon = (xy_y == 0. && (this->m_proj_parm.mode == OBLIQ || this->m_proj_parm.mode == EQUIT)) - ? (xy_x == 0. ? 0. : xy_x < 0. ? -HALFPI : HALFPI) + lp_lon = (xy_y == 0. && (this->m_proj_parm.mode == obliq || this->m_proj_parm.mode == equit)) + ? (xy_x == 0. ? 0. : xy_x < 0. ? -half_pi : half_pi) : atan2(xy_x, xy_y); } } @@ -187,14 +189,14 @@ namespace projections template <typename Parameters, typename T> inline void setup_ortho(Parameters& par, par_ortho<T>& proj_parm) { - if (fabs(fabs(par.phi0) - geometry::math::half_pi<T>()) <= EPS10) - proj_parm.mode = par.phi0 < 0. ? S_POLE : N_POLE; - else if (fabs(par.phi0) > EPS10) { - proj_parm.mode = OBLIQ; + if (fabs(fabs(par.phi0) - geometry::math::half_pi<T>()) <= epsilon10) + proj_parm.mode = par.phi0 < 0. ? s_pole : n_pole; + else if (fabs(par.phi0) > epsilon10) { + proj_parm.mode = obliq; proj_parm.sinph0 = sin(par.phi0); proj_parm.cosph0 = cos(par.phi0); } else - proj_parm.mode = EQUIT; + proj_parm.mode = equit; par.es = 0.; } @@ -213,10 +215,10 @@ namespace projections \par Example \image html ex_ortho.gif */ - template <typename CalculationType, typename Parameters> - struct ortho_spheroid : public detail::ortho::base_ortho_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct ortho_spheroid : public detail::ortho::base_ortho_spheroid<T, Parameters> { - inline ortho_spheroid(const Parameters& par) : detail::ortho::base_ortho_spheroid<CalculationType, Parameters>(par) + inline ortho_spheroid(const Parameters& par) : detail::ortho::base_ortho_spheroid<T, Parameters>(par) { detail::ortho::setup_ortho(this->m_par, this->m_proj_parm); } @@ -230,20 +232,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::ortho, ortho_spheroid, ortho_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class ortho_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class ortho_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<ortho_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<ortho_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void ortho_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void ortho_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("ortho", new ortho_entry<CalculationType, Parameters>); + factory.add_to_factory("ortho", new ortho_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/poly.hpp b/boost/geometry/srs/projections/proj/poly.hpp index ff97ecadec..95da13f0d7 100644 --- a/boost/geometry/srs/projections/proj/poly.hpp +++ b/boost/geometry/srs/projections/proj/poly.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_POLY_HPP -#define BOOST_GEOMETRY_PROJECTIONS_POLY_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_POLY_HPP +#define BOOST_GEOMETRY_PROJECTIONS_POLY_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -53,7 +52,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct poly {}; + struct poly {}; // Polyconic (American) }} //namespace srs::par4 @@ -63,44 +62,42 @@ namespace projections namespace detail { namespace poly { - static const double TOL = 1e-10; - static const double CONV = 1e-10; - static const int N_ITER = 10; - static const int I_ITER = 20; - static const double ITOL = 1.e-12; + static const double tolerance = 1e-10; + static const double conv_tolerance = 1e-10; + static const int n_iter = 10; + static const int i_iter = 20; + static const double i_tolerance = 1.e-12; template <typename T> struct par_poly { T ml0; - T en[EN_SIZE]; + detail::en<T> en; }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_poly_ellipsoid : public base_t_fi<base_poly_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_poly_ellipsoid + : public base_t_fi<base_poly_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_poly<CalculationType> m_proj_parm; + par_poly<T> m_proj_parm; inline base_poly_ellipsoid(const Parameters& par) - : base_t_fi<base_poly_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_poly_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) ellipsoid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType ms, sp, cp; + T ms, sp, cp; - if (fabs(lp_lat) <= TOL) { xy_x = lp_lon; xy_y = -this->m_proj_parm.ml0; } - else { + if (fabs(lp_lat) <= tolerance) { + xy_x = lp_lon; + xy_y = -this->m_proj_parm.ml0; + } else { sp = sin(lp_lat); - ms = fabs(cp = cos(lp_lat)) > TOL ? pj_msfn(sp, cp, this->m_par.es) / sp : 0.; + ms = fabs(cp = cos(lp_lat)) > tolerance ? pj_msfn(sp, cp, this->m_par.es) / sp : 0.; xy_x = ms * sin(lp_lon *= sp); xy_y = (pj_mlfn(lp_lat, sp, cp, this->m_proj_parm.en) - this->m_proj_parm.ml0) + ms * (1. - cos(lp_lon)); } @@ -108,22 +105,23 @@ namespace projections // INVERSE(e_inverse) ellipsoid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { xy_y += this->m_proj_parm.ml0; - if (fabs(xy_y) <= TOL) { + if (fabs(xy_y) <= tolerance) { lp_lon = xy_x; lp_lat = 0.; } else { - CalculationType r, c, sp, cp, s2ph, ml, mlb, mlp, dPhi; + T r, c, sp, cp, s2ph, ml, mlb, mlp, dPhi; int i; r = xy_y * xy_y + xy_x * xy_x; - for (lp_lat = xy_y, i = I_ITER; i ; --i) { + for (lp_lat = xy_y, i = i_iter; i ; --i) { sp = sin(lp_lat); s2ph = sp * ( cp = cos(lp_lat)); - if (fabs(cp) < ITOL) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + if (fabs(cp) < i_tolerance) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } 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; @@ -132,11 +130,12 @@ namespace projections ( ml + ml + c * mlb - 2. * xy_y * (c * ml + 1.) ) / ( this->m_par.es * s2ph * (mlb - 2. * xy_y * ml) / c + 2.* (xy_y - ml) * (c * mlp - 1. / s2ph) - mlp - mlp )); - if (fabs(dPhi) <= ITOL) + if (fabs(dPhi) <= i_tolerance) break; } - if (!i) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + if (!i) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } c = sin(lp_lat); lp_lon = asin(xy_x * tan(lp_lat) * sqrt(1. - this->m_par.es * c * c)) / sin(lp_lat); } @@ -150,27 +149,23 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_poly_spheroid : public base_t_fi<base_poly_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_poly_spheroid + : public base_t_fi<base_poly_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_poly<CalculationType> m_proj_parm; + par_poly<T> m_proj_parm; inline base_poly_spheroid(const Parameters& par) - : base_t_fi<base_poly_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_poly_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType cot, E; + T cot, E; - if (fabs(lp_lat) <= TOL) { + if (fabs(lp_lat) <= tolerance) { xy_x = lp_lon; xy_y = this->m_proj_parm.ml0; } else { @@ -182,26 +177,27 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType B, dphi, tp; + T B, dphi, tp; int i; - if (fabs(xy_y = this->m_par.phi0 + xy_y) <= TOL) { + if (fabs(xy_y = this->m_par.phi0 + xy_y) <= tolerance) { lp_lon = xy_x; lp_lat = 0.; } else { lp_lat = xy_y; B = xy_x * xy_x + xy_y * xy_y; - i = N_ITER; + i = n_iter; do { tp = tan(lp_lat); lp_lat -= (dphi = (xy_y * (lp_lat * tp + 1.) - lp_lat - .5 * ( lp_lat * lp_lat + B) * tp) / ((lp_lat - xy_y) / tp - 1.)); - } while (fabs(dphi) > CONV && --i); - if (! i) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + } while (fabs(dphi) > conv_tolerance && --i); + if (! i) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } lp_lon = asin(xy_x * tan(lp_lat)) / sin(lp_lat); } } @@ -217,9 +213,8 @@ namespace projections template <typename Parameters, typename T> inline void setup_poly(Parameters& par, par_poly<T>& proj_parm) { - if (par.es) { - if (!pj_enfn(par.es, proj_parm.en)) - BOOST_THROW_EXCEPTION( projection_exception(0) ); + if (par.es != 0.0) { + proj_parm.en = pj_enfn<T>(par.es); proj_parm.ml0 = pj_mlfn(par.phi0, sin(par.phi0), cos(par.phi0), proj_parm.en); } else { proj_parm.ml0 = -par.phi0; @@ -242,10 +237,10 @@ namespace projections \par Example \image html ex_poly.gif */ - template <typename CalculationType, typename Parameters> - struct poly_ellipsoid : public detail::poly::base_poly_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct poly_ellipsoid : public detail::poly::base_poly_ellipsoid<T, Parameters> { - inline poly_ellipsoid(const Parameters& par) : detail::poly::base_poly_ellipsoid<CalculationType, Parameters>(par) + inline poly_ellipsoid(const Parameters& par) : detail::poly::base_poly_ellipsoid<T, Parameters>(par) { detail::poly::setup_poly(this->m_par, this->m_proj_parm); } @@ -264,10 +259,10 @@ namespace projections \par Example \image html ex_poly.gif */ - template <typename CalculationType, typename Parameters> - struct poly_spheroid : public detail::poly::base_poly_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct poly_spheroid : public detail::poly::base_poly_spheroid<T, Parameters> { - inline poly_spheroid(const Parameters& par) : detail::poly::base_poly_spheroid<CalculationType, Parameters>(par) + inline poly_spheroid(const Parameters& par) : detail::poly::base_poly_spheroid<T, Parameters>(par) { detail::poly::setup_poly(this->m_par, this->m_proj_parm); } @@ -281,23 +276,23 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::poly, poly_spheroid, poly_ellipsoid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class poly_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class poly_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { if (par.es) - return new base_v_fi<poly_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<poly_ellipsoid<T, Parameters>, T, Parameters>(par); else - return new base_v_fi<poly_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<poly_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void poly_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void poly_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("poly", new poly_entry<CalculationType, Parameters>); + factory.add_to_factory("poly", new poly_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/putp2.hpp b/boost/geometry/srs/projections/proj/putp2.hpp index 458ee81aa3..181afe5086 100644 --- a/boost/geometry/srs/projections/proj/putp2.hpp +++ b/boost/geometry/srs/projections/proj/putp2.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_PUTP2_HPP -#define BOOST_GEOMETRY_PROJECTIONS_PUTP2_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_PUTP2_HPP +#define BOOST_GEOMETRY_PROJECTIONS_PUTP2_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -52,7 +51,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct putp2 {}; + struct putp2 {}; // Putnins P2 }} //namespace srs::par4 @@ -65,55 +64,51 @@ namespace projections static const double C_x = 1.89490; static const double C_y = 1.71848; static const double C_p = 0.6141848493043784; - static const double EPS = 1e-10; - static const int NITER = 10; - //static const double PI_DIV_3 = 1.0471975511965977; + static const double epsilon = 1e-10; + static const int n_iter = 10; + //static const double third_pi = 1.0471975511965977; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_putp2_spheroid : public base_t_fi<base_putp2_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_putp2_spheroid + : public base_t_fi<base_putp2_spheroid<T, Parameters>, T, Parameters> { - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_putp2_spheroid(const Parameters& par) - : base_t_fi<base_putp2_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_putp2_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType PI_DIV_3 = detail::PI_DIV_3<CalculationType>(); + static const T third_pi = detail::third_pi<T>(); - CalculationType p, c, s, V; + T p, c, s, V; int i; p = C_p * sin(lp_lat); s = lp_lat * lp_lat; lp_lat *= 0.615709 + s * ( 0.00909953 + s * 0.0046292 ); - for (i = NITER; i ; --i) { + for (i = n_iter; i ; --i) { c = cos(lp_lat); s = sin(lp_lat); lp_lat -= V = (lp_lat + s * (c - 1.) - p) / (1. + c * (c - 1.) - s * s); - if (fabs(V) < EPS) + if (fabs(V) < epsilon) break; } if (!i) - lp_lat = lp_lat < 0 ? - PI_DIV_3 : PI_DIV_3; + lp_lat = lp_lat < 0 ? - third_pi : third_pi; xy_x = C_x * lp_lon * (cos(lp_lat) - 0.5); xy_y = C_y * sin(lp_lat); } // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType c; + T c; lp_lat = aasin(xy_y / C_y); lp_lon = xy_x / (C_x * ((c = cos(lp_lat)) - 0.5)); @@ -149,10 +144,10 @@ namespace projections \par Example \image html ex_putp2.gif */ - template <typename CalculationType, typename Parameters> - struct putp2_spheroid : public detail::putp2::base_putp2_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct putp2_spheroid : public detail::putp2::base_putp2_spheroid<T, Parameters> { - inline putp2_spheroid(const Parameters& par) : detail::putp2::base_putp2_spheroid<CalculationType, Parameters>(par) + inline putp2_spheroid(const Parameters& par) : detail::putp2::base_putp2_spheroid<T, Parameters>(par) { detail::putp2::setup_putp2(this->m_par); } @@ -166,20 +161,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::putp2, putp2_spheroid, putp2_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class putp2_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class putp2_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<putp2_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<putp2_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void putp2_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void putp2_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("putp2", new putp2_entry<CalculationType, Parameters>); + factory.add_to_factory("putp2", new putp2_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/putp3.hpp b/boost/geometry/srs/projections/proj/putp3.hpp index 91150082b8..aac6d04f2d 100644 --- a/boost/geometry/srs/projections/proj/putp3.hpp +++ b/boost/geometry/srs/projections/proj/putp3.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_PUTP3_HPP -#define BOOST_GEOMETRY_PROJECTIONS_PUTP3_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,7 +37,8 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -#include <boost/core/ignore_unused.hpp> +#ifndef BOOST_GEOMETRY_PROJECTIONS_PUTP3_HPP +#define BOOST_GEOMETRY_PROJECTIONS_PUTP3_HPP #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> @@ -53,8 +50,8 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct putp3 {}; - struct putp3p {}; + struct putp3 {}; // Putnins P3 + struct putp3p {}; // Putnins P3' }} //namespace srs::par4 @@ -74,23 +71,19 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_putp3_spheroid : public base_t_fi<base_putp3_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_putp3_spheroid + : public base_t_fi<base_putp3_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_putp3<CalculationType> m_proj_parm; + par_putp3<T> m_proj_parm; inline base_putp3_spheroid(const Parameters& par) - : base_t_fi<base_putp3_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_putp3_spheroid<T, Parameters>, + T, Parameters>(*this, par) {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { xy_x = C * lp_lon * (1. - this->m_proj_parm.A * lp_lat * lp_lat); xy_y = C * lp_lat; @@ -98,7 +91,7 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { lp_lat = xy_y / C; lp_lon = xy_x / (C * (1. - this->m_proj_parm.A * lp_lat * lp_lat)); @@ -111,20 +104,14 @@ namespace projections }; - template <typename Parameters, typename T> - inline void setup(Parameters& par, par_putp3<T>& proj_parm) - { - boost::ignore_unused(proj_parm); - par.es = 0.; - } - // Putnins P3 template <typename Parameters, typename T> inline void setup_putp3(Parameters& par, par_putp3<T>& proj_parm) { proj_parm.A = 4. * RPISQ; - setup(par, proj_parm); + + par.es = 0.; } // Putnins P3' @@ -132,7 +119,8 @@ namespace projections inline void setup_putp3p(Parameters& par, par_putp3<T>& proj_parm) { proj_parm.A = 2. * RPISQ; - setup(par, proj_parm); + + par.es = 0.; } }} // namespace detail::putp3 @@ -150,10 +138,10 @@ namespace projections \par Example \image html ex_putp3.gif */ - template <typename CalculationType, typename Parameters> - struct putp3_spheroid : public detail::putp3::base_putp3_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct putp3_spheroid : public detail::putp3::base_putp3_spheroid<T, Parameters> { - inline putp3_spheroid(const Parameters& par) : detail::putp3::base_putp3_spheroid<CalculationType, Parameters>(par) + inline putp3_spheroid(const Parameters& par) : detail::putp3::base_putp3_spheroid<T, Parameters>(par) { detail::putp3::setup_putp3(this->m_par, this->m_proj_parm); } @@ -171,10 +159,10 @@ namespace projections \par Example \image html ex_putp3p.gif */ - template <typename CalculationType, typename Parameters> - struct putp3p_spheroid : public detail::putp3::base_putp3_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct putp3p_spheroid : public detail::putp3::base_putp3_spheroid<T, Parameters> { - inline putp3p_spheroid(const Parameters& par) : detail::putp3::base_putp3_spheroid<CalculationType, Parameters>(par) + inline putp3p_spheroid(const Parameters& par) : detail::putp3::base_putp3_spheroid<T, Parameters>(par) { detail::putp3::setup_putp3p(this->m_par, this->m_proj_parm); } @@ -189,31 +177,31 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::putp3p, putp3p_spheroid, putp3p_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class putp3_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class putp3_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<putp3_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<putp3_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class putp3p_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class putp3p_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<putp3p_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<putp3p_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void putp3_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void putp3_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("putp3", new putp3_entry<CalculationType, Parameters>); - factory.add_to_factory("putp3p", new putp3p_entry<CalculationType, Parameters>); + factory.add_to_factory("putp3", new putp3_entry<T, Parameters>); + factory.add_to_factory("putp3p", new putp3p_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/putp4p.hpp b/boost/geometry/srs/projections/proj/putp4p.hpp index 4252b37141..899278eba8 100644 --- a/boost/geometry/srs/projections/proj/putp4p.hpp +++ b/boost/geometry/srs/projections/proj/putp4p.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_PUTP4P_HPP -#define BOOST_GEOMETRY_PROJECTIONS_PUTP4P_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,7 +37,8 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -#include <boost/core/ignore_unused.hpp> +#ifndef BOOST_GEOMETRY_PROJECTIONS_PUTP4P_HPP +#define BOOST_GEOMETRY_PROJECTIONS_PUTP4P_HPP #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> @@ -54,8 +51,8 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct putp4p {}; - struct weren {}; + struct putp4p {}; // Putnins P4' + struct weren {}; // Werenskiold I }} //namespace srs::par4 @@ -71,33 +68,31 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_putp4p_spheroid : public base_t_fi<base_putp4p_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_putp4p_spheroid + : public base_t_fi<base_putp4p_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_putp4p<CalculationType> m_proj_parm; + par_putp4p<T> m_proj_parm; inline base_putp4p_spheroid(const Parameters& par) - : base_t_fi<base_putp4p_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_putp4p_spheroid<T, Parameters>, + T, Parameters>(*this, par) {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { + static T const third = detail::third<T>(); + lp_lat = aasin(0.883883476 * sin(lp_lat)); xy_x = this->m_proj_parm.C_x * lp_lon * cos(lp_lat); - xy_x /= cos(lp_lat *= 0.333333333333333); + xy_x /= cos(lp_lat *= third); xy_y = this->m_proj_parm.C_y * sin(lp_lat); } // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { lp_lat = aasin(xy_y / this->m_proj_parm.C_y); lp_lon = xy_x * cos(lp_lat) / this->m_proj_parm.C_x; @@ -113,13 +108,6 @@ namespace projections }; - template <typename Parameters, typename T> - inline void setup(Parameters& par, par_putp4p<T>& proj_parm) - { - boost::ignore_unused(proj_parm); - par.es = 0.; - } - // Putnins P4' template <typename Parameters, typename T> @@ -127,7 +115,8 @@ namespace projections { proj_parm.C_x = 0.874038744; proj_parm.C_y = 3.883251825; - setup(par, proj_parm); + + par.es = 0.; } // Werenskiold I @@ -136,7 +125,8 @@ namespace projections { proj_parm.C_x = 1.; proj_parm.C_y = 4.442882938; - setup(par, proj_parm); + + par.es = 0.; } }} // namespace detail::putp4p @@ -154,10 +144,10 @@ namespace projections \par Example \image html ex_putp4p.gif */ - template <typename CalculationType, typename Parameters> - struct putp4p_spheroid : public detail::putp4p::base_putp4p_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct putp4p_spheroid : public detail::putp4p::base_putp4p_spheroid<T, Parameters> { - inline putp4p_spheroid(const Parameters& par) : detail::putp4p::base_putp4p_spheroid<CalculationType, Parameters>(par) + inline putp4p_spheroid(const Parameters& par) : detail::putp4p::base_putp4p_spheroid<T, Parameters>(par) { detail::putp4p::setup_putp4p(this->m_par, this->m_proj_parm); } @@ -175,10 +165,10 @@ namespace projections \par Example \image html ex_weren.gif */ - template <typename CalculationType, typename Parameters> - struct weren_spheroid : public detail::putp4p::base_putp4p_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct weren_spheroid : public detail::putp4p::base_putp4p_spheroid<T, Parameters> { - inline weren_spheroid(const Parameters& par) : detail::putp4p::base_putp4p_spheroid<CalculationType, Parameters>(par) + inline weren_spheroid(const Parameters& par) : detail::putp4p::base_putp4p_spheroid<T, Parameters>(par) { detail::putp4p::setup_weren(this->m_par, this->m_proj_parm); } @@ -193,31 +183,31 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::weren, weren_spheroid, weren_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class putp4p_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class putp4p_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<putp4p_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<putp4p_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class weren_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class weren_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<weren_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<weren_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void putp4p_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void putp4p_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("putp4p", new putp4p_entry<CalculationType, Parameters>); - factory.add_to_factory("weren", new weren_entry<CalculationType, Parameters>); + factory.add_to_factory("putp4p", new putp4p_entry<T, Parameters>); + factory.add_to_factory("weren", new weren_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/putp5.hpp b/boost/geometry/srs/projections/proj/putp5.hpp index 652dca5231..de308a8948 100644 --- a/boost/geometry/srs/projections/proj/putp5.hpp +++ b/boost/geometry/srs/projections/proj/putp5.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_PUTP5_HPP -#define BOOST_GEOMETRY_PROJECTIONS_PUTP5_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,7 +37,8 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -#include <boost/core/ignore_unused.hpp> +#ifndef BOOST_GEOMETRY_PROJECTIONS_PUTP5_HPP +#define BOOST_GEOMETRY_PROJECTIONS_PUTP5_HPP #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> @@ -53,8 +50,8 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct putp5 {}; - struct putp5p {}; + struct putp5 {}; // Putnins P5 + struct putp5p {}; // Putnins P5' }} //namespace srs::par4 @@ -74,23 +71,19 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_putp5_spheroid : public base_t_fi<base_putp5_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_putp5_spheroid + : public base_t_fi<base_putp5_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_putp5<CalculationType> m_proj_parm; + par_putp5<T> m_proj_parm; inline base_putp5_spheroid(const Parameters& par) - : base_t_fi<base_putp5_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_putp5_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { xy_x = C * lp_lon * (this->m_proj_parm.A - this->m_proj_parm.B * sqrt(1. + D * lp_lat * lp_lat)); xy_y = C * lp_lat; @@ -98,7 +91,7 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { lp_lat = xy_y / C; lp_lon = xy_x / (C * (this->m_proj_parm.A - this->m_proj_parm.B * sqrt(1. + D * lp_lat * lp_lat))); @@ -110,14 +103,7 @@ namespace projections } }; - - template <typename Parameters, typename T> - inline void setup(Parameters& par, par_putp5<T>& proj_parm) - { - boost::ignore_unused(proj_parm); - par.es = 0.; - } - + // Putnins P5 template <typename Parameters, typename T> @@ -125,7 +111,8 @@ namespace projections { proj_parm.A = 2.; proj_parm.B = 1.; - setup(par, proj_parm); + + par.es = 0.; } // Putnins P5' @@ -134,7 +121,8 @@ namespace projections { proj_parm.A = 1.5; proj_parm.B = 0.5; - setup(par, proj_parm); + + par.es = 0.; } }} // namespace detail::putp5 @@ -152,10 +140,10 @@ namespace projections \par Example \image html ex_putp5.gif */ - template <typename CalculationType, typename Parameters> - struct putp5_spheroid : public detail::putp5::base_putp5_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct putp5_spheroid : public detail::putp5::base_putp5_spheroid<T, Parameters> { - inline putp5_spheroid(const Parameters& par) : detail::putp5::base_putp5_spheroid<CalculationType, Parameters>(par) + inline putp5_spheroid(const Parameters& par) : detail::putp5::base_putp5_spheroid<T, Parameters>(par) { detail::putp5::setup_putp5(this->m_par, this->m_proj_parm); } @@ -173,10 +161,10 @@ namespace projections \par Example \image html ex_putp5p.gif */ - template <typename CalculationType, typename Parameters> - struct putp5p_spheroid : public detail::putp5::base_putp5_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct putp5p_spheroid : public detail::putp5::base_putp5_spheroid<T, Parameters> { - inline putp5p_spheroid(const Parameters& par) : detail::putp5::base_putp5_spheroid<CalculationType, Parameters>(par) + inline putp5p_spheroid(const Parameters& par) : detail::putp5::base_putp5_spheroid<T, Parameters>(par) { detail::putp5::setup_putp5p(this->m_par, this->m_proj_parm); } @@ -191,31 +179,31 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::putp5p, putp5p_spheroid, putp5p_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class putp5_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class putp5_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<putp5_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<putp5_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class putp5p_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class putp5p_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<putp5p_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<putp5p_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void putp5_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void putp5_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("putp5", new putp5_entry<CalculationType, Parameters>); - factory.add_to_factory("putp5p", new putp5p_entry<CalculationType, Parameters>); + factory.add_to_factory("putp5", new putp5_entry<T, Parameters>); + factory.add_to_factory("putp5p", new putp5p_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/putp6.hpp b/boost/geometry/srs/projections/proj/putp6.hpp index 2dff641717..19ca6cc76d 100644 --- a/boost/geometry/srs/projections/proj/putp6.hpp +++ b/boost/geometry/srs/projections/proj/putp6.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_PUTP6_HPP -#define BOOST_GEOMETRY_PROJECTIONS_PUTP6_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,7 +37,8 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -#include <boost/core/ignore_unused.hpp> +#ifndef BOOST_GEOMETRY_PROJECTIONS_PUTP6_HPP +#define BOOST_GEOMETRY_PROJECTIONS_PUTP6_HPP #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> @@ -54,8 +51,8 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct putp6 {}; - struct putp6p {}; + struct putp6 {}; // Putnins P6 + struct putp6p {}; // Putnins P6' }} //namespace srs::par4 @@ -65,8 +62,8 @@ namespace projections namespace detail { namespace putp6 { - static const double EPS = 1e-10; - static const int NITER = 10; + static const double epsilon = 1e-10; + static const int n_iter = 10; static const double CON_POLE = 1.732050807568877; template <typename T> @@ -76,34 +73,30 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_putp6_spheroid : public base_t_fi<base_putp6_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_putp6_spheroid + : public base_t_fi<base_putp6_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_putp6<CalculationType> m_proj_parm; + par_putp6<T> m_proj_parm; inline base_putp6_spheroid(const Parameters& par) - : base_t_fi<base_putp6_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_putp6_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType p, r, V; + T p, r, V; int i; p = this->m_proj_parm.B * sin(lp_lat); lp_lat *= 1.10265779; - for (i = NITER; i ; --i) { + for (i = n_iter; i ; --i) { r = sqrt(1. + lp_lat * lp_lat); lp_lat -= V = ( (this->m_proj_parm.A - r) * lp_lat - log(lp_lat + r) - p ) / (this->m_proj_parm.A - 2. * r); - if (fabs(V) < EPS) + if (fabs(V) < epsilon) break; } if (!i) @@ -114,9 +107,9 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType r; + T r; lp_lat = xy_y / this->m_proj_parm.C_y; r = sqrt(1. + lp_lat * lp_lat); @@ -130,14 +123,7 @@ namespace projections } }; - - template <typename Parameters, typename T> - inline void setup(Parameters& par, par_putp6<T>& proj_parm) - { - boost::ignore_unused(proj_parm); - par.es = 0.; - } - + // Putnins P6 template <typename Parameters, typename T> @@ -148,7 +134,8 @@ namespace projections proj_parm.A = 4.; proj_parm.B = 2.1471437182129378784; proj_parm.D = 2.; - setup(par, proj_parm); + + par.es = 0.; } // Putnins P6' @@ -160,7 +147,8 @@ namespace projections proj_parm.A = 6.; proj_parm.B = 5.61125; proj_parm.D = 3.; - setup(par, proj_parm); + + par.es = 0.; } }} // namespace detail::putp6 @@ -178,10 +166,10 @@ namespace projections \par Example \image html ex_putp6.gif */ - template <typename CalculationType, typename Parameters> - struct putp6_spheroid : public detail::putp6::base_putp6_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct putp6_spheroid : public detail::putp6::base_putp6_spheroid<T, Parameters> { - inline putp6_spheroid(const Parameters& par) : detail::putp6::base_putp6_spheroid<CalculationType, Parameters>(par) + inline putp6_spheroid(const Parameters& par) : detail::putp6::base_putp6_spheroid<T, Parameters>(par) { detail::putp6::setup_putp6(this->m_par, this->m_proj_parm); } @@ -199,10 +187,10 @@ namespace projections \par Example \image html ex_putp6p.gif */ - template <typename CalculationType, typename Parameters> - struct putp6p_spheroid : public detail::putp6::base_putp6_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct putp6p_spheroid : public detail::putp6::base_putp6_spheroid<T, Parameters> { - inline putp6p_spheroid(const Parameters& par) : detail::putp6::base_putp6_spheroid<CalculationType, Parameters>(par) + inline putp6p_spheroid(const Parameters& par) : detail::putp6::base_putp6_spheroid<T, Parameters>(par) { detail::putp6::setup_putp6p(this->m_par, this->m_proj_parm); } @@ -217,31 +205,31 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::putp6p, putp6p_spheroid, putp6p_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class putp6_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class putp6_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<putp6_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<putp6_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class putp6p_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class putp6p_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<putp6p_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<putp6p_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void putp6_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void putp6_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("putp6", new putp6_entry<CalculationType, Parameters>); - factory.add_to_factory("putp6p", new putp6p_entry<CalculationType, Parameters>); + factory.add_to_factory("putp6", new putp6_entry<T, Parameters>); + factory.add_to_factory("putp6p", new putp6p_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/qsc.hpp b/boost/geometry/srs/projections/proj/qsc.hpp index 4cccc29f8b..bb31849049 100644 --- a/boost/geometry/srs/projections/proj/qsc.hpp +++ b/boost/geometry/srs/projections/proj/qsc.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_QSC_HPP -#define BOOST_GEOMETRY_PROJECTIONS_QSC_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,17 +15,37 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: // This implements the Quadrilateralized Spherical Cube (QSC) projection. // Copyright (c) 2011, 2012 Martin Lambers <marlam@marlam.de> + +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + // The QSC projection was introduced in: // [OL76] // E.M. O'Neill and R.E. Laubscher, "Extended Studies of a Quadrilateralized // Spherical Cube Earth Data Base", Naval Environmental Prediction Research // Facility Tech. Report NEPRF 3-76 (CSC), May 1976. + // The preceding shift from an ellipsoid to a sphere, which allows to apply // this projection to ellipsoids as used in the Ellipsoidal Cube Map model, // is described in @@ -37,6 +53,7 @@ // M. Lambers and A. Kolb, "Ellipsoidal Cube Maps for Accurate Rendering of // Planetary-Scale Terrain Data", Proc. Pacfic Graphics (Short Papers), Sep. // 2012 + // You have to choose one of the following projection centers, // corresponding to the centers of the six cube faces: // phi0 = 0.0, lam0 = 0.0 ("front" face) @@ -46,32 +63,19 @@ // phi0 = 90.0 ("top" face) // phi0 = -90.0 ("bottom" face) // Other projection centers will not work! + // In the projection code below, each cube face is handled differently. // See the computation of the face parameter in the ENTRY0(qsc) function // and the handling of different face values (FACE_*) in the forward and // inverse projections. + // Furthermore, the projection is originally only defined for theta angles // between (-1/4 * PI) and (+1/4 * PI) on the current cube face. This area // of definition is named AREA_0 in the projection code below. The other // three areas of a cube face are handled by rotation of AREA_0. -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_QSC_HPP +#define BOOST_GEOMETRY_PROJECTIONS_QSC_HPP #include <boost/core/ignore_unused.hpp> #include <boost/geometry/util/math.hpp> @@ -86,7 +90,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct qsc {}; + struct qsc {}; // Quadrilateralized Spherical Cube }} //namespace srs::par4 @@ -95,76 +99,81 @@ namespace projections #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace qsc { - static const double EPS10 = 1.e-10; - static const int FACE_FRONT = 0; - static const int FACE_RIGHT = 1; - static const int FACE_BACK = 2; - static const int FACE_LEFT = 3; - static const int FACE_TOP = 4; - static const int FACE_BOTTOM = 5; - static const int AREA_0 = 0; - static const int AREA_1 = 1; - static const int AREA_2 = 2; - static const int AREA_3 = 3; + + /* The six cube faces. */ + enum face_type { + face_front = 0, + face_right = 1, + face_back = 2, + face_left = 3, + face_top = 4, + face_bottom = 5 + }; template <typename T> struct par_qsc { - int face; - T a_squared; - T b; - T one_minus_f; - T one_minus_f_squared; + face_type face; + T a_squared; + T b; + T one_minus_f; + T one_minus_f_squared; }; - /* The six cube faces. */ + static const double epsilon10 = 1.e-10; /* The four areas on a cube face. AREA_0 is the area of definition, * the other three areas are counted counterclockwise. */ + enum area_type { + area_0 = 0, + area_1 = 1, + area_2 = 2, + area_3 = 3 + }; /* Helper function for forward projection: compute the theta angle * and determine the area number. */ template <typename T> - inline T qsc_fwd_equat_face_theta(T const& phi, T const& y, T const& x, int *area) + inline T qsc_fwd_equat_face_theta(T const& phi, T const& y, T const& x, area_type *area) { - static const T FORTPI = detail::FORTPI<T>(); - static const T HALFPI = detail::HALFPI<T>(); - static const T ONEPI = detail::ONEPI<T>(); - - T theta; - if (phi < EPS10) { - *area = AREA_0; - theta = 0.0; + static const T fourth_pi = detail::fourth_pi<T>(); + static const T half_pi = detail::half_pi<T>(); + static const T pi = detail::pi<T>(); + + T theta; + if (phi < epsilon10) { + *area = area_0; + theta = 0.0; + } else { + theta = atan2(y, x); + if (fabs(theta) <= fourth_pi) { + *area = area_0; + } else if (theta > fourth_pi && theta <= half_pi + fourth_pi) { + *area = area_1; + theta -= half_pi; + } else if (theta > half_pi + fourth_pi || theta <= -(half_pi + fourth_pi)) { + *area = area_2; + theta = (theta >= 0.0 ? theta - pi : theta + pi); } else { - theta = atan2(y, x); - if (fabs(theta) <= FORTPI) { - *area = AREA_0; - } else if (theta > FORTPI && theta <= HALFPI + FORTPI) { - *area = AREA_1; - theta -= HALFPI; - } else if (theta > HALFPI + FORTPI || theta <= -(HALFPI + FORTPI)) { - *area = AREA_2; - theta = (theta >= 0.0 ? theta - ONEPI : theta + ONEPI); - } else { - *area = AREA_3; - theta += HALFPI; - } + *area = area_3; + theta += half_pi; } - return (theta); + } + return theta; } /* Helper function: shift the longitude. */ template <typename T> inline T qsc_shift_lon_origin(T const& lon, T const& offset) { - static const T ONEPI = detail::ONEPI<T>(); - static const T TWOPI = detail::TWOPI<T>(); + static const T pi = detail::pi<T>(); + static const T two_pi = detail::two_pi<T>(); T slon = lon + offset; - if (slon < -ONEPI) { - slon += TWOPI; - } else if (slon > +ONEPI) { - slon -= TWOPI; + if (slon < -pi) { + slon += two_pi; + } else if (slon > +pi) { + slon -= two_pi; } return slon; } @@ -172,40 +181,33 @@ namespace projections /* Forward projection, ellipsoid */ // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_qsc_ellipsoid : public base_t_fi<base_qsc_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_qsc_ellipsoid + : public base_t_fi<base_qsc_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_qsc<CalculationType> m_proj_parm; + par_qsc<T> m_proj_parm; inline base_qsc_ellipsoid(const Parameters& par) - : base_t_fi<base_qsc_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_qsc_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType FORTPI = detail::FORTPI<CalculationType>(); - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); - static const CalculationType ONEPI = detail::ONEPI<CalculationType>(); - - CalculationType lat, lon; - CalculationType sinlat, coslat; - CalculationType sinlon, coslon; - CalculationType q = 0.0, r = 0.0, s = 0.0; - CalculationType theta, phi; - CalculationType t, mu, nu; - int area; + static const T fourth_pi = detail::fourth_pi<T>(); + static const T half_pi = detail::half_pi<T>(); + static const T pi = detail::pi<T>(); + + T lat, lon; + T theta, phi; + T t, mu; /* nu; */ + area_type area; /* Convert the geodetic latitude to a geocentric latitude. * This corresponds to the shift from the ellipsoid to the sphere * described in [LK12]. */ - if (this->m_par.es) { + if (this->m_par.es != 0.0) { lat = atan(this->m_proj_parm.one_minus_f_squared * tan(lp_lat)); } else { lat = lp_lat; @@ -217,13 +219,47 @@ namespace projections * directly from phi, lam. For the other faces, we must use * unit sphere cartesian coordinates as an intermediate step. */ lon = lp_lon; - if (this->m_proj_parm.face != FACE_TOP && this->m_proj_parm.face != FACE_BOTTOM) { - if (this->m_proj_parm.face == FACE_RIGHT) { - lon = qsc_shift_lon_origin(lon, +HALFPI); - } else if (this->m_proj_parm.face == FACE_BACK) { - lon = qsc_shift_lon_origin(lon, +ONEPI); - } else if (this->m_proj_parm.face == FACE_LEFT) { - lon = qsc_shift_lon_origin(lon, -HALFPI); + if (this->m_proj_parm.face == face_top) { + phi = half_pi - lat; + if (lon >= fourth_pi && lon <= half_pi + fourth_pi) { + area = area_0; + theta = lon - half_pi; + } else if (lon > half_pi + fourth_pi || lon <= -(half_pi + fourth_pi)) { + area = area_1; + theta = (lon > 0.0 ? lon - pi : lon + pi); + } else if (lon > -(half_pi + fourth_pi) && lon <= -fourth_pi) { + area = area_2; + theta = lon + half_pi; + } else { + area = area_3; + theta = lon; + } + } else if (this->m_proj_parm.face == face_bottom) { + phi = half_pi + lat; + if (lon >= fourth_pi && lon <= half_pi + fourth_pi) { + area = area_0; + theta = -lon + half_pi; + } else if (lon < fourth_pi && lon >= -fourth_pi) { + area = area_1; + theta = -lon; + } else if (lon < -fourth_pi && lon >= -(half_pi + fourth_pi)) { + area = area_2; + theta = -lon - half_pi; + } else { + area = area_3; + theta = (lon > 0.0 ? -lon + pi : -lon - pi); + } + } else { + T q, r, s; + T sinlat, coslat; + T sinlon, coslon; + + if (this->m_proj_parm.face == face_right) { + lon = qsc_shift_lon_origin(lon, +half_pi); + } else if (this->m_proj_parm.face == face_back) { + lon = qsc_shift_lon_origin(lon, +pi); + } else if (this->m_proj_parm.face == face_left) { + lon = qsc_shift_lon_origin(lon, -half_pi); } sinlat = sin(lat); coslat = cos(lat); @@ -232,85 +268,60 @@ namespace projections q = coslat * coslon; r = coslat * sinlon; s = sinlat; - } - if (this->m_proj_parm.face == FACE_FRONT) { - phi = acos(q); - theta = qsc_fwd_equat_face_theta(phi, s, r, &area); - } else if (this->m_proj_parm.face == FACE_RIGHT) { - phi = acos(r); - theta = qsc_fwd_equat_face_theta(phi, s, -q, &area); - } else if (this->m_proj_parm.face == FACE_BACK) { - phi = acos(-q); - theta = qsc_fwd_equat_face_theta(phi, s, -r, &area); - } else if (this->m_proj_parm.face == FACE_LEFT) { - phi = acos(-r); - theta = qsc_fwd_equat_face_theta(phi, s, q, &area); - } else if (this->m_proj_parm.face == FACE_TOP) { - phi = HALFPI - lat; - if (lon >= FORTPI && lon <= HALFPI + FORTPI) { - area = AREA_0; - theta = lon - HALFPI; - } else if (lon > HALFPI + FORTPI || lon <= -(HALFPI + FORTPI)) { - area = AREA_1; - theta = (lon > 0.0 ? lon - ONEPI : lon + ONEPI); - } else if (lon > -(HALFPI + FORTPI) && lon <= -FORTPI) { - area = AREA_2; - theta = lon + HALFPI; - } else { - area = AREA_3; - theta = lon; - } - } else /* this->m_proj_parm.face == FACE_BOTTOM */ { - phi = HALFPI + lat; - if (lon >= FORTPI && lon <= HALFPI + FORTPI) { - area = AREA_0; - theta = -lon + HALFPI; - } else if (lon < FORTPI && lon >= -FORTPI) { - area = AREA_1; - theta = -lon; - } else if (lon < -FORTPI && lon >= -(HALFPI + FORTPI)) { - area = AREA_2; - theta = -lon - HALFPI; + + if (this->m_proj_parm.face == face_front) { + phi = acos(q); + theta = qsc_fwd_equat_face_theta(phi, s, r, &area); + } else if (this->m_proj_parm.face == face_right) { + phi = acos(r); + theta = qsc_fwd_equat_face_theta(phi, s, -q, &area); + } else if (this->m_proj_parm.face == face_back) { + phi = acos(-q); + theta = qsc_fwd_equat_face_theta(phi, s, -r, &area); + } else if (this->m_proj_parm.face == face_left) { + phi = acos(-r); + theta = qsc_fwd_equat_face_theta(phi, s, q, &area); } else { - area = AREA_3; - theta = (lon > 0.0 ? -lon + ONEPI : -lon - ONEPI); + /* Impossible */ + phi = theta = 0.0; + area = area_0; } } /* Compute mu and nu for the area of definition. * For mu, see Eq. (3-21) in [OL76], but note the typos: * compare with Eq. (3-14). For nu, see Eq. (3-38). */ - mu = atan((12.0 / ONEPI) * (theta + acos(sin(theta) * cos(FORTPI)) - HALFPI)); + mu = atan((12.0 / pi) * (theta + acos(sin(theta) * cos(fourth_pi)) - half_pi)); + // TODO: (cos(mu) * cos(mu)) could be replaced with sqr(cos(mu)) t = sqrt((1.0 - cos(phi)) / (cos(mu) * cos(mu)) / (1.0 - cos(atan(1.0 / cos(theta))))); /* nu = atan(t); We don't really need nu, just t, see below. */ /* Apply the result to the real area. */ - if (area == AREA_1) { - mu += HALFPI; - } else if (area == AREA_2) { - mu += ONEPI; - } else if (area == AREA_3) { - mu += HALFPI + ONEPI; + if (area == area_1) { + mu += half_pi; + } else if (area == area_2) { + mu += pi; + } else if (area == area_3) { + mu += half_pi + pi; } /* Now compute x, y from mu and nu */ /* t = tan(nu); */ xy_x = t * cos(mu); xy_y = t * sin(mu); - boost::ignore_unused(nu); } /* Inverse projection, ellipsoid */ // INVERSE(e_inverse) // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); - static const CalculationType ONEPI = detail::ONEPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); + static const T pi = detail::pi<T>(); - CalculationType mu, nu, cosmu, tannu; - CalculationType tantheta, theta, cosphi, phi; - CalculationType t; + T mu, nu, cosmu, tannu; + T tantheta, theta, cosphi, phi; + T t; int area; /* Convert the input x, y to the mu and nu angles as used by QSC. @@ -318,16 +329,16 @@ namespace projections nu = atan(sqrt(xy_x * xy_x + xy_y * xy_y)); mu = atan2(xy_y, xy_x); if (xy_x >= 0.0 && xy_x >= fabs(xy_y)) { - area = AREA_0; + area = area_0; } else if (xy_y >= 0.0 && xy_y >= fabs(xy_x)) { - area = AREA_1; - mu -= HALFPI; + area = area_1; + mu -= half_pi; } else if (xy_x < 0.0 && -xy_x >= fabs(xy_y)) { - area = AREA_2; - mu = (mu < 0.0 ? mu + ONEPI : mu - ONEPI); + area = area_2; + mu = (mu < 0.0 ? mu + pi : mu - pi); } else { - area = AREA_3; - mu += HALFPI; + area = area_3; + mu += half_pi; } /* Compute phi and theta for the area of definition. @@ -335,7 +346,7 @@ namespace projections * good hints can be found here (as of 2011-12-14): * http://fits.gsfc.nasa.gov/fitsbits/saf.93/saf.9302 * (search for "Message-Id: <9302181759.AA25477 at fits.cv.nrao.edu>") */ - t = (ONEPI / 12.0) * tan(mu); + t = (pi / 12.0) * tan(mu); tantheta = sin(t) / (cos(t) - (1.0 / sqrt(2.0))); theta = atan(tantheta); cosmu = cos(mu); @@ -351,33 +362,33 @@ namespace projections * For the top and bottom face, we can compute phi and lam directly. * For the other faces, we must use unit sphere cartesian coordinates * as an intermediate step. */ - if (this->m_proj_parm.face == FACE_TOP) { + if (this->m_proj_parm.face == face_top) { phi = acos(cosphi); - lp_lat = HALFPI - phi; - if (area == AREA_0) { - lp_lon = theta + HALFPI; - } else if (area == AREA_1) { - lp_lon = (theta < 0.0 ? theta + ONEPI : theta - ONEPI); - } else if (area == AREA_2) { - lp_lon = theta - HALFPI; + lp_lat = half_pi - phi; + if (area == area_0) { + lp_lon = theta + half_pi; + } else if (area == area_1) { + lp_lon = (theta < 0.0 ? theta + pi : theta - pi); + } else if (area == area_2) { + lp_lon = theta - half_pi; } else /* area == AREA_3 */ { lp_lon = theta; } - } else if (this->m_proj_parm.face == FACE_BOTTOM) { + } else if (this->m_proj_parm.face == face_bottom) { phi = acos(cosphi); - lp_lat = phi - HALFPI; - if (area == AREA_0) { - lp_lon = -theta + HALFPI; - } else if (area == AREA_1) { + lp_lat = phi - half_pi; + if (area == area_0) { + lp_lon = -theta + half_pi; + } else if (area == area_1) { lp_lon = -theta; - } else if (area == AREA_2) { - lp_lon = -theta - HALFPI; - } else /* area == AREA_3 */ { - lp_lon = (theta < 0.0 ? -theta - ONEPI : -theta + ONEPI); + } else if (area == area_2) { + lp_lon = -theta - half_pi; + } else /* area == area_3 */ { + lp_lon = (theta < 0.0 ? -theta - pi : -theta + pi); } } else { /* Compute phi and lam via cartesian unit sphere coordinates. */ - CalculationType q, r, s, t; + T q, r, s; q = cosphi; t = q * q; if (t >= 1.0) { @@ -392,48 +403,48 @@ namespace projections r = sqrt(1.0 - t); } /* Rotate q,r,s into the correct area. */ - if (area == AREA_1) { + if (area == area_1) { t = r; r = -s; s = t; - } else if (area == AREA_2) { + } else if (area == area_2) { r = -r; s = -s; - } else if (area == AREA_3) { + } else if (area == area_3) { t = r; r = s; s = -t; } /* Rotate q,r,s into the correct cube face. */ - if (this->m_proj_parm.face == FACE_RIGHT) { + if (this->m_proj_parm.face == face_right) { t = q; q = -r; r = t; - } else if (this->m_proj_parm.face == FACE_BACK) { + } else if (this->m_proj_parm.face == face_back) { q = -q; r = -r; - } else if (this->m_proj_parm.face == FACE_LEFT) { + } else if (this->m_proj_parm.face == face_left) { t = q; q = r; r = -t; } /* Now compute phi and lam from the unit sphere coordinates. */ - lp_lat = acos(-s) - HALFPI; + lp_lat = acos(-s) - half_pi; lp_lon = atan2(r, q); - if (this->m_proj_parm.face == FACE_RIGHT) { - lp_lon = qsc_shift_lon_origin(lp_lon, -HALFPI); - } else if (this->m_proj_parm.face == FACE_BACK) { - lp_lon = qsc_shift_lon_origin(lp_lon, -ONEPI); - } else if (this->m_proj_parm.face == FACE_LEFT) { - lp_lon = qsc_shift_lon_origin(lp_lon, +HALFPI); + if (this->m_proj_parm.face == face_right) { + lp_lon = qsc_shift_lon_origin(lp_lon, -half_pi); + } else if (this->m_proj_parm.face == face_back) { + lp_lon = qsc_shift_lon_origin(lp_lon, -pi); + } else if (this->m_proj_parm.face == face_left) { + lp_lon = qsc_shift_lon_origin(lp_lon, +half_pi); } } /* Apply the shift from the sphere to the ellipsoid as described * in [LK12]. */ - if (this->m_par.es) { + if (this->m_par.es != 0.0) { int invert_sign; - CalculationType tanphi, xa; + T tanphi, xa; invert_sign = (lp_lat < 0.0 ? 1 : 0); tanphi = tan(lp_lat); xa = this->m_proj_parm.b / sqrt(tanphi * tanphi + this->m_proj_parm.one_minus_f_squared); @@ -455,29 +466,29 @@ namespace projections template <typename Parameters, typename T> inline void setup_qsc(Parameters& par, par_qsc<T>& proj_parm) { - static const T FORTPI = detail::FORTPI<T>(); - static const T HALFPI = detail::HALFPI<T>(); - - /* Determine the cube face from the center of projection. */ - if (par.phi0 >= HALFPI - FORTPI / 2.0) { - proj_parm.face = FACE_TOP; - } else if (par.phi0 <= -(HALFPI - FORTPI / 2.0)) { - proj_parm.face = FACE_BOTTOM; - } else if (fabs(par.lam0) <= FORTPI) { - proj_parm.face = FACE_FRONT; - } else if (fabs(par.lam0) <= HALFPI + FORTPI) { - proj_parm.face = (par.lam0 > 0.0 ? FACE_RIGHT : FACE_LEFT); - } else { - proj_parm.face = FACE_BACK; - } - /* Fill in useful values for the ellipsoid <-> sphere shift - * described in [LK12]. */ - if (par.es) { - proj_parm.a_squared = par.a * par.a; - proj_parm.b = par.a * sqrt(1.0 - par.es); - proj_parm.one_minus_f = 1.0 - (par.a - proj_parm.b) / par.a; - proj_parm.one_minus_f_squared = proj_parm.one_minus_f * proj_parm.one_minus_f; - } + static const T fourth_pi = detail::fourth_pi<T>(); + static const T half_pi = detail::half_pi<T>(); + + /* Determine the cube face from the center of projection. */ + if (par.phi0 >= half_pi - fourth_pi / 2.0) { + proj_parm.face = face_top; + } else if (par.phi0 <= -(half_pi - fourth_pi / 2.0)) { + proj_parm.face = face_bottom; + } else if (fabs(par.lam0) <= fourth_pi) { + proj_parm.face = face_front; + } else if (fabs(par.lam0) <= half_pi + fourth_pi) { + proj_parm.face = (par.lam0 > 0.0 ? face_right : face_left); + } else { + proj_parm.face = face_back; + } + /* Fill in useful values for the ellipsoid <-> sphere shift + * described in [LK12]. */ + if (par.es != 0.0) { + proj_parm.a_squared = par.a * par.a; + proj_parm.b = par.a * sqrt(1.0 - par.es); + proj_parm.one_minus_f = 1.0 - (par.a - proj_parm.b) / par.a; + proj_parm.one_minus_f_squared = proj_parm.one_minus_f * proj_parm.one_minus_f; + } } }} // namespace detail::qsc @@ -495,10 +506,10 @@ namespace projections \par Example \image html ex_qsc.gif */ - template <typename CalculationType, typename Parameters> - struct qsc_ellipsoid : public detail::qsc::base_qsc_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct qsc_ellipsoid : public detail::qsc::base_qsc_ellipsoid<T, Parameters> { - inline qsc_ellipsoid(const Parameters& par) : detail::qsc::base_qsc_ellipsoid<CalculationType, Parameters>(par) + inline qsc_ellipsoid(const Parameters& par) : detail::qsc::base_qsc_ellipsoid<T, Parameters>(par) { detail::qsc::setup_qsc(this->m_par, this->m_proj_parm); } @@ -512,20 +523,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::qsc, qsc_ellipsoid, qsc_ellipsoid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class qsc_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class qsc_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<qsc_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<qsc_ellipsoid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void qsc_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void qsc_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("qsc", new qsc_entry<CalculationType, Parameters>); + factory.add_to_factory("qsc", new qsc_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/robin.hpp b/boost/geometry/srs/projections/proj/robin.hpp index 52acb58e41..f5ec97be51 100644 --- a/boost/geometry/srs/projections/proj/robin.hpp +++ b/boost/geometry/srs/projections/proj/robin.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_ROBIN_HPP -#define BOOST_GEOMETRY_PROJECTIONS_ROBIN_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_ROBIN_HPP +#define BOOST_GEOMETRY_PROJECTIONS_ROBIN_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -54,7 +53,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct robin {}; + struct robin {}; // Robinson }} //namespace srs::par4 @@ -68,9 +67,11 @@ namespace projections static const double FYC = 1.3523; static const double C1 = 11.45915590261646417544; static const double RC1 = 0.08726646259971647884; - static const int NODES = 18; - static const double ONEEPS = 1.000001; - static const double EPS = 1e-8; + static const int n_nodes = 18; + static const double one_plus_eps = 1.000001; + static const double epsilon = 1e-8; + /* Not sure at all of the appropriate number for max_iter... */ + static const int max_iter = 100; /* note: following terms based upon 5 deg. intervals in degrees. @@ -82,14 +83,14 @@ namespace projections */ template <typename T> - struct COEFS { + struct coefs { T c0, c1, c2, c3; }; template <typename T> - inline const COEFS<T> * X() + inline const coefs<T> * coefs_x() { - static const COEFS<T> result[] = { + static const coefs<T> result[] = { {1.0, 2.2199e-17, -7.15515e-05, 3.1103e-06}, {0.9986, -0.000482243, -2.4897e-05, -1.3309e-06}, {0.9954, -0.00083103, -4.48605e-05, -9.86701e-07}, @@ -114,9 +115,9 @@ namespace projections } template <typename T> - inline const COEFS<T> * Y() + inline const coefs<T> * coefs_y() { - static const COEFS<T> result[] = { + static const coefs<T> result[] = { {-5.20417e-18, 0.0124, 1.21431e-18, -8.45284e-11}, {0.062, 0.0124, -1.26793e-09, 4.22642e-10}, {0.124, 0.0124, 5.07171e-09, -1.60604e-09}, @@ -141,87 +142,85 @@ namespace projections } // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_robin_spheroid : public base_t_fi<base_robin_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_robin_spheroid + : public base_t_fi<base_robin_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_robin_spheroid(const Parameters& par) - : base_t_fi<base_robin_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_robin_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} - template <typename T> - inline T V(COEFS<T> const& C, T const& z) const - { return (C.c0 + z * (C.c1 + z * (C.c2 + z * C.c3))); } - template <typename T> - inline T DV(COEFS<T> const& C, T const& z) const - { return (C.c1 + z * (C.c2 + C.c2 + z * 3. * C.c3)); } + inline T v(coefs<T> const& c, T const& z) const + { return (c.c0 + z * (c.c1 + z * (c.c2 + z * c.c3))); } + inline T dv(coefs<T> const& c, T const& z) const + { return (c.c1 + z * (c.c2 + c.c2 + z * 3. * c.c3)); } // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { int i; - CalculationType dphi; + T dphi; i = int_floor((dphi = fabs(lp_lat)) * C1); - if (i < 0) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); - if (i >= NODES) i = NODES - 1; - dphi = geometry::math::r2d<CalculationType>() * (dphi - RC1 * i); - xy_x = V(X<CalculationType>()[i], dphi) * FXC * lp_lon; - xy_y = V(Y<CalculationType>()[i], dphi) * FYC; + if (i < 0) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } + if (i >= n_nodes) i = n_nodes - 1; + dphi = geometry::math::r2d<T>() * (dphi - RC1 * i); + xy_x = v(coefs_x<T>()[i], dphi) * FXC * lp_lon; + xy_y = v(coefs_y<T>()[i], dphi) * FYC; if (lp_lat < 0.) xy_y = -xy_y; } // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); - const COEFS<CalculationType> * X = robin::X<CalculationType>(); - const COEFS<CalculationType> * Y = robin::Y<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); + const coefs<T> * coefs_x = robin::coefs_x<T>(); + const coefs<T> * coefs_y = robin::coefs_y<T>(); int i; - CalculationType t, t1; - COEFS<CalculationType> T; + T t, t1; + coefs<T> coefs_t; + int iters; lp_lon = xy_x / FXC; lp_lat = fabs(xy_y / FYC); if (lp_lat >= 1.) { /* simple pathologic cases */ - if (lp_lat > ONEEPS) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); - else { - lp_lat = xy_y < 0. ? -HALFPI : HALFPI; - lp_lon /= X[NODES].c0; + if (lp_lat > one_plus_eps) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } else { + lp_lat = xy_y < 0. ? -half_pi : half_pi; + lp_lon /= coefs_x[n_nodes].c0; } } else { /* general problem */ /* in Y space, reduce to table interval */ - i = int_floor(lp_lat * NODES); - if( i < 0 || i >= NODES ) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + i = int_floor(lp_lat * n_nodes); + if( i < 0 || i >= n_nodes ) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } for (;;) { - if (Y[i].c0 > lp_lat) --i; - else if (Y[i+1].c0 <= lp_lat) ++i; + if (coefs_y[i].c0 > lp_lat) --i; + else if (coefs_y[i+1].c0 <= lp_lat) ++i; else break; } - T = Y[i]; + coefs_t = coefs_y[i]; /* first guess, linear interp */ - t = 5. * (lp_lat - T.c0)/(Y[i+1].c0 - T.c0); + t = 5. * (lp_lat - coefs_t.c0)/(coefs_y[i+1].c0 - coefs_t.c0); /* make into root */ - T.c0 -= lp_lat; - for (;;) { /* Newton-Raphson reduction */ - t -= t1 = V(T,t) / DV(T,t); - if (fabs(t1) < EPS) + coefs_t.c0 = (T)(coefs_t.c0 - lp_lat); + for (iters = max_iter; iters ; --iters) { /* Newton-Raphson */ + t -= t1 = v(coefs_t,t) / dv(coefs_t,t); + if (fabs(t1) < epsilon) break; } - lp_lat = (5 * i + t) * geometry::math::d2r<CalculationType>(); + if( iters == 0 ) + BOOST_THROW_EXCEPTION( projection_exception(error_non_convergent) ); + lp_lat = (5 * i + t) * geometry::math::d2r<T>(); if (xy_y < 0.) lp_lat = -lp_lat; - lp_lon /= V(X[i], t); + lp_lon /= v(coefs_x[i], t); } } @@ -254,10 +253,10 @@ namespace projections \par Example \image html ex_robin.gif */ - template <typename CalculationType, typename Parameters> - struct robin_spheroid : public detail::robin::base_robin_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct robin_spheroid : public detail::robin::base_robin_spheroid<T, Parameters> { - inline robin_spheroid(const Parameters& par) : detail::robin::base_robin_spheroid<CalculationType, Parameters>(par) + inline robin_spheroid(const Parameters& par) : detail::robin::base_robin_spheroid<T, Parameters>(par) { detail::robin::setup_robin(this->m_par); } @@ -271,20 +270,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::robin, robin_spheroid, robin_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class robin_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class robin_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<robin_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<robin_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void robin_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void robin_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("robin", new robin_entry<CalculationType, Parameters>); + factory.add_to_factory("robin", new robin_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/rouss.hpp b/boost/geometry/srs/projections/proj/rouss.hpp index edad904799..1cbc795e9d 100644 --- a/boost/geometry/srs/projections/proj/rouss.hpp +++ b/boost/geometry/srs/projections/proj/rouss.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_ROUSS_HPP -#define BOOST_GEOMETRY_PROJECTIONS_ROUSS_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -43,6 +39,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_ROUSS_HPP +#define BOOST_GEOMETRY_PROJECTIONS_ROUSS_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -54,7 +53,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct rouss {}; + struct rouss {}; // Roussilhe Stereographic }} //namespace srs::par4 @@ -71,29 +70,25 @@ namespace projections T B1, B2, B3, B4, B5, B6, B7, B8; T C1, C2, C3, C4, C5, C6, C7, C8; T D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11; - MDIST<T> en; + mdist<T> en; }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_rouss_ellipsoid : public base_t_fi<base_rouss_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_rouss_ellipsoid + : public base_t_fi<base_rouss_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_rouss<CalculationType> m_proj_parm; + par_rouss<T> m_proj_parm; inline base_rouss_ellipsoid(const Parameters& par) - : base_t_fi<base_rouss_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_rouss_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) ellipsoid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType s, al, cp, sp, al2, s2; + T s, al, cp, sp, al2, s2; cp = cos(lp_lat); sp = sin(lp_lat); @@ -110,9 +105,9 @@ namespace projections // INVERSE(e_inverse) ellipsoid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType s, al, x = xy_x / this->m_par.k0, y = xy_y / this->m_par.k0, x2, y2;; + T s, al, x = xy_x / this->m_par.k0, y = xy_y / this->m_par.k0, x2, y2; x2 = x * x; y2 = y * y; @@ -141,6 +136,7 @@ namespace projections if (!proj_mdist_ini(par.es, proj_parm.en)) BOOST_THROW_EXCEPTION( projection_exception(0) ); + es2 = sin(par.phi0); proj_parm.s0 = proj_mdist(par.phi0, es2, cos(par.phi0), proj_parm.en); t = 1. - (es2 = par.es * es2 * es2); @@ -197,10 +193,10 @@ namespace projections \par Example \image html ex_rouss.gif */ - template <typename CalculationType, typename Parameters> - struct rouss_ellipsoid : public detail::rouss::base_rouss_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct rouss_ellipsoid : public detail::rouss::base_rouss_ellipsoid<T, Parameters> { - inline rouss_ellipsoid(const Parameters& par) : detail::rouss::base_rouss_ellipsoid<CalculationType, Parameters>(par) + inline rouss_ellipsoid(const Parameters& par) : detail::rouss::base_rouss_ellipsoid<T, Parameters>(par) { detail::rouss::setup_rouss(this->m_par, this->m_proj_parm); } @@ -214,20 +210,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::rouss, rouss_ellipsoid, rouss_ellipsoid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class rouss_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class rouss_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<rouss_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<rouss_ellipsoid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void rouss_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void rouss_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("rouss", new rouss_entry<CalculationType, Parameters>); + factory.add_to_factory("rouss", new rouss_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/rpoly.hpp b/boost/geometry/srs/projections/proj/rpoly.hpp index fcb9f1043b..b2146426bd 100644 --- a/boost/geometry/srs/projections/proj/rpoly.hpp +++ b/boost/geometry/srs/projections/proj/rpoly.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_RPOLY_HPP -#define BOOST_GEOMETRY_PROJECTIONS_RPOLY_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_RPOLY_HPP +#define BOOST_GEOMETRY_PROJECTIONS_RPOLY_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -51,7 +50,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct rpoly {}; + struct rpoly {}; // Rectangular Polyconic }} //namespace srs::par4 @@ -61,7 +60,7 @@ namespace projections namespace detail { namespace rpoly { - static const double EPS = 1e-9; + static const double epsilon = 1e-9; template <typename T> struct par_rpoly @@ -73,31 +72,27 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_rpoly_spheroid : public base_t_f<base_rpoly_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_rpoly_spheroid + : public base_t_f<base_rpoly_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_rpoly<CalculationType> m_proj_parm; + par_rpoly<T> m_proj_parm; inline base_rpoly_spheroid(const Parameters& par) - : base_t_f<base_rpoly_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_f<base_rpoly_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType fa; + T fa; if (this->m_proj_parm.mode) fa = tan(lp_lon * this->m_proj_parm.fxb) * this->m_proj_parm.fxa; else fa = 0.5 * lp_lon; - if (fabs(lp_lat) < EPS) { + if (fabs(lp_lat) < epsilon) { xy_x = fa + fa; xy_y = - this->m_par.phi0; } else { @@ -118,7 +113,7 @@ namespace projections template <typename Parameters, typename T> inline void setup_rpoly(Parameters& par, par_rpoly<T>& proj_parm) { - if ((proj_parm.mode = (proj_parm.phi1 = fabs(pj_param(par.params, "rlat_ts").f)) > EPS)) { + if ((proj_parm.mode = (proj_parm.phi1 = fabs(pj_get_param_r(par.params, "lat_ts"))) > epsilon)) { proj_parm.fxb = 0.5 * sin(proj_parm.phi1); proj_parm.fxa = 0.5 / proj_parm.fxb; } @@ -143,10 +138,10 @@ namespace projections \par Example \image html ex_rpoly.gif */ - template <typename CalculationType, typename Parameters> - struct rpoly_spheroid : public detail::rpoly::base_rpoly_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct rpoly_spheroid : public detail::rpoly::base_rpoly_spheroid<T, Parameters> { - inline rpoly_spheroid(const Parameters& par) : detail::rpoly::base_rpoly_spheroid<CalculationType, Parameters>(par) + inline rpoly_spheroid(const Parameters& par) : detail::rpoly::base_rpoly_spheroid<T, Parameters>(par) { detail::rpoly::setup_rpoly(this->m_par, this->m_proj_parm); } @@ -160,20 +155,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::rpoly, rpoly_spheroid, rpoly_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class rpoly_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class rpoly_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_f<rpoly_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_f<rpoly_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void rpoly_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void rpoly_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("rpoly", new rpoly_entry<CalculationType, Parameters>); + factory.add_to_factory("rpoly", new rpoly_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/sconics.hpp b/boost/geometry/srs/projections/proj/sconics.hpp index b5f97fa542..b1119d622a 100644 --- a/boost/geometry/srs/projections/proj/sconics.hpp +++ b/boost/geometry/srs/projections/proj/sconics.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_SCONICS_HPP -#define BOOST_GEOMETRY_PROJECTIONS_SCONICS_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,10 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_SCONICS_HPP +#define BOOST_GEOMETRY_PROJECTIONS_SCONICS_HPP + + #include <boost/geometry/util/math.hpp> #include <boost/math/special_functions/hypot.hpp> @@ -54,13 +54,13 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct euler {}; - struct murd1 {}; - struct murd2 {}; - struct murd3 {}; - struct pconic {}; - struct tissot {}; - struct vitk1 {}; + struct euler {}; // Euler + struct murd1 {}; // Murdoch I + struct murd2 {}; // Murdoch II + struct murd3 {}; // Murdoch III + struct pconic {}; // Perspective Conic + struct tissot {}; // Tissot + struct vitk1 {}; // Vitkovsky I }} //namespace srs::par4 @@ -70,15 +70,17 @@ namespace projections namespace detail { namespace sconics { - static const int EULER = 0; - static const int MURD1 = 1; - static const int MURD2 = 2; - static const int MURD3 = 3; - static const int PCONIC = 4; - static const int TISSOT = 5; - static const int VITK1 = 6; - static const double EPS10 = 1.e-10; - static const double EPS = 1e-10; + enum proj_type { + proj_euler = 0, + proj_murd1 = 1, + proj_murd2 = 2, + proj_murd3 = 3, + proj_pconic = 4, + proj_tissot = 5, + proj_vitk1 = 6 + }; + static const double epsilon10 = 1.e-10; + static const double epsilon = 1e-10; template <typename T> struct par_sconics @@ -88,7 +90,7 @@ namespace projections T rho_0; T sig; T c1, c2; - int type; + proj_type type; }; /* get common factors for simple conics */ @@ -98,46 +100,41 @@ namespace projections T p1, p2; int err = 0; - if (!pj_param(par.params, "tlat_1").i || - !pj_param(par.params, "tlat_2").i) { + if (!pj_param_r(par.params, "lat_1", p1) || + !pj_param_r(par.params, "lat_2", p2)) { err = -41; } else { - p1 = pj_param(par.params, "rlat_1").f; - p2 = pj_param(par.params, "rlat_2").f; + //p1 = pj_get_param_r(par.params, "lat_1"); // set above + //p2 = pj_get_param_r(par.params, "lat_2"); // set above *del = 0.5 * (p2 - p1); proj_parm.sig = 0.5 * (p2 + p1); - err = (fabs(*del) < EPS || fabs(proj_parm.sig) < EPS) ? -42 : 0; - *del = *del; + err = (fabs(*del) < epsilon || fabs(proj_parm.sig) < epsilon) ? -42 : 0; } return err; } // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_sconics_spheroid : public base_t_fi<base_sconics_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_sconics_spheroid + : public base_t_fi<base_sconics_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_sconics<CalculationType> m_proj_parm; + par_sconics<T> m_proj_parm; inline base_sconics_spheroid(const Parameters& par) - : base_t_fi<base_sconics_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_sconics_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType rho; + T rho; switch (this->m_proj_parm.type) { - case MURD2: + case proj_murd2: rho = this->m_proj_parm.rho_c + tan(this->m_proj_parm.sig - lp_lat); break; - case PCONIC: + case proj_pconic: rho = this->m_proj_parm.c2 * (this->m_proj_parm.c1 - tan(lp_lat - this->m_proj_parm.sig)); break; default: @@ -150,9 +147,9 @@ namespace projections // INVERSE(s_inverse) ellipsoid & spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType rho; + T rho; rho = boost::math::hypot(xy_x, xy_y = this->m_proj_parm.rho_0 - xy_y); if (this->m_proj_parm.n < 0.) { @@ -160,12 +157,14 @@ namespace projections xy_x = - xy_x; xy_y = - xy_y; } + lp_lon = atan2(xy_x, xy_y) / this->m_proj_parm.n; + switch (this->m_proj_parm.type) { - case PCONIC: + case proj_pconic: lp_lat = atan(this->m_proj_parm.c1 - rho / this->m_proj_parm.c2) + this->m_proj_parm.sig; break; - case MURD2: + case proj_murd2: lp_lat = this->m_proj_parm.sig - atan(rho - this->m_proj_parm.rho_c); break; default: @@ -181,115 +180,113 @@ namespace projections }; template <typename Parameters, typename T> - inline void setup(Parameters& par, par_sconics<T>& proj_parm) + inline void setup(Parameters& par, par_sconics<T>& proj_parm, proj_type type) { - static const T HALFPI = detail::HALFPI<T>(); + static const T half_pi = detail::half_pi<T>(); T del, cs; - int i; + int err; + + proj_parm.type = type; + + err = phi12(par, proj_parm, &del); + if(err) + BOOST_THROW_EXCEPTION( projection_exception(err) ); - if( (i = phi12(par, proj_parm, &del)) ) - BOOST_THROW_EXCEPTION( projection_exception(i) ); switch (proj_parm.type) { - case TISSOT: + case proj_tissot: proj_parm.n = sin(proj_parm.sig); cs = cos(del); proj_parm.rho_c = proj_parm.n / cs + cs / proj_parm.n; proj_parm.rho_0 = sqrt((proj_parm.rho_c - 2 * sin(par.phi0))/proj_parm.n); break; - case MURD1: + case proj_murd1: proj_parm.rho_c = sin(del)/(del * tan(proj_parm.sig)) + proj_parm.sig; proj_parm.rho_0 = proj_parm.rho_c - par.phi0; proj_parm.n = sin(proj_parm.sig); break; - case MURD2: + case proj_murd2: proj_parm.rho_c = (cs = sqrt(cos(del))) / tan(proj_parm.sig); proj_parm.rho_0 = proj_parm.rho_c + tan(proj_parm.sig - par.phi0); proj_parm.n = sin(proj_parm.sig) * cs; break; - case MURD3: + case proj_murd3: proj_parm.rho_c = del / (tan(proj_parm.sig) * tan(del)) + proj_parm.sig; proj_parm.rho_0 = proj_parm.rho_c - par.phi0; proj_parm.n = sin(proj_parm.sig) * sin(del) * tan(del) / (del * del); break; - case EULER: + case proj_euler: proj_parm.n = sin(proj_parm.sig) * sin(del) / del; del *= 0.5; proj_parm.rho_c = del / (tan(del) * tan(proj_parm.sig)) + proj_parm.sig; proj_parm.rho_0 = proj_parm.rho_c - par.phi0; break; - case PCONIC: + case proj_pconic: proj_parm.n = sin(proj_parm.sig); proj_parm.c2 = cos(del); proj_parm.c1 = 1./tan(proj_parm.sig); - if (fabs(del = par.phi0 - proj_parm.sig) - EPS10 >= HALFPI) - BOOST_THROW_EXCEPTION( projection_exception(-43) ); + if (fabs(del = par.phi0 - proj_parm.sig) - epsilon10 >= half_pi) + BOOST_THROW_EXCEPTION( projection_exception(error_lat_0_half_pi_from_mean) ); proj_parm.rho_0 = proj_parm.c2 * (proj_parm.c1 - tan(del)); break; - case VITK1: + case proj_vitk1: proj_parm.n = (cs = tan(del)) * sin(proj_parm.sig) / del; proj_parm.rho_c = del / (cs * tan(proj_parm.sig)) + proj_parm.sig; proj_parm.rho_0 = proj_parm.rho_c - par.phi0; break; } + par.es = 0; } + // Euler + template <typename Parameters, typename T> + inline void setup_euler(Parameters& par, par_sconics<T>& proj_parm) + { + setup(par, proj_parm, proj_euler); + } + // Tissot template <typename Parameters, typename T> inline void setup_tissot(Parameters& par, par_sconics<T>& proj_parm) { - proj_parm.type = TISSOT; - setup(par, proj_parm); + setup(par, proj_parm, proj_tissot); } // Murdoch I template <typename Parameters, typename T> inline void setup_murd1(Parameters& par, par_sconics<T>& proj_parm) { - proj_parm.type = MURD1; - setup(par, proj_parm); + setup(par, proj_parm, proj_murd1); } // Murdoch II template <typename Parameters, typename T> inline void setup_murd2(Parameters& par, par_sconics<T>& proj_parm) { - proj_parm.type = MURD2; - setup(par, proj_parm); + setup(par, proj_parm, proj_murd2); } // Murdoch III template <typename Parameters, typename T> inline void setup_murd3(Parameters& par, par_sconics<T>& proj_parm) { - proj_parm.type = MURD3; - setup(par, proj_parm); - } - - // Euler - template <typename Parameters, typename T> - inline void setup_euler(Parameters& par, par_sconics<T>& proj_parm) - { - proj_parm.type = EULER; - setup(par, proj_parm); - } + setup(par, proj_parm, proj_murd3); + } // Perspective Conic template <typename Parameters, typename T> inline void setup_pconic(Parameters& par, par_sconics<T>& proj_parm) { - proj_parm.type = PCONIC; - setup(par, proj_parm); + setup(par, proj_parm, proj_pconic); } // Vitkovsky I template <typename Parameters, typename T> inline void setup_vitk1(Parameters& par, par_sconics<T>& proj_parm) { - proj_parm.type = VITK1; - setup(par, proj_parm); + setup(par, proj_parm, proj_vitk1); } }} // namespace detail::sconics @@ -310,10 +307,10 @@ namespace projections \par Example \image html ex_tissot.gif */ - template <typename CalculationType, typename Parameters> - struct tissot_spheroid : public detail::sconics::base_sconics_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct tissot_spheroid : public detail::sconics::base_sconics_spheroid<T, Parameters> { - inline tissot_spheroid(const Parameters& par) : detail::sconics::base_sconics_spheroid<CalculationType, Parameters>(par) + inline tissot_spheroid(const Parameters& par) : detail::sconics::base_sconics_spheroid<T, Parameters>(par) { detail::sconics::setup_tissot(this->m_par, this->m_proj_parm); } @@ -334,10 +331,10 @@ namespace projections \par Example \image html ex_murd1.gif */ - template <typename CalculationType, typename Parameters> - struct murd1_spheroid : public detail::sconics::base_sconics_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct murd1_spheroid : public detail::sconics::base_sconics_spheroid<T, Parameters> { - inline murd1_spheroid(const Parameters& par) : detail::sconics::base_sconics_spheroid<CalculationType, Parameters>(par) + inline murd1_spheroid(const Parameters& par) : detail::sconics::base_sconics_spheroid<T, Parameters>(par) { detail::sconics::setup_murd1(this->m_par, this->m_proj_parm); } @@ -358,10 +355,10 @@ namespace projections \par Example \image html ex_murd2.gif */ - template <typename CalculationType, typename Parameters> - struct murd2_spheroid : public detail::sconics::base_sconics_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct murd2_spheroid : public detail::sconics::base_sconics_spheroid<T, Parameters> { - inline murd2_spheroid(const Parameters& par) : detail::sconics::base_sconics_spheroid<CalculationType, Parameters>(par) + inline murd2_spheroid(const Parameters& par) : detail::sconics::base_sconics_spheroid<T, Parameters>(par) { detail::sconics::setup_murd2(this->m_par, this->m_proj_parm); } @@ -382,10 +379,10 @@ namespace projections \par Example \image html ex_murd3.gif */ - template <typename CalculationType, typename Parameters> - struct murd3_spheroid : public detail::sconics::base_sconics_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct murd3_spheroid : public detail::sconics::base_sconics_spheroid<T, Parameters> { - inline murd3_spheroid(const Parameters& par) : detail::sconics::base_sconics_spheroid<CalculationType, Parameters>(par) + inline murd3_spheroid(const Parameters& par) : detail::sconics::base_sconics_spheroid<T, Parameters>(par) { detail::sconics::setup_murd3(this->m_par, this->m_proj_parm); } @@ -406,10 +403,10 @@ namespace projections \par Example \image html ex_euler.gif */ - template <typename CalculationType, typename Parameters> - struct euler_spheroid : public detail::sconics::base_sconics_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct euler_spheroid : public detail::sconics::base_sconics_spheroid<T, Parameters> { - inline euler_spheroid(const Parameters& par) : detail::sconics::base_sconics_spheroid<CalculationType, Parameters>(par) + inline euler_spheroid(const Parameters& par) : detail::sconics::base_sconics_spheroid<T, Parameters>(par) { detail::sconics::setup_euler(this->m_par, this->m_proj_parm); } @@ -430,10 +427,10 @@ namespace projections \par Example \image html ex_pconic.gif */ - template <typename CalculationType, typename Parameters> - struct pconic_spheroid : public detail::sconics::base_sconics_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct pconic_spheroid : public detail::sconics::base_sconics_spheroid<T, Parameters> { - inline pconic_spheroid(const Parameters& par) : detail::sconics::base_sconics_spheroid<CalculationType, Parameters>(par) + inline pconic_spheroid(const Parameters& par) : detail::sconics::base_sconics_spheroid<T, Parameters>(par) { detail::sconics::setup_pconic(this->m_par, this->m_proj_parm); } @@ -454,10 +451,10 @@ namespace projections \par Example \image html ex_vitk1.gif */ - template <typename CalculationType, typename Parameters> - struct vitk1_spheroid : public detail::sconics::base_sconics_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct vitk1_spheroid : public detail::sconics::base_sconics_spheroid<T, Parameters> { - inline vitk1_spheroid(const Parameters& par) : detail::sconics::base_sconics_spheroid<CalculationType, Parameters>(par) + inline vitk1_spheroid(const Parameters& par) : detail::sconics::base_sconics_spheroid<T, Parameters>(par) { detail::sconics::setup_vitk1(this->m_par, this->m_proj_parm); } @@ -477,86 +474,86 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::vitk1, vitk1_spheroid, vitk1_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class tissot_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class tissot_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<tissot_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<tissot_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class murd1_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class murd1_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<murd1_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<murd1_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class murd2_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class murd2_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<murd2_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<murd2_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class murd3_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class murd3_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<murd3_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<murd3_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class euler_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class euler_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<euler_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<euler_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class pconic_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class pconic_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<pconic_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<pconic_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class vitk1_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class vitk1_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<vitk1_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<vitk1_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void sconics_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void sconics_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("tissot", new tissot_entry<CalculationType, Parameters>); - factory.add_to_factory("murd1", new murd1_entry<CalculationType, Parameters>); - factory.add_to_factory("murd2", new murd2_entry<CalculationType, Parameters>); - factory.add_to_factory("murd3", new murd3_entry<CalculationType, Parameters>); - factory.add_to_factory("euler", new euler_entry<CalculationType, Parameters>); - factory.add_to_factory("pconic", new pconic_entry<CalculationType, Parameters>); - factory.add_to_factory("vitk1", new vitk1_entry<CalculationType, Parameters>); + factory.add_to_factory("tissot", new tissot_entry<T, Parameters>); + factory.add_to_factory("murd1", new murd1_entry<T, Parameters>); + factory.add_to_factory("murd2", new murd2_entry<T, Parameters>); + factory.add_to_factory("murd3", new murd3_entry<T, Parameters>); + factory.add_to_factory("euler", new euler_entry<T, Parameters>); + factory.add_to_factory("pconic", new pconic_entry<T, Parameters>); + factory.add_to_factory("vitk1", new vitk1_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/somerc.hpp b/boost/geometry/srs/projections/proj/somerc.hpp index e67d09719e..548ebe5275 100644 --- a/boost/geometry/srs/projections/proj/somerc.hpp +++ b/boost/geometry/srs/projections/proj/somerc.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_SOMERC_HPP -#define BOOST_GEOMETRY_PROJECTIONS_SOMERC_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_SOMERC_HPP +#define BOOST_GEOMETRY_PROJECTIONS_SOMERC_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -54,7 +53,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct somerc {}; + struct somerc {}; // Swiss. Obl. Mercator }} //namespace srs::par4 @@ -63,8 +62,8 @@ namespace projections #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace somerc { - static const double EPS = 1.e-10; - static const int NITER = 6; + static const double epsilon = 1.e-10; + static const int n_iter = 6; template <typename T> struct par_somerc @@ -73,70 +72,67 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_somerc_ellipsoid : public base_t_fi<base_somerc_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_somerc_ellipsoid + : public base_t_fi<base_somerc_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_somerc<CalculationType> m_proj_parm; + par_somerc<T> m_proj_parm; inline base_somerc_ellipsoid(const Parameters& par) - : base_t_fi<base_somerc_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_somerc_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType FORTPI = detail::FORTPI<CalculationType>(); - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T fourth_pi = detail::fourth_pi<T>(); + static const T half_pi = detail::half_pi<T>(); - CalculationType phip, lamp, phipp, lampp, sp, cp; + T phip, lamp, phipp, lampp, sp, cp; sp = this->m_par.e * sin(lp_lat); phip = 2.* atan( exp( this->m_proj_parm.c * ( - log(tan(FORTPI + 0.5 * lp_lat)) - this->m_proj_parm.hlf_e * log((1. + sp)/(1. - sp))) - + this->m_proj_parm.K)) - HALFPI; + log(tan(fourth_pi + 0.5 * lp_lat)) - this->m_proj_parm.hlf_e * log((1. + sp)/(1. - sp))) + + this->m_proj_parm.K)) - half_pi; lamp = this->m_proj_parm.c * lp_lon; cp = cos(phip); phipp = aasin(this->m_proj_parm.cosp0 * sin(phip) - this->m_proj_parm.sinp0 * cp * cos(lamp)); lampp = aasin(cp * sin(lamp) / cos(phipp)); xy_x = this->m_proj_parm.kR * lampp; - xy_y = this->m_proj_parm.kR * log(tan(FORTPI + 0.5 * phipp)); + xy_y = this->m_proj_parm.kR * log(tan(fourth_pi + 0.5 * phipp)); } // INVERSE(e_inverse) ellipsoid & spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType FORTPI = detail::FORTPI<CalculationType>(); + static const T fourth_pi = detail::fourth_pi<T>(); - CalculationType phip, lamp, phipp, lampp, cp, esp, con, delp; + T phip, lamp, phipp, lampp, cp, esp, con, delp; int i; - phipp = 2. * (atan(exp(xy_y / this->m_proj_parm.kR)) - FORTPI); + phipp = 2. * (atan(exp(xy_y / this->m_proj_parm.kR)) - fourth_pi); lampp = xy_x / this->m_proj_parm.kR; cp = cos(phipp); phip = aasin(this->m_proj_parm.cosp0 * sin(phipp) + this->m_proj_parm.sinp0 * cp * cos(lampp)); lamp = aasin(cp * sin(lampp) / cos(phip)); - con = (this->m_proj_parm.K - log(tan(FORTPI + 0.5 * phip)))/this->m_proj_parm.c; - for (i = NITER; i ; --i) { + con = (this->m_proj_parm.K - log(tan(fourth_pi + 0.5 * phip)))/this->m_proj_parm.c; + for (i = n_iter; i ; --i) { esp = this->m_par.e * sin(phip); - delp = (con + log(tan(FORTPI + 0.5 * phip)) - this->m_proj_parm.hlf_e * + delp = (con + log(tan(fourth_pi + 0.5 * phip)) - this->m_proj_parm.hlf_e * log((1. + esp)/(1. - esp)) ) * (1. - esp * esp) * cos(phip) * this->m_par.rone_es; phip -= delp; - if (fabs(delp) < EPS) + if (fabs(delp) < epsilon) break; } if (i) { lp_lat = phip; lp_lon = lamp / this->m_proj_parm.c; - } else - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + } else { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } } static inline std::string get_name() @@ -150,7 +146,7 @@ namespace projections template <typename Parameters, typename T> inline void setup_somerc(Parameters& par, par_somerc<T>& proj_parm) { - static const T FORTPI = detail::FORTPI<T>(); + static const T fourth_pi = detail::fourth_pi<T>(); T cp, phip0, sp; @@ -161,8 +157,8 @@ namespace projections sp = sin(par.phi0); proj_parm.cosp0 = cos( phip0 = aasin(proj_parm.sinp0 = sp / proj_parm.c) ); sp *= par.e; - proj_parm.K = log(tan(FORTPI + 0.5 * phip0)) - proj_parm.c * ( - log(tan(FORTPI + 0.5 * par.phi0)) - proj_parm.hlf_e * + proj_parm.K = log(tan(fourth_pi + 0.5 * phip0)) - proj_parm.c * ( + log(tan(fourth_pi + 0.5 * par.phi0)) - proj_parm.hlf_e * log((1. + sp) / (1. - sp))); proj_parm.kR = par.k0 * sqrt(par.one_es) / (1. - sp * sp); } @@ -183,10 +179,10 @@ namespace projections \par Example \image html ex_somerc.gif */ - template <typename CalculationType, typename Parameters> - struct somerc_ellipsoid : public detail::somerc::base_somerc_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct somerc_ellipsoid : public detail::somerc::base_somerc_ellipsoid<T, Parameters> { - inline somerc_ellipsoid(const Parameters& par) : detail::somerc::base_somerc_ellipsoid<CalculationType, Parameters>(par) + inline somerc_ellipsoid(const Parameters& par) : detail::somerc::base_somerc_ellipsoid<T, Parameters>(par) { detail::somerc::setup_somerc(this->m_par, this->m_proj_parm); } @@ -200,20 +196,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::somerc, somerc_ellipsoid, somerc_ellipsoid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class somerc_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class somerc_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<somerc_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<somerc_ellipsoid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void somerc_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void somerc_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("somerc", new somerc_entry<CalculationType, Parameters>); + factory.add_to_factory("somerc", new somerc_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/stere.hpp b/boost/geometry/srs/projections/proj/stere.hpp index 9278902e34..ea8af31149 100644 --- a/boost/geometry/srs/projections/proj/stere.hpp +++ b/boost/geometry/srs/projections/proj/stere.hpp @@ -1,8 +1,4 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_STERE_HPP -#define BOOST_GEOMETRY_PROJECTIONS_STERE_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_STERE_HPP +#define BOOST_GEOMETRY_PROJECTIONS_STERE_HPP + #include <boost/config.hpp> #include <boost/geometry/util/math.hpp> #include <boost/math/special_functions/hypot.hpp> @@ -56,8 +55,8 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct stere {}; - struct ups {}; + struct stere {}; // Stereographic + struct ups {}; // Universal Polar Stereographic }} //namespace srs::par4 @@ -66,14 +65,17 @@ namespace projections #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace stere { - static const double EPS10 = 1.e-10; - static const double TOL = 1.e-8; - static const int NITER = 8; - static const double CONV = 1.e-10; - static const int S_POLE = 0; - static const int N_POLE = 1; - static const int OBLIQ = 2; - static const int EQUIT = 3; + static const double epsilon10 = 1.e-10; + static const double tolerance = 1.e-8; + static const int n_iter = 8; + static const double conv_tolerance = 1.e-10; + + enum mode_type { + s_pole = 0, + n_pole = 1, + obliq = 2, + equit = 3 + }; template <typename T> struct par_stere @@ -82,118 +84,125 @@ namespace projections T sinX1; T cosX1; T akm1; - int mode; + mode_type mode; }; template <typename T> inline T ssfn_(T const& phit, T sinphi, T const& eccen) { + static const T half_pi = detail::half_pi<T>(); + sinphi *= eccen; - return (tan (.5 * (geometry::math::half_pi<T>() + phit)) * - pow((1. - sinphi) / (1. + sinphi), .5 * eccen)); + return (tan (.5 * (half_pi + phit)) * + math::pow((T(1) - sinphi) / (T(1) + sinphi), T(0.5) * eccen)); } // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_stere_ellipsoid : public base_t_fi<base_stere_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_stere_ellipsoid + : public base_t_fi<base_stere_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_stere<CalculationType> m_proj_parm; + par_stere<T> m_proj_parm; inline base_stere_ellipsoid(const Parameters& par) - : base_t_fi<base_stere_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_stere_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) ellipsoid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); - CalculationType coslam, sinlam, sinX=0.0, cosX=0.0, X, A, sinphi; + T coslam, sinlam, sinX=0.0, cosX=0.0, X, A = 0.0, sinphi; coslam = cos(lp_lon); sinlam = sin(lp_lon); sinphi = sin(lp_lat); - if (this->m_proj_parm.mode == OBLIQ || this->m_proj_parm.mode == EQUIT) { - sinX = sin(X = 2. * atan(ssfn_(lp_lat, sinphi, this->m_par.e)) - HALFPI); + if (this->m_proj_parm.mode == obliq || this->m_proj_parm.mode == equit) { + sinX = sin(X = 2. * atan(ssfn_(lp_lat, sinphi, this->m_par.e)) - half_pi); cosX = cos(X); } switch (this->m_proj_parm.mode) { - case OBLIQ: + case obliq: A = this->m_proj_parm.akm1 / (this->m_proj_parm.cosX1 * (1. + this->m_proj_parm.sinX1 * sinX + this->m_proj_parm.cosX1 * cosX * coslam)); xy_y = A * (this->m_proj_parm.cosX1 * sinX - this->m_proj_parm.sinX1 * cosX * coslam); - goto xmul; - case EQUIT: - A = this->m_proj_parm.akm1 / (1. + cosX * coslam); - xy_y = A * sinX; + goto xmul; /* but why not just xy.x = A * cosX; break; ? */ + + case equit: + // TODO: calculate denominator once + /* avoid zero division */ + if (1. + cosX * coslam == 0.0) { + xy_y = HUGE_VAL; + } else { + A = this->m_proj_parm.akm1 / (1. + cosX * coslam); + xy_y = A * sinX; + } xmul: xy_x = A * cosX; break; - case S_POLE: + + case s_pole: lp_lat = -lp_lat; coslam = - coslam; sinphi = -sinphi; BOOST_FALLTHROUGH; - case N_POLE: + case n_pole: xy_x = this->m_proj_parm.akm1 * pj_tsfn(lp_lat, sinphi, this->m_par.e); xy_y = - xy_x * coslam; break; } + xy_x = xy_x * sinlam; } // INVERSE(e_inverse) ellipsoid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); - CalculationType cosphi, sinphi, tp=0.0, phi_l=0.0, rho, halfe=0.0, halfpi=0.0; + T cosphi, sinphi, tp=0.0, phi_l=0.0, rho, halfe=0.0, halfpi=0.0; int i; rho = boost::math::hypot(xy_x, xy_y); switch (this->m_proj_parm.mode) { - case OBLIQ: - case EQUIT: + case obliq: + case equit: cosphi = cos( tp = 2. * atan2(rho * this->m_proj_parm.cosX1 , this->m_proj_parm.akm1) ); sinphi = sin(tp); - if( rho == 0.0 ) + if( rho == 0.0 ) phi_l = asin(cosphi * this->m_proj_parm.sinX1); - else + else phi_l = asin(cosphi * this->m_proj_parm.sinX1 + (xy_y * sinphi * this->m_proj_parm.cosX1 / rho)); - tp = tan(.5 * (HALFPI + phi_l)); + tp = tan(.5 * (half_pi + phi_l)); xy_x *= sinphi; xy_y = rho * this->m_proj_parm.cosX1 * cosphi - xy_y * this->m_proj_parm.sinX1* sinphi; - halfpi = HALFPI; + halfpi = half_pi; halfe = .5 * this->m_par.e; break; - case N_POLE: + case n_pole: xy_y = -xy_y; BOOST_FALLTHROUGH; - case S_POLE: - phi_l = HALFPI - 2. * atan(tp = - rho / this->m_proj_parm.akm1); - halfpi = -HALFPI; + case s_pole: + phi_l = half_pi - 2. * atan(tp = - rho / this->m_proj_parm.akm1); + halfpi = -half_pi; halfe = -.5 * this->m_par.e; break; } - for (i = NITER; i--; phi_l = lp_lat) { + for (i = n_iter; i--; phi_l = lp_lat) { sinphi = this->m_par.e * sin(phi_l); - lp_lat = 2. * atan(tp * pow((1.+sinphi)/(1.-sinphi), halfe)) - halfpi; - if (fabs(phi_l - lp_lat) < CONV) { - if (this->m_proj_parm.mode == S_POLE) + lp_lat = T(2) * atan(tp * math::pow((T(1)+sinphi)/(T(1)-sinphi), halfe)) - halfpi; + if (fabs(phi_l - lp_lat) < conv_tolerance) { + if (this->m_proj_parm.mode == s_pole) lp_lat = -lp_lat; lp_lon = (xy_x == 0. && xy_y == 0.) ? 0. : atan2(xy_x, xy_y); return; } } - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); } static inline std::string get_name() @@ -204,54 +213,52 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_stere_spheroid : public base_t_fi<base_stere_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_stere_spheroid + : public base_t_fi<base_stere_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_stere<CalculationType> m_proj_parm; + par_stere<T> m_proj_parm; inline base_stere_spheroid(const Parameters& par) - : base_t_fi<base_stere_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_stere_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType FORTPI = detail::FORTPI<CalculationType>(); - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T fourth_pi = detail::fourth_pi<T>(); + static const T half_pi = detail::half_pi<T>(); - CalculationType sinphi, cosphi, coslam, sinlam; + T sinphi, cosphi, coslam, sinlam; sinphi = sin(lp_lat); cosphi = cos(lp_lat); coslam = cos(lp_lon); sinlam = sin(lp_lon); switch (this->m_proj_parm.mode) { - case EQUIT: + case equit: xy_y = 1. + cosphi * coslam; goto oblcon; - case OBLIQ: + case obliq: xy_y = 1. + this->m_proj_parm.sinX1 * sinphi + this->m_proj_parm.cosX1 * cosphi * coslam; oblcon: - if (xy_y <= EPS10) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + if (xy_y <= epsilon10) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } xy_x = (xy_y = this->m_proj_parm.akm1 / xy_y) * cosphi * sinlam; - xy_y *= (this->m_proj_parm.mode == EQUIT) ? sinphi : + xy_y *= (this->m_proj_parm.mode == equit) ? sinphi : this->m_proj_parm.cosX1 * sinphi - this->m_proj_parm.sinX1 * cosphi * coslam; break; - case N_POLE: + case n_pole: coslam = - coslam; lp_lat = - lp_lat; BOOST_FALLTHROUGH; - case S_POLE: - if (fabs(lp_lat - HALFPI) < TOL) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); - xy_x = sinlam * ( xy_y = this->m_proj_parm.akm1 * tan(FORTPI + .5 * lp_lat) ); + case s_pole: + if (fabs(lp_lat - half_pi) < tolerance) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } + xy_x = sinlam * ( xy_y = this->m_proj_parm.akm1 * tan(fourth_pi + .5 * lp_lat) ); xy_y *= coslam; break; } @@ -259,38 +266,39 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType c, rh, sinc, cosc; + T c, rh, sinc, cosc; sinc = sin(c = 2. * atan((rh = boost::math::hypot(xy_x, xy_y)) / this->m_proj_parm.akm1)); cosc = cos(c); lp_lon = 0.; + switch (this->m_proj_parm.mode) { - case EQUIT: - if (fabs(rh) <= EPS10) + case equit: + if (fabs(rh) <= epsilon10) lp_lat = 0.; else lp_lat = asin(xy_y * sinc / rh); if (cosc != 0. || xy_x != 0.) lp_lon = atan2(xy_x * sinc, cosc * rh); break; - case OBLIQ: - if (fabs(rh) <= EPS10) + case obliq: + if (fabs(rh) <= epsilon10) lp_lat = this->m_par.phi0; else lp_lat = asin(cosc * this->m_proj_parm.sinX1 + xy_y * sinc * this->m_proj_parm.cosX1 / rh); if ((c = cosc - this->m_proj_parm.sinX1 * sin(lp_lat)) != 0. || xy_x != 0.) lp_lon = atan2(xy_x * sinc * this->m_proj_parm.cosX1, c * rh); break; - case N_POLE: + case n_pole: xy_y = -xy_y; BOOST_FALLTHROUGH; - case S_POLE: - if (fabs(rh) <= EPS10) + case s_pole: + if (fabs(rh) <= epsilon10) lp_lat = this->m_par.phi0; else - lp_lat = asin(this->m_proj_parm.mode == S_POLE ? - cosc : cosc); + lp_lat = asin(this->m_proj_parm.mode == s_pole ? - cosc : cosc); lp_lon = (xy_x == 0. && xy_y == 0.) ? 0. : atan2(xy_x, xy_y); break; } @@ -306,25 +314,26 @@ namespace projections template <typename Parameters, typename T> inline void setup(Parameters& par, par_stere<T>& proj_parm) /* general initialization */ { - static const T FORTPI = detail::FORTPI<T>(); - static const T HALFPI = detail::HALFPI<T>(); + static const T fourth_pi = detail::fourth_pi<T>(); + static const T half_pi = detail::half_pi<T>(); T t; - if (fabs((t = fabs(par.phi0)) - HALFPI) < EPS10) - proj_parm.mode = par.phi0 < 0. ? S_POLE : N_POLE; + if (fabs((t = fabs(par.phi0)) - half_pi) < epsilon10) + proj_parm.mode = par.phi0 < 0. ? s_pole : n_pole; else - proj_parm.mode = t > EPS10 ? OBLIQ : EQUIT; + proj_parm.mode = t > epsilon10 ? obliq : equit; proj_parm.phits = fabs(proj_parm.phits); + if (par.es != 0.0) { T X; switch (proj_parm.mode) { - case N_POLE: - case S_POLE: - if (fabs(proj_parm.phits - HALFPI) < EPS10) + case n_pole: + case s_pole: + if (fabs(proj_parm.phits - half_pi) < epsilon10) proj_parm.akm1 = 2. * par.k0 / - sqrt(pow(1+par.e,1+par.e)*pow(1-par.e,1-par.e)); + sqrt(math::pow(T(1)+par.e,T(1)+par.e)*math::pow(T(1)-par.e,T(1)-par.e)); else { proj_parm.akm1 = cos(proj_parm.phits) / pj_tsfn(proj_parm.phits, t = sin(proj_parm.phits), par.e); @@ -332,12 +341,10 @@ namespace projections proj_parm.akm1 /= sqrt(1. - t * t); } break; - case EQUIT: - //proj_parm.akm1 = 2. * par.k0; - //break; - case OBLIQ: + case equit: + case obliq: t = sin(par.phi0); - X = 2. * atan(ssfn_(par.phi0, t, par.e)) - HALFPI; + X = 2. * atan(ssfn_(par.phi0, t, par.e)) - half_pi; t *= par.e; proj_parm.akm1 = 2. * par.k0 * cos(par.phi0) / sqrt(1. - t * t); proj_parm.sinX1 = sin(X); @@ -346,17 +353,17 @@ namespace projections } } else { switch (proj_parm.mode) { - case OBLIQ: + case obliq: proj_parm.sinX1 = sin(par.phi0); proj_parm.cosX1 = cos(par.phi0); BOOST_FALLTHROUGH; - case EQUIT: + case equit: proj_parm.akm1 = 2. * par.k0; break; - case S_POLE: - case N_POLE: - proj_parm.akm1 = fabs(proj_parm.phits - HALFPI) >= EPS10 ? - cos(proj_parm.phits) / tan(FORTPI - .5 * proj_parm.phits) : + case s_pole: + case n_pole: + proj_parm.akm1 = fabs(proj_parm.phits - half_pi) >= epsilon10 ? + cos(proj_parm.phits) / tan(fourth_pi - .5 * proj_parm.phits) : 2. * par.k0 ; break; } @@ -368,10 +375,11 @@ namespace projections template <typename Parameters, typename T> inline void setup_stere(Parameters& par, par_stere<T>& proj_parm) { - static const T HALFPI = detail::HALFPI<T>(); + static const T half_pi = detail::half_pi<T>(); + + if (! pj_param_r(par.params, "lat_ts", proj_parm.phits)) + proj_parm.phits = half_pi; - proj_parm.phits = pj_param(par.params, "tlat_ts").i ? - pj_param(par.params, "rlat_ts").f : HALFPI; setup(par, proj_parm); } @@ -379,17 +387,19 @@ namespace projections template <typename Parameters, typename T> inline void setup_ups(Parameters& par, par_stere<T>& proj_parm) { - static const T HALFPI = detail::HALFPI<T>(); + static const T half_pi = detail::half_pi<T>(); /* International Ellipsoid */ - par.phi0 = pj_param(par.params, "bsouth").i ? -HALFPI: HALFPI; - if (!par.es) - BOOST_THROW_EXCEPTION( projection_exception(-34) ); + par.phi0 = pj_get_param_b(par.params, "south") ? -half_pi: half_pi; + if (par.es == 0.0) { + BOOST_THROW_EXCEPTION( projection_exception(error_ellipsoid_use_required) ); + } par.k0 = .994; par.x0 = 2000000.; par.y0 = 2000000.; - proj_parm.phits = HALFPI; + proj_parm.phits = half_pi; par.lam0 = 0.; + setup(par, proj_parm); } @@ -411,10 +421,10 @@ namespace projections \par Example \image html ex_stere.gif */ - template <typename CalculationType, typename Parameters> - struct stere_ellipsoid : public detail::stere::base_stere_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct stere_ellipsoid : public detail::stere::base_stere_ellipsoid<T, Parameters> { - inline stere_ellipsoid(const Parameters& par) : detail::stere::base_stere_ellipsoid<CalculationType, Parameters>(par) + inline stere_ellipsoid(const Parameters& par) : detail::stere::base_stere_ellipsoid<T, Parameters>(par) { detail::stere::setup_stere(this->m_par, this->m_proj_parm); } @@ -435,10 +445,10 @@ namespace projections \par Example \image html ex_stere.gif */ - template <typename CalculationType, typename Parameters> - struct stere_spheroid : public detail::stere::base_stere_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct stere_spheroid : public detail::stere::base_stere_spheroid<T, Parameters> { - inline stere_spheroid(const Parameters& par) : detail::stere::base_stere_spheroid<CalculationType, Parameters>(par) + inline stere_spheroid(const Parameters& par) : detail::stere::base_stere_spheroid<T, Parameters>(par) { detail::stere::setup_stere(this->m_par, this->m_proj_parm); } @@ -459,10 +469,10 @@ namespace projections \par Example \image html ex_ups.gif */ - template <typename CalculationType, typename Parameters> - struct ups_ellipsoid : public detail::stere::base_stere_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct ups_ellipsoid : public detail::stere::base_stere_ellipsoid<T, Parameters> { - inline ups_ellipsoid(const Parameters& par) : detail::stere::base_stere_ellipsoid<CalculationType, Parameters>(par) + inline ups_ellipsoid(const Parameters& par) : detail::stere::base_stere_ellipsoid<T, Parameters>(par) { detail::stere::setup_ups(this->m_par, this->m_proj_parm); } @@ -483,10 +493,10 @@ namespace projections \par Example \image html ex_ups.gif */ - template <typename CalculationType, typename Parameters> - struct ups_spheroid : public detail::stere::base_stere_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct ups_spheroid : public detail::stere::base_stere_spheroid<T, Parameters> { - inline ups_spheroid(const Parameters& par) : detail::stere::base_stere_spheroid<CalculationType, Parameters>(par) + inline ups_spheroid(const Parameters& par) : detail::stere::base_stere_spheroid<T, Parameters>(par) { detail::stere::setup_ups(this->m_par, this->m_proj_parm); } @@ -501,37 +511,37 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::ups, ups_spheroid, ups_ellipsoid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class stere_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class stere_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { if (par.es) - return new base_v_fi<stere_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<stere_ellipsoid<T, Parameters>, T, Parameters>(par); else - return new base_v_fi<stere_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<stere_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class ups_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class ups_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { if (par.es) - return new base_v_fi<ups_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<ups_ellipsoid<T, Parameters>, T, Parameters>(par); else - return new base_v_fi<ups_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<ups_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void stere_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void stere_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("stere", new stere_entry<CalculationType, Parameters>); - factory.add_to_factory("ups", new ups_entry<CalculationType, Parameters>); + factory.add_to_factory("stere", new stere_entry<T, Parameters>); + factory.add_to_factory("ups", new ups_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/sterea.hpp b/boost/geometry/srs/projections/proj/sterea.hpp index f9de2c6896..055be84e98 100644 --- a/boost/geometry/srs/projections/proj/sterea.hpp +++ b/boost/geometry/srs/projections/proj/sterea.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_STEREA_HPP -#define BOOST_GEOMETRY_PROJECTIONS_STEREA_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -43,6 +39,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_STEREA_HPP +#define BOOST_GEOMETRY_PROJECTIONS_STEREA_HPP + #include <boost/math/special_functions/hypot.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -57,7 +56,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct sterea {}; + struct sterea {}; // Oblique Stereographic Alternative }} //namespace srs::par4 @@ -67,40 +66,33 @@ namespace projections namespace detail { namespace sterea { - static const double DEL_TOL = 1.e-14; - static const int MAX_ITER = 10; - template <typename T> struct par_sterea { T phic0; T cosc0, sinc0; T R2; - gauss::GAUSS<T> en; + gauss<T> en; }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_sterea_ellipsoid : public base_t_fi<base_sterea_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_sterea_ellipsoid + : public base_t_fi<base_sterea_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_sterea<CalculationType> m_proj_parm; + par_sterea<T> m_proj_parm; inline base_sterea_ellipsoid(const Parameters& par) - : base_t_fi<base_sterea_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_sterea_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) ellipsoid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType cosc, sinc, cosl_, k; + T cosc, sinc, cosl_, k; - detail::gauss::gauss(m_proj_parm.en, lp_lon, lp_lat); + detail::gauss_fwd(m_proj_parm.en, lp_lon, lp_lat); sinc = sin(lp_lat); cosc = cos(lp_lat); cosl_ = cos(lp_lon); @@ -111,24 +103,24 @@ namespace projections // INVERSE(e_inverse) ellipsoid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType rho, c, sinc, cosc; + T rho, c, sinc, cosc; xy_x /= this->m_par.k0; xy_y /= this->m_par.k0; - if((rho = boost::math::hypot(xy_x, xy_y))) { + if((rho = boost::math::hypot(xy_x, xy_y)) != 0.0) { c = 2. * atan2(rho, this->m_proj_parm.R2); sinc = sin(c); cosc = cos(c); lp_lat = asin(cosc * this->m_proj_parm.sinc0 + xy_y * sinc * this->m_proj_parm.cosc0 / rho); lp_lon = atan2(xy_x * sinc, rho * this->m_proj_parm.cosc0 * cosc - - xy_y * this->m_proj_parm.sinc0 * sinc); + xy_y * this->m_proj_parm.sinc0 * sinc); } else { lp_lat = this->m_proj_parm.phic0; lp_lon = 0.; } - detail::gauss::inv_gauss(m_proj_parm.en, lp_lon, lp_lat); + detail::gauss_inv(m_proj_parm.en, lp_lon, lp_lat); } static inline std::string get_name() @@ -144,7 +136,7 @@ namespace projections { T R; - proj_parm.en = detail::gauss::gauss_ini(par.e, par.phi0, proj_parm.phic0, R); + proj_parm.en = detail::gauss_ini(par.e, par.phi0, proj_parm.phic0, R); proj_parm.sinc0 = sin(proj_parm.phic0); proj_parm.cosc0 = cos(proj_parm.phic0); proj_parm.R2 = 2. * R; @@ -166,10 +158,10 @@ namespace projections \par Example \image html ex_sterea.gif */ - template <typename CalculationType, typename Parameters> - struct sterea_ellipsoid : public detail::sterea::base_sterea_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct sterea_ellipsoid : public detail::sterea::base_sterea_ellipsoid<T, Parameters> { - inline sterea_ellipsoid(const Parameters& par) : detail::sterea::base_sterea_ellipsoid<CalculationType, Parameters>(par) + inline sterea_ellipsoid(const Parameters& par) : detail::sterea::base_sterea_ellipsoid<T, Parameters>(par) { detail::sterea::setup_sterea(this->m_par, this->m_proj_parm); } @@ -183,20 +175,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::sterea, sterea_ellipsoid, sterea_ellipsoid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class sterea_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class sterea_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<sterea_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<sterea_ellipsoid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void sterea_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void sterea_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("sterea", new sterea_entry<CalculationType, Parameters>); + factory.add_to_factory("sterea", new sterea_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/sts.hpp b/boost/geometry/srs/projections/proj/sts.hpp index ca0d3f0cd1..73bef01626 100644 --- a/boost/geometry/srs/projections/proj/sts.hpp +++ b/boost/geometry/srs/projections/proj/sts.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_STS_HPP -#define BOOST_GEOMETRY_PROJECTIONS_STS_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_STS_HPP +#define BOOST_GEOMETRY_PROJECTIONS_STS_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -52,10 +51,10 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct kav5 {}; - struct qua_aut {}; - struct mbt_s {}; - struct fouc {}; + struct kav5 {}; // Kavraisky V + struct qua_aut {}; // Quartic Authalic + struct fouc {}; // Foucaut + struct mbt_s {}; // McBryde-Thomas Flat-Polar Sine (No. 1) }} //namespace srs::par4 @@ -68,29 +67,25 @@ namespace projections struct par_sts { T C_x, C_y, C_p; - int tan_mode; + bool tan_mode; }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_sts_spheroid : public base_t_fi<base_sts_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_sts_spheroid + : public base_t_fi<base_sts_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_sts<CalculationType> m_proj_parm; + par_sts<T> m_proj_parm; inline base_sts_spheroid(const Parameters& par) - : base_t_fi<base_sts_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_sts_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType c; + T c; xy_x = this->m_proj_parm.C_x * lp_lon * cos(lp_lat); xy_y = this->m_proj_parm.C_y; @@ -107,9 +102,9 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType c; + T c; xy_y /= this->m_proj_parm.C_y; c = cos(lp_lat = this->m_proj_parm.tan_mode ? atan(xy_y) : aasin(xy_y)); @@ -129,7 +124,7 @@ namespace projections }; template <typename Parameters, typename T> - inline void setup(Parameters& par, par_sts<T>& proj_parm, T const& p, T const& q, int mode) + inline void setup(Parameters& par, par_sts<T>& proj_parm, T const& p, T const& q, bool mode) { par.es = 0.; proj_parm.C_x = q / p; @@ -139,32 +134,32 @@ namespace projections } + // Foucaut + template <typename Parameters, typename T> + inline void setup_fouc(Parameters& par, par_sts<T>& proj_parm) + { + setup(par, proj_parm, 2., 2., true); + } + // Kavraisky V template <typename Parameters, typename T> inline void setup_kav5(Parameters& par, par_sts<T>& proj_parm) { - setup(par, proj_parm, 1.50488, 1.35439, 0); + setup(par, proj_parm, 1.50488, 1.35439, false); } // Quartic Authalic template <typename Parameters, typename T> inline void setup_qua_aut(Parameters& par, par_sts<T>& proj_parm) { - setup(par, proj_parm, 2., 2., 0); + setup(par, proj_parm, 2., 2., false); } // McBryde-Thomas Flat-Polar Sine (No. 1) template <typename Parameters, typename T> inline void setup_mbt_s(Parameters& par, par_sts<T>& proj_parm) { - setup(par, proj_parm, 1.48875, 1.36509, 0); - } - - // Foucaut - template <typename Parameters, typename T> - inline void setup_fouc(Parameters& par, par_sts<T>& proj_parm) - { - setup(par, proj_parm, 2., 2., 1); + setup(par, proj_parm, 1.48875, 1.36509, false); } }} // namespace detail::sts @@ -182,10 +177,10 @@ namespace projections \par Example \image html ex_kav5.gif */ - template <typename CalculationType, typename Parameters> - struct kav5_spheroid : public detail::sts::base_sts_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct kav5_spheroid : public detail::sts::base_sts_spheroid<T, Parameters> { - inline kav5_spheroid(const Parameters& par) : detail::sts::base_sts_spheroid<CalculationType, Parameters>(par) + inline kav5_spheroid(const Parameters& par) : detail::sts::base_sts_spheroid<T, Parameters>(par) { detail::sts::setup_kav5(this->m_par, this->m_proj_parm); } @@ -203,10 +198,10 @@ namespace projections \par Example \image html ex_qua_aut.gif */ - template <typename CalculationType, typename Parameters> - struct qua_aut_spheroid : public detail::sts::base_sts_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct qua_aut_spheroid : public detail::sts::base_sts_spheroid<T, Parameters> { - inline qua_aut_spheroid(const Parameters& par) : detail::sts::base_sts_spheroid<CalculationType, Parameters>(par) + inline qua_aut_spheroid(const Parameters& par) : detail::sts::base_sts_spheroid<T, Parameters>(par) { detail::sts::setup_qua_aut(this->m_par, this->m_proj_parm); } @@ -224,10 +219,10 @@ namespace projections \par Example \image html ex_mbt_s.gif */ - template <typename CalculationType, typename Parameters> - struct mbt_s_spheroid : public detail::sts::base_sts_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct mbt_s_spheroid : public detail::sts::base_sts_spheroid<T, Parameters> { - inline mbt_s_spheroid(const Parameters& par) : detail::sts::base_sts_spheroid<CalculationType, Parameters>(par) + inline mbt_s_spheroid(const Parameters& par) : detail::sts::base_sts_spheroid<T, Parameters>(par) { detail::sts::setup_mbt_s(this->m_par, this->m_proj_parm); } @@ -245,10 +240,10 @@ namespace projections \par Example \image html ex_fouc.gif */ - template <typename CalculationType, typename Parameters> - struct fouc_spheroid : public detail::sts::base_sts_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct fouc_spheroid : public detail::sts::base_sts_spheroid<T, Parameters> { - inline fouc_spheroid(const Parameters& par) : detail::sts::base_sts_spheroid<CalculationType, Parameters>(par) + inline fouc_spheroid(const Parameters& par) : detail::sts::base_sts_spheroid<T, Parameters>(par) { detail::sts::setup_fouc(this->m_par, this->m_proj_parm); } @@ -265,53 +260,53 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::fouc, fouc_spheroid, fouc_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class kav5_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class kav5_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<kav5_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<kav5_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class qua_aut_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class qua_aut_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<qua_aut_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<qua_aut_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class mbt_s_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class mbt_s_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<mbt_s_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<mbt_s_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class fouc_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class fouc_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<fouc_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<fouc_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void sts_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void sts_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("kav5", new kav5_entry<CalculationType, Parameters>); - factory.add_to_factory("qua_aut", new qua_aut_entry<CalculationType, Parameters>); - factory.add_to_factory("mbt_s", new mbt_s_entry<CalculationType, Parameters>); - factory.add_to_factory("fouc", new fouc_entry<CalculationType, Parameters>); + factory.add_to_factory("kav5", new kav5_entry<T, Parameters>); + factory.add_to_factory("qua_aut", new qua_aut_entry<T, Parameters>); + factory.add_to_factory("mbt_s", new mbt_s_entry<T, Parameters>); + factory.add_to_factory("fouc", new fouc_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/tcc.hpp b/boost/geometry/srs/projections/proj/tcc.hpp index 26cb62b3e8..34e386f91c 100644 --- a/boost/geometry/srs/projections/proj/tcc.hpp +++ b/boost/geometry/srs/projections/proj/tcc.hpp @@ -1,8 +1,4 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_TCC_HPP -#define BOOST_GEOMETRY_PROJECTIONS_TCC_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_TCC_HPP +#define BOOST_GEOMETRY_PROJECTIONS_TCC_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -51,7 +50,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct tcc {}; + struct tcc {}; // Transverse Central Cylindrical }} //namespace srs::par4 @@ -61,30 +60,27 @@ namespace projections namespace detail { namespace tcc { - static const double EPS10 = 1.e-10; + static const double epsilon10 = 1.e-10; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_tcc_spheroid : public base_t_f<base_tcc_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_tcc_spheroid + : public base_t_f<base_tcc_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - inline base_tcc_spheroid(const Parameters& par) - : base_t_f<base_tcc_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_f<base_tcc_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType b, bt; + T b, bt; b = cos(lp_lat) * sin(lp_lon); - if ((bt = 1. - b * b) < EPS10) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + if ((bt = 1. - b * b) < epsilon10) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } xy_x = b / sqrt(bt); xy_y = atan2(tan(lp_lat) , cos(lp_lon)); } @@ -119,10 +115,10 @@ namespace projections \par Example \image html ex_tcc.gif */ - template <typename CalculationType, typename Parameters> - struct tcc_spheroid : public detail::tcc::base_tcc_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct tcc_spheroid : public detail::tcc::base_tcc_spheroid<T, Parameters> { - inline tcc_spheroid(const Parameters& par) : detail::tcc::base_tcc_spheroid<CalculationType, Parameters>(par) + inline tcc_spheroid(const Parameters& par) : detail::tcc::base_tcc_spheroid<T, Parameters>(par) { detail::tcc::setup_tcc(this->m_par); } @@ -136,20 +132,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::tcc, tcc_spheroid, tcc_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class tcc_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class tcc_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_f<tcc_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_f<tcc_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void tcc_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void tcc_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("tcc", new tcc_entry<CalculationType, Parameters>); + factory.add_to_factory("tcc", new tcc_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/tcea.hpp b/boost/geometry/srs/projections/proj/tcea.hpp index b87574e947..3eafcc262a 100644 --- a/boost/geometry/srs/projections/proj/tcea.hpp +++ b/boost/geometry/srs/projections/proj/tcea.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_TCEA_HPP -#define BOOST_GEOMETRY_PROJECTIONS_TCEA_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_TCEA_HPP +#define BOOST_GEOMETRY_PROJECTIONS_TCEA_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -51,7 +50,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct tcea {}; + struct tcea {}; // Transverse Cylindrical Equal Area }} //namespace srs::par4 @@ -60,42 +59,30 @@ namespace projections #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace tcea { - template <typename T> - struct par_tcea - { - T rk0; - }; - // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_tcea_spheroid : public base_t_fi<base_tcea_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_tcea_spheroid + : public base_t_fi<base_tcea_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_tcea<CalculationType> m_proj_parm; - inline base_tcea_spheroid(const Parameters& par) - : base_t_fi<base_tcea_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_tcea_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - xy_x = this->m_proj_parm.rk0 * cos(lp_lat) * sin(lp_lon); + xy_x = cos(lp_lat) * sin(lp_lon) / this->m_par.k0; xy_y = this->m_par.k0 * (atan2(tan(lp_lat), cos(lp_lon)) - this->m_par.phi0); } // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType t; + T t; - xy_y = xy_y * this->m_proj_parm.rk0 + this->m_par.phi0; + xy_y = xy_y / this->m_par.k0 + this->m_par.phi0; xy_x *= this->m_par.k0; t = sqrt(1. - xy_x * xy_x); lp_lat = asin(t * sin(xy_y)); @@ -110,10 +97,9 @@ namespace projections }; // Transverse Cylindrical Equal Area - template <typename Parameters, typename T> - inline void setup_tcea(Parameters& par, par_tcea<T>& proj_parm) + template <typename Parameters> + inline void setup_tcea(Parameters& par) { - proj_parm.rk0 = 1 / par.k0; par.es = 0.; } @@ -132,12 +118,12 @@ namespace projections \par Example \image html ex_tcea.gif */ - template <typename CalculationType, typename Parameters> - struct tcea_spheroid : public detail::tcea::base_tcea_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct tcea_spheroid : public detail::tcea::base_tcea_spheroid<T, Parameters> { - inline tcea_spheroid(const Parameters& par) : detail::tcea::base_tcea_spheroid<CalculationType, Parameters>(par) + inline tcea_spheroid(const Parameters& par) : detail::tcea::base_tcea_spheroid<T, Parameters>(par) { - detail::tcea::setup_tcea(this->m_par, this->m_proj_parm); + detail::tcea::setup_tcea(this->m_par); } }; @@ -149,20 +135,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::tcea, tcea_spheroid, tcea_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class tcea_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class tcea_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<tcea_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<tcea_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void tcea_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void tcea_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("tcea", new tcea_entry<CalculationType, Parameters>); + factory.add_to_factory("tcea", new tcea_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/tmerc.hpp b/boost/geometry/srs/projections/proj/tmerc.hpp index 6ed2902142..7c976f82d5 100644 --- a/boost/geometry/srs/projections/proj/tmerc.hpp +++ b/boost/geometry/srs/projections/proj/tmerc.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_TMERC_HPP -#define BOOST_GEOMETRY_PROJECTIONS_TMERC_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_TMERC_HPP +#define BOOST_GEOMETRY_PROJECTIONS_TMERC_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -56,8 +55,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct tmerc {}; - struct utm {}; + struct tmerc {}; // Transverse Mercator }} //namespace srs::par4 @@ -67,15 +65,7 @@ namespace projections namespace detail { namespace tmerc { - static const double EPS10 = 1.e-10; - //static const double FC1 = 1.; - //static const double FC2 = .5; - //static const double FC3 = .16666666666666666666; - //static const double FC4 = .08333333333333333333; - //static const double FC5 = .05; - //static const double FC6 = .03333333333333333333; - //static const double FC7 = .02380952380952380952; - //static const double FC8 = .01785714285714285714; + static const double epsilon10 = 1.e-10; template <typename T> inline T FC1() { return 1.; } @@ -99,39 +89,35 @@ namespace projections { T esp; T ml0; - T en[EN_SIZE]; + detail::en<T> en; }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_tmerc_ellipsoid : public base_t_fi<base_tmerc_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_tmerc_ellipsoid + : public base_t_fi<base_tmerc_ellipsoid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_tmerc<CalculationType> m_proj_parm; + par_tmerc<T> m_proj_parm; inline base_tmerc_ellipsoid(const Parameters& par) - : base_t_fi<base_tmerc_ellipsoid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_tmerc_ellipsoid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(e_forward) ellipse // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); - static const CalculationType FC1 = tmerc::FC1<CalculationType>(); - static const CalculationType FC2 = tmerc::FC2<CalculationType>(); - static const CalculationType FC3 = tmerc::FC3<CalculationType>(); - static const CalculationType FC4 = tmerc::FC4<CalculationType>(); - static const CalculationType FC5 = tmerc::FC5<CalculationType>(); - static const CalculationType FC6 = tmerc::FC6<CalculationType>(); - static const CalculationType FC7 = tmerc::FC7<CalculationType>(); - static const CalculationType FC8 = tmerc::FC8<CalculationType>(); - - CalculationType al, als, n, cosphi, sinphi, t; + static const T half_pi = detail::half_pi<T>(); + static const T FC1 = tmerc::FC1<T>(); + static const T FC2 = tmerc::FC2<T>(); + static const T FC3 = tmerc::FC3<T>(); + static const T FC4 = tmerc::FC4<T>(); + static const T FC5 = tmerc::FC5<T>(); + static const T FC6 = tmerc::FC6<T>(); + static const T FC7 = tmerc::FC7<T>(); + static const T FC8 = tmerc::FC8<T>(); + + T al, als, n, cosphi, sinphi, t; /* * Fail if our longitude is more than 90 degrees from the @@ -140,11 +126,11 @@ namespace projections * * http://trac.osgeo.org/proj/ticket/5 */ - if( lp_lon < -HALFPI || lp_lon > HALFPI ) + if( lp_lon < -half_pi || lp_lon > half_pi ) { xy_x = HUGE_VAL; xy_y = HUGE_VAL; - BOOST_THROW_EXCEPTION( projection_exception(-14) ); + BOOST_THROW_EXCEPTION( projection_exception(error_lat_or_lon_exceed_limit) ); return; } @@ -171,23 +157,23 @@ namespace projections // INVERSE(e_inverse) ellipsoid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); - static const CalculationType FC1 = tmerc::FC1<CalculationType>(); - static const CalculationType FC2 = tmerc::FC2<CalculationType>(); - static const CalculationType FC3 = tmerc::FC3<CalculationType>(); - static const CalculationType FC4 = tmerc::FC4<CalculationType>(); - static const CalculationType FC5 = tmerc::FC5<CalculationType>(); - static const CalculationType FC6 = tmerc::FC6<CalculationType>(); - static const CalculationType FC7 = tmerc::FC7<CalculationType>(); - static const CalculationType FC8 = tmerc::FC8<CalculationType>(); - - CalculationType n, con, cosphi, d, ds, sinphi, t; + static const T half_pi = detail::half_pi<T>(); + static const T FC1 = tmerc::FC1<T>(); + static const T FC2 = tmerc::FC2<T>(); + static const T FC3 = tmerc::FC3<T>(); + static const T FC4 = tmerc::FC4<T>(); + static const T FC5 = tmerc::FC5<T>(); + static const T FC6 = tmerc::FC6<T>(); + static const T FC7 = tmerc::FC7<T>(); + static const T FC8 = tmerc::FC8<T>(); + + T n, con, cosphi, d, ds, sinphi, t; lp_lat = pj_inv_mlfn(this->m_proj_parm.ml0 + xy_y / this->m_par.k0, this->m_par.es, this->m_proj_parm.en); - if (fabs(lp_lat) >= HALFPI) { - lp_lat = xy_y < 0. ? -HALFPI : HALFPI; + if (fabs(lp_lat) >= half_pi) { + lp_lat = xy_y < 0. ? -half_pi : half_pi; lp_lon = 0.; } else { sinphi = sin(lp_lat); @@ -220,27 +206,23 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_tmerc_spheroid : public base_t_fi<base_tmerc_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_tmerc_spheroid + : public base_t_fi<base_tmerc_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_tmerc<CalculationType> m_proj_parm; + par_tmerc<T> m_proj_parm; inline base_tmerc_spheroid(const Parameters& par) - : base_t_fi<base_tmerc_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_tmerc_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) sphere // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); - CalculationType b, cosphi; + T b, cosphi; /* * Fail if our longitude is more than 90 degrees from the @@ -249,26 +231,26 @@ namespace projections * * http://trac.osgeo.org/proj/ticket/5 */ - if( lp_lon < -HALFPI || lp_lon > HALFPI ) + if( lp_lon < -half_pi || lp_lon > half_pi ) { xy_x = HUGE_VAL; xy_y = HUGE_VAL; - BOOST_THROW_EXCEPTION( projection_exception(-14) ); + BOOST_THROW_EXCEPTION( projection_exception(error_lat_or_lon_exceed_limit) ); return; } cosphi = cos(lp_lat); b = cosphi * sin(lp_lon); - if (fabs(fabs(b) - 1.) <= EPS10) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + if (fabs(fabs(b) - 1.) <= epsilon10) + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); xy_x = this->m_proj_parm.ml0 * log((1. + b) / (1. - b)); xy_y = cosphi * cos(lp_lon) / sqrt(1. - b * b); b = fabs( xy_y ); if (b >= 1.) { - if ((b - 1.) > EPS10) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + if ((b - 1.) > epsilon10) + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); else xy_y = 0.; } else xy_y = acos(xy_y); @@ -280,16 +262,19 @@ namespace projections // INVERSE(s_inverse) sphere // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType h, g; + T h, g; h = exp(xy_x / this->m_proj_parm.esp); g = .5 * (h - 1. / h); h = cos(this->m_par.phi0 + xy_y / this->m_proj_parm.esp); lp_lat = asin(sqrt((1. - h * h) / (1. + g * g))); - if (xy_y < 0.) lp_lat = -lp_lat; - lp_lon = (g || h) ? atan2(g, h) : 0.; + + /* Make sure that phi is on the correct hemisphere when false northing is used */ + if (xy_y < 0. && -lp_lat+this->m_par.phi0 < 0.0) lp_lat = -lp_lat; + + lp_lon = (g != 0.0 || h != 0.0) ? atan2(g, h) : 0.; } static inline std::string get_name() @@ -300,11 +285,10 @@ namespace projections }; template <typename Parameters, typename T> - inline void setup(Parameters& par, par_tmerc<T>& proj_parm) /* general initialization */ + inline void setup(Parameters& par, par_tmerc<T>& proj_parm) { - if (par.es) { - if (!pj_enfn(par.es, proj_parm.en)) - BOOST_THROW_EXCEPTION( projection_exception(0) ); + if (par.es != 0.0) { + proj_parm.en = pj_enfn<T>(par.es); proj_parm.ml0 = pj_mlfn(par.phi0, sin(par.phi0), cos(par.phi0), proj_parm.en); proj_parm.esp = par.es / (1. - par.es); } else { @@ -313,40 +297,6 @@ namespace projections } } - - // Transverse Mercator - template <typename Parameters, typename T> - inline void setup_tmerc(Parameters& par, par_tmerc<T>& proj_parm) - { - setup(par, proj_parm); - } - - // Universal Transverse Mercator (UTM) - template <typename Parameters, typename T> - inline void setup_utm(Parameters& par, par_tmerc<T>& proj_parm) - { - static const T ONEPI = detail::ONEPI<T>(); - - int zone; - - par.y0 = pj_param(par.params, "bsouth").i ? 10000000. : 0.; - par.x0 = 500000.; - if (pj_param(par.params, "tzone").i) /* zone input ? */ - if ((zone = pj_param(par.params, "izone").i) > 0 && zone <= 60) - --zone; - else - BOOST_THROW_EXCEPTION( projection_exception(-35) ); - else /* nearest central meridian input */ - if ((zone = int_floor((adjlon(par.lam0) + ONEPI) * 30. / ONEPI)) < 0) - zone = 0; - else if (zone >= 60) - zone = 59; - par.lam0 = (zone + .5) * ONEPI / 30. - ONEPI; - par.k0 = 0.9996; - par.phi0 = 0.; - setup(par, proj_parm); - } - }} // namespace detail::tmerc #endif // doxygen @@ -363,12 +313,12 @@ namespace projections \par Example \image html ex_tmerc.gif */ - template <typename CalculationType, typename Parameters> - struct tmerc_ellipsoid : public detail::tmerc::base_tmerc_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct tmerc_ellipsoid : public detail::tmerc::base_tmerc_ellipsoid<T, Parameters> { - inline tmerc_ellipsoid(const Parameters& par) : detail::tmerc::base_tmerc_ellipsoid<CalculationType, Parameters>(par) + inline tmerc_ellipsoid(const Parameters& par) : detail::tmerc::base_tmerc_ellipsoid<T, Parameters>(par) { - detail::tmerc::setup_tmerc(this->m_par, this->m_proj_parm); + detail::tmerc::setup(this->m_par, this->m_proj_parm); } }; @@ -385,60 +335,12 @@ namespace projections \par Example \image html ex_tmerc.gif */ - template <typename CalculationType, typename Parameters> - struct tmerc_spheroid : public detail::tmerc::base_tmerc_spheroid<CalculationType, Parameters> - { - inline tmerc_spheroid(const Parameters& par) : detail::tmerc::base_tmerc_spheroid<CalculationType, Parameters>(par) - { - detail::tmerc::setup_tmerc(this->m_par, this->m_proj_parm); - } - }; - - /*! - \brief Universal Transverse Mercator (UTM) projection - \ingroup projections - \tparam Geographic latlong point type - \tparam Cartesian xy point type - \tparam Parameters parameter type - \par Projection characteristics - - Cylindrical - - Spheroid - \par Projection parameters - - zone: UTM Zone (integer) - - south: Denotes southern hemisphere UTM zone (boolean) - \par Example - \image html ex_utm.gif - */ - template <typename CalculationType, typename Parameters> - struct utm_ellipsoid : public detail::tmerc::base_tmerc_ellipsoid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct tmerc_spheroid : public detail::tmerc::base_tmerc_spheroid<T, Parameters> { - inline utm_ellipsoid(const Parameters& par) : detail::tmerc::base_tmerc_ellipsoid<CalculationType, Parameters>(par) + inline tmerc_spheroid(const Parameters& par) : detail::tmerc::base_tmerc_spheroid<T, Parameters>(par) { - detail::tmerc::setup_utm(this->m_par, this->m_proj_parm); - } - }; - - /*! - \brief Universal Transverse Mercator (UTM) projection - \ingroup projections - \tparam Geographic latlong point type - \tparam Cartesian xy point type - \tparam Parameters parameter type - \par Projection characteristics - - Cylindrical - - Spheroid - \par Projection parameters - - zone: UTM Zone (integer) - - south: Denotes southern hemisphere UTM zone (boolean) - \par Example - \image html ex_utm.gif - */ - template <typename CalculationType, typename Parameters> - struct utm_spheroid : public detail::tmerc::base_tmerc_spheroid<CalculationType, Parameters> - { - inline utm_spheroid(const Parameters& par) : detail::tmerc::base_tmerc_spheroid<CalculationType, Parameters>(par) - { - detail::tmerc::setup_utm(this->m_par, this->m_proj_parm); + detail::tmerc::setup(this->m_par, this->m_proj_parm); } }; @@ -448,40 +350,25 @@ namespace projections // Static projection BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::tmerc, tmerc_spheroid, tmerc_ellipsoid) - BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::utm, utm_spheroid, utm_ellipsoid) // Factory entry(s) - dynamic projection - template <typename CalculationType, typename Parameters> - class tmerc_entry : public detail::factory_entry<CalculationType, Parameters> - { - public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const - { - if (par.es) - return new base_v_fi<tmerc_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); - else - return new base_v_fi<tmerc_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); - } - }; - - template <typename CalculationType, typename Parameters> - class utm_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class tmerc_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { if (par.es) - return new base_v_fi<utm_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<tmerc_ellipsoid<T, Parameters>, T, Parameters>(par); else - return new base_v_fi<utm_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<tmerc_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void tmerc_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void tmerc_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("tmerc", new tmerc_entry<CalculationType, Parameters>); - factory.add_to_factory("utm", new utm_entry<CalculationType, Parameters>); + factory.add_to_factory("tmerc", new tmerc_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/tpeqd.hpp b/boost/geometry/srs/projections/proj/tpeqd.hpp index 2d08d49bde..1e8447076a 100644 --- a/boost/geometry/srs/projections/proj/tpeqd.hpp +++ b/boost/geometry/srs/projections/proj/tpeqd.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_TPEQD_HPP -#define BOOST_GEOMETRY_PROJECTIONS_TPEQD_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_TPEQD_HPP +#define BOOST_GEOMETRY_PROJECTIONS_TPEQD_HPP + #include <boost/geometry/util/math.hpp> #include <boost/math/special_functions/hypot.hpp> @@ -55,7 +54,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct tpeqd {}; + struct tpeqd {}; // Two Point Equidistant }} //namespace srs::par4 @@ -72,25 +71,21 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_tpeqd_spheroid : public base_t_fi<base_tpeqd_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_tpeqd_spheroid + : public base_t_fi<base_tpeqd_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_tpeqd<CalculationType> m_proj_parm; + par_tpeqd<T> m_proj_parm; inline base_tpeqd_spheroid(const Parameters& par) - : base_t_fi<base_tpeqd_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_tpeqd_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) sphere // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType t, z1, z2, dl1, dl2, sp, cp; + T t, z1, z2, dl1, dl2, sp, cp; sp = sin(lp_lat); cp = cos(lp_lat); @@ -98,6 +93,7 @@ namespace projections z2 = aacos(this->m_proj_parm.sp2 * sp + this->m_proj_parm.cp2 * cp * cos(dl2 = lp_lon - this->m_proj_parm.dlam2)); z1 *= z1; z2 *= z2; + xy_x = this->m_proj_parm.r2z0 * (t = z1 - z2); t = this->m_proj_parm.z02 - t; xy_y = this->m_proj_parm.r2z0 * asqrt(4. * this->m_proj_parm.z02 * z2 - t * t); @@ -107,9 +103,9 @@ namespace projections // INVERSE(s_inverse) sphere // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - CalculationType cz1, cz2, s, d, cp, sp; + T cz1, cz2, s, d, cp, sp; cz1 = cos(boost::math::hypot(xy_y, xy_x + this->m_proj_parm.hz0)); cz2 = cos(boost::math::hypot(xy_y, xy_x - this->m_proj_parm.hz0)); @@ -140,14 +136,17 @@ namespace projections T lam_1, lam_2, phi_1, phi_2, A12, pp; /* get control point locations */ - phi_1 = pj_param(par.params, "rlat_1").f; - lam_1 = pj_param(par.params, "rlon_1").f; - phi_2 = pj_param(par.params, "rlat_2").f; - lam_2 = pj_param(par.params, "rlon_2").f; + phi_1 = pj_get_param_r(par.params, "lat_1"); + lam_1 = pj_get_param_r(par.params, "lon_1"); + phi_2 = pj_get_param_r(par.params, "lat_2"); + lam_2 = pj_get_param_r(par.params, "lon_2"); + if (phi_1 == phi_2 && lam_1 == lam_2) - BOOST_THROW_EXCEPTION( projection_exception(-25) ); + BOOST_THROW_EXCEPTION( projection_exception(error_control_point_no_dist) ); + par.lam0 = adjlon(0.5 * (lam_1 + lam_2)); proj_parm.dlam2 = adjlon(lam_2 - lam_1); + proj_parm.cp1 = cos(phi_1); proj_parm.cp2 = cos(phi_2); proj_parm.sp1 = sin(phi_1); @@ -168,6 +167,7 @@ namespace projections proj_parm.rhshz0 = .5 / sin(proj_parm.hz0); proj_parm.r2z0 = 0.5 / proj_parm.z02; proj_parm.z02 *= proj_parm.z02; + par.es = 0.; } @@ -191,10 +191,10 @@ namespace projections \par Example \image html ex_tpeqd.gif */ - template <typename CalculationType, typename Parameters> - struct tpeqd_spheroid : public detail::tpeqd::base_tpeqd_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct tpeqd_spheroid : public detail::tpeqd::base_tpeqd_spheroid<T, Parameters> { - inline tpeqd_spheroid(const Parameters& par) : detail::tpeqd::base_tpeqd_spheroid<CalculationType, Parameters>(par) + inline tpeqd_spheroid(const Parameters& par) : detail::tpeqd::base_tpeqd_spheroid<T, Parameters>(par) { detail::tpeqd::setup_tpeqd(this->m_par, this->m_proj_parm); } @@ -208,20 +208,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::tpeqd, tpeqd_spheroid, tpeqd_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class tpeqd_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class tpeqd_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<tpeqd_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<tpeqd_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void tpeqd_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void tpeqd_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("tpeqd", new tpeqd_entry<CalculationType, Parameters>); + factory.add_to_factory("tpeqd", new tpeqd_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/urm5.hpp b/boost/geometry/srs/projections/proj/urm5.hpp index 96b541f4ea..bdda5fc400 100644 --- a/boost/geometry/srs/projections/proj/urm5.hpp +++ b/boost/geometry/srs/projections/proj/urm5.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_URM5_HPP -#define BOOST_GEOMETRY_PROJECTIONS_URM5_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_URM5_HPP +#define BOOST_GEOMETRY_PROJECTIONS_URM5_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -52,7 +51,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct urm5 {}; + struct urm5 {}; // Urmaev V }} //namespace srs::par4 @@ -68,25 +67,21 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_urm5_spheroid : public base_t_f<base_urm5_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_urm5_spheroid + : public base_t_f<base_urm5_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_urm5<CalculationType> m_proj_parm; + par_urm5<T> m_proj_parm; inline base_urm5_spheroid(const Parameters& par) - : base_t_f<base_urm5_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_f<base_urm5_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType t; + T t; t = lp_lat = aasin(this->m_proj_parm.n * sin(lp_lat)); xy_x = this->m_proj_parm.m * lp_lon * cos(lp_lat); @@ -107,17 +102,18 @@ namespace projections { T alpha, t; - if (pj_param(par.params, "tn").i) { - proj_parm.n = pj_param(par.params, "dn").f; + if (pj_param_f(par.params, "n", proj_parm.n)) { if (proj_parm.n <= 0. || proj_parm.n > 1.) - BOOST_THROW_EXCEPTION( projection_exception(-40) ); - } else - BOOST_THROW_EXCEPTION( projection_exception(-40) ); - proj_parm.q3 = pj_param(par.params, "dq").f / 3.; - alpha = pj_param(par.params, "ralpha").f; + BOOST_THROW_EXCEPTION( projection_exception(error_n_out_of_range) ); + } else { + BOOST_THROW_EXCEPTION( projection_exception(error_n_out_of_range) ); + } + proj_parm.q3 = pj_get_param_f(par.params, "q") / 3.; + alpha = pj_get_param_r(par.params, "alpha"); t = proj_parm.n * sin(alpha); proj_parm.m = cos(alpha) / sqrt(1. - t * t); proj_parm.rmn = 1. / (proj_parm.m * proj_parm.n); + par.es = 0.; } @@ -141,10 +137,10 @@ namespace projections \par Example \image html ex_urm5.gif */ - template <typename CalculationType, typename Parameters> - struct urm5_spheroid : public detail::urm5::base_urm5_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct urm5_spheroid : public detail::urm5::base_urm5_spheroid<T, Parameters> { - inline urm5_spheroid(const Parameters& par) : detail::urm5::base_urm5_spheroid<CalculationType, Parameters>(par) + inline urm5_spheroid(const Parameters& par) : detail::urm5::base_urm5_spheroid<T, Parameters>(par) { detail::urm5::setup_urm5(this->m_par, this->m_proj_parm); } @@ -158,20 +154,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::urm5, urm5_spheroid, urm5_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class urm5_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class urm5_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_f<urm5_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_f<urm5_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void urm5_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void urm5_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("urm5", new urm5_entry<CalculationType, Parameters>); + factory.add_to_factory("urm5", new urm5_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/urmfps.hpp b/boost/geometry/srs/projections/proj/urmfps.hpp index 14840057dc..d4b303ba37 100644 --- a/boost/geometry/srs/projections/proj/urmfps.hpp +++ b/boost/geometry/srs/projections/proj/urmfps.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_URMFPS_HPP -#define BOOST_GEOMETRY_PROJECTIONS_URMFPS_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_URMFPS_HPP +#define BOOST_GEOMETRY_PROJECTIONS_URMFPS_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -52,8 +51,8 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct urmfps {}; - struct wag1 {}; + struct urmfps {}; // Urmaev Flat-Polar Sinusoidal + struct wag1 {}; // Wagner I (Kavraisky VI) }} //namespace srs::par4 @@ -73,23 +72,19 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_urmfps_spheroid : public base_t_fi<base_urmfps_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_urmfps_spheroid + : public base_t_fi<base_urmfps_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_urmfps<CalculationType> m_proj_parm; + par_urmfps<T> m_proj_parm; inline base_urmfps_spheroid(const Parameters& par) - : base_t_fi<base_urmfps_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_urmfps_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) sphere // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { lp_lat = aasin(this->m_proj_parm.n * sin(lp_lat)); xy_x = C_x * lp_lon * cos(lp_lat); @@ -98,7 +93,7 @@ namespace projections // INVERSE(s_inverse) sphere // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { xy_y /= this->m_proj_parm.C_y; lp_lat = aasin(sin(xy_y) / this->m_proj_parm.n); @@ -124,12 +119,12 @@ namespace projections template <typename Parameters, typename T> inline void setup_urmfps(Parameters& par, par_urmfps<T>& proj_parm) { - if (pj_param(par.params, "tn").i) { - proj_parm.n = pj_param(par.params, "dn").f; + if (pj_param_f(par.params, "n", proj_parm.n)) { if (proj_parm.n <= 0. || proj_parm.n > 1.) - BOOST_THROW_EXCEPTION( projection_exception(-40) ); + BOOST_THROW_EXCEPTION( projection_exception(error_n_out_of_range) ); } else - BOOST_THROW_EXCEPTION( projection_exception(-40) ); + BOOST_THROW_EXCEPTION( projection_exception(error_n_out_of_range) ); + setup(par, proj_parm); } @@ -158,10 +153,10 @@ namespace projections \par Example \image html ex_urmfps.gif */ - template <typename CalculationType, typename Parameters> - struct urmfps_spheroid : public detail::urmfps::base_urmfps_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct urmfps_spheroid : public detail::urmfps::base_urmfps_spheroid<T, Parameters> { - inline urmfps_spheroid(const Parameters& par) : detail::urmfps::base_urmfps_spheroid<CalculationType, Parameters>(par) + inline urmfps_spheroid(const Parameters& par) : detail::urmfps::base_urmfps_spheroid<T, Parameters>(par) { detail::urmfps::setup_urmfps(this->m_par, this->m_proj_parm); } @@ -179,10 +174,10 @@ namespace projections \par Example \image html ex_wag1.gif */ - template <typename CalculationType, typename Parameters> - struct wag1_spheroid : public detail::urmfps::base_urmfps_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct wag1_spheroid : public detail::urmfps::base_urmfps_spheroid<T, Parameters> { - inline wag1_spheroid(const Parameters& par) : detail::urmfps::base_urmfps_spheroid<CalculationType, Parameters>(par) + inline wag1_spheroid(const Parameters& par) : detail::urmfps::base_urmfps_spheroid<T, Parameters>(par) { detail::urmfps::setup_wag1(this->m_par, this->m_proj_parm); } @@ -197,31 +192,31 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::wag1, wag1_spheroid, wag1_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class urmfps_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class urmfps_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<urmfps_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<urmfps_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class wag1_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class wag1_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<wag1_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<wag1_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void urmfps_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void urmfps_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("urmfps", new urmfps_entry<CalculationType, Parameters>); - factory.add_to_factory("wag1", new wag1_entry<CalculationType, Parameters>); + factory.add_to_factory("urmfps", new urmfps_entry<T, Parameters>); + factory.add_to_factory("wag1", new wag1_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/vandg.hpp b/boost/geometry/srs/projections/proj/vandg.hpp index 1fd95285ea..4124ca2354 100644 --- a/boost/geometry/srs/projections/proj/vandg.hpp +++ b/boost/geometry/srs/projections/proj/vandg.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_VANDG_HPP -#define BOOST_GEOMETRY_PROJECTIONS_VANDG_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017, 2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_VANDG_HPP +#define BOOST_GEOMETRY_PROJECTIONS_VANDG_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -63,14 +62,7 @@ namespace projections namespace detail { namespace vandg { - static const double TOL = 1.e-10; - //static const double THIRD = .33333333333333333333; - //static const double TWO_THRD = .66666666666666666666; - //static const double C2_27 = .07407407407407407407; - //static const double PI4_3 = 4.18879020478639098458; - //static const double PISQ = 9.86960440108935861869; - //static const double TPISQ = 19.73920880217871723738; - //static const double HPISQ = 4.93480220054467930934; + static const double tolerance = 1.e-10; template <typename T> inline T C2_27() { return .07407407407407407407407407407407; } @@ -82,42 +74,38 @@ namespace projections inline T HPISQ() { return 4.9348022005446793094172454999381; } // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_vandg_spheroid : public base_t_fi<base_vandg_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_vandg_spheroid + : public base_t_fi<base_vandg_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_vandg_spheroid(const Parameters& par) - : base_t_fi<base_vandg_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_vandg_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); - static const CalculationType ONEPI = detail::ONEPI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); + static const T pi = detail::pi<T>(); - CalculationType al, al2, g, g2, p2; + T al, al2, g, g2, p2; - p2 = fabs(lp_lat / HALFPI); - if ((p2 - TOL) > 1.) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + p2 = fabs(lp_lat / half_pi); + if ((p2 - tolerance) > 1.) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } if (p2 > 1.) p2 = 1.; - if (fabs(lp_lat) <= TOL) { + if (fabs(lp_lat) <= tolerance) { xy_x = lp_lon; xy_y = 0.; - } else if (fabs(lp_lon) <= TOL || fabs(p2 - 1.) < TOL) { + } else if (fabs(lp_lon) <= tolerance || fabs(p2 - 1.) < tolerance) { xy_x = 0.; - xy_y = ONEPI * tan(.5 * asin(p2)); + xy_y = pi * tan(.5 * asin(p2)); if (lp_lat < 0.) xy_y = -xy_y; } else { - al = .5 * fabs(ONEPI / lp_lon - lp_lon / ONEPI); + al = .5 * fabs(pi / lp_lon - lp_lon / pi); al2 = al * al; g = sqrt(1. - p2 * p2); g = g / (p2 + g - 1.); @@ -125,63 +113,65 @@ namespace projections p2 = g * (2. / p2 - 1.); p2 = p2 * p2; xy_x = g - p2; g = p2 + al2; - xy_x = ONEPI * (al * xy_x + sqrt(al2 * xy_x * xy_x - g * (g2 - p2))) / g; + xy_x = pi * (al * xy_x + sqrt(al2 * xy_x * xy_x - g * (g2 - p2))) / g; if (lp_lon < 0.) xy_x = -xy_x; - xy_y = fabs(xy_x / ONEPI); + xy_y = fabs(xy_x / pi); xy_y = 1. - xy_y * (xy_y + 2. * al); - if (xy_y < -TOL) - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + if (xy_y < -tolerance) { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } if (xy_y < 0.) xy_y = 0.; else - xy_y = sqrt(xy_y) * (lp_lat < 0. ? -ONEPI : ONEPI); + xy_y = sqrt(xy_y) * (lp_lat < 0. ? -pi : pi); } } // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); - static const CalculationType ONEPI = detail::ONEPI<CalculationType>(); - static const CalculationType PISQ = detail::PI_SQR<CalculationType>(); - static const CalculationType THIRD = detail::THIRD<CalculationType>(); - static const CalculationType TWOPI = detail::TWOPI<CalculationType>(); - - static const CalculationType C2_27 = vandg::C2_27<CalculationType>(); - static const CalculationType PI4_3 = vandg::PI4_3<CalculationType>(); - static const CalculationType TPISQ = vandg::TPISQ<CalculationType>(); - static const CalculationType HPISQ = vandg::HPISQ<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); + static const T pi = detail::pi<T>(); + static const T pi_sqr = detail::pi_sqr<T>(); + static const T third = detail::third<T>(); + static const T two_pi = detail::two_pi<T>(); + + static const T C2_27 = vandg::C2_27<T>(); + static const T PI4_3 = vandg::PI4_3<T>(); + static const T TPISQ = vandg::TPISQ<T>(); + static const T HPISQ = vandg::HPISQ<T>(); - CalculationType t, c0, c1, c2, c3, al, r2, r, m, d, ay, x2, y2; + T t, c0, c1, c2, c3, al, r2, r, m, d, ay, x2, y2; x2 = xy_x * xy_x; - if ((ay = fabs(xy_y)) < TOL) { + if ((ay = fabs(xy_y)) < tolerance) { lp_lat = 0.; t = x2 * x2 + TPISQ * (x2 + HPISQ); - lp_lon = fabs(xy_x) <= TOL ? 0. : - .5 * (x2 - PISQ + sqrt(t)) / xy_x; + lp_lon = fabs(xy_x) <= tolerance ? 0. : + .5 * (x2 - pi_sqr + sqrt(t)) / xy_x; return; } y2 = xy_y * xy_y; r = x2 + y2; r2 = r * r; - c1 = - ONEPI * ay * (r + PISQ); - c3 = r2 + TWOPI * (ay * r + ONEPI * (y2 + ONEPI * (ay + HALFPI))); - c2 = c1 + PISQ * (r - 3. * y2); - c0 = ONEPI * ay; + c1 = - pi * ay * (r + pi_sqr); + c3 = r2 + two_pi * (ay * r + pi * (y2 + pi * (ay + half_pi))); + c2 = c1 + pi_sqr * (r - 3. * y2); + c0 = pi * ay; c2 /= c3; - al = c1 / c3 - THIRD * c2 * c2; - m = 2. * sqrt(-THIRD * al); - d = C2_27 * c2 * c2 * c2 + (c0 * c0 - THIRD * c2 * c1) / c3; - if (((t = fabs(d = 3. * d / (al * m))) - TOL) <= 1.) { - d = t > 1. ? (d > 0. ? 0. : ONEPI) : acos(d); - lp_lat = ONEPI * (m * cos(d * THIRD + PI4_3) - THIRD * c2); + al = c1 / c3 - third * c2 * c2; + m = 2. * sqrt(-third * al); + d = C2_27 * c2 * c2 * c2 + (c0 * c0 - third * c2 * c1) / c3; + if (((t = fabs(d = 3. * d / (al * m))) - tolerance) <= 1.) { + d = t > 1. ? (d > 0. ? 0. : pi) : acos(d); + lp_lat = pi * (m * cos(d * third + PI4_3) - third * c2); if (xy_y < 0.) lp_lat = -lp_lat; t = r2 + TPISQ * (x2 - y2 + HPISQ); - lp_lon = fabs(xy_x) <= TOL ? 0. : - .5 * (r - PISQ + (t <= 0. ? 0. : sqrt(t))) / xy_x; - } else - BOOST_THROW_EXCEPTION( projection_exception(-20) ); + lp_lon = fabs(xy_x) <= tolerance ? 0. : + .5 * (r - pi_sqr + (t <= 0. ? 0. : sqrt(t))) / xy_x; + } else { + BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); + } } static inline std::string get_name() @@ -213,10 +203,10 @@ namespace projections \par Example \image html ex_vandg.gif */ - template <typename CalculationType, typename Parameters> - struct vandg_spheroid : public detail::vandg::base_vandg_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct vandg_spheroid : public detail::vandg::base_vandg_spheroid<T, Parameters> { - inline vandg_spheroid(const Parameters& par) : detail::vandg::base_vandg_spheroid<CalculationType, Parameters>(par) + inline vandg_spheroid(const Parameters& par) : detail::vandg::base_vandg_spheroid<T, Parameters>(par) { detail::vandg::setup_vandg(this->m_par); } @@ -230,20 +220,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::vandg, vandg_spheroid, vandg_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class vandg_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class vandg_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<vandg_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<vandg_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void vandg_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void vandg_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("vandg", new vandg_entry<CalculationType, Parameters>); + factory.add_to_factory("vandg", new vandg_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/vandg2.hpp b/boost/geometry/srs/projections/proj/vandg2.hpp index 650a64f432..a1af0302a7 100644 --- a/boost/geometry/srs/projections/proj/vandg2.hpp +++ b/boost/geometry/srs/projections/proj/vandg2.hpp @@ -1,8 +1,4 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_VANDG2_HPP -#define BOOST_GEOMETRY_PROJECTIONS_VANDG2_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_VANDG2_HPP +#define BOOST_GEOMETRY_PROJECTIONS_VANDG2_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -53,8 +52,8 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct vandg2 {}; - struct vandg3 {}; + struct vandg2 {}; // van der Grinten II + struct vandg3 {}; // van der Grinten III }} //namespace srs::par4 @@ -64,57 +63,52 @@ namespace projections namespace detail { namespace vandg2 { - static const double TOL = 1e-10; - //static const double TWORPI = 0.63661977236758134308; + static const double tolerance = 1e-10; struct par_vandg2 { - int vdg3; + bool vdg3; }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_vandg2_spheroid : public base_t_f<base_vandg2_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_vandg2_spheroid + : public base_t_f<base_vandg2_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - par_vandg2 m_proj_parm; inline base_vandg2_spheroid(const Parameters& par) - : base_t_f<base_vandg2_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_f<base_vandg2_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType ONEPI = detail::ONEPI<CalculationType>(); - static const CalculationType TWORPI = detail::TWO_D_PI<CalculationType>(); + static const T pi = detail::pi<T>(); + static const T two_div_pi = detail::two_div_pi<T>(); - CalculationType x1, at, bt, ct; + T x1, at, bt, ct; - bt = fabs(TWORPI * lp_lat); + bt = fabs(two_div_pi * lp_lat); if ((ct = 1. - bt * bt) < 0.) ct = 0.; else ct = sqrt(ct); - if (fabs(lp_lon) < TOL) { + if (fabs(lp_lon) < tolerance) { xy_x = 0.; - xy_y = ONEPI * (lp_lat < 0. ? -bt : bt) / (1. + ct); + xy_y = pi * (lp_lat < 0. ? -bt : bt) / (1. + ct); } else { - at = 0.5 * fabs(ONEPI / lp_lon - lp_lon / ONEPI); + at = 0.5 * fabs(pi / lp_lon - lp_lon / pi); if (this->m_proj_parm.vdg3) { x1 = bt / (1. + ct); - xy_x = ONEPI * (sqrt(at * at + 1. - x1 * x1) - at); - xy_y = ONEPI * x1; + xy_x = pi * (sqrt(at * at + 1. - x1 * x1) - at); + xy_y = pi * x1; } else { x1 = (ct * sqrt(1. + at * at) - at * ct * ct) / (1. + at * at * bt * bt); - xy_x = ONEPI * x1; - xy_y = ONEPI * sqrt(1. - x1 * (x1 + 2. * at) + TOL); + xy_x = pi * x1; + xy_y = pi * sqrt(1. - x1 * (x1 + 2. * at) + tolerance); } if ( lp_lon < 0.) xy_x = -xy_x; if ( lp_lat < 0.) xy_y = -xy_y; @@ -132,14 +126,14 @@ namespace projections template <typename Parameters> inline void setup_vandg2(Parameters& /*par*/, par_vandg2& proj_parm) { - proj_parm.vdg3 = 0; + proj_parm.vdg3 = false; } // van der Grinten III template <typename Parameters> inline void setup_vandg3(Parameters& par, par_vandg2& proj_parm) { - proj_parm.vdg3 = 1; + proj_parm.vdg3 = true; par.es = 0.; } @@ -159,10 +153,10 @@ namespace projections \par Example \image html ex_vandg2.gif */ - template <typename CalculationType, typename Parameters> - struct vandg2_spheroid : public detail::vandg2::base_vandg2_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct vandg2_spheroid : public detail::vandg2::base_vandg2_spheroid<T, Parameters> { - inline vandg2_spheroid(const Parameters& par) : detail::vandg2::base_vandg2_spheroid<CalculationType, Parameters>(par) + inline vandg2_spheroid(const Parameters& par) : detail::vandg2::base_vandg2_spheroid<T, Parameters>(par) { detail::vandg2::setup_vandg2(this->m_par, this->m_proj_parm); } @@ -181,10 +175,10 @@ namespace projections \par Example \image html ex_vandg3.gif */ - template <typename CalculationType, typename Parameters> - struct vandg3_spheroid : public detail::vandg2::base_vandg2_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct vandg3_spheroid : public detail::vandg2::base_vandg2_spheroid<T, Parameters> { - inline vandg3_spheroid(const Parameters& par) : detail::vandg2::base_vandg2_spheroid<CalculationType, Parameters>(par) + inline vandg3_spheroid(const Parameters& par) : detail::vandg2::base_vandg2_spheroid<T, Parameters>(par) { detail::vandg2::setup_vandg3(this->m_par, this->m_proj_parm); } @@ -199,31 +193,31 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::vandg3, vandg3_spheroid, vandg3_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class vandg2_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class vandg2_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_f<vandg2_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_f<vandg2_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - class vandg3_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class vandg3_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_f<vandg3_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_f<vandg3_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void vandg2_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void vandg2_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("vandg2", new vandg2_entry<CalculationType, Parameters>); - factory.add_to_factory("vandg3", new vandg3_entry<CalculationType, Parameters>); + factory.add_to_factory("vandg2", new vandg2_entry<T, Parameters>); + factory.add_to_factory("vandg3", new vandg3_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/vandg4.hpp b/boost/geometry/srs/projections/proj/vandg4.hpp index 0b85fedef4..35f1dafdb0 100644 --- a/boost/geometry/srs/projections/proj/vandg4.hpp +++ b/boost/geometry/srs/projections/proj/vandg4.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_VANDG4_HPP -#define BOOST_GEOMETRY_PROJECTIONS_VANDG4_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_VANDG4_HPP +#define BOOST_GEOMETRY_PROJECTIONS_VANDG4_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -53,7 +52,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct vandg4 {}; + struct vandg4 {}; // van der Grinten IV }} //namespace srs::par4 @@ -63,48 +62,42 @@ namespace projections namespace detail { namespace vandg4 { - static const double TOL = 1e-10; - //static const double TWORPI = 0.63661977236758134308; + static const double tolerance = 1e-10; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_vandg4_spheroid : public base_t_f<base_vandg4_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_vandg4_spheroid + : public base_t_f<base_vandg4_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_vandg4_spheroid(const Parameters& par) - : base_t_f<base_vandg4_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_f<base_vandg4_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); - static const CalculationType TWORPI = detail::TWO_D_PI<CalculationType>(); + static const T half_pi = detail::half_pi<T>(); + static const T two_div_pi = detail::two_div_pi<T>(); - CalculationType x1, t, bt, ct, ft, bt2, ct2, dt, dt2; + T x1, t, bt, ct, ft, bt2, ct2, dt, dt2; - if (fabs(lp_lat) < TOL) { + if (fabs(lp_lat) < tolerance) { xy_x = lp_lon; xy_y = 0.; - } else if (fabs(lp_lon) < TOL || fabs(fabs(lp_lat) - HALFPI) < TOL) { + } else if (fabs(lp_lon) < tolerance || fabs(fabs(lp_lat) - half_pi) < tolerance) { xy_x = 0.; xy_y = lp_lat; } else { - bt = fabs(TWORPI * lp_lat); + bt = fabs(two_div_pi * lp_lat); bt2 = bt * bt; ct = 0.5 * (bt * (8. - bt * (2. + bt2)) - 5.) / (bt2 * (bt - 1.)); ct2 = ct * ct; - dt = TWORPI * lp_lon; + dt = two_div_pi * lp_lon; dt = dt + 1. / dt; dt = sqrt(dt * dt - 4.); - if ((fabs(lp_lon) - HALFPI) < 0.) dt = -dt; + if ((fabs(lp_lon) - half_pi) < 0.) dt = -dt; dt2 = dt * dt; x1 = bt + ct; x1 *= x1; t = bt + 3.*ct; @@ -113,8 +106,8 @@ namespace projections ct2 * (12. * bt * ct + 4. * ct2) ); x1 = (dt*(x1 + ct2 - 1.) + 2.*sqrt(ft)) / (4.* x1 + dt2); - xy_x = HALFPI * x1; - xy_y = HALFPI * sqrt(1. + dt * fabs(x1) - x1 * x1); + xy_x = half_pi * x1; + xy_y = half_pi * sqrt(1. + dt * fabs(x1) - x1 * x1); if (lp_lon < 0.) xy_x = -xy_x; if (lp_lat < 0.) xy_y = -xy_y; } @@ -150,10 +143,10 @@ namespace projections \par Example \image html ex_vandg4.gif */ - template <typename CalculationType, typename Parameters> - struct vandg4_spheroid : public detail::vandg4::base_vandg4_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct vandg4_spheroid : public detail::vandg4::base_vandg4_spheroid<T, Parameters> { - inline vandg4_spheroid(const Parameters& par) : detail::vandg4::base_vandg4_spheroid<CalculationType, Parameters>(par) + inline vandg4_spheroid(const Parameters& par) : detail::vandg4::base_vandg4_spheroid<T, Parameters>(par) { detail::vandg4::setup_vandg4(this->m_par); } @@ -167,20 +160,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::vandg4, vandg4_spheroid, vandg4_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class vandg4_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class vandg4_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_f<vandg4_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_f<vandg4_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void vandg4_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void vandg4_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("vandg4", new vandg4_entry<CalculationType, Parameters>); + factory.add_to_factory("vandg4", new vandg4_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/wag2.hpp b/boost/geometry/srs/projections/proj/wag2.hpp index 2d16892a9d..c598936e08 100644 --- a/boost/geometry/srs/projections/proj/wag2.hpp +++ b/boost/geometry/srs/projections/proj/wag2.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_WAG2_HPP -#define BOOST_GEOMETRY_PROJECTIONS_WAG2_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_WAG2_HPP +#define BOOST_GEOMETRY_PROJECTIONS_WAG2_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -52,7 +51,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct wag2 {}; + struct wag2 {}; // Wagner II }} //namespace srs::par4 @@ -68,22 +67,17 @@ namespace projections static const double C_p2 = 0.88550; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_wag2_spheroid : public base_t_fi<base_wag2_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_wag2_spheroid + : public base_t_fi<base_wag2_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_wag2_spheroid(const Parameters& par) - : base_t_fi<base_wag2_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_wag2_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { lp_lat = aasin(C_p1 * sin(C_p2 * lp_lat)); xy_x = C_x * lp_lon * cos(lp_lat); @@ -92,7 +86,7 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { lp_lat = xy_y / C_y; lp_lon = xy_x / (C_x * cos(lp_lat)); @@ -128,10 +122,10 @@ namespace projections \par Example \image html ex_wag2.gif */ - template <typename CalculationType, typename Parameters> - struct wag2_spheroid : public detail::wag2::base_wag2_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct wag2_spheroid : public detail::wag2::base_wag2_spheroid<T, Parameters> { - inline wag2_spheroid(const Parameters& par) : detail::wag2::base_wag2_spheroid<CalculationType, Parameters>(par) + inline wag2_spheroid(const Parameters& par) : detail::wag2::base_wag2_spheroid<T, Parameters>(par) { detail::wag2::setup_wag2(this->m_par); } @@ -145,20 +139,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::wag2, wag2_spheroid, wag2_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class wag2_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class wag2_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<wag2_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<wag2_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void wag2_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void wag2_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("wag2", new wag2_entry<CalculationType, Parameters>); + factory.add_to_factory("wag2", new wag2_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/wag3.hpp b/boost/geometry/srs/projections/proj/wag3.hpp index 3ddbfe8258..05edf18ec8 100644 --- a/boost/geometry/srs/projections/proj/wag3.hpp +++ b/boost/geometry/srs/projections/proj/wag3.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_WAG3_HPP -#define BOOST_GEOMETRY_PROJECTIONS_WAG3_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_WAG3_HPP +#define BOOST_GEOMETRY_PROJECTIONS_WAG3_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -51,7 +50,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct wag3 {}; + struct wag3 {}; // Wagner III }} //namespace srs::par4 @@ -67,38 +66,34 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_wag3_spheroid : public base_t_fi<base_wag3_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_wag3_spheroid + : public base_t_fi<base_wag3_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_wag3<CalculationType> m_proj_parm; + par_wag3<T> m_proj_parm; inline base_wag3_spheroid(const Parameters& par) - : base_t_fi<base_wag3_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_wag3_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType TWOTHIRD = detail::TWOTHIRD<CalculationType>(); + static const T two_thirds = detail::two_thirds<T>(); - xy_x = this->m_proj_parm.C_x * lp_lon * cos(TWOTHIRD * lp_lat); + xy_x = this->m_proj_parm.C_x * lp_lon * cos(two_thirds * lp_lat); xy_y = lp_lat; } // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { - static const CalculationType TWOTHIRD = detail::TWOTHIRD<CalculationType>(); + static const T two_thirds = detail::two_thirds<T>(); lp_lat = xy_y; - lp_lon = xy_x / (this->m_proj_parm.C_x * cos(TWOTHIRD * lp_lat)); + lp_lon = xy_x / (this->m_proj_parm.C_x * cos(two_thirds * lp_lat)); } static inline std::string get_name() @@ -114,7 +109,7 @@ namespace projections { T ts; - ts = pj_param(par.params, "rlat_ts").f; + ts = pj_get_param_r(par.params, "lat_ts"); proj_parm.C_x = cos(ts) / cos(2.*ts/3.); par.es = 0.; } @@ -136,10 +131,10 @@ namespace projections \par Example \image html ex_wag3.gif */ - template <typename CalculationType, typename Parameters> - struct wag3_spheroid : public detail::wag3::base_wag3_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct wag3_spheroid : public detail::wag3::base_wag3_spheroid<T, Parameters> { - inline wag3_spheroid(const Parameters& par) : detail::wag3::base_wag3_spheroid<CalculationType, Parameters>(par) + inline wag3_spheroid(const Parameters& par) : detail::wag3::base_wag3_spheroid<T, Parameters>(par) { detail::wag3::setup_wag3(this->m_par, this->m_proj_parm); } @@ -153,20 +148,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::wag3, wag3_spheroid, wag3_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class wag3_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class wag3_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<wag3_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<wag3_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void wag3_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void wag3_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("wag3", new wag3_entry<CalculationType, Parameters>); + factory.add_to_factory("wag3", new wag3_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/wag7.hpp b/boost/geometry/srs/projections/proj/wag7.hpp index c752ff33ee..4604dc6eab 100644 --- a/boost/geometry/srs/projections/proj/wag7.hpp +++ b/boost/geometry/srs/projections/proj/wag7.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_WAG7_HPP -#define BOOST_GEOMETRY_PROJECTIONS_WAG7_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_WAG7_HPP +#define BOOST_GEOMETRY_PROJECTIONS_WAG7_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -51,7 +50,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct wag7 {}; + struct wag7 {}; // Wagner VII }} //namespace srs::par4 @@ -62,24 +61,19 @@ namespace projections { // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_wag7_spheroid : public base_t_f<base_wag7_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_wag7_spheroid + : public base_t_f<base_wag7_spheroid<T, Parameters>, T, Parameters> { - - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - inline base_wag7_spheroid(const Parameters& par) - : base_t_f<base_wag7_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_f<base_wag7_spheroid<T, Parameters>, T, Parameters>(*this, par) + {} // FORWARD(s_forward) sphere // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - CalculationType theta, ct, D; + T theta, ct, D; theta = asin(xy_y = 0.90630778703664996 * sin(lp_lat)); xy_x = 2.66723 * (ct = cos(theta)) * sin(lp_lon /= 3.); @@ -117,10 +111,10 @@ namespace projections \par Example \image html ex_wag7.gif */ - template <typename CalculationType, typename Parameters> - struct wag7_spheroid : public detail::wag7::base_wag7_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct wag7_spheroid : public detail::wag7::base_wag7_spheroid<T, Parameters> { - inline wag7_spheroid(const Parameters& par) : detail::wag7::base_wag7_spheroid<CalculationType, Parameters>(par) + inline wag7_spheroid(const Parameters& par) : detail::wag7::base_wag7_spheroid<T, Parameters>(par) { detail::wag7::setup_wag7(this->m_par); } @@ -134,20 +128,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::wag7, wag7_spheroid, wag7_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class wag7_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class wag7_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_f<wag7_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_f<wag7_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void wag7_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void wag7_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("wag7", new wag7_entry<CalculationType, Parameters>); + factory.add_to_factory("wag7", new wag7_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/wink1.hpp b/boost/geometry/srs/projections/proj/wink1.hpp index 36ecc95500..5fdd739629 100644 --- a/boost/geometry/srs/projections/proj/wink1.hpp +++ b/boost/geometry/srs/projections/proj/wink1.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_WINK1_HPP -#define BOOST_GEOMETRY_PROJECTIONS_WINK1_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_WINK1_HPP +#define BOOST_GEOMETRY_PROJECTIONS_WINK1_HPP + #include <boost/geometry/srs/projections/impl/base_static.hpp> #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> #include <boost/geometry/srs/projections/impl/projects.hpp> @@ -51,7 +50,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct wink1 {}; + struct wink1 {}; // Winkel I }} //namespace srs::par4 @@ -68,23 +67,19 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_wink1_spheroid : public base_t_fi<base_wink1_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_wink1_spheroid + : public base_t_fi<base_wink1_spheroid<T, Parameters>, T, Parameters> { - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_wink1<CalculationType> m_proj_parm; + par_wink1<T> m_proj_parm; inline base_wink1_spheroid(const Parameters& par) - : base_t_fi<base_wink1_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_fi<base_wink1_spheroid<T, Parameters>, T, Parameters>(*this, par) {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { xy_x = .5 * lp_lon * (this->m_proj_parm.cosphi1 + cos(lp_lat)); xy_y = lp_lat; @@ -92,7 +87,7 @@ namespace projections // INVERSE(s_inverse) spheroid // 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 + inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const { lp_lat = xy_y; lp_lon = 2. * xy_x / (this->m_proj_parm.cosphi1 + cos(lp_lat)); @@ -109,7 +104,7 @@ namespace projections template <typename Parameters, typename T> inline void setup_wink1(Parameters& par, par_wink1<T>& proj_parm) { - proj_parm.cosphi1 = cos(pj_param(par.params, "rlat_ts").f); + proj_parm.cosphi1 = cos(pj_get_param_r(par.params, "lat_ts")); par.es = 0.; } @@ -130,10 +125,10 @@ namespace projections \par Example \image html ex_wink1.gif */ - template <typename CalculationType, typename Parameters> - struct wink1_spheroid : public detail::wink1::base_wink1_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct wink1_spheroid : public detail::wink1::base_wink1_spheroid<T, Parameters> { - inline wink1_spheroid(const Parameters& par) : detail::wink1::base_wink1_spheroid<CalculationType, Parameters>(par) + inline wink1_spheroid(const Parameters& par) : detail::wink1::base_wink1_spheroid<T, Parameters>(par) { detail::wink1::setup_wink1(this->m_par, this->m_proj_parm); } @@ -147,20 +142,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::wink1, wink1_spheroid, wink1_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class wink1_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class wink1_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_fi<wink1_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_fi<wink1_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void wink1_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void wink1_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("wink1", new wink1_entry<CalculationType, Parameters>); + factory.add_to_factory("wink1", new wink1_entry<T, Parameters>); } } // namespace detail diff --git a/boost/geometry/srs/projections/proj/wink2.hpp b/boost/geometry/srs/projections/proj/wink2.hpp index 9c90d42481..ba6fb70bf1 100644 --- a/boost/geometry/srs/projections/proj/wink2.hpp +++ b/boost/geometry/srs/projections/proj/wink2.hpp @@ -1,13 +1,9 @@ -#ifndef BOOST_GEOMETRY_PROJECTIONS_WINK2_HPP -#define BOOST_GEOMETRY_PROJECTIONS_WINK2_HPP - -// Boost.Geometry - extensions-gis-projections (based on PROJ4) -// This file is automatically generated. DO NOT EDIT. +// Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017, 2018. +// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. // Use, modification and distribution is subject to the Boost Software License, @@ -19,7 +15,7 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels -// Last updated version of proj: 4.9.1 +// Last updated version of proj: 5.0.0 // Original copyright notice: @@ -41,6 +37,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifndef BOOST_GEOMETRY_PROJECTIONS_WINK2_HPP +#define BOOST_GEOMETRY_PROJECTIONS_WINK2_HPP + #include <boost/geometry/util/math.hpp> #include <boost/geometry/srs/projections/impl/base_static.hpp> @@ -53,7 +52,7 @@ namespace boost { namespace geometry namespace srs { namespace par4 { - struct wink2 {}; + struct wink2 {}; // Winkel II }} //namespace srs::par4 @@ -63,10 +62,8 @@ namespace projections namespace detail { namespace wink2 { - static const int MAX_ITER = 10; - - static const double LOOP_TOL = 1e-7; - //static const double TWO_D_PI = 0.636619772367581343; + static const int max_iter = 10; + static const double loop_tol = 1e-7; template <typename T> struct par_wink2 @@ -75,47 +72,43 @@ namespace projections }; // template class, using CRTP to implement forward/inverse - template <typename CalculationType, typename Parameters> - struct base_wink2_spheroid : public base_t_f<base_wink2_spheroid<CalculationType, Parameters>, - CalculationType, Parameters> + template <typename T, typename Parameters> + struct base_wink2_spheroid + : public base_t_f<base_wink2_spheroid<T, Parameters>, T, Parameters> { - typedef CalculationType geographic_type; - typedef CalculationType cartesian_type; - - par_wink2<CalculationType> m_proj_parm; + par_wink2<T> m_proj_parm; inline base_wink2_spheroid(const Parameters& par) - : base_t_f<base_wink2_spheroid<CalculationType, Parameters>, - CalculationType, Parameters>(*this, par) {} + : base_t_f<base_wink2_spheroid<T, Parameters>, T, Parameters>(*this, par) {} // FORWARD(s_forward) spheroid // Project coordinates from geographic (lon, lat) to cartesian (x, y) - inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const { - static const CalculationType ONEPI = detail::ONEPI<CalculationType>(); - static const CalculationType HALFPI = detail::HALFPI<CalculationType>(); - static const CalculationType FORTPI = detail::FORTPI<CalculationType>(); - static const CalculationType TWO_D_PI = detail::TWO_D_PI<CalculationType>(); + static const T pi = detail::pi<T>(); + static const T half_pi = detail::half_pi<T>(); + static const T fourth_pi = detail::fourth_pi<T>(); + static const T two_div_pi = detail::two_div_pi<T>(); - CalculationType k, V; + T k, V; int i; - xy_y = lp_lat * TWO_D_PI; - k = ONEPI * sin(lp_lat); + xy_y = lp_lat * two_div_pi; + k = pi * sin(lp_lat); lp_lat *= 1.8; - for (i = MAX_ITER; i ; --i) { + for (i = max_iter; i ; --i) { lp_lat -= V = (lp_lat + sin(lp_lat) - k) / (1. + cos(lp_lat)); - if (fabs(V) < LOOP_TOL) + if (fabs(V) < loop_tol) break; } if (!i) - lp_lat = (lp_lat < 0.) ? -HALFPI : HALFPI; + lp_lat = (lp_lat < 0.) ? -half_pi : half_pi; else lp_lat *= 0.5; xy_x = 0.5 * lp_lon * (cos(lp_lat) + this->m_proj_parm.cosphi1); - xy_y = FORTPI * (sin(lp_lat) + xy_y); + xy_y = fourth_pi * (sin(lp_lat) + xy_y); } static inline std::string get_name() @@ -129,7 +122,7 @@ namespace projections template <typename Parameters, typename T> inline void setup_wink2(Parameters& par, par_wink2<T>& proj_parm) { - proj_parm.cosphi1 = cos(pj_param(par.params, "rlat_1").f); + proj_parm.cosphi1 = cos(pj_get_param_r(par.params, "lat_1")); par.es = 0.; } @@ -151,10 +144,10 @@ namespace projections \par Example \image html ex_wink2.gif */ - template <typename CalculationType, typename Parameters> - struct wink2_spheroid : public detail::wink2::base_wink2_spheroid<CalculationType, Parameters> + template <typename T, typename Parameters> + struct wink2_spheroid : public detail::wink2::base_wink2_spheroid<T, Parameters> { - inline wink2_spheroid(const Parameters& par) : detail::wink2::base_wink2_spheroid<CalculationType, Parameters>(par) + inline wink2_spheroid(const Parameters& par) : detail::wink2::base_wink2_spheroid<T, Parameters>(par) { detail::wink2::setup_wink2(this->m_par, this->m_proj_parm); } @@ -168,20 +161,20 @@ namespace projections BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::wink2, wink2_spheroid, wink2_spheroid) // Factory entry(s) - template <typename CalculationType, typename Parameters> - class wink2_entry : public detail::factory_entry<CalculationType, Parameters> + template <typename T, typename Parameters> + class wink2_entry : public detail::factory_entry<T, Parameters> { public : - virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const + virtual base_v<T, Parameters>* create_new(const Parameters& par) const { - return new base_v_f<wink2_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par); + return new base_v_f<wink2_spheroid<T, Parameters>, T, Parameters>(par); } }; - template <typename CalculationType, typename Parameters> - inline void wink2_init(detail::base_factory<CalculationType, Parameters>& factory) + template <typename T, typename Parameters> + inline void wink2_init(detail::base_factory<T, Parameters>& factory) { - factory.add_to_factory("wink2", new wink2_entry<CalculationType, Parameters>); + factory.add_to_factory("wink2", new wink2_entry<T, Parameters>); } } // namespace detail |