diff options
Diffstat (limited to 'boost/geometry/srs/projections/proj/eqdc.hpp')
-rw-r--r-- | boost/geometry/srs/projections/proj/eqdc.hpp | 114 |
1 files changed, 50 insertions, 64 deletions
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 |