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_ECK3_HPP
41 #define BOOST_GEOMETRY_PROJECTIONS_ECK3_HPP
43 #include <boost/core/ignore_unused.hpp>
45 #include <boost/geometry/srs/projections/impl/base_static.hpp>
46 #include <boost/geometry/srs/projections/impl/base_dynamic.hpp>
47 #include <boost/geometry/srs/projections/impl/projects.hpp>
48 #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
49 #include <boost/geometry/srs/projections/impl/aasincos.hpp>
51 namespace boost { namespace geometry
56 #ifndef DOXYGEN_NO_DETAIL
57 namespace detail { namespace eck3
66 template <typename T, typename Parameters>
67 struct base_eck3_spheroid
69 par_eck3<T> m_proj_parm;
71 // FORWARD(s_forward) spheroid
72 // Project coordinates from geographic (lon, lat) to cartesian (x, y)
73 inline void fwd(Parameters const& , T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
75 xy_y = this->m_proj_parm.C_y * lp_lat;
76 xy_x = this->m_proj_parm.C_x * lp_lon * (this->m_proj_parm.A + asqrt(1. - this->m_proj_parm.B * lp_lat * lp_lat));
79 // INVERSE(s_inverse) spheroid
80 // Project coordinates from cartesian (x, y) to geographic (lon, lat)
81 inline void inv(Parameters const& , T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
84 lp_lat = xy_y / this->m_proj_parm.C_y;
85 denominator = (this->m_proj_parm.C_x * (this->m_proj_parm.A + asqrt(1. - this->m_proj_parm.B * lp_lat * lp_lat)));
86 if ( denominator == 0.0) {
90 lp_lon = xy_x / denominator;
93 static inline std::string get_name()
95 return "eck3_spheroid";
100 template <typename Parameters>
101 inline void setup(Parameters& par)
108 template <typename Parameters, typename T>
109 inline void setup_eck3(Parameters& par, par_eck3<T>& proj_parm)
111 proj_parm.C_x = 0.42223820031577120149;
112 proj_parm.C_y = 0.84447640063154240298;
114 proj_parm.B = 0.4052847345693510857755;
120 template <typename Parameters, typename T>
121 inline void setup_putp1(Parameters& par, par_eck3<T>& proj_parm)
123 proj_parm.C_x = 1.89490;
124 proj_parm.C_y = 0.94745;
126 proj_parm.B = 0.30396355092701331433;
132 template <typename Parameters, typename T>
133 inline void setup_wag6(Parameters& par, par_eck3<T>& proj_parm)
135 proj_parm.C_x = proj_parm.C_y = 0.94745;
137 proj_parm.B = 0.30396355092701331433;
143 template <typename Parameters, typename T>
144 inline void setup_kav7(Parameters& par, par_eck3<T>& proj_parm)
146 /* Defined twice in original code - Using 0.866...,
147 * but leaving the other one here as a safety measure.
148 * proj_parm.C_x = 0.2632401569273184856851; */
149 proj_parm.C_x = 0.8660254037844;
152 proj_parm.B = 0.30396355092701331433;
157 }} // namespace detail::eck3
161 \brief Eckert III projection
163 \tparam Geographic latlong point type
164 \tparam Cartesian xy point type
165 \tparam Parameters parameter type
166 \par Projection characteristics
170 \image html ex_eck3.gif
172 template <typename T, typename Parameters>
173 struct eck3_spheroid : public detail::eck3::base_eck3_spheroid<T, Parameters>
175 template <typename Params>
176 inline eck3_spheroid(Params const& , Parameters & par)
178 detail::eck3::setup_eck3(par, this->m_proj_parm);
183 \brief Putnins P1 projection
185 \tparam Geographic latlong point type
186 \tparam Cartesian xy point type
187 \tparam Parameters parameter type
188 \par Projection characteristics
192 \image html ex_putp1.gif
194 template <typename T, typename Parameters>
195 struct putp1_spheroid : public detail::eck3::base_eck3_spheroid<T, Parameters>
197 template <typename Params>
198 inline putp1_spheroid(Params const& , Parameters & par)
200 detail::eck3::setup_putp1(par, this->m_proj_parm);
205 \brief Wagner VI projection
207 \tparam Geographic latlong point type
208 \tparam Cartesian xy point type
209 \tparam Parameters parameter type
210 \par Projection characteristics
214 \image html ex_wag6.gif
216 template <typename T, typename Parameters>
217 struct wag6_spheroid : public detail::eck3::base_eck3_spheroid<T, Parameters>
219 template <typename Params>
220 inline wag6_spheroid(Params const& , Parameters & par)
222 detail::eck3::setup_wag6(par, this->m_proj_parm);
227 \brief Kavraisky VII projection
229 \tparam Geographic latlong point type
230 \tparam Cartesian xy point type
231 \tparam Parameters parameter type
232 \par Projection characteristics
236 \image html ex_kav7.gif
238 template <typename T, typename Parameters>
239 struct kav7_spheroid : public detail::eck3::base_eck3_spheroid<T, Parameters>
241 template <typename Params>
242 inline kav7_spheroid(Params const& , Parameters & par)
244 detail::eck3::setup_kav7(par, this->m_proj_parm);
248 #ifndef DOXYGEN_NO_DETAIL
253 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_eck3, eck3_spheroid)
254 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_putp1, putp1_spheroid)
255 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_wag6, wag6_spheroid)
256 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_kav7, kav7_spheroid)
259 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(eck3_entry, eck3_spheroid)
260 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(putp1_entry, putp1_spheroid)
261 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(wag6_entry, wag6_spheroid)
262 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(kav7_entry, kav7_spheroid)
264 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(eck3_init)
266 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(eck3, eck3_entry);
267 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(putp1, putp1_entry);
268 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(wag6, wag6_entry);
269 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(kav7, kav7_entry);
272 } // namespace detail
275 } // namespace projections
277 }} // namespace boost::geometry
279 #endif // BOOST_GEOMETRY_PROJECTIONS_ECK3_HPP