]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/srs/projections/proj/oea.hpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / boost / geometry / srs / projections / proj / oea.hpp
1 #ifndef BOOST_GEOMETRY_PROJECTIONS_OEA_HPP
2 #define BOOST_GEOMETRY_PROJECTIONS_OEA_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.
10 // Modifications copyright (c) 2017, 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/math/special_functions/hypot.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 #include <boost/geometry/srs/projections/impl/aasincos.hpp>
51
52 namespace boost { namespace geometry
53 {
54
55 namespace srs { namespace par4
56 {
57 struct oea {};
58
59 }} //namespace srs::par4
60
61 namespace projections
62 {
63 #ifndef DOXYGEN_NO_DETAIL
64 namespace detail { namespace oea
65 {
66 template <typename T>
67 struct par_oea
68 {
69 T theta;
70 T m, n;
71 T two_r_m, two_r_n, rm, rn, hm, hn;
72 T cp0, sp0;
73 };
74
75 // template class, using CRTP to implement forward/inverse
76 template <typename CalculationType, typename Parameters>
77 struct base_oea_spheroid : public base_t_fi<base_oea_spheroid<CalculationType, Parameters>,
78 CalculationType, Parameters>
79 {
80
81 typedef CalculationType geographic_type;
82 typedef CalculationType cartesian_type;
83
84 par_oea<CalculationType> m_proj_parm;
85
86 inline base_oea_spheroid(const Parameters& par)
87 : base_t_fi<base_oea_spheroid<CalculationType, Parameters>,
88 CalculationType, Parameters>(*this, par) {}
89
90 // FORWARD(s_forward) sphere
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 CalculationType Az, M, N, cp, sp, cl, shz;
95
96 cp = cos(lp_lat);
97 sp = sin(lp_lat);
98 cl = cos(lp_lon);
99 Az = aatan2(cp * sin(lp_lon), this->m_proj_parm.cp0 * sp - this->m_proj_parm.sp0 * cp * cl) + this->m_proj_parm.theta;
100 shz = sin(0.5 * aacos(this->m_proj_parm.sp0 * sp + this->m_proj_parm.cp0 * cp * cl));
101 M = aasin(shz * sin(Az));
102 N = aasin(shz * cos(Az) * cos(M) / cos(M * this->m_proj_parm.two_r_m));
103 xy_y = this->m_proj_parm.n * sin(N * this->m_proj_parm.two_r_n);
104 xy_x = this->m_proj_parm.m * sin(M * this->m_proj_parm.two_r_m) * cos(N) / cos(N * this->m_proj_parm.two_r_n);
105 }
106
107 // INVERSE(s_inverse) sphere
108 // Project coordinates from cartesian (x, y) to geographic (lon, lat)
109 inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
110 {
111 CalculationType N, M, xp, yp, z, Az, cz, sz, cAz;
112
113 N = this->m_proj_parm.hn * aasin(xy_y * this->m_proj_parm.rn);
114 M = this->m_proj_parm.hm * aasin(xy_x * this->m_proj_parm.rm * cos(N * this->m_proj_parm.two_r_n) / cos(N));
115 xp = 2. * sin(M);
116 yp = 2. * sin(N) * cos(M * this->m_proj_parm.two_r_m) / cos(M);
117 cAz = cos(Az = aatan2(xp, yp) - this->m_proj_parm.theta);
118 z = 2. * aasin(0.5 * boost::math::hypot(xp, yp));
119 sz = sin(z);
120 cz = cos(z);
121 lp_lat = aasin(this->m_proj_parm.sp0 * cz + this->m_proj_parm.cp0 * sz * cAz);
122 lp_lon = aatan2(sz * sin(Az),
123 this->m_proj_parm.cp0 * cz - this->m_proj_parm.sp0 * sz * cAz);
124 }
125
126 static inline std::string get_name()
127 {
128 return "oea_spheroid";
129 }
130
131 };
132
133 // Oblated Equal Area
134 template <typename Parameters, typename T>
135 inline void setup_oea(Parameters& par, par_oea<T>& proj_parm)
136 {
137 if (((proj_parm.n = pj_param(par.params, "dn").f) <= 0.) ||
138 ((proj_parm.m = pj_param(par.params, "dm").f) <= 0.))
139 BOOST_THROW_EXCEPTION( projection_exception(-39) );
140 else {
141 proj_parm.theta = pj_param(par.params, "rtheta").f;
142 proj_parm.sp0 = sin(par.phi0);
143 proj_parm.cp0 = cos(par.phi0);
144 proj_parm.rn = 1./ proj_parm.n;
145 proj_parm.rm = 1./ proj_parm.m;
146 proj_parm.two_r_n = 2. * proj_parm.rn;
147 proj_parm.two_r_m = 2. * proj_parm.rm;
148 proj_parm.hm = 0.5 * proj_parm.m;
149 proj_parm.hn = 0.5 * proj_parm.n;
150 par.es = 0.;
151 }
152 }
153
154 }} // namespace detail::oea
155 #endif // doxygen
156
157 /*!
158 \brief Oblated Equal Area projection
159 \ingroup projections
160 \tparam Geographic latlong point type
161 \tparam Cartesian xy point type
162 \tparam Parameters parameter type
163 \par Projection characteristics
164 - Miscellaneous
165 - Spheroid
166 \par Projection parameters
167 - n (real)
168 - m (real)
169 - theta: Theta (degrees)
170 \par Example
171 \image html ex_oea.gif
172 */
173 template <typename CalculationType, typename Parameters>
174 struct oea_spheroid : public detail::oea::base_oea_spheroid<CalculationType, Parameters>
175 {
176 inline oea_spheroid(const Parameters& par) : detail::oea::base_oea_spheroid<CalculationType, Parameters>(par)
177 {
178 detail::oea::setup_oea(this->m_par, this->m_proj_parm);
179 }
180 };
181
182 #ifndef DOXYGEN_NO_DETAIL
183 namespace detail
184 {
185
186 // Static projection
187 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::oea, oea_spheroid, oea_spheroid)
188
189 // Factory entry(s)
190 template <typename CalculationType, typename Parameters>
191 class oea_entry : public detail::factory_entry<CalculationType, Parameters>
192 {
193 public :
194 virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const
195 {
196 return new base_v_fi<oea_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par);
197 }
198 };
199
200 template <typename CalculationType, typename Parameters>
201 inline void oea_init(detail::base_factory<CalculationType, Parameters>& factory)
202 {
203 factory.add_to_factory("oea", new oea_entry<CalculationType, Parameters>);
204 }
205
206 } // namespace detail
207 #endif // doxygen
208
209 } // namespace projections
210
211 }} // namespace boost::geometry
212
213 #endif // BOOST_GEOMETRY_PROJECTIONS_OEA_HPP
214