// 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)
#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>
{
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[] */
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;
}
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;
}
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);
return phi;
}
/* convergence failed */
- BOOST_THROW_EXCEPTION( projection_exception(-17) );
+ BOOST_THROW_EXCEPTION( projection_exception(error_non_conv_inv_meri_dist) );
}
} // namespace detail