]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/srs/projections/proj/vandg2.hpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / boost / geometry / srs / projections / proj / vandg2.hpp
1 #ifndef BOOST_GEOMETRY_PROJECTIONS_VANDG2_HPP
2 #define BOOST_GEOMETRY_PROJECTIONS_VANDG2_HPP
3
4 // Boost.Geometry - extensions-gis-projections (based on PROJ4)
5 // This file is automatically generated. DO NOT EDIT.
6
7 // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands.
8
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.
12
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)
16
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
21
22 // Last updated version of proj: 4.9.1
23
24 // Original copyright notice:
25
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:
32
33 // The above copyright notice and this permission notice shall be included
34 // in all copies or substantial portions of the Software.
35
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.
43
44 #include <boost/geometry/util/math.hpp>
45
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>
50
51 namespace boost { namespace geometry
52 {
53
54 namespace srs { namespace par4
55 {
56 struct vandg2 {};
57 struct vandg3 {};
58
59 }} //namespace srs::par4
60
61 namespace projections
62 {
63 #ifndef DOXYGEN_NO_DETAIL
64 namespace detail { namespace vandg2
65 {
66
67 static const double TOL = 1e-10;
68 //static const double TWORPI = 0.63661977236758134308;
69
70 struct par_vandg2
71 {
72 int vdg3;
73 };
74
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>
79 {
80
81 typedef CalculationType geographic_type;
82 typedef CalculationType cartesian_type;
83
84 par_vandg2 m_proj_parm;
85
86 inline base_vandg2_spheroid(const Parameters& par)
87 : base_t_f<base_vandg2_spheroid<CalculationType, Parameters>,
88 CalculationType, Parameters>(*this, par) {}
89
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
93 {
94 static const CalculationType ONEPI = detail::ONEPI<CalculationType>();
95 static const CalculationType TWORPI = detail::TWO_D_PI<CalculationType>();
96
97 CalculationType x1, at, bt, ct;
98
99 bt = fabs(TWORPI * lp_lat);
100 if ((ct = 1. - bt * bt) < 0.)
101 ct = 0.;
102 else
103 ct = sqrt(ct);
104 if (fabs(lp_lon) < TOL) {
105 xy_x = 0.;
106 xy_y = ONEPI * (lp_lat < 0. ? -bt : bt) / (1. + ct);
107 } else {
108 at = 0.5 * fabs(ONEPI / lp_lon - lp_lon / ONEPI);
109 if (this->m_proj_parm.vdg3) {
110 x1 = bt / (1. + ct);
111 xy_x = ONEPI * (sqrt(at * at + 1. - x1 * x1) - at);
112 xy_y = ONEPI * x1;
113 } else {
114 x1 = (ct * sqrt(1. + at * at) - at * ct * ct) /
115 (1. + at * at * bt * bt);
116 xy_x = ONEPI * x1;
117 xy_y = ONEPI * sqrt(1. - x1 * (x1 + 2. * at) + TOL);
118 }
119 if ( lp_lon < 0.) xy_x = -xy_x;
120 if ( lp_lat < 0.) xy_y = -xy_y;
121 }
122 }
123
124 static inline std::string get_name()
125 {
126 return "vandg2_spheroid";
127 }
128
129 };
130
131 // van der Grinten II
132 template <typename Parameters>
133 inline void setup_vandg2(Parameters& /*par*/, par_vandg2& proj_parm)
134 {
135 proj_parm.vdg3 = 0;
136 }
137
138 // van der Grinten III
139 template <typename Parameters>
140 inline void setup_vandg3(Parameters& par, par_vandg2& proj_parm)
141 {
142 proj_parm.vdg3 = 1;
143 par.es = 0.;
144 }
145
146 }} // namespace detail::vandg2
147 #endif // doxygen
148
149 /*!
150 \brief van der Grinten II projection
151 \ingroup projections
152 \tparam Geographic latlong point type
153 \tparam Cartesian xy point type
154 \tparam Parameters parameter type
155 \par Projection characteristics
156 - Miscellaneous
157 - Spheroid
158 - no inverse
159 \par Example
160 \image html ex_vandg2.gif
161 */
162 template <typename CalculationType, typename Parameters>
163 struct vandg2_spheroid : public detail::vandg2::base_vandg2_spheroid<CalculationType, Parameters>
164 {
165 inline vandg2_spheroid(const Parameters& par) : detail::vandg2::base_vandg2_spheroid<CalculationType, Parameters>(par)
166 {
167 detail::vandg2::setup_vandg2(this->m_par, this->m_proj_parm);
168 }
169 };
170
171 /*!
172 \brief van der Grinten III projection
173 \ingroup projections
174 \tparam Geographic latlong point type
175 \tparam Cartesian xy point type
176 \tparam Parameters parameter type
177 \par Projection characteristics
178 - Miscellaneous
179 - Spheroid
180 - no inverse
181 \par Example
182 \image html ex_vandg3.gif
183 */
184 template <typename CalculationType, typename Parameters>
185 struct vandg3_spheroid : public detail::vandg2::base_vandg2_spheroid<CalculationType, Parameters>
186 {
187 inline vandg3_spheroid(const Parameters& par) : detail::vandg2::base_vandg2_spheroid<CalculationType, Parameters>(par)
188 {
189 detail::vandg2::setup_vandg3(this->m_par, this->m_proj_parm);
190 }
191 };
192
193 #ifndef DOXYGEN_NO_DETAIL
194 namespace detail
195 {
196
197 // Static projection
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)
200
201 // Factory entry(s)
202 template <typename CalculationType, typename Parameters>
203 class vandg2_entry : public detail::factory_entry<CalculationType, Parameters>
204 {
205 public :
206 virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const
207 {
208 return new base_v_f<vandg2_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par);
209 }
210 };
211
212 template <typename CalculationType, typename Parameters>
213 class vandg3_entry : public detail::factory_entry<CalculationType, Parameters>
214 {
215 public :
216 virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const
217 {
218 return new base_v_f<vandg3_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par);
219 }
220 };
221
222 template <typename CalculationType, typename Parameters>
223 inline void vandg2_init(detail::base_factory<CalculationType, Parameters>& factory)
224 {
225 factory.add_to_factory("vandg2", new vandg2_entry<CalculationType, Parameters>);
226 factory.add_to_factory("vandg3", new vandg3_entry<CalculationType, Parameters>);
227 }
228
229 } // namespace detail
230 #endif // doxygen
231
232 } // namespace projections
233
234 }} // namespace boost::geometry
235
236 #endif // BOOST_GEOMETRY_PROJECTIONS_VANDG2_HPP
237