]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/srs/projections/proj/boggs.hpp
6c371e430fc2956aeeb335b7df0aba05667021b2
[ceph.git] / ceph / src / boost / boost / geometry / srs / projections / proj / boggs.hpp
1 #ifndef BOOST_GEOMETRY_PROJECTIONS_BOGGS_HPP
2 #define BOOST_GEOMETRY_PROJECTIONS_BOGGS_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 boggs {};
57
58 }} //namespace srs::par4
59
60 namespace projections
61 {
62 #ifndef DOXYGEN_NO_DETAIL
63 namespace detail { namespace boggs
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 FXC = 2.00276;
70 static const double FXC2 = 1.11072;
71 static const double FYC = 0.49931;
72 static const double FYC2 = 1.41421356237309504880;
73
74 // template class, using CRTP to implement forward/inverse
75 template <typename CalculationType, typename Parameters>
76 struct base_boggs_spheroid : public base_t_f<base_boggs_spheroid<CalculationType, Parameters>,
77 CalculationType, Parameters>
78 {
79
80 typedef CalculationType geographic_type;
81 typedef CalculationType cartesian_type;
82
83
84 inline base_boggs_spheroid(const Parameters& par)
85 : base_t_f<base_boggs_spheroid<CalculationType, Parameters>,
86 CalculationType, Parameters>(*this, par) {}
87
88 // FORWARD(s_forward) spheroid
89 // Project coordinates from geographic (lon, lat) to cartesian (x, y)
90 inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
91 {
92 static const CalculationType HALFPI = detail::HALFPI<CalculationType>();
93 static const CalculationType ONEPI = detail::ONEPI<CalculationType>();
94
95 CalculationType theta, th1, c;
96 int i;
97
98 theta = lp_lat;
99 if (fabs(fabs(lp_lat) - HALFPI) < EPS)
100 xy_x = 0.;
101 else {
102 c = sin(theta) * ONEPI;
103 for (i = NITER; i; --i) {
104 theta -= th1 = (theta + sin(theta) - c) /
105 (1. + cos(theta));
106 if (fabs(th1) < EPS) break;
107 }
108 theta *= 0.5;
109 xy_x = FXC * lp_lon / (1. / cos(lp_lat) + FXC2 / cos(theta));
110 }
111 xy_y = FYC * (lp_lat + FYC2 * sin(theta));
112 }
113
114 static inline std::string get_name()
115 {
116 return "boggs_spheroid";
117 }
118
119 };
120
121 // Boggs Eumorphic
122 template <typename Parameters>
123 inline void setup_boggs(Parameters& par)
124 {
125 par.es = 0.;
126 }
127
128 }} // namespace detail::boggs
129 #endif // doxygen
130
131 /*!
132 \brief Boggs Eumorphic projection
133 \ingroup projections
134 \tparam Geographic latlong point type
135 \tparam Cartesian xy point type
136 \tparam Parameters parameter type
137 \par Projection characteristics
138 - Pseudocylindrical
139 - no inverse
140 - Spheroid
141 \par Example
142 \image html ex_boggs.gif
143 */
144 template <typename CalculationType, typename Parameters>
145 struct boggs_spheroid : public detail::boggs::base_boggs_spheroid<CalculationType, Parameters>
146 {
147 inline boggs_spheroid(const Parameters& par) : detail::boggs::base_boggs_spheroid<CalculationType, Parameters>(par)
148 {
149 detail::boggs::setup_boggs(this->m_par);
150 }
151 };
152
153 #ifndef DOXYGEN_NO_DETAIL
154 namespace detail
155 {
156
157 // Static projection
158 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::boggs, boggs_spheroid, boggs_spheroid)
159
160 // Factory entry(s)
161 template <typename CalculationType, typename Parameters>
162 class boggs_entry : public detail::factory_entry<CalculationType, Parameters>
163 {
164 public :
165 virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const
166 {
167 return new base_v_f<boggs_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par);
168 }
169 };
170
171 template <typename CalculationType, typename Parameters>
172 inline void boggs_init(detail::base_factory<CalculationType, Parameters>& factory)
173 {
174 factory.add_to_factory("boggs", new boggs_entry<CalculationType, Parameters>);
175 }
176
177 } // namespace detail
178 #endif // doxygen
179
180 } // namespace projections
181
182 }} // namespace boost::geometry
183
184 #endif // BOOST_GEOMETRY_PROJECTIONS_BOGGS_HPP
185