]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/srs/projections/proj/hatano.hpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / boost / geometry / srs / projections / proj / hatano.hpp
1 #ifndef BOOST_GEOMETRY_PROJECTIONS_HATANO_HPP
2 #define BOOST_GEOMETRY_PROJECTIONS_HATANO_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 hatano {};
57
58 }} //namespace srs::par4
59
60 namespace projections
61 {
62 #ifndef DOXYGEN_NO_DETAIL
63 namespace detail { namespace hatano
64 {
65
66 static const int NITER = 20;
67 static const double EPS = 1e-7;
68 static const double ONETOL = 1.000001;
69 static const double CN_ = 2.67595;
70 static const double CS_ = 2.43763;
71 static const double RCN = 0.37369906014686373063;
72 static const double RCS = 0.41023453108141924738;
73 static const double FYCN = 1.75859;
74 static const double FYCS = 1.93052;
75 static const double RYCN = 0.56863737426006061674;
76 static const double RYCS = 0.51799515156538134803;
77 static const double FXC = 0.85;
78 static const double RXC = 1.17647058823529411764;
79
80 // template class, using CRTP to implement forward/inverse
81 template <typename CalculationType, typename Parameters>
82 struct base_hatano_spheroid : public base_t_fi<base_hatano_spheroid<CalculationType, Parameters>,
83 CalculationType, Parameters>
84 {
85
86 typedef CalculationType geographic_type;
87 typedef CalculationType cartesian_type;
88
89
90 inline base_hatano_spheroid(const Parameters& par)
91 : base_t_fi<base_hatano_spheroid<CalculationType, Parameters>,
92 CalculationType, Parameters>(*this, par) {}
93
94 // FORWARD(s_forward) spheroid
95 // Project coordinates from geographic (lon, lat) to cartesian (x, y)
96 inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
97 {
98 CalculationType th1, c;
99 int i;
100
101 c = sin(lp_lat) * (lp_lat < 0. ? CS_ : CN_);
102 for (i = NITER; i; --i) {
103 lp_lat -= th1 = (lp_lat + sin(lp_lat) - c) / (1. + cos(lp_lat));
104 if (fabs(th1) < EPS) break;
105 }
106 xy_x = FXC * lp_lon * cos(lp_lat *= .5);
107 xy_y = sin(lp_lat) * (lp_lat < 0. ? FYCS : FYCN);
108 }
109
110 // INVERSE(s_inverse) spheroid
111 // Project coordinates from cartesian (x, y) to geographic (lon, lat)
112 inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
113 {
114 CalculationType th;
115
116 th = xy_y * ( xy_y < 0. ? RYCS : RYCN);
117 if (fabs(th) > 1.) {
118 if (fabs(th) > ONETOL) {
119 BOOST_THROW_EXCEPTION( projection_exception(-20) );
120 } else {
121 th = th > 0. ? geometry::math::half_pi<double>() : - geometry::math::half_pi<double>();
122 }
123 } else {
124 th = asin(th);
125 }
126
127 lp_lon = RXC * xy_x / cos(th);
128 th += th;
129 lp_lat = (th + sin(th)) * (xy_y < 0. ? RCS : RCN);
130 if (fabs(lp_lat) > 1.) {
131 if (fabs(lp_lat) > ONETOL) {
132 BOOST_THROW_EXCEPTION( projection_exception(-20) );
133 } else {
134 lp_lat = lp_lat > 0. ? geometry::math::half_pi<double>() : - geometry::math::half_pi<double>();
135 }
136 } else {
137 lp_lat = asin(lp_lat);
138 }
139 }
140
141 static inline std::string get_name()
142 {
143 return "hatano_spheroid";
144 }
145
146 };
147
148 // Hatano Asymmetrical Equal Area
149 template <typename Parameters>
150 inline void setup_hatano(Parameters& par)
151 {
152 par.es = 0.;
153 }
154
155 }} // namespace detail::hatano
156 #endif // doxygen
157
158 /*!
159 \brief Hatano Asymmetrical Equal Area projection
160 \ingroup projections
161 \tparam Geographic latlong point type
162 \tparam Cartesian xy point type
163 \tparam Parameters parameter type
164 \par Projection characteristics
165 - Pseudocylindrical
166 - Spheroid
167 \par Example
168 \image html ex_hatano.gif
169 */
170 template <typename CalculationType, typename Parameters>
171 struct hatano_spheroid : public detail::hatano::base_hatano_spheroid<CalculationType, Parameters>
172 {
173 inline hatano_spheroid(const Parameters& par) : detail::hatano::base_hatano_spheroid<CalculationType, Parameters>(par)
174 {
175 detail::hatano::setup_hatano(this->m_par);
176 }
177 };
178
179 #ifndef DOXYGEN_NO_DETAIL
180 namespace detail
181 {
182
183 // Static projection
184 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::hatano, hatano_spheroid, hatano_spheroid)
185
186 // Factory entry(s)
187 template <typename CalculationType, typename Parameters>
188 class hatano_entry : public detail::factory_entry<CalculationType, Parameters>
189 {
190 public :
191 virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const
192 {
193 return new base_v_fi<hatano_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par);
194 }
195 };
196
197 template <typename CalculationType, typename Parameters>
198 inline void hatano_init(detail::base_factory<CalculationType, Parameters>& factory)
199 {
200 factory.add_to_factory("hatano", new hatano_entry<CalculationType, Parameters>);
201 }
202
203 } // namespace detail
204 #endif // doxygen
205
206 } // namespace projections
207
208 }} // namespace boost::geometry
209
210 #endif // BOOST_GEOMETRY_PROJECTIONS_HATANO_HPP
211