1 #ifndef BOOST_GEOMETRY_PROJECTIONS_VANDG2_HPP
2 #define BOOST_GEOMETRY_PROJECTIONS_VANDG2_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, 2018.
10 // Modifications copyright (c) 2017-2018, 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/util/math.hpp>
46 #include <boost/geometry/srs/projections/impl/base_static.hpp>
47 #include <boost/geometry/srs/projections/impl/base_dynamic.hpp>
48 #include <boost/geometry/srs/projections/impl/projects.hpp>
49 #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
51 namespace boost { namespace geometry
54 namespace srs { namespace par4
59 }} //namespace srs::par4
63 #ifndef DOXYGEN_NO_DETAIL
64 namespace detail { namespace vandg2
67 static const double TOL = 1e-10;
68 //static const double TWORPI = 0.63661977236758134308;
75 // template class, using CRTP to implement forward/inverse
76 template <typename CalculationType, typename Parameters>
77 struct base_vandg2_spheroid : public base_t_f<base_vandg2_spheroid<CalculationType, Parameters>,
78 CalculationType, Parameters>
81 typedef CalculationType geographic_type;
82 typedef CalculationType cartesian_type;
84 par_vandg2 m_proj_parm;
86 inline base_vandg2_spheroid(const Parameters& par)
87 : base_t_f<base_vandg2_spheroid<CalculationType, Parameters>,
88 CalculationType, Parameters>(*this, par) {}
90 // FORWARD(s_forward) spheroid
91 // Project coordinates from geographic (lon, lat) to cartesian (x, y)
92 inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
94 static const CalculationType ONEPI = detail::ONEPI<CalculationType>();
95 static const CalculationType TWORPI = detail::TWO_D_PI<CalculationType>();
97 CalculationType x1, at, bt, ct;
99 bt = fabs(TWORPI * lp_lat);
100 if ((ct = 1. - bt * bt) < 0.)
104 if (fabs(lp_lon) < TOL) {
106 xy_y = ONEPI * (lp_lat < 0. ? -bt : bt) / (1. + ct);
108 at = 0.5 * fabs(ONEPI / lp_lon - lp_lon / ONEPI);
109 if (this->m_proj_parm.vdg3) {
111 xy_x = ONEPI * (sqrt(at * at + 1. - x1 * x1) - at);
114 x1 = (ct * sqrt(1. + at * at) - at * ct * ct) /
115 (1. + at * at * bt * bt);
117 xy_y = ONEPI * sqrt(1. - x1 * (x1 + 2. * at) + TOL);
119 if ( lp_lon < 0.) xy_x = -xy_x;
120 if ( lp_lat < 0.) xy_y = -xy_y;
124 static inline std::string get_name()
126 return "vandg2_spheroid";
131 // van der Grinten II
132 template <typename Parameters>
133 inline void setup_vandg2(Parameters& /*par*/, par_vandg2& proj_parm)
138 // van der Grinten III
139 template <typename Parameters>
140 inline void setup_vandg3(Parameters& par, par_vandg2& proj_parm)
146 }} // namespace detail::vandg2
150 \brief van der Grinten II projection
152 \tparam Geographic latlong point type
153 \tparam Cartesian xy point type
154 \tparam Parameters parameter type
155 \par Projection characteristics
160 \image html ex_vandg2.gif
162 template <typename CalculationType, typename Parameters>
163 struct vandg2_spheroid : public detail::vandg2::base_vandg2_spheroid<CalculationType, Parameters>
165 inline vandg2_spheroid(const Parameters& par) : detail::vandg2::base_vandg2_spheroid<CalculationType, Parameters>(par)
167 detail::vandg2::setup_vandg2(this->m_par, this->m_proj_parm);
172 \brief van der Grinten III projection
174 \tparam Geographic latlong point type
175 \tparam Cartesian xy point type
176 \tparam Parameters parameter type
177 \par Projection characteristics
182 \image html ex_vandg3.gif
184 template <typename CalculationType, typename Parameters>
185 struct vandg3_spheroid : public detail::vandg2::base_vandg2_spheroid<CalculationType, Parameters>
187 inline vandg3_spheroid(const Parameters& par) : detail::vandg2::base_vandg2_spheroid<CalculationType, Parameters>(par)
189 detail::vandg2::setup_vandg3(this->m_par, this->m_proj_parm);
193 #ifndef DOXYGEN_NO_DETAIL
198 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::vandg2, vandg2_spheroid, vandg2_spheroid)
199 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::vandg3, vandg3_spheroid, vandg3_spheroid)
202 template <typename CalculationType, typename Parameters>
203 class vandg2_entry : public detail::factory_entry<CalculationType, Parameters>
206 virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const
208 return new base_v_f<vandg2_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par);
212 template <typename CalculationType, typename Parameters>
213 class vandg3_entry : public detail::factory_entry<CalculationType, Parameters>
216 virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const
218 return new base_v_f<vandg3_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par);
222 template <typename CalculationType, typename Parameters>
223 inline void vandg2_init(detail::base_factory<CalculationType, Parameters>& factory)
225 factory.add_to_factory("vandg2", new vandg2_entry<CalculationType, Parameters>);
226 factory.add_to_factory("vandg3", new vandg3_entry<CalculationType, Parameters>);
229 } // namespace detail
232 } // namespace projections
234 }} // namespace boost::geometry
236 #endif // BOOST_GEOMETRY_PROJECTIONS_VANDG2_HPP