]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/geometry/srs/projections/proj/sts.hpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / boost / geometry / srs / projections / proj / sts.hpp
CommitLineData
11fdf7f2
TL
1#ifndef BOOST_GEOMETRY_PROJECTIONS_STS_HPP
2#define BOOST_GEOMETRY_PROJECTIONS_STS_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/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>
49
50namespace boost { namespace geometry
51{
52
53namespace srs { namespace par4
54{
55 struct kav5 {};
56 struct qua_aut {};
57 struct mbt_s {};
58 struct fouc {};
59
60}} //namespace srs::par4
61
62namespace projections
63{
64 #ifndef DOXYGEN_NO_DETAIL
65 namespace detail { namespace sts
66 {
67 template <typename T>
68 struct par_sts
69 {
70 T C_x, C_y, C_p;
71 int tan_mode;
72 };
73
74 // template class, using CRTP to implement forward/inverse
75 template <typename CalculationType, typename Parameters>
76 struct base_sts_spheroid : public base_t_fi<base_sts_spheroid<CalculationType, Parameters>,
77 CalculationType, Parameters>
78 {
79
80 typedef CalculationType geographic_type;
81 typedef CalculationType cartesian_type;
82
83 par_sts<CalculationType> m_proj_parm;
84
85 inline base_sts_spheroid(const Parameters& par)
86 : base_t_fi<base_sts_spheroid<CalculationType, Parameters>,
87 CalculationType, Parameters>(*this, par) {}
88
89 // FORWARD(s_forward) spheroid
90 // Project coordinates from geographic (lon, lat) to cartesian (x, y)
91 inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
92 {
93 CalculationType c;
94
95 xy_x = this->m_proj_parm.C_x * lp_lon * cos(lp_lat);
96 xy_y = this->m_proj_parm.C_y;
97 lp_lat *= this->m_proj_parm.C_p;
98 c = cos(lp_lat);
99 if (this->m_proj_parm.tan_mode) {
100 xy_x *= c * c;
101 xy_y *= tan(lp_lat);
102 } else {
103 xy_x /= c;
104 xy_y *= sin(lp_lat);
105 }
106 }
107
108 // INVERSE(s_inverse) spheroid
109 // Project coordinates from cartesian (x, y) to geographic (lon, lat)
110 inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
111 {
112 CalculationType c;
113
114 xy_y /= this->m_proj_parm.C_y;
115 c = cos(lp_lat = this->m_proj_parm.tan_mode ? atan(xy_y) : aasin(xy_y));
116 lp_lat /= this->m_proj_parm.C_p;
117 lp_lon = xy_x / (this->m_proj_parm.C_x * cos(lp_lat));
118 if (this->m_proj_parm.tan_mode)
119 lp_lon /= c * c;
120 else
121 lp_lon *= c;
122 }
123
124 static inline std::string get_name()
125 {
126 return "sts_spheroid";
127 }
128
129 };
130
131 template <typename Parameters, typename T>
132 inline void setup(Parameters& par, par_sts<T>& proj_parm, T const& p, T const& q, int mode)
133 {
134 par.es = 0.;
135 proj_parm.C_x = q / p;
136 proj_parm.C_y = p;
137 proj_parm.C_p = 1/ q;
138 proj_parm.tan_mode = mode;
139 }
140
141
142 // Kavraisky V
143 template <typename Parameters, typename T>
144 inline void setup_kav5(Parameters& par, par_sts<T>& proj_parm)
145 {
146 setup(par, proj_parm, 1.50488, 1.35439, 0);
147 }
148
149 // Quartic Authalic
150 template <typename Parameters, typename T>
151 inline void setup_qua_aut(Parameters& par, par_sts<T>& proj_parm)
152 {
153 setup(par, proj_parm, 2., 2., 0);
154 }
155
156 // McBryde-Thomas Flat-Polar Sine (No. 1)
157 template <typename Parameters, typename T>
158 inline void setup_mbt_s(Parameters& par, par_sts<T>& proj_parm)
159 {
160 setup(par, proj_parm, 1.48875, 1.36509, 0);
161 }
162
163 // Foucaut
164 template <typename Parameters, typename T>
165 inline void setup_fouc(Parameters& par, par_sts<T>& proj_parm)
166 {
167 setup(par, proj_parm, 2., 2., 1);
168 }
169
170 }} // namespace detail::sts
171 #endif // doxygen
172
173 /*!
174 \brief Kavraisky V projection
175 \ingroup projections
176 \tparam Geographic latlong point type
177 \tparam Cartesian xy point type
178 \tparam Parameters parameter type
179 \par Projection characteristics
180 - Pseudocylindrical
181 - Spheroid
182 \par Example
183 \image html ex_kav5.gif
184 */
185 template <typename CalculationType, typename Parameters>
186 struct kav5_spheroid : public detail::sts::base_sts_spheroid<CalculationType, Parameters>
187 {
188 inline kav5_spheroid(const Parameters& par) : detail::sts::base_sts_spheroid<CalculationType, Parameters>(par)
189 {
190 detail::sts::setup_kav5(this->m_par, this->m_proj_parm);
191 }
192 };
193
194 /*!
195 \brief Quartic Authalic projection
196 \ingroup projections
197 \tparam Geographic latlong point type
198 \tparam Cartesian xy point type
199 \tparam Parameters parameter type
200 \par Projection characteristics
201 - Pseudocylindrical
202 - Spheroid
203 \par Example
204 \image html ex_qua_aut.gif
205 */
206 template <typename CalculationType, typename Parameters>
207 struct qua_aut_spheroid : public detail::sts::base_sts_spheroid<CalculationType, Parameters>
208 {
209 inline qua_aut_spheroid(const Parameters& par) : detail::sts::base_sts_spheroid<CalculationType, Parameters>(par)
210 {
211 detail::sts::setup_qua_aut(this->m_par, this->m_proj_parm);
212 }
213 };
214
215 /*!
216 \brief McBryde-Thomas Flat-Polar Sine (No. 1) projection
217 \ingroup projections
218 \tparam Geographic latlong point type
219 \tparam Cartesian xy point type
220 \tparam Parameters parameter type
221 \par Projection characteristics
222 - Pseudocylindrical
223 - Spheroid
224 \par Example
225 \image html ex_mbt_s.gif
226 */
227 template <typename CalculationType, typename Parameters>
228 struct mbt_s_spheroid : public detail::sts::base_sts_spheroid<CalculationType, Parameters>
229 {
230 inline mbt_s_spheroid(const Parameters& par) : detail::sts::base_sts_spheroid<CalculationType, Parameters>(par)
231 {
232 detail::sts::setup_mbt_s(this->m_par, this->m_proj_parm);
233 }
234 };
235
236 /*!
237 \brief Foucaut projection
238 \ingroup projections
239 \tparam Geographic latlong point type
240 \tparam Cartesian xy point type
241 \tparam Parameters parameter type
242 \par Projection characteristics
243 - Pseudocylindrical
244 - Spheroid
245 \par Example
246 \image html ex_fouc.gif
247 */
248 template <typename CalculationType, typename Parameters>
249 struct fouc_spheroid : public detail::sts::base_sts_spheroid<CalculationType, Parameters>
250 {
251 inline fouc_spheroid(const Parameters& par) : detail::sts::base_sts_spheroid<CalculationType, Parameters>(par)
252 {
253 detail::sts::setup_fouc(this->m_par, this->m_proj_parm);
254 }
255 };
256
257 #ifndef DOXYGEN_NO_DETAIL
258 namespace detail
259 {
260
261 // Static projection
262 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::kav5, kav5_spheroid, kav5_spheroid)
263 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::qua_aut, qua_aut_spheroid, qua_aut_spheroid)
264 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::mbt_s, mbt_s_spheroid, mbt_s_spheroid)
265 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::fouc, fouc_spheroid, fouc_spheroid)
266
267 // Factory entry(s)
268 template <typename CalculationType, typename Parameters>
269 class kav5_entry : public detail::factory_entry<CalculationType, Parameters>
270 {
271 public :
272 virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const
273 {
274 return new base_v_fi<kav5_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par);
275 }
276 };
277
278 template <typename CalculationType, typename Parameters>
279 class qua_aut_entry : public detail::factory_entry<CalculationType, Parameters>
280 {
281 public :
282 virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const
283 {
284 return new base_v_fi<qua_aut_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par);
285 }
286 };
287
288 template <typename CalculationType, typename Parameters>
289 class mbt_s_entry : public detail::factory_entry<CalculationType, Parameters>
290 {
291 public :
292 virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const
293 {
294 return new base_v_fi<mbt_s_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par);
295 }
296 };
297
298 template <typename CalculationType, typename Parameters>
299 class fouc_entry : public detail::factory_entry<CalculationType, Parameters>
300 {
301 public :
302 virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const
303 {
304 return new base_v_fi<fouc_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par);
305 }
306 };
307
308 template <typename CalculationType, typename Parameters>
309 inline void sts_init(detail::base_factory<CalculationType, Parameters>& factory)
310 {
311 factory.add_to_factory("kav5", new kav5_entry<CalculationType, Parameters>);
312 factory.add_to_factory("qua_aut", new qua_aut_entry<CalculationType, Parameters>);
313 factory.add_to_factory("mbt_s", new mbt_s_entry<CalculationType, Parameters>);
314 factory.add_to_factory("fouc", new fouc_entry<CalculationType, Parameters>);
315 }
316
317 } // namespace detail
318 #endif // doxygen
319
320} // namespace projections
321
322}} // namespace boost::geometry
323
324#endif // BOOST_GEOMETRY_PROJECTIONS_STS_HPP
325