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_BACON_HPP
41 #define BOOST_GEOMETRY_PROJECTIONS_BACON_HPP
43 #include <boost/geometry/util/math.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>
50 namespace boost { namespace geometry
55 #ifndef DOXYGEN_NO_DETAIL
56 namespace detail { namespace bacon
59 //static const double half_pi_sqr = 2.46740110027233965467;
60 static const double epsilon = 1e-10;
68 template <typename T, typename Parameters>
69 struct base_bacon_spheroid
71 par_bacon m_proj_parm;
73 // FORWARD(s_forward) spheroid
74 // Project coordinates from geographic (lon, lat) to cartesian (x, y)
75 inline void fwd(Parameters const& , T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
77 static const T half_pi = detail::half_pi<T>();
78 static const T half_pi_sqr = detail::half_pi_sqr<T>();
82 xy_y = this->m_proj_parm.bacn ? half_pi * sin(lp_lat) : lp_lat;
83 if ((ax = fabs(lp_lon)) >= epsilon) {
84 if (this->m_proj_parm.ortl && ax >= half_pi)
85 xy_x = sqrt(half_pi_sqr - lp_lat * lp_lat + epsilon) + ax - half_pi;
87 f = 0.5 * (half_pi_sqr / ax + ax);
88 xy_x = ax - f + sqrt(f * f - xy_y * xy_y);
90 if (lp_lon < 0.) xy_x = - xy_x;
95 static inline std::string get_name()
97 return "bacon_spheroid";
103 template <typename Parameters>
104 inline void setup_apian(Parameters& par, par_bacon& proj_parm)
106 proj_parm.bacn = proj_parm.ortl = false;
111 template <typename Parameters>
112 inline void setup_ortel(Parameters& par, par_bacon& proj_parm)
114 proj_parm.bacn = false;
115 proj_parm.ortl = true;
120 template <typename Parameters>
121 inline void setup_bacon(Parameters& par, par_bacon& proj_parm)
123 proj_parm.bacn = true;
124 proj_parm.ortl = false;
128 }} // namespace detail::bacon
132 \brief Apian Globular I projection
134 \tparam Geographic latlong point type
135 \tparam Cartesian xy point type
136 \tparam Parameters parameter type
137 \par Projection characteristics
142 \image html ex_apian.gif
144 template <typename T, typename Parameters>
145 struct apian_spheroid : public detail::bacon::base_bacon_spheroid<T, Parameters>
147 template <typename Params>
148 inline apian_spheroid(Params const& , Parameters & par)
150 detail::bacon::setup_apian(par, this->m_proj_parm);
155 \brief Ortelius Oval projection
157 \tparam Geographic latlong point type
158 \tparam Cartesian xy point type
159 \tparam Parameters parameter type
160 \par Projection characteristics
165 \image html ex_ortel.gif
167 template <typename T, typename Parameters>
168 struct ortel_spheroid : public detail::bacon::base_bacon_spheroid<T, Parameters>
170 template <typename Params>
171 inline ortel_spheroid(Params const& , Parameters & par)
173 detail::bacon::setup_ortel(par, this->m_proj_parm);
178 \brief Bacon Globular projection
180 \tparam Geographic latlong point type
181 \tparam Cartesian xy point type
182 \tparam Parameters parameter type
183 \par Projection characteristics
188 \image html ex_bacon.gif
190 template <typename T, typename Parameters>
191 struct bacon_spheroid : public detail::bacon::base_bacon_spheroid<T, Parameters>
193 template <typename Params>
194 inline bacon_spheroid(Params const& , Parameters & par)
196 detail::bacon::setup_bacon(par, this->m_proj_parm);
200 #ifndef DOXYGEN_NO_DETAIL
205 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_F(srs::spar::proj_apian, apian_spheroid)
206 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_F(srs::spar::proj_bacon, bacon_spheroid)
207 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_F(srs::spar::proj_ortel, ortel_spheroid)
210 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_F(apian_entry, apian_spheroid)
211 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_F(ortel_entry, ortel_spheroid)
212 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_F(bacon_entry, bacon_spheroid)
214 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(bacon_init)
216 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(apian, apian_entry)
217 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(ortel, ortel_entry)
218 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(bacon, bacon_entry)
221 } // namespace detail
224 } // namespace projections
226 }} // namespace boost::geometry
228 #endif // BOOST_GEOMETRY_PROJECTIONS_BACON_HPP