]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/srs/projections/proj/putp2.hpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / boost / geometry / srs / projections / proj / putp2.hpp
1 #ifndef BOOST_GEOMETRY_PROJECTIONS_PUTP2_HPP
2 #define BOOST_GEOMETRY_PROJECTIONS_PUTP2_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
50 namespace boost { namespace geometry
51 {
52
53 namespace srs { namespace par4
54 {
55 struct putp2 {};
56
57 }} //namespace srs::par4
58
59 namespace projections
60 {
61 #ifndef DOXYGEN_NO_DETAIL
62 namespace detail { namespace putp2
63 {
64
65 static const double C_x = 1.89490;
66 static const double C_y = 1.71848;
67 static const double C_p = 0.6141848493043784;
68 static const double EPS = 1e-10;
69 static const int NITER = 10;
70 //static const double PI_DIV_3 = 1.0471975511965977;
71
72 // template class, using CRTP to implement forward/inverse
73 template <typename CalculationType, typename Parameters>
74 struct base_putp2_spheroid : public base_t_fi<base_putp2_spheroid<CalculationType, Parameters>,
75 CalculationType, Parameters>
76 {
77
78 typedef CalculationType geographic_type;
79 typedef CalculationType cartesian_type;
80
81
82 inline base_putp2_spheroid(const Parameters& par)
83 : base_t_fi<base_putp2_spheroid<CalculationType, Parameters>,
84 CalculationType, Parameters>(*this, par) {}
85
86 // FORWARD(s_forward) spheroid
87 // Project coordinates from geographic (lon, lat) to cartesian (x, y)
88 inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
89 {
90 static const CalculationType PI_DIV_3 = detail::PI_DIV_3<CalculationType>();
91
92 CalculationType p, c, s, V;
93 int i;
94
95 p = C_p * sin(lp_lat);
96 s = lp_lat * lp_lat;
97 lp_lat *= 0.615709 + s * ( 0.00909953 + s * 0.0046292 );
98 for (i = NITER; i ; --i) {
99 c = cos(lp_lat);
100 s = sin(lp_lat);
101 lp_lat -= V = (lp_lat + s * (c - 1.) - p) /
102 (1. + c * (c - 1.) - s * s);
103 if (fabs(V) < EPS)
104 break;
105 }
106 if (!i)
107 lp_lat = lp_lat < 0 ? - PI_DIV_3 : PI_DIV_3;
108 xy_x = C_x * lp_lon * (cos(lp_lat) - 0.5);
109 xy_y = C_y * sin(lp_lat);
110 }
111
112 // INVERSE(s_inverse) spheroid
113 // Project coordinates from cartesian (x, y) to geographic (lon, lat)
114 inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
115 {
116 CalculationType c;
117
118 lp_lat = aasin(xy_y / C_y);
119 lp_lon = xy_x / (C_x * ((c = cos(lp_lat)) - 0.5));
120 lp_lat = aasin((lp_lat + sin(lp_lat) * (c - 1.)) / C_p);
121 }
122
123 static inline std::string get_name()
124 {
125 return "putp2_spheroid";
126 }
127
128 };
129
130 // Putnins P2
131 template <typename Parameters>
132 inline void setup_putp2(Parameters& par)
133 {
134 par.es = 0.;
135 }
136
137 }} // namespace detail::putp2
138 #endif // doxygen
139
140 /*!
141 \brief Putnins P2 projection
142 \ingroup projections
143 \tparam Geographic latlong point type
144 \tparam Cartesian xy point type
145 \tparam Parameters parameter type
146 \par Projection characteristics
147 - Pseudocylindrical
148 - Spheroid
149 \par Example
150 \image html ex_putp2.gif
151 */
152 template <typename CalculationType, typename Parameters>
153 struct putp2_spheroid : public detail::putp2::base_putp2_spheroid<CalculationType, Parameters>
154 {
155 inline putp2_spheroid(const Parameters& par) : detail::putp2::base_putp2_spheroid<CalculationType, Parameters>(par)
156 {
157 detail::putp2::setup_putp2(this->m_par);
158 }
159 };
160
161 #ifndef DOXYGEN_NO_DETAIL
162 namespace detail
163 {
164
165 // Static projection
166 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::putp2, putp2_spheroid, putp2_spheroid)
167
168 // Factory entry(s)
169 template <typename CalculationType, typename Parameters>
170 class putp2_entry : public detail::factory_entry<CalculationType, Parameters>
171 {
172 public :
173 virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const
174 {
175 return new base_v_fi<putp2_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par);
176 }
177 };
178
179 template <typename CalculationType, typename Parameters>
180 inline void putp2_init(detail::base_factory<CalculationType, Parameters>& factory)
181 {
182 factory.add_to_factory("putp2", new putp2_entry<CalculationType, Parameters>);
183 }
184
185 } // namespace detail
186 #endif // doxygen
187
188 } // namespace projections
189
190 }} // namespace boost::geometry
191
192 #endif // BOOST_GEOMETRY_PROJECTIONS_PUTP2_HPP
193