Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:40

0001 // Boost.Geometry - gis-projections (based on PROJ4)
0002 
0003 // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands.
0004 
0005 // This file was modified by Oracle on 2017, 2018, 2019.
0006 // Modifications copyright (c) 2017-2019, Oracle and/or its affiliates.
0007 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle.
0008 
0009 // Use, modification and distribution is subject to the Boost Software License,
0010 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0011 // http://www.boost.org/LICENSE_1_0.txt)
0012 
0013 // This file is converted from PROJ4, http://trac.osgeo.org/proj
0014 // PROJ4 is originally written by Gerald Evenden (then of the USGS)
0015 // PROJ4 is maintained by Frank Warmerdam
0016 // PROJ4 is converted to Boost.Geometry by Barend Gehrels
0017 
0018 // Last updated version of proj: 5.0.0
0019 
0020 // Original copyright notice:
0021 
0022 // Permission is hereby granted, free of charge, to any person obtaining a
0023 // copy of this software and associated documentation files (the "Software"),
0024 // to deal in the Software without restriction, including without limitation
0025 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
0026 // and/or sell copies of the Software, and to permit persons to whom the
0027 // Software is furnished to do so, subject to the following conditions:
0028 
0029 // The above copyright notice and this permission notice shall be included
0030 // in all copies or substantial portions of the Software.
0031 
0032 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
0033 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0034 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
0035 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
0036 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
0037 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
0038 // DEALINGS IN THE SOFTWARE.
0039 
0040 #ifndef BOOST_GEOMETRY_PROJECTIONS_BACON_HPP
0041 #define BOOST_GEOMETRY_PROJECTIONS_BACON_HPP
0042 
0043 #include <boost/geometry/util/math.hpp>
0044 
0045 #include <boost/geometry/srs/projections/impl/base_static.hpp>
0046 #include <boost/geometry/srs/projections/impl/base_dynamic.hpp>
0047 #include <boost/geometry/srs/projections/impl/projects.hpp>
0048 #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
0049 
0050 namespace boost { namespace geometry
0051 {
0052 
0053 namespace projections
0054 {
0055     #ifndef DOXYGEN_NO_DETAIL
0056     namespace detail { namespace bacon
0057     {
0058 
0059             //static const double half_pi_sqr = 2.46740110027233965467;
0060             static const double epsilon = 1e-10;
0061 
0062             struct par_bacon
0063             {
0064                 bool bacn;
0065                 bool ortl;
0066             };
0067 
0068             template <typename T, typename Parameters>
0069             struct base_bacon_spheroid
0070             {
0071                 par_bacon m_proj_parm;
0072 
0073                 // FORWARD(s_forward)  spheroid
0074                 // Project coordinates from geographic (lon, lat) to cartesian (x, y)
0075                 inline void fwd(Parameters const& , T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
0076                 {
0077                     static const T half_pi = detail::half_pi<T>();
0078                     static const T half_pi_sqr = detail::half_pi_sqr<T>();
0079 
0080                     T ax, f;
0081 
0082                     xy_y = this->m_proj_parm.bacn ? half_pi * sin(lp_lat) : lp_lat;
0083                     if ((ax = fabs(lp_lon)) >= epsilon) {
0084                         if (this->m_proj_parm.ortl && ax >= half_pi)
0085                             xy_x = sqrt(half_pi_sqr - lp_lat * lp_lat + epsilon) + ax - half_pi;
0086                         else {
0087                             f = 0.5 * (half_pi_sqr / ax + ax);
0088                             xy_x = ax - f + sqrt(f * f - xy_y * xy_y);
0089                         }
0090                         if (lp_lon < 0.) xy_x = - xy_x;
0091                     } else
0092                         xy_x = 0.;
0093                 }
0094 
0095                 static inline std::string get_name()
0096                 {
0097                     return "bacon_spheroid";
0098                 }
0099 
0100             };
0101 
0102             // Apian Globular I
0103             template <typename Parameters>
0104             inline void setup_apian(Parameters& par, par_bacon& proj_parm)
0105             {
0106                 proj_parm.bacn = proj_parm.ortl = false;
0107                 par.es = 0.;
0108             }
0109 
0110             // Ortelius Oval
0111             template <typename Parameters>
0112             inline void setup_ortel(Parameters& par, par_bacon& proj_parm)
0113             {
0114                 proj_parm.bacn = false;
0115                 proj_parm.ortl = true;
0116                 par.es = 0.;
0117             }
0118 
0119             // Bacon Globular
0120             template <typename Parameters>
0121             inline void setup_bacon(Parameters& par, par_bacon& proj_parm)
0122             {
0123                 proj_parm.bacn = true;
0124                 proj_parm.ortl = false;
0125                 par.es = 0.;
0126             }
0127 
0128     }} // namespace detail::bacon
0129     #endif // doxygen
0130 
0131     /*!
0132         \brief Apian Globular I projection
0133         \ingroup projections
0134         \tparam Geographic latlong point type
0135         \tparam Cartesian xy point type
0136         \tparam Parameters parameter type
0137         \par Projection characteristics
0138          - Miscellaneous
0139          - Spheroid
0140          - no inverse
0141         \par Example
0142         \image html ex_apian.gif
0143     */
0144     template <typename T, typename Parameters>
0145     struct apian_spheroid : public detail::bacon::base_bacon_spheroid<T, Parameters>
0146     {
0147         template <typename Params>
0148         inline apian_spheroid(Params const& , Parameters & par)
0149         {
0150             detail::bacon::setup_apian(par, this->m_proj_parm);
0151         }
0152     };
0153 
0154     /*!
0155         \brief Ortelius Oval projection
0156         \ingroup projections
0157         \tparam Geographic latlong point type
0158         \tparam Cartesian xy point type
0159         \tparam Parameters parameter type
0160         \par Projection characteristics
0161          - Miscellaneous
0162          - Spheroid
0163          - no inverse
0164         \par Example
0165         \image html ex_ortel.gif
0166     */
0167     template <typename T, typename Parameters>
0168     struct ortel_spheroid : public detail::bacon::base_bacon_spheroid<T, Parameters>
0169     {
0170         template <typename Params>
0171         inline ortel_spheroid(Params const& , Parameters & par)
0172         {
0173             detail::bacon::setup_ortel(par, this->m_proj_parm);
0174         }
0175     };
0176 
0177     /*!
0178         \brief Bacon Globular projection
0179         \ingroup projections
0180         \tparam Geographic latlong point type
0181         \tparam Cartesian xy point type
0182         \tparam Parameters parameter type
0183         \par Projection characteristics
0184          - Miscellaneous
0185          - Spheroid
0186          - no inverse
0187         \par Example
0188         \image html ex_bacon.gif
0189     */
0190     template <typename T, typename Parameters>
0191     struct bacon_spheroid : public detail::bacon::base_bacon_spheroid<T, Parameters>
0192     {
0193         template <typename Params>
0194         inline bacon_spheroid(Params const& , Parameters & par)
0195         {
0196             detail::bacon::setup_bacon(par, this->m_proj_parm);
0197         }
0198     };
0199 
0200     #ifndef DOXYGEN_NO_DETAIL
0201     namespace detail
0202     {
0203 
0204         // Static projection
0205         BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_F(srs::spar::proj_apian, apian_spheroid)
0206         BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_F(srs::spar::proj_bacon, bacon_spheroid)
0207         BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_F(srs::spar::proj_ortel, ortel_spheroid)
0208 
0209         // Factory entry(s)
0210         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_F(apian_entry, apian_spheroid)
0211         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_F(ortel_entry, ortel_spheroid)
0212         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_F(bacon_entry, bacon_spheroid)
0213 
0214         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(bacon_init)
0215         {
0216             BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(apian, apian_entry)
0217             BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(ortel, ortel_entry)
0218             BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(bacon, bacon_entry)
0219         }
0220 
0221     } // namespace detail
0222     #endif // doxygen
0223 
0224 } // namespace projections
0225 
0226 }} // namespace boost::geometry
0227 
0228 #endif // BOOST_GEOMETRY_PROJECTIONS_BACON_HPP
0229