]>
Commit | Line | Data |
---|---|---|
92f5a8d4 | 1 | // Boost.Geometry - gis-projections (based on PROJ4) |
11fdf7f2 TL |
2 | |
3 | // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. | |
4 | ||
92f5a8d4 TL |
5 | // This file was modified by Oracle on 2017, 2018, 2019. |
6 | // Modifications copyright (c) 2017-2019, Oracle and/or its affiliates. | |
11fdf7f2 TL |
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 | ||
92f5a8d4 | 18 | // Last updated version of proj: 5.0.0 |
11fdf7f2 TL |
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 | ||
92f5a8d4 TL |
40 | #ifndef BOOST_GEOMETRY_PROJECTIONS_STS_HPP |
41 | #define BOOST_GEOMETRY_PROJECTIONS_STS_HPP | |
42 | ||
11fdf7f2 TL |
43 | #include <boost/geometry/srs/projections/impl/base_static.hpp> |
44 | #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> | |
45 | #include <boost/geometry/srs/projections/impl/projects.hpp> | |
46 | #include <boost/geometry/srs/projections/impl/factory_entry.hpp> | |
47 | #include <boost/geometry/srs/projections/impl/aasincos.hpp> | |
48 | ||
49 | namespace boost { namespace geometry | |
50 | { | |
51 | ||
11fdf7f2 TL |
52 | namespace projections |
53 | { | |
54 | #ifndef DOXYGEN_NO_DETAIL | |
55 | namespace detail { namespace sts | |
56 | { | |
57 | template <typename T> | |
58 | struct par_sts | |
59 | { | |
60 | T C_x, C_y, C_p; | |
92f5a8d4 | 61 | bool tan_mode; |
11fdf7f2 TL |
62 | }; |
63 | ||
92f5a8d4 TL |
64 | template <typename T, typename Parameters> |
65 | struct base_sts_spheroid | |
11fdf7f2 | 66 | { |
92f5a8d4 | 67 | par_sts<T> m_proj_parm; |
11fdf7f2 TL |
68 | |
69 | // FORWARD(s_forward) spheroid | |
70 | // Project coordinates from geographic (lon, lat) to cartesian (x, y) | |
92f5a8d4 | 71 | inline void fwd(Parameters const& , T const& lp_lon, T lp_lat, T& xy_x, T& xy_y) const |
11fdf7f2 | 72 | { |
92f5a8d4 | 73 | T c; |
11fdf7f2 TL |
74 | |
75 | xy_x = this->m_proj_parm.C_x * lp_lon * cos(lp_lat); | |
76 | xy_y = this->m_proj_parm.C_y; | |
77 | lp_lat *= this->m_proj_parm.C_p; | |
78 | c = cos(lp_lat); | |
79 | if (this->m_proj_parm.tan_mode) { | |
80 | xy_x *= c * c; | |
81 | xy_y *= tan(lp_lat); | |
82 | } else { | |
83 | xy_x /= c; | |
84 | xy_y *= sin(lp_lat); | |
85 | } | |
86 | } | |
87 | ||
88 | // INVERSE(s_inverse) spheroid | |
89 | // Project coordinates from cartesian (x, y) to geographic (lon, lat) | |
92f5a8d4 | 90 | inline void inv(Parameters const& , T const& xy_x, T xy_y, T& lp_lon, T& lp_lat) const |
11fdf7f2 | 91 | { |
92f5a8d4 | 92 | T c; |
11fdf7f2 TL |
93 | |
94 | xy_y /= this->m_proj_parm.C_y; | |
95 | c = cos(lp_lat = this->m_proj_parm.tan_mode ? atan(xy_y) : aasin(xy_y)); | |
96 | lp_lat /= this->m_proj_parm.C_p; | |
97 | lp_lon = xy_x / (this->m_proj_parm.C_x * cos(lp_lat)); | |
98 | if (this->m_proj_parm.tan_mode) | |
99 | lp_lon /= c * c; | |
100 | else | |
101 | lp_lon *= c; | |
102 | } | |
103 | ||
104 | static inline std::string get_name() | |
105 | { | |
106 | return "sts_spheroid"; | |
107 | } | |
108 | ||
109 | }; | |
110 | ||
111 | template <typename Parameters, typename T> | |
92f5a8d4 | 112 | inline void setup(Parameters& par, par_sts<T>& proj_parm, T const& p, T const& q, bool mode) |
11fdf7f2 TL |
113 | { |
114 | par.es = 0.; | |
115 | proj_parm.C_x = q / p; | |
116 | proj_parm.C_y = p; | |
117 | proj_parm.C_p = 1/ q; | |
118 | proj_parm.tan_mode = mode; | |
119 | } | |
120 | ||
121 | ||
92f5a8d4 TL |
122 | // Foucaut |
123 | template <typename Parameters, typename T> | |
124 | inline void setup_fouc(Parameters& par, par_sts<T>& proj_parm) | |
125 | { | |
126 | setup(par, proj_parm, 2., 2., true); | |
127 | } | |
128 | ||
11fdf7f2 TL |
129 | // Kavraisky V |
130 | template <typename Parameters, typename T> | |
131 | inline void setup_kav5(Parameters& par, par_sts<T>& proj_parm) | |
132 | { | |
92f5a8d4 | 133 | setup(par, proj_parm, 1.50488, 1.35439, false); |
11fdf7f2 TL |
134 | } |
135 | ||
136 | // Quartic Authalic | |
137 | template <typename Parameters, typename T> | |
138 | inline void setup_qua_aut(Parameters& par, par_sts<T>& proj_parm) | |
139 | { | |
92f5a8d4 | 140 | setup(par, proj_parm, 2., 2., false); |
11fdf7f2 TL |
141 | } |
142 | ||
143 | // McBryde-Thomas Flat-Polar Sine (No. 1) | |
144 | template <typename Parameters, typename T> | |
145 | inline void setup_mbt_s(Parameters& par, par_sts<T>& proj_parm) | |
146 | { | |
92f5a8d4 | 147 | setup(par, proj_parm, 1.48875, 1.36509, false); |
11fdf7f2 TL |
148 | } |
149 | ||
150 | }} // namespace detail::sts | |
151 | #endif // doxygen | |
152 | ||
153 | /*! | |
154 | \brief Kavraisky V projection | |
155 | \ingroup projections | |
156 | \tparam Geographic latlong point type | |
157 | \tparam Cartesian xy point type | |
158 | \tparam Parameters parameter type | |
159 | \par Projection characteristics | |
160 | - Pseudocylindrical | |
161 | - Spheroid | |
162 | \par Example | |
163 | \image html ex_kav5.gif | |
164 | */ | |
92f5a8d4 TL |
165 | template <typename T, typename Parameters> |
166 | struct kav5_spheroid : public detail::sts::base_sts_spheroid<T, Parameters> | |
11fdf7f2 | 167 | { |
92f5a8d4 TL |
168 | template <typename Params> |
169 | inline kav5_spheroid(Params const& , Parameters & par) | |
11fdf7f2 | 170 | { |
92f5a8d4 | 171 | detail::sts::setup_kav5(par, this->m_proj_parm); |
11fdf7f2 TL |
172 | } |
173 | }; | |
174 | ||
175 | /*! | |
176 | \brief Quartic Authalic projection | |
177 | \ingroup projections | |
178 | \tparam Geographic latlong point type | |
179 | \tparam Cartesian xy point type | |
180 | \tparam Parameters parameter type | |
181 | \par Projection characteristics | |
182 | - Pseudocylindrical | |
183 | - Spheroid | |
184 | \par Example | |
185 | \image html ex_qua_aut.gif | |
186 | */ | |
92f5a8d4 TL |
187 | template <typename T, typename Parameters> |
188 | struct qua_aut_spheroid : public detail::sts::base_sts_spheroid<T, Parameters> | |
11fdf7f2 | 189 | { |
92f5a8d4 TL |
190 | template <typename Params> |
191 | inline qua_aut_spheroid(Params const& , Parameters & par) | |
11fdf7f2 | 192 | { |
92f5a8d4 | 193 | detail::sts::setup_qua_aut(par, this->m_proj_parm); |
11fdf7f2 TL |
194 | } |
195 | }; | |
196 | ||
197 | /*! | |
198 | \brief McBryde-Thomas Flat-Polar Sine (No. 1) projection | |
199 | \ingroup projections | |
200 | \tparam Geographic latlong point type | |
201 | \tparam Cartesian xy point type | |
202 | \tparam Parameters parameter type | |
203 | \par Projection characteristics | |
204 | - Pseudocylindrical | |
205 | - Spheroid | |
206 | \par Example | |
207 | \image html ex_mbt_s.gif | |
208 | */ | |
92f5a8d4 TL |
209 | template <typename T, typename Parameters> |
210 | struct mbt_s_spheroid : public detail::sts::base_sts_spheroid<T, Parameters> | |
11fdf7f2 | 211 | { |
92f5a8d4 TL |
212 | template <typename Params> |
213 | inline mbt_s_spheroid(Params const& , Parameters & par) | |
11fdf7f2 | 214 | { |
92f5a8d4 | 215 | detail::sts::setup_mbt_s(par, this->m_proj_parm); |
11fdf7f2 TL |
216 | } |
217 | }; | |
218 | ||
219 | /*! | |
220 | \brief Foucaut projection | |
221 | \ingroup projections | |
222 | \tparam Geographic latlong point type | |
223 | \tparam Cartesian xy point type | |
224 | \tparam Parameters parameter type | |
225 | \par Projection characteristics | |
226 | - Pseudocylindrical | |
227 | - Spheroid | |
228 | \par Example | |
229 | \image html ex_fouc.gif | |
230 | */ | |
92f5a8d4 TL |
231 | template <typename T, typename Parameters> |
232 | struct fouc_spheroid : public detail::sts::base_sts_spheroid<T, Parameters> | |
11fdf7f2 | 233 | { |
92f5a8d4 TL |
234 | template <typename Params> |
235 | inline fouc_spheroid(Params const& , Parameters & par) | |
11fdf7f2 | 236 | { |
92f5a8d4 | 237 | detail::sts::setup_fouc(par, this->m_proj_parm); |
11fdf7f2 TL |
238 | } |
239 | }; | |
240 | ||
241 | #ifndef DOXYGEN_NO_DETAIL | |
242 | namespace detail | |
243 | { | |
244 | ||
245 | // Static projection | |
92f5a8d4 TL |
246 | BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_kav5, kav5_spheroid) |
247 | BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_qua_aut, qua_aut_spheroid) | |
248 | BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_mbt_s, mbt_s_spheroid) | |
249 | BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_fouc, fouc_spheroid) | |
11fdf7f2 TL |
250 | |
251 | // Factory entry(s) | |
92f5a8d4 TL |
252 | BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(kav5_entry, kav5_spheroid) |
253 | BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(qua_aut_entry, qua_aut_spheroid) | |
254 | BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(mbt_s_entry, mbt_s_spheroid) | |
255 | BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(fouc_entry, fouc_spheroid) | |
256 | ||
257 | BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(sts_init) | |
11fdf7f2 | 258 | { |
92f5a8d4 TL |
259 | BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(kav5, kav5_entry) |
260 | BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(qua_aut, qua_aut_entry) | |
261 | BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(mbt_s, mbt_s_entry) | |
262 | BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(fouc, fouc_entry) | |
11fdf7f2 TL |
263 | } |
264 | ||
265 | } // namespace detail | |
266 | #endif // doxygen | |
267 | ||
268 | } // namespace projections | |
269 | ||
270 | }} // namespace boost::geometry | |
271 | ||
272 | #endif // BOOST_GEOMETRY_PROJECTIONS_STS_HPP | |
273 |