Back to home page

EIC code displayed by LXR

 
 

    


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

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_GSTMERC_HPP
0041 #define BOOST_GEOMETRY_PROJECTIONS_GSTMERC_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/pj_phi2.hpp>
0048 #include <boost/geometry/srs/projections/impl/pj_tsfn.hpp>
0049 
0050 namespace boost { namespace geometry
0051 {
0052 
0053 namespace projections
0054 {
0055     #ifndef DOXYGEN_NO_DETAIL
0056     namespace detail { namespace gstmerc
0057     {
0058             template <typename T>
0059             struct par_gstmerc
0060             {
0061                 T lamc;
0062                 T phic;
0063                 T c;
0064                 T n1;
0065                 T n2;
0066                 T XS;
0067                 T YS;
0068             };
0069 
0070             template <typename T, typename Parameters>
0071             struct base_gstmerc_spheroid
0072             {
0073                 par_gstmerc<T> m_proj_parm;
0074 
0075                 // FORWARD(s_forward)  spheroid
0076                 // Project coordinates from geographic (lon, lat) to cartesian (x, y)
0077                 inline void fwd(Parameters const& par, T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
0078                 {
0079                     T L, Ls, sinLs1, Ls1;
0080 
0081                     L= this->m_proj_parm.n1*lp_lon;
0082                     Ls= this->m_proj_parm.c+this->m_proj_parm.n1*log(pj_tsfn(-1.0*lp_lat,-1.0*sin(lp_lat), par.e));
0083                     sinLs1= sin(L)/cosh(Ls);
0084                     Ls1= log(pj_tsfn(-1.0*asin(sinLs1),0.0,0.0));
0085                     xy_x= (this->m_proj_parm.XS + this->m_proj_parm.n2*Ls1) * par.ra;
0086                     xy_y= (this->m_proj_parm.YS + this->m_proj_parm.n2*atan(sinh(Ls)/cos(L))) * par.ra;
0087                 }
0088 
0089                 // INVERSE(s_inverse)  spheroid
0090                 // Project coordinates from cartesian (x, y) to geographic (lon, lat)
0091                 inline void inv(Parameters const& par, T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
0092                 {
0093                     T L, LC, sinC;
0094 
0095                     L= atan(sinh((xy_x * par.a - this->m_proj_parm.XS)/this->m_proj_parm.n2)/cos((xy_y * par.a - this->m_proj_parm.YS)/this->m_proj_parm.n2));
0096                     sinC= sin((xy_y * par.a - this->m_proj_parm.YS)/this->m_proj_parm.n2)/cosh((xy_x * par.a - this->m_proj_parm.XS)/this->m_proj_parm.n2);
0097                     LC= log(pj_tsfn(-1.0*asin(sinC),0.0,0.0));
0098                     lp_lon= L/this->m_proj_parm.n1;
0099                     lp_lat= -1.0*pj_phi2(exp((LC-this->m_proj_parm.c)/this->m_proj_parm.n1), par.e);
0100                 }
0101 
0102                 static inline std::string get_name()
0103                 {
0104                     return "gstmerc_spheroid";
0105                 }
0106 
0107             };
0108 
0109             // Gauss-Schreiber Transverse Mercator (aka Gauss-Laborde Reunion)
0110             template <typename Parameters, typename T>
0111             inline void setup_gstmerc(Parameters const& par, par_gstmerc<T>& proj_parm)
0112             {
0113                 proj_parm.lamc= par.lam0;
0114                 proj_parm.n1= sqrt(T(1)+par.es*math::pow(cos(par.phi0),4)/(T(1)-par.es));
0115                 proj_parm.phic= asin(sin(par.phi0)/proj_parm.n1);
0116                 proj_parm.c= log(pj_tsfn(-1.0*proj_parm.phic,0.0,0.0))
0117                            - proj_parm.n1*log(pj_tsfn(-1.0*par.phi0,-1.0*sin(par.phi0),par.e));
0118                 proj_parm.n2= par.k0*par.a*sqrt(1.0-par.es)/(1.0-par.es*sin(par.phi0)*sin(par.phi0));
0119                 proj_parm.XS= 0;/* -par.x0 */
0120                 proj_parm.YS= -1.0*proj_parm.n2*proj_parm.phic;/* -par.y0 */
0121             }
0122 
0123     }} // namespace detail::gstmerc
0124     #endif // doxygen
0125 
0126     /*!
0127         \brief Gauss-Schreiber Transverse Mercator (aka Gauss-Laborde Reunion) projection
0128         \ingroup projections
0129         \tparam Geographic latlong point type
0130         \tparam Cartesian xy point type
0131         \tparam Parameters parameter type
0132         \par Projection characteristics
0133          - Cylindrical
0134          - Spheroid
0135          - Ellipsoid
0136         \par Projection parameters
0137          - lat_0: Latitude of origin
0138          - lon_0: Central meridian
0139          - k_0: Scale factor
0140         \par Example
0141         \image html ex_gstmerc.gif
0142     */
0143     template <typename T, typename Parameters>
0144     struct gstmerc_spheroid : public detail::gstmerc::base_gstmerc_spheroid<T, Parameters>
0145     {
0146         template <typename Params>
0147         inline gstmerc_spheroid(Params const& , Parameters const& par)
0148         {
0149             detail::gstmerc::setup_gstmerc(par, this->m_proj_parm);
0150         }
0151     };
0152 
0153     #ifndef DOXYGEN_NO_DETAIL
0154     namespace detail
0155     {
0156 
0157         // Static projection
0158         BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_gstmerc, gstmerc_spheroid)
0159 
0160         // Factory entry(s)
0161         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(gstmerc_entry, gstmerc_spheroid)
0162 
0163         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(gstmerc_init)
0164         {
0165             BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(gstmerc, gstmerc_entry);
0166         }
0167 
0168     } // namespace detail
0169     #endif // doxygen
0170 
0171 } // namespace projections
0172 
0173 }} // namespace boost::geometry
0174 
0175 #endif // BOOST_GEOMETRY_PROJECTIONS_GSTMERC_HPP
0176