Imported Upstream version 1.72.0
[platform/upstream/boost.git] / boost / geometry / srs / projections / proj / lcc.hpp
index ebd9c3b..7210c3b 100644 (file)
@@ -2,8 +2,8 @@
 
 // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands.
 
-// This file was modified by Oracle on 2017, 2018.
-// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates.
+// This file was modified by Oracle on 2017, 2018, 2019.
+// Modifications copyright (c) 2017-2019, 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,
@@ -66,28 +66,22 @@ namespace projections
             template <typename T>
             struct par_lcc
             {
-                T   phi1;
-                T   phi2;
-                T   n;
-                T   rho0;
-                T   c;
-                int ellips;
+                T    phi1;
+                T    phi2;
+                T    n;
+                T    rho0;
+                T    c;
+                bool ellips;
             };
 
-            // template class, using CRTP to implement forward/inverse
             template <typename T, typename Parameters>
             struct base_lcc_ellipsoid
-                : public base_t_fi<base_lcc_ellipsoid<T, Parameters>, T, Parameters>
             {
                 par_lcc<T> m_proj_parm;
 
-                inline base_lcc_ellipsoid(const Parameters& 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(T lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
+                inline void fwd(Parameters const& par, T lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
                 {
                     static const T fourth_pi = detail::fourth_pi<T>();
                     static const T half_pi = detail::half_pi<T>();
@@ -101,24 +95,24 @@ namespace projections
                         rho = 0.;
                     } 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(pj_tsfn(lp_lat, sin(lp_lat), 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) );
+                    xy_x = par.k0 * (rho * sin( lp_lon) );
+                    xy_y = 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(T xy_x, T xy_y, T& lp_lon, T& lp_lat) const
+                inline void inv(Parameters const& par, T xy_x, T xy_y, T& lp_lon, T& lp_lat) const
                 {
                     static const T half_pi = detail::half_pi<T>();
 
                     T rho;
 
-                    xy_x /= this->m_par.k0;
-                    xy_y /= this->m_par.k0;
+                    xy_x /= par.k0;
+                    xy_y /= par.k0;
 
                     xy_y = this->m_proj_parm.rho0 - xy_y;
                     rho = boost::math::hypot(xy_x, xy_y);
@@ -129,7 +123,7 @@ namespace projections
                             xy_y = -xy_y;
                         }
                         if (this->m_proj_parm.ellips) {
-                            lp_lat = pj_phi2(math::pow(rho / this->m_proj_parm.c, T(1)/this->m_proj_parm.n), this->m_par.e);
+                            lp_lat = pj_phi2(math::pow(rho / this->m_proj_parm.c, T(1)/this->m_proj_parm.n), par.e);
                             if (lp_lat == HUGE_VAL) {
                                 BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) );
                             }
@@ -193,7 +187,7 @@ namespace projections
                 if( (proj_parm.ellips = (par.es != 0.)) ) {
                     double ml1, m1;
 
-                    par.e = sqrt(par.es);
+                    par.e = sqrt(par.es); // TODO: Isn't it already set?
                     m1 = pj_msfn(sinphi, cosphi, par.es);
                     ml1 = pj_tsfn(proj_parm.phi1, sinphi, par.e);
                     if (secant) { /* secant cone */
@@ -239,10 +233,9 @@ namespace projections
     struct lcc_ellipsoid : public detail::lcc::base_lcc_ellipsoid<T, Parameters>
     {
         template <typename Params>
-        inline lcc_ellipsoid(Params const& params, Parameters const& par)
-            : detail::lcc::base_lcc_ellipsoid<T, Parameters>(par)
+        inline lcc_ellipsoid(Params const& params, Parameters & par)
         {
-            detail::lcc::setup_lcc(params, this->m_par, this->m_proj_parm);
+            detail::lcc::setup_lcc(params, par, this->m_proj_parm);
         }
     };
 
@@ -251,7 +244,7 @@ namespace projections
     {
 
         // Static projection
-        BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::spar::proj_lcc, lcc_ellipsoid, lcc_ellipsoid)
+        BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_lcc, lcc_ellipsoid)
 
         // Factory entry(s)
         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(lcc_entry, lcc_ellipsoid)