1 #ifndef BOOST_GEOMETRY_PROJECTIONS_ECK4_HPP
2 #define BOOST_GEOMETRY_PROJECTIONS_ECK4_HPP
4 // Boost.Geometry - extensions-gis-projections (based on PROJ4)
5 // This file is automatically generated. DO NOT EDIT.
7 // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands.
9 // This file was modified by Oracle on 2017.
10 // Modifications copyright (c) 2017, Oracle and/or its affiliates.
11 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle.
13 // Use, modification and distribution is subject to the Boost Software License,
14 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
15 // http://www.boost.org/LICENSE_1_0.txt)
17 // This file is converted from PROJ4, http://trac.osgeo.org/proj
18 // PROJ4 is originally written by Gerald Evenden (then of the USGS)
19 // PROJ4 is maintained by Frank Warmerdam
20 // PROJ4 is converted to Boost.Geometry by Barend Gehrels
22 // Last updated version of proj: 4.9.1
24 // Original copyright notice:
26 // Permission is hereby granted, free of charge, to any person obtaining a
27 // copy of this software and associated documentation files (the "Software"),
28 // to deal in the Software without restriction, including without limitation
29 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
30 // and/or sell copies of the Software, and to permit persons to whom the
31 // Software is furnished to do so, subject to the following conditions:
33 // The above copyright notice and this permission notice shall be included
34 // in all copies or substantial portions of the Software.
36 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
37 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
38 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
39 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
40 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
41 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
42 // DEALINGS IN THE SOFTWARE.
44 #include <boost/geometry/srs/projections/impl/base_static.hpp>
45 #include <boost/geometry/srs/projections/impl/base_dynamic.hpp>
46 #include <boost/geometry/srs/projections/impl/projects.hpp>
47 #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
48 #include <boost/geometry/srs/projections/impl/aasincos.hpp>
50 namespace boost { namespace geometry
53 namespace srs { namespace par4
57 }} //namespace srs::par4
61 #ifndef DOXYGEN_NO_DETAIL
62 namespace detail { namespace eck4
65 static const double C_x = .42223820031577120149;
66 static const double C_y = 1.32650042817700232218;
67 static const double RC_y = .75386330736002178205;
68 static const double C_p = 3.57079632679489661922;
69 static const double RC_p = .28004957675577868795;
70 static const double EPS = 1e-7;
71 static const int NITER = 6;
73 // template class, using CRTP to implement forward/inverse
74 template <typename CalculationType, typename Parameters>
75 struct base_eck4_spheroid : public base_t_fi<base_eck4_spheroid<CalculationType, Parameters>,
76 CalculationType, Parameters>
79 typedef CalculationType geographic_type;
80 typedef CalculationType cartesian_type;
83 inline base_eck4_spheroid(const Parameters& par)
84 : base_t_fi<base_eck4_spheroid<CalculationType, Parameters>,
85 CalculationType, Parameters>(*this, par) {}
87 // FORWARD(s_forward) spheroid
88 // Project coordinates from geographic (lon, lat) to cartesian (x, y)
89 inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
91 CalculationType p, V, s, c;
94 p = C_p * sin(lp_lat);
96 lp_lat *= 0.895168 + V * ( 0.0218849 + V * 0.00826809 );
97 for (i = NITER; i ; --i) {
100 lp_lat -= V = (lp_lat + s * (c + 2.) - p) /
101 (1. + c * (c + 2.) - s * s);
107 xy_y = lp_lat < 0. ? -C_y : C_y;
109 xy_x = C_x * lp_lon * (1. + cos(lp_lat));
110 xy_y = C_y * sin(lp_lat);
114 // INVERSE(s_inverse) spheroid
115 // Project coordinates from cartesian (x, y) to geographic (lon, lat)
116 inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
120 lp_lat = aasin(xy_y / C_y);
121 lp_lon = xy_x / (C_x * (1. + (c = cos(lp_lat))));
122 lp_lat = aasin((lp_lat + sin(lp_lat) * (c + 2.)) / C_p);
125 static inline std::string get_name()
127 return "eck4_spheroid";
133 template <typename Parameters>
134 inline void setup_eck4(Parameters& par)
139 }} // namespace detail::eck4
143 \brief Eckert IV projection
145 \tparam Geographic latlong point type
146 \tparam Cartesian xy point type
147 \tparam Parameters parameter type
148 \par Projection characteristics
152 \image html ex_eck4.gif
154 template <typename CalculationType, typename Parameters>
155 struct eck4_spheroid : public detail::eck4::base_eck4_spheroid<CalculationType, Parameters>
157 inline eck4_spheroid(const Parameters& par) : detail::eck4::base_eck4_spheroid<CalculationType, Parameters>(par)
159 detail::eck4::setup_eck4(this->m_par);
163 #ifndef DOXYGEN_NO_DETAIL
168 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::eck4, eck4_spheroid, eck4_spheroid)
171 template <typename CalculationType, typename Parameters>
172 class eck4_entry : public detail::factory_entry<CalculationType, Parameters>
175 virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const
177 return new base_v_fi<eck4_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par);
181 template <typename CalculationType, typename Parameters>
182 inline void eck4_init(detail::base_factory<CalculationType, Parameters>& factory)
184 factory.add_to_factory("eck4", new eck4_entry<CalculationType, Parameters>);
187 } // namespace detail
190 } // namespace projections
192 }} // namespace boost::geometry
194 #endif // BOOST_GEOMETRY_PROJECTIONS_ECK4_HPP