Imported Upstream version 1.72.0
[platform/upstream/boost.git] / boost / geometry / srs / projections / proj / healpix.hpp
index 2084ae8..670b8b9 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,
@@ -74,17 +74,17 @@ namespace projections
             template <typename T>
             struct par_healpix
             {
-                int north_square;
-                int south_square;
                 T qp;
                 detail::apa<T> apa;
+                int north_square;
+                int south_square;
             };
 
             template <typename T>
             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). */
+                int cn; /* An integer 0--3 indicating the position of the polar cap. */
                 enum region_type {north, south, equatorial} region;
             };
             template <typename T>
@@ -546,28 +546,22 @@ namespace projections
                 xy_y = vector[1];
             }
 
-            // template class, using CRTP to implement forward/inverse
             template <typename T, typename Parameters>
             struct base_healpix_ellipsoid
-                : public base_t_fi<base_healpix_ellipsoid<T, Parameters>, T, Parameters>
             {
                 par_healpix<T> m_proj_parm;
 
-                inline base_healpix_ellipsoid(const Parameters& 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(T const& lp_lon, T lp_lat, T& xy_x, T& xy_y) const
+                inline void fwd(Parameters const& par, T const& lp_lon, T lp_lat, T& xy_x, T& xy_y) const
                 {
-                    lp_lat = auth_lat(this->params(), m_proj_parm, lp_lat, 0);
+                    lp_lat = auth_lat(par, m_proj_parm, lp_lat, 0);
                     return healpix_sphere(lp_lon, lp_lat, xy_x, xy_y);
                 }
 
                 // INVERSE(e_healpix_inverse)  ellipsoid
                 // Project coordinates from cartesian (x, y) to geographic (lon, lat)
-                inline void inv(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
+                inline void inv(Parameters const& par, T const& xy_x, T const& 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) {
@@ -576,7 +570,7 @@ namespace projections
                         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);
+                    lp_lat = auth_lat(par, m_proj_parm, lp_lat, 1);
                 }
 
                 static inline std::string get_name()
@@ -586,27 +580,21 @@ namespace projections
 
             };
 
-            // template class, using CRTP to implement forward/inverse
             template <typename T, typename Parameters>
             struct base_healpix_spheroid
-                : public base_t_fi<base_healpix_spheroid<T, Parameters>, T, Parameters>
             {
                 par_healpix<T> m_proj_parm;
 
-                inline base_healpix_spheroid(const Parameters& 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(T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
+                inline void fwd(Parameters const& , T const& lp_lon, T const& 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(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
+                inline void inv(Parameters const& , T const& xy_x, T const& 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) {
@@ -624,29 +612,23 @@ namespace projections
 
             };
 
-            // template class, using CRTP to implement forward/inverse
             template <typename T, typename Parameters>
             struct base_rhealpix_ellipsoid
-                : public base_t_fi<base_rhealpix_ellipsoid<T, Parameters>, T, Parameters>
             {
                 par_healpix<T> m_proj_parm;
 
-                inline base_rhealpix_ellipsoid(const Parameters& 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(T const& lp_lon, T lp_lat, T& xy_x, T& xy_y) const
+                inline void fwd(Parameters const& par, T const& lp_lon, T lp_lat, T& xy_x, T& xy_y) const
                 {
-                    lp_lat = auth_lat(this->params(), m_proj_parm, lp_lat, 0);
+                    lp_lat = auth_lat(par, m_proj_parm, lp_lat, 0);
                     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);
                 }
 
                 // INVERSE(e_rhealpix_inverse)  ellipsoid
                 // 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
                 {
                     /* 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) {
@@ -656,7 +638,7 @@ namespace projections
                     }
                     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);
-                    lp_lat = auth_lat(this->params(), m_proj_parm, lp_lat, 1);
+                    lp_lat = auth_lat(par, m_proj_parm, lp_lat, 1);
                 }
 
                 static inline std::string get_name()
@@ -666,20 +648,14 @@ namespace projections
 
             };
 
-            // template class, using CRTP to implement forward/inverse
             template <typename T, typename Parameters>
             struct base_rhealpix_spheroid
-                : public base_t_fi<base_rhealpix_spheroid<T, Parameters>, T, Parameters>
             {
                 par_healpix<T> m_proj_parm;
 
-                inline base_rhealpix_spheroid(const Parameters& 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(T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
+                inline void fwd(Parameters const& , T const& lp_lon, T const& 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);
@@ -687,7 +663,7 @@ namespace projections
 
                 // INVERSE(s_rhealpix_inverse)  sphere
                 // 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& , 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) {
@@ -762,10 +738,9 @@ namespace projections
     struct healpix_ellipsoid : public detail::healpix::base_healpix_ellipsoid<T, Parameters>
     {
         template <typename Params>
-        inline healpix_ellipsoid(Params const& , Parameters const& par)
-            : detail::healpix::base_healpix_ellipsoid<T, Parameters>(par)
+        inline healpix_ellipsoid(Params const& , Parameters & par)
         {
-            detail::healpix::setup_healpix(this->m_par, this->m_proj_parm);
+            detail::healpix::setup_healpix(par, this->m_proj_parm);
         }
     };
 
@@ -785,10 +760,9 @@ namespace projections
     struct healpix_spheroid : public detail::healpix::base_healpix_spheroid<T, Parameters>
     {
         template <typename Params>
-        inline healpix_spheroid(Params const& , Parameters const& par)
-            : detail::healpix::base_healpix_spheroid<T, Parameters>(par)
+        inline healpix_spheroid(Params const& , Parameters & par)
         {
-            detail::healpix::setup_healpix(this->m_par, this->m_proj_parm);
+            detail::healpix::setup_healpix(par, this->m_proj_parm);
         }
     };
 
@@ -811,10 +785,9 @@ namespace projections
     struct rhealpix_ellipsoid : public detail::healpix::base_rhealpix_ellipsoid<T, Parameters>
     {
         template <typename Params>
-        inline rhealpix_ellipsoid(Params const& params, Parameters const& par)
-            : detail::healpix::base_rhealpix_ellipsoid<T, Parameters>(par)
+        inline rhealpix_ellipsoid(Params const& params, Parameters & par)
         {
-            detail::healpix::setup_rhealpix(params, this->m_par, this->m_proj_parm);
+            detail::healpix::setup_rhealpix(params, par, this->m_proj_parm);
         }
     };
 
@@ -837,10 +810,9 @@ namespace projections
     struct rhealpix_spheroid : public detail::healpix::base_rhealpix_spheroid<T, Parameters>
     {
         template <typename Params>
-        inline rhealpix_spheroid(Params const& params, Parameters const& par)
-            : detail::healpix::base_rhealpix_spheroid<T, Parameters>(par)
+        inline rhealpix_spheroid(Params const& params, Parameters & par)
         {
-            detail::healpix::setup_rhealpix(params, this->m_par, this->m_proj_parm);
+            detail::healpix::setup_rhealpix(params, par, this->m_proj_parm);
         }
     };
 
@@ -849,8 +821,8 @@ namespace projections
     {
 
         // Static projection
-        BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::spar::proj_healpix, healpix_spheroid, healpix_ellipsoid)
-        BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::spar::proj_rhealpix, rhealpix_spheroid, rhealpix_ellipsoid)
+        BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI2(srs::spar::proj_healpix, healpix_spheroid, healpix_ellipsoid)
+        BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI2(srs::spar::proj_rhealpix, rhealpix_spheroid, rhealpix_ellipsoid)
 
         // Factory entry(s)
         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI2(healpix_entry, healpix_spheroid, healpix_ellipsoid)