summaryrefslogtreecommitdiff
path: root/boost/geometry/srs/projections/proj/nzmg.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/geometry/srs/projections/proj/nzmg.hpp')
-rw-r--r--boost/geometry/srs/projections/proj/nzmg.hpp110
1 files changed, 52 insertions, 58 deletions
diff --git a/boost/geometry/srs/projections/proj/nzmg.hpp b/boost/geometry/srs/projections/proj/nzmg.hpp
index 067eece27a..2806e1a2d2 100644
--- a/boost/geometry/srs/projections/proj/nzmg.hpp
+++ b/boost/geometry/srs/projections/proj/nzmg.hpp
@@ -1,13 +1,9 @@
-#ifndef BOOST_GEOMETRY_PROJECTIONS_NZMG_HPP
-#define BOOST_GEOMETRY_PROJECTIONS_NZMG_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,12 +15,12 @@
// 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:
// Purpose: Implementation of the nzmg (New Zealand Map Grid) projection.
-// Very loosely based upon DMA code by Bradford W. Drew
+// Very loosely based upon DMA code by Bradford W. Drew
// Author: Gerald Evenden
// Copyright (c) 1995, Gerald Evenden
@@ -46,6 +42,9 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
+#ifndef BOOST_GEOMETRY_PROJECTIONS_NZMG_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_NZMG_HPP
+
#include <boost/geometry/util/math.hpp>
#include <boost/geometry/srs/projections/impl/base_static.hpp>
@@ -59,7 +58,7 @@ namespace boost { namespace geometry
namespace srs { namespace par4
{
- struct nzmg {};
+ struct nzmg {}; // New Zealand Map Grid
}} //namespace srs::par4
@@ -69,22 +68,20 @@ namespace projections
namespace detail { namespace nzmg
{
- static const double EPSLN = 1e-10;
- //static const double SEC5_TO_RAD = 0.4848136811095359935899141023;
- //static const double RAD_TO_SEC5 = 2.062648062470963551564733573;
+ static const double epsilon = 1e-10;
static const int Nbf = 5;
static const int Ntpsi = 9;
static const int Ntphi = 8;
template <typename T>
- inline T SEC5_TO_RAD() { return 0.4848136811095359935899141023; }
+ inline T sec5_to_rad() { return 0.4848136811095359935899141023; }
template <typename T>
- inline T RAD_TO_SEC5() { return 2.062648062470963551564733573; }
+ inline T rad_to_sec5() { return 2.062648062470963551564733573; }
template <typename T>
- inline const COMPLEX<T> * bf()
+ inline const pj_complex<T> * bf()
{
- static const COMPLEX<T> result[] = {
+ static const pj_complex<T> result[] = {
{.7557853228, 0.0},
{.249204646, .003371507},
{-.001541739, .041058560},
@@ -98,80 +95,76 @@ namespace projections
template <typename T>
inline const T * tphi()
{
- static const T result[] = { 1.5627014243, .5185406398, -.03333098, -.1052906, -.0368594,
- .007317, .01220, .00394, -.0013 };
+ static const T result[] = { 1.5627014243, .5185406398, -.03333098,
+ -.1052906, -.0368594, .007317,
+ .01220, .00394, -.0013 };
return result;
}
template <typename T>
inline const T * tpsi()
{
static const T result[] = { .6399175073, -.1358797613, .063294409, -.02526853, .0117879,
- -.0055161, .0026906, -.001333, .00067, -.00034 };
+ -.0055161, .0026906, -.001333, .00067, -.00034 };
return result;
}
// template class, using CRTP to implement forward/inverse
- template <typename CalculationType, typename Parameters>
- struct base_nzmg_ellipsoid : public base_t_fi<base_nzmg_ellipsoid<CalculationType, Parameters>,
- CalculationType, Parameters>
+ template <typename T, typename Parameters>
+ struct base_nzmg_ellipsoid
+ : public base_t_fi<base_nzmg_ellipsoid<T, Parameters>, T, Parameters>
{
-
- typedef CalculationType geographic_type;
- typedef CalculationType cartesian_type;
-
-
inline base_nzmg_ellipsoid(const Parameters& par)
- : base_t_fi<base_nzmg_ellipsoid<CalculationType, Parameters>,
- CalculationType, Parameters>(*this, par) {}
+ : base_t_fi<base_nzmg_ellipsoid<T, Parameters>, T, Parameters>(*this, par)
+ {}
// FORWARD(e_forward) 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
{
- static const CalculationType RAD_TO_SEC5 = nzmg::RAD_TO_SEC5<CalculationType>();
+ static const T rad_to_sec5 = nzmg::rad_to_sec5<T>();
- COMPLEX<CalculationType> p;
- const CalculationType * C;
+ pj_complex<T> p;
+ const T * C;
int i;
- lp_lat = (lp_lat - this->m_par.phi0) * RAD_TO_SEC5;
- for (p.r = *(C = tpsi<CalculationType>() + (i = Ntpsi)); i ; --i)
+ lp_lat = (lp_lat - this->m_par.phi0) * rad_to_sec5;
+ for (p.r = *(C = tpsi<T>() + (i = Ntpsi)); i ; --i)
p.r = *--C + lp_lat * p.r;
p.r *= lp_lat;
p.i = lp_lon;
- p = pj_zpoly1(p, bf<CalculationType>(), Nbf);
+ p = pj_zpoly1(p, bf<T>(), Nbf);
xy_x = p.i;
xy_y = p.r;
}
// INVERSE(e_inverse) 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
{
- static const CalculationType SEC5_TO_RAD = nzmg::SEC5_TO_RAD<CalculationType>();
+ static const T sec5_to_rad = nzmg::sec5_to_rad<T>();
int nn, i;
- COMPLEX<CalculationType> p, f, fp, dp;
- CalculationType den;
- const CalculationType* C;
+ pj_complex<T> p, f, fp, dp;
+ T den;
+ const T* C;
p.r = xy_y;
p.i = xy_x;
for (nn = 20; nn ;--nn) {
- f = pj_zpolyd1(p, bf<CalculationType>(), Nbf, &fp);
+ f = pj_zpolyd1(p, bf<T>(), Nbf, &fp);
f.r -= xy_y;
f.i -= xy_x;
den = fp.r * fp.r + fp.i * fp.i;
p.r += dp.r = -(f.r * fp.r + f.i * fp.i) / den;
p.i += dp.i = -(f.i * fp.r - f.r * fp.i) / den;
- if ((fabs(dp.r) + fabs(dp.i)) <= EPSLN)
+ if ((fabs(dp.r) + fabs(dp.i)) <= epsilon)
break;
}
if (nn) {
lp_lon = p.i;
- for (lp_lat = *(C = tphi<CalculationType>() + (i = Ntphi)); i ; --i)
+ for (lp_lat = *(C = tphi<T>() + (i = Ntphi)); i ; --i)
lp_lat = *--C + p.r * lp_lat;
- lp_lat = this->m_par.phi0 + p.r * lp_lat * SEC5_TO_RAD;
+ lp_lat = this->m_par.phi0 + p.r * lp_lat * sec5_to_rad;
} else
lp_lon = lp_lat = HUGE_VAL;
}
@@ -188,11 +181,12 @@ namespace projections
inline void setup_nzmg(Parameters& par)
{
typedef typename Parameters::type calc_t;
+ static const calc_t d2r = geometry::math::d2r<calc_t>();
/* force to International major axis */
par.ra = 1. / (par.a = 6378388.0);
- par.lam0 = geometry::math::d2r<calc_t>() * 173.;
- par.phi0 = geometry::math::d2r<calc_t>() * -41.;
+ par.lam0 = 173. * d2r;
+ par.phi0 = -41. * d2r;
par.x0 = 2510000.;
par.y0 = 6023150.;
}
@@ -211,10 +205,10 @@ namespace projections
\par Example
\image html ex_nzmg.gif
*/
- template <typename CalculationType, typename Parameters>
- struct nzmg_ellipsoid : public detail::nzmg::base_nzmg_ellipsoid<CalculationType, Parameters>
+ template <typename T, typename Parameters>
+ struct nzmg_ellipsoid : public detail::nzmg::base_nzmg_ellipsoid<T, Parameters>
{
- inline nzmg_ellipsoid(const Parameters& par) : detail::nzmg::base_nzmg_ellipsoid<CalculationType, Parameters>(par)
+ inline nzmg_ellipsoid(const Parameters& par) : detail::nzmg::base_nzmg_ellipsoid<T, Parameters>(par)
{
detail::nzmg::setup_nzmg(this->m_par);
}
@@ -228,20 +222,20 @@ namespace projections
BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::nzmg, nzmg_ellipsoid, nzmg_ellipsoid)
// Factory entry(s)
- template <typename CalculationType, typename Parameters>
- class nzmg_entry : public detail::factory_entry<CalculationType, Parameters>
+ template <typename T, typename Parameters>
+ class nzmg_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<nzmg_ellipsoid<CalculationType, Parameters>, CalculationType, Parameters>(par);
+ return new base_v_fi<nzmg_ellipsoid<T, Parameters>, T, Parameters>(par);
}
};
- template <typename CalculationType, typename Parameters>
- inline void nzmg_init(detail::base_factory<CalculationType, Parameters>& factory)
+ template <typename T, typename Parameters>
+ inline void nzmg_init(detail::base_factory<T, Parameters>& factory)
{
- factory.add_to_factory("nzmg", new nzmg_entry<CalculationType, Parameters>);
+ factory.add_to_factory("nzmg", new nzmg_entry<T, Parameters>);
}
} // namespace detail