]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/boost/geometry/srs/projections/impl/proj_mdist.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / geometry / srs / projections / impl / proj_mdist.hpp
index 1c325df1c640f58b77604d6653becdaf2b31b062..9e8f0cfbe0daedd2eee70825bffa66a659aa0ffc 100644 (file)
@@ -3,6 +3,10 @@
 
 // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
 
+// This file was modified by Oracle on 2018.
+// Modifications copyright (c) 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,
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
@@ -36,6 +40,8 @@
 #define BOOST_GEOMETRY_PROJECTIONS_PROJ_MDIST_HPP
 
 
+#include <boost/geometry/srs/projections/exception.hpp>
+#include <boost/geometry/srs/projections/impl/pj_strerrno.hpp>
 #include <boost/geometry/util/math.hpp>
 
 
@@ -43,23 +49,23 @@ namespace boost { namespace geometry { namespace projections
 {
 namespace detail
 {
-    static const int MDIST_MAX_ITER = 20;
-
     template <typename T>
-    struct MDIST
+    struct mdist
     {
-        int nb;
+        static const int static_size = 20;
+
         T es;
         T E;
-        T b[MDIST_MAX_ITER];
+        T b[static_size];
+        int nb;
     };
 
-    template <typename CT>
-    inline bool proj_mdist_ini(CT const& es, MDIST<CT>& b)
+    template <typename T>
+    inline bool proj_mdist_ini(T const& es, mdist<T>& b)
     {
-        CT numf, numfi, twon1, denf, denfi, ens, T, twon;
-        CT den, El, Es;
-        CT E[MDIST_MAX_ITER];
+        T numf, numfi, twon1, denf, denfi, ens, t, twon;
+        T den, El, Es;
+        T E[mdist<T>::static_size];
         int i, j;
 
         /* generate E(e^2) and its terms E[] */
@@ -68,12 +74,13 @@ namespace detail
         denf = 1.;
         twon = 4.;
         Es = El = E[0] = 1.;
-        for (i = 1; i < MDIST_MAX_ITER ; ++i)
+        for (i = 1; i < mdist<T>::static_size ; ++i)
         {
             numf *= (twon1 * twon1);
             den = twon * denf * denf * twon1;
-            T = numf/den;
-            Es -= (E[i] = T * ens);
+            t = numf/den;
+            E[i] = t * ens;
+            Es -= E[i];
             ens *= es;
             twon *= 4.;
             denf *= ++denfi;
@@ -103,7 +110,7 @@ namespace detail
     }
 
     template <typename T>
-    inline T proj_mdist(T const& phi, T const& sphi, T const& cphi, MDIST<T> const& b)
+    inline T proj_mdist(T const& phi, T const& sphi, T const& cphi, mdist<T> const& b)
     {
         T sc, sum, sphi2, D;
         int i;
@@ -117,14 +124,14 @@ namespace detail
     }
 
     template <typename T>
-    inline T proj_inv_mdist(T const& dist, MDIST<T> const& b)
+    inline T proj_inv_mdist(T const& dist, mdist<T> const& b)
     {
         static const T TOL = 1e-14;
         T s, t, phi, k;
         int i;
 
         k = 1./(1.- b.es);
-        i = MDIST_MAX_ITER;
+        i = mdist<T>::static_size;
         phi = dist;
         while ( i-- ) {
             s = sin(phi);
@@ -135,7 +142,7 @@ namespace detail
                 return phi;
         }
             /* convergence failed */
-        BOOST_THROW_EXCEPTION( projection_exception(-17) );
+        BOOST_THROW_EXCEPTION( projection_exception(error_non_conv_inv_meri_dist) );
     }
 } // namespace detail