]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/srs/projections/proj/urmfps.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / geometry / srs / projections / proj / urmfps.hpp
1 // Boost.Geometry - gis-projections (based on PROJ4)
2
3 // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands.
4
5 // This file was modified by Oracle on 2017, 2018, 2019.
6 // Modifications copyright (c) 2017-2019, Oracle and/or its affiliates.
7 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle.
8
9 // Use, modification and distribution is subject to the Boost Software License,
10 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
11 // http://www.boost.org/LICENSE_1_0.txt)
12
13 // This file is converted from PROJ4, http://trac.osgeo.org/proj
14 // PROJ4 is originally written by Gerald Evenden (then of the USGS)
15 // PROJ4 is maintained by Frank Warmerdam
16 // PROJ4 is converted to Boost.Geometry by Barend Gehrels
17
18 // Last updated version of proj: 5.0.0
19
20 // Original copyright notice:
21
22 // Permission is hereby granted, free of charge, to any person obtaining a
23 // copy of this software and associated documentation files (the "Software"),
24 // to deal in the Software without restriction, including without limitation
25 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
26 // and/or sell copies of the Software, and to permit persons to whom the
27 // Software is furnished to do so, subject to the following conditions:
28
29 // The above copyright notice and this permission notice shall be included
30 // in all copies or substantial portions of the Software.
31
32 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
33 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
35 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
37 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
38 // DEALINGS IN THE SOFTWARE.
39
40 #ifndef BOOST_GEOMETRY_PROJECTIONS_URMFPS_HPP
41 #define BOOST_GEOMETRY_PROJECTIONS_URMFPS_HPP
42
43 #include <boost/geometry/srs/projections/impl/aasincos.hpp>
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/factory_entry.hpp>
47 #include <boost/geometry/srs/projections/impl/pj_param.hpp>
48 #include <boost/geometry/srs/projections/impl/projects.hpp>
49
50 namespace boost { namespace geometry
51 {
52
53 namespace projections
54 {
55 #ifndef DOXYGEN_NO_DETAIL
56 namespace detail { namespace urmfps
57 {
58
59 static const double C_x = 0.8773826753;
60 static const double Cy = 1.139753528477;
61
62 template <typename T>
63 struct par_urmfps
64 {
65 T n, C_y;
66 };
67
68 template <typename T, typename Parameters>
69 struct base_urmfps_spheroid
70 {
71 par_urmfps<T> m_proj_parm;
72
73 // FORWARD(s_forward) sphere
74 // Project coordinates from geographic (lon, lat) to cartesian (x, y)
75 inline void fwd(Parameters const& , T const& lp_lon, T lp_lat, T& xy_x, T& xy_y) const
76 {
77 lp_lat = aasin(this->m_proj_parm.n * sin(lp_lat));
78 xy_x = C_x * lp_lon * cos(lp_lat);
79 xy_y = this->m_proj_parm.C_y * lp_lat;
80 }
81
82 // INVERSE(s_inverse) sphere
83 // Project coordinates from cartesian (x, y) to geographic (lon, lat)
84 inline void inv(Parameters const& , T const& xy_x, T xy_y, T& lp_lon, T& lp_lat) const
85 {
86 xy_y /= this->m_proj_parm.C_y;
87 lp_lat = aasin(sin(xy_y) / this->m_proj_parm.n);
88 lp_lon = xy_x / (C_x * cos(xy_y));
89 }
90
91 static inline std::string get_name()
92 {
93 return "urmfps_spheroid";
94 }
95
96 };
97
98 template <typename Parameters, typename T>
99 inline void setup(Parameters& par, par_urmfps<T>& proj_parm)
100 {
101 proj_parm.C_y = Cy / proj_parm.n;
102 par.es = 0.;
103 }
104
105
106 // Urmaev Flat-Polar Sinusoidal
107 template <typename Params, typename Parameters, typename T>
108 inline void setup_urmfps(Params const& params, Parameters& par, par_urmfps<T>& proj_parm)
109 {
110 if (pj_param_f<srs::spar::n>(params, "n", srs::dpar::n, proj_parm.n)) {
111 if (proj_parm.n <= 0. || proj_parm.n > 1.)
112 BOOST_THROW_EXCEPTION( projection_exception(error_n_out_of_range) );
113 } else
114 BOOST_THROW_EXCEPTION( projection_exception(error_n_out_of_range) );
115
116 setup(par, proj_parm);
117 }
118
119 // Wagner I (Kavraisky VI)
120 template <typename Parameters, typename T>
121 inline void setup_wag1(Parameters& par, par_urmfps<T>& proj_parm)
122 {
123 proj_parm.n = 0.8660254037844386467637231707;
124 setup(par, proj_parm);
125 }
126
127 }} // namespace detail::urmfps
128 #endif // doxygen
129
130 /*!
131 \brief Urmaev Flat-Polar Sinusoidal projection
132 \ingroup projections
133 \tparam Geographic latlong point type
134 \tparam Cartesian xy point type
135 \tparam Parameters parameter type
136 \par Projection characteristics
137 - Pseudocylindrical
138 - Spheroid
139 \par Projection parameters
140 - n (real)
141 \par Example
142 \image html ex_urmfps.gif
143 */
144 template <typename T, typename Parameters>
145 struct urmfps_spheroid : public detail::urmfps::base_urmfps_spheroid<T, Parameters>
146 {
147 template <typename Params>
148 inline urmfps_spheroid(Params const& params, Parameters & par)
149 {
150 detail::urmfps::setup_urmfps(params, par, this->m_proj_parm);
151 }
152 };
153
154 /*!
155 \brief Wagner I (Kavraisky VI) projection
156 \ingroup projections
157 \tparam Geographic latlong point type
158 \tparam Cartesian xy point type
159 \tparam Parameters parameter type
160 \par Projection characteristics
161 - Pseudocylindrical
162 - Spheroid
163 \par Example
164 \image html ex_wag1.gif
165 */
166 template <typename T, typename Parameters>
167 struct wag1_spheroid : public detail::urmfps::base_urmfps_spheroid<T, Parameters>
168 {
169 template <typename Params>
170 inline wag1_spheroid(Params const& , Parameters & par)
171 {
172 detail::urmfps::setup_wag1(par, this->m_proj_parm);
173 }
174 };
175
176 #ifndef DOXYGEN_NO_DETAIL
177 namespace detail
178 {
179
180 // Static projection
181 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_urmfps, urmfps_spheroid)
182 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_wag1, wag1_spheroid)
183
184 // Factory entry(s)
185 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(urmfps_entry, urmfps_spheroid)
186 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(wag1_entry, wag1_spheroid)
187
188 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(urmfps_init)
189 {
190 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(urmfps, urmfps_entry)
191 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(wag1, wag1_entry)
192 }
193
194 } // namespace detail
195 #endif // doxygen
196
197 } // namespace projections
198
199 }} // namespace boost::geometry
200
201 #endif // BOOST_GEOMETRY_PROJECTIONS_URMFPS_HPP
202