]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/srs/projections/proj/ocea.hpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / boost / geometry / srs / projections / proj / ocea.hpp
1 #ifndef BOOST_GEOMETRY_PROJECTIONS_OCEA_HPP
2 #define BOOST_GEOMETRY_PROJECTIONS_OCEA_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/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 ocea {};
57
58 }} //namespace srs::par4
59
60 namespace projections
61 {
62 #ifndef DOXYGEN_NO_DETAIL
63 namespace detail { namespace ocea
64 {
65 template <typename T>
66 struct par_ocea
67 {
68 T rok;
69 T rtk;
70 T sinphi;
71 T cosphi;
72 T singam;
73 T cosgam;
74 };
75
76 // template class, using CRTP to implement forward/inverse
77 template <typename CalculationType, typename Parameters>
78 struct base_ocea_spheroid : public base_t_fi<base_ocea_spheroid<CalculationType, Parameters>,
79 CalculationType, Parameters>
80 {
81
82 typedef CalculationType geographic_type;
83 typedef CalculationType cartesian_type;
84
85 par_ocea<CalculationType> m_proj_parm;
86
87 inline base_ocea_spheroid(const Parameters& par)
88 : base_t_fi<base_ocea_spheroid<CalculationType, Parameters>,
89 CalculationType, Parameters>(*this, par) {}
90
91 // FORWARD(s_forward) spheroid
92 // Project coordinates from geographic (lon, lat) to cartesian (x, y)
93 inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
94 {
95 static const CalculationType ONEPI = detail::ONEPI<CalculationType>();
96
97 CalculationType t;
98
99 xy_y = sin(lp_lon);
100 /*
101 xy_x = atan2((tan(lp_lat) * this->m_proj_parm.cosphi + this->m_proj_parm.sinphi * xy_y) , cos(lp_lon));
102 */
103 t = cos(lp_lon);
104 xy_x = atan((tan(lp_lat) * this->m_proj_parm.cosphi + this->m_proj_parm.sinphi * xy_y) / t);
105 if (t < 0.)
106 xy_x += ONEPI;
107 xy_x *= this->m_proj_parm.rtk;
108 xy_y = this->m_proj_parm.rok * (this->m_proj_parm.sinphi * sin(lp_lat) - this->m_proj_parm.cosphi * cos(lp_lat) * xy_y);
109 }
110
111 // INVERSE(s_inverse) spheroid
112 // Project coordinates from cartesian (x, y) to geographic (lon, lat)
113 inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
114 {
115 CalculationType t, s;
116
117 xy_y /= this->m_proj_parm.rok;
118 xy_x /= this->m_proj_parm.rtk;
119 t = sqrt(1. - xy_y * xy_y);
120 lp_lat = asin(xy_y * this->m_proj_parm.sinphi + t * this->m_proj_parm.cosphi * (s = sin(xy_x)));
121 lp_lon = atan2(t * this->m_proj_parm.sinphi * s - xy_y * this->m_proj_parm.cosphi,
122 t * cos(xy_x));
123 }
124
125 static inline std::string get_name()
126 {
127 return "ocea_spheroid";
128 }
129
130 };
131
132 // Oblique Cylindrical Equal Area
133 template <typename Parameters, typename T>
134 inline void setup_ocea(Parameters& par, par_ocea<T>& proj_parm)
135 {
136 static const T HALFPI = detail::HALFPI<T>();
137
138 T phi_0=0.0, phi_1, phi_2, lam_1, lam_2, lonz, alpha;
139
140 proj_parm.rok = 1. / par.k0;
141 proj_parm.rtk = par.k0;
142 if ( pj_param(par.params, "talpha").i) {
143 alpha = pj_param(par.params, "ralpha").f;
144 lonz = pj_param(par.params, "rlonc").f;
145 proj_parm.singam = atan(-cos(alpha)/(-sin(phi_0) * sin(alpha))) + lonz;
146 proj_parm.sinphi = asin(cos(phi_0) * sin(alpha));
147 } else {
148 phi_1 = pj_param(par.params, "rlat_1").f;
149 phi_2 = pj_param(par.params, "rlat_2").f;
150 lam_1 = pj_param(par.params, "rlon_1").f;
151 lam_2 = pj_param(par.params, "rlon_2").f;
152 proj_parm.singam = atan2(cos(phi_1) * sin(phi_2) * cos(lam_1) -
153 sin(phi_1) * cos(phi_2) * cos(lam_2),
154 sin(phi_1) * cos(phi_2) * sin(lam_2) -
155 cos(phi_1) * sin(phi_2) * sin(lam_1) );
156 if (lam_1 == -HALFPI)
157 proj_parm.singam = -proj_parm.singam;
158 proj_parm.sinphi = atan(-cos(proj_parm.singam - lam_1) / tan(phi_1));
159 }
160 par.lam0 = proj_parm.singam + HALFPI;
161 proj_parm.cosphi = cos(proj_parm.sinphi);
162 proj_parm.sinphi = sin(proj_parm.sinphi);
163 proj_parm.cosgam = cos(proj_parm.singam);
164 proj_parm.singam = sin(proj_parm.singam);
165 par.es = 0.;
166 }
167
168 }} // namespace detail::ocea
169 #endif // doxygen
170
171 /*!
172 \brief Oblique Cylindrical Equal Area 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 - Cylindrical
179 - Spheroid
180 \par Projection parameters
181 - lonc: Longitude (only used if alpha (or gamma) is specified) (degrees)
182 - alpha: Alpha (degrees)
183 - lat_1: Latitude of first standard parallel (degrees)
184 - lat_2: Latitude of second standard parallel (degrees)
185 - lon_1 (degrees)
186 - lon_2 (degrees)
187 \par Example
188 \image html ex_ocea.gif
189 */
190 template <typename CalculationType, typename Parameters>
191 struct ocea_spheroid : public detail::ocea::base_ocea_spheroid<CalculationType, Parameters>
192 {
193 inline ocea_spheroid(const Parameters& par) : detail::ocea::base_ocea_spheroid<CalculationType, Parameters>(par)
194 {
195 detail::ocea::setup_ocea(this->m_par, this->m_proj_parm);
196 }
197 };
198
199 #ifndef DOXYGEN_NO_DETAIL
200 namespace detail
201 {
202
203 // Static projection
204 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::ocea, ocea_spheroid, ocea_spheroid)
205
206 // Factory entry(s)
207 template <typename CalculationType, typename Parameters>
208 class ocea_entry : public detail::factory_entry<CalculationType, Parameters>
209 {
210 public :
211 virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const
212 {
213 return new base_v_fi<ocea_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par);
214 }
215 };
216
217 template <typename CalculationType, typename Parameters>
218 inline void ocea_init(detail::base_factory<CalculationType, Parameters>& factory)
219 {
220 factory.add_to_factory("ocea", new ocea_entry<CalculationType, Parameters>);
221 }
222
223 } // namespace detail
224 #endif // doxygen
225
226 } // namespace projections
227
228 }} // namespace boost::geometry
229
230 #endif // BOOST_GEOMETRY_PROJECTIONS_OCEA_HPP
231