Back to home page

EIC code displayed by LXR

 
 

    


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

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_STS_HPP
0041 #define BOOST_GEOMETRY_PROJECTIONS_STS_HPP
0042 
0043 #include <boost/geometry/srs/projections/impl/base_static.hpp>
0044 #include <boost/geometry/srs/projections/impl/base_dynamic.hpp>
0045 #include <boost/geometry/srs/projections/impl/projects.hpp>
0046 #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
0047 #include <boost/geometry/srs/projections/impl/aasincos.hpp>
0048 
0049 namespace boost { namespace geometry
0050 {
0051 
0052 namespace projections
0053 {
0054     #ifndef DOXYGEN_NO_DETAIL
0055     namespace detail { namespace sts
0056     {
0057             template <typename T>
0058             struct par_sts
0059             {
0060                 T C_x, C_y, C_p;
0061                 bool tan_mode;
0062             };
0063 
0064             template <typename T, typename Parameters>
0065             struct base_sts_spheroid
0066             {
0067                 par_sts<T> m_proj_parm;
0068 
0069                 // FORWARD(s_forward)  spheroid
0070                 // Project coordinates from geographic (lon, lat) to cartesian (x, y)
0071                 inline void fwd(Parameters const& , T const& lp_lon, T lp_lat, T& xy_x, T& xy_y) const
0072                 {
0073                     T c;
0074 
0075                     xy_x = this->m_proj_parm.C_x * lp_lon * cos(lp_lat);
0076                     xy_y = this->m_proj_parm.C_y;
0077                     lp_lat *= this->m_proj_parm.C_p;
0078                     c = cos(lp_lat);
0079                     if (this->m_proj_parm.tan_mode) {
0080                         xy_x *= c * c;
0081                         xy_y *= tan(lp_lat);
0082                     } else {
0083                         xy_x /= c;
0084                         xy_y *= sin(lp_lat);
0085                     }
0086                 }
0087 
0088                 // INVERSE(s_inverse)  spheroid
0089                 // Project coordinates from cartesian (x, y) to geographic (lon, lat)
0090                 inline void inv(Parameters const& , T const& xy_x, T xy_y, T& lp_lon, T& lp_lat) const
0091                 {
0092                     T c;
0093 
0094                     xy_y /= this->m_proj_parm.C_y;
0095                     c = cos(lp_lat = this->m_proj_parm.tan_mode ? atan(xy_y) : aasin(xy_y));
0096                     lp_lat /= this->m_proj_parm.C_p;
0097                     lp_lon = xy_x / (this->m_proj_parm.C_x * cos(lp_lat));
0098                     if (this->m_proj_parm.tan_mode)
0099                         lp_lon /= c * c;
0100                     else
0101                         lp_lon *= c;
0102                 }
0103 
0104                 static inline std::string get_name()
0105                 {
0106                     return "sts_spheroid";
0107                 }
0108 
0109             };
0110 
0111             template <typename Parameters, typename T>
0112             inline void setup(Parameters& par, par_sts<T>& proj_parm, T const& p, T const& q, bool mode)
0113             {
0114                 par.es = 0.;
0115                 proj_parm.C_x = q / p;
0116                 proj_parm.C_y = p;
0117                 proj_parm.C_p = 1/ q;
0118                 proj_parm.tan_mode = mode;
0119             }
0120 
0121 
0122             // Foucaut
0123             template <typename Parameters, typename T>
0124             inline void setup_fouc(Parameters& par, par_sts<T>& proj_parm)
0125             {
0126                 setup(par, proj_parm, 2., 2., true);
0127             }
0128 
0129             // Kavraisky V
0130             template <typename Parameters, typename T>
0131             inline void setup_kav5(Parameters& par, par_sts<T>& proj_parm)
0132             {
0133                 setup(par, proj_parm, 1.50488, 1.35439, false);
0134             }
0135 
0136             // Quartic Authalic
0137             template <typename Parameters, typename T>
0138             inline void setup_qua_aut(Parameters& par, par_sts<T>& proj_parm)
0139             {
0140                 setup(par, proj_parm, 2., 2., false);
0141             }
0142 
0143             // McBryde-Thomas Flat-Polar Sine (No. 1)
0144             template <typename Parameters, typename T>
0145             inline void setup_mbt_s(Parameters& par, par_sts<T>& proj_parm)
0146             {
0147                 setup(par, proj_parm, 1.48875, 1.36509, false);
0148             }
0149 
0150     }} // namespace detail::sts
0151     #endif // doxygen
0152 
0153     /*!
0154         \brief Kavraisky V projection
0155         \ingroup projections
0156         \tparam Geographic latlong point type
0157         \tparam Cartesian xy point type
0158         \tparam Parameters parameter type
0159         \par Projection characteristics
0160          - Pseudocylindrical
0161          - Spheroid
0162         \par Example
0163         \image html ex_kav5.gif
0164     */
0165     template <typename T, typename Parameters>
0166     struct kav5_spheroid : public detail::sts::base_sts_spheroid<T, Parameters>
0167     {
0168         template <typename Params>
0169         inline kav5_spheroid(Params const& , Parameters & par)
0170         {
0171             detail::sts::setup_kav5(par, this->m_proj_parm);
0172         }
0173     };
0174 
0175     /*!
0176         \brief Quartic Authalic projection
0177         \ingroup projections
0178         \tparam Geographic latlong point type
0179         \tparam Cartesian xy point type
0180         \tparam Parameters parameter type
0181         \par Projection characteristics
0182          - Pseudocylindrical
0183          - Spheroid
0184         \par Example
0185         \image html ex_qua_aut.gif
0186     */
0187     template <typename T, typename Parameters>
0188     struct qua_aut_spheroid : public detail::sts::base_sts_spheroid<T, Parameters>
0189     {
0190         template <typename Params>
0191         inline qua_aut_spheroid(Params const& , Parameters & par)
0192         {
0193             detail::sts::setup_qua_aut(par, this->m_proj_parm);
0194         }
0195     };
0196 
0197     /*!
0198         \brief McBryde-Thomas Flat-Polar Sine (No. 1) projection
0199         \ingroup projections
0200         \tparam Geographic latlong point type
0201         \tparam Cartesian xy point type
0202         \tparam Parameters parameter type
0203         \par Projection characteristics
0204          - Pseudocylindrical
0205          - Spheroid
0206         \par Example
0207         \image html ex_mbt_s.gif
0208     */
0209     template <typename T, typename Parameters>
0210     struct mbt_s_spheroid : public detail::sts::base_sts_spheroid<T, Parameters>
0211     {
0212         template <typename Params>
0213         inline mbt_s_spheroid(Params const& , Parameters & par)
0214         {
0215             detail::sts::setup_mbt_s(par, this->m_proj_parm);
0216         }
0217     };
0218 
0219     /*!
0220         \brief Foucaut projection
0221         \ingroup projections
0222         \tparam Geographic latlong point type
0223         \tparam Cartesian xy point type
0224         \tparam Parameters parameter type
0225         \par Projection characteristics
0226          - Pseudocylindrical
0227          - Spheroid
0228         \par Example
0229         \image html ex_fouc.gif
0230     */
0231     template <typename T, typename Parameters>
0232     struct fouc_spheroid : public detail::sts::base_sts_spheroid<T, Parameters>
0233     {
0234         template <typename Params>
0235         inline fouc_spheroid(Params const& , Parameters & par)
0236         {
0237             detail::sts::setup_fouc(par, this->m_proj_parm);
0238         }
0239     };
0240 
0241     #ifndef DOXYGEN_NO_DETAIL
0242     namespace detail
0243     {
0244 
0245         // Static projection
0246         BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_kav5, kav5_spheroid)
0247         BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_qua_aut, qua_aut_spheroid)
0248         BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_mbt_s, mbt_s_spheroid)
0249         BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_fouc, fouc_spheroid)
0250 
0251         // Factory entry(s)
0252         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(kav5_entry, kav5_spheroid)
0253         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(qua_aut_entry, qua_aut_spheroid)
0254         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(mbt_s_entry, mbt_s_spheroid)
0255         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(fouc_entry, fouc_spheroid)
0256 
0257         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(sts_init)
0258         {
0259             BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(kav5, kav5_entry)
0260             BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(qua_aut, qua_aut_entry)
0261             BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(mbt_s, mbt_s_entry)
0262             BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(fouc, fouc_entry)
0263         }
0264 
0265     } // namespace detail
0266     #endif // doxygen
0267 
0268 } // namespace projections
0269 
0270 }} // namespace boost::geometry
0271 
0272 #endif // BOOST_GEOMETRY_PROJECTIONS_STS_HPP
0273