1 // Boost.Geometry - gis-projections (based on PROJ4)
3 // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands.
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.
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)
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
18 // Last updated version of proj: 5.0.0
20 // Original copyright notice:
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:
29 // The above copyright notice and this permission notice shall be included
30 // in all copies or substantial portions of the Software.
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.
40 #ifndef BOOST_GEOMETRY_PROJECTIONS_STS_HPP
41 #define BOOST_GEOMETRY_PROJECTIONS_STS_HPP
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>
49 namespace boost { namespace geometry
54 #ifndef DOXYGEN_NO_DETAIL
55 namespace detail { namespace sts
64 template <typename T, typename Parameters>
65 struct base_sts_spheroid
67 par_sts<T> m_proj_parm;
69 // FORWARD(s_forward) spheroid
70 // Project coordinates from geographic (lon, lat) to cartesian (x, y)
71 inline void fwd(Parameters const& , T const& lp_lon, T lp_lat, T& xy_x, T& xy_y) const
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;
79 if (this->m_proj_parm.tan_mode) {
88 // INVERSE(s_inverse) spheroid
89 // Project coordinates from cartesian (x, y) to geographic (lon, lat)
90 inline void inv(Parameters const& , T const& xy_x, T xy_y, T& lp_lon, T& lp_lat) const
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)
104 static inline std::string get_name()
106 return "sts_spheroid";
111 template <typename Parameters, typename T>
112 inline void setup(Parameters& par, par_sts<T>& proj_parm, T const& p, T const& q, bool mode)
115 proj_parm.C_x = q / p;
117 proj_parm.C_p = 1/ q;
118 proj_parm.tan_mode = mode;
123 template <typename Parameters, typename T>
124 inline void setup_fouc(Parameters& par, par_sts<T>& proj_parm)
126 setup(par, proj_parm, 2., 2., true);
130 template <typename Parameters, typename T>
131 inline void setup_kav5(Parameters& par, par_sts<T>& proj_parm)
133 setup(par, proj_parm, 1.50488, 1.35439, false);
137 template <typename Parameters, typename T>
138 inline void setup_qua_aut(Parameters& par, par_sts<T>& proj_parm)
140 setup(par, proj_parm, 2., 2., false);
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)
147 setup(par, proj_parm, 1.48875, 1.36509, false);
150 }} // namespace detail::sts
154 \brief Kavraisky V projection
156 \tparam Geographic latlong point type
157 \tparam Cartesian xy point type
158 \tparam Parameters parameter type
159 \par Projection characteristics
163 \image html ex_kav5.gif
165 template <typename T, typename Parameters>
166 struct kav5_spheroid : public detail::sts::base_sts_spheroid<T, Parameters>
168 template <typename Params>
169 inline kav5_spheroid(Params const& , Parameters & par)
171 detail::sts::setup_kav5(par, this->m_proj_parm);
176 \brief Quartic Authalic projection
178 \tparam Geographic latlong point type
179 \tparam Cartesian xy point type
180 \tparam Parameters parameter type
181 \par Projection characteristics
185 \image html ex_qua_aut.gif
187 template <typename T, typename Parameters>
188 struct qua_aut_spheroid : public detail::sts::base_sts_spheroid<T, Parameters>
190 template <typename Params>
191 inline qua_aut_spheroid(Params const& , Parameters & par)
193 detail::sts::setup_qua_aut(par, this->m_proj_parm);
198 \brief McBryde-Thomas Flat-Polar Sine (No. 1) projection
200 \tparam Geographic latlong point type
201 \tparam Cartesian xy point type
202 \tparam Parameters parameter type
203 \par Projection characteristics
207 \image html ex_mbt_s.gif
209 template <typename T, typename Parameters>
210 struct mbt_s_spheroid : public detail::sts::base_sts_spheroid<T, Parameters>
212 template <typename Params>
213 inline mbt_s_spheroid(Params const& , Parameters & par)
215 detail::sts::setup_mbt_s(par, this->m_proj_parm);
220 \brief Foucaut projection
222 \tparam Geographic latlong point type
223 \tparam Cartesian xy point type
224 \tparam Parameters parameter type
225 \par Projection characteristics
229 \image html ex_fouc.gif
231 template <typename T, typename Parameters>
232 struct fouc_spheroid : public detail::sts::base_sts_spheroid<T, Parameters>
234 template <typename Params>
235 inline fouc_spheroid(Params const& , Parameters & par)
237 detail::sts::setup_fouc(par, this->m_proj_parm);
241 #ifndef DOXYGEN_NO_DETAIL
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)
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)
257 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(sts_init)
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)
265 } // namespace detail
268 } // namespace projections
270 }} // namespace boost::geometry
272 #endif // BOOST_GEOMETRY_PROJECTIONS_STS_HPP