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) 2022, Oracle and/or its affiliates.
0004 
0005 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle.
0006 
0007 // Use, modification and distribution is subject to the Boost Software License,
0008 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0009 // http://www.boost.org/LICENSE_1_0.txt)
0010 
0011 // This file is converted from PROJ4, http://trac.osgeo.org/proj
0012 // PROJ4 is originally written by Gerald Evenden (then of the USGS)
0013 // PROJ4 is maintained by Frank Warmerdam
0014 // PROJ4 is converted to Boost.Geometry by Barend Gehrels
0015 
0016 // Last updated version of proj: 9.0.0
0017 
0018 // Original copyright notice:
0019 
0020 // Permission is hereby granted, free of charge, to any person obtaining a
0021 // copy of this software and associated documentation files (the "Software"),
0022 // to deal in the Software without restriction, including without limitation
0023 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
0024 // and/or sell copies of the Software, and to permit persons to whom the
0025 // Software is furnished to do so, subject to the following conditions:
0026 
0027 // The above copyright notice and this permission notice shall be included
0028 // in all copies or substantial portions of the Software.
0029 
0030 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
0031 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0032 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
0033 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
0034 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
0035 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
0036 // DEALINGS IN THE SOFTWARE.
0037 
0038 #ifndef BOOST_GEOMETRY_PROJECTIONS_COL_URBAN_HPP
0039 #define BOOST_GEOMETRY_PROJECTIONS_COL_URBAN_HPP
0040 
0041 #include <boost/geometry/util/math.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/pj_param.hpp>
0046 #include <boost/geometry/srs/projections/impl/projects.hpp>
0047 #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
0048 
0049 namespace boost { namespace geometry
0050 {
0051 
0052 namespace projections
0053 {
0054     #ifndef DOXYGEN_NO_DETAIL
0055     namespace detail { namespace col_urban
0056     {
0057             template <typename T>
0058             struct par_col_urban
0059             {
0060                 T h0; // height of projection origin, divided by semi-major axis (a)
0061                 T rho0; // adimensional value, contrary to Guidance note 7.2
0062                 T A;
0063                 T B; // adimensional value, contrary to Guidance note 7.2
0064                 T C;
0065                 T D; // adimensional value, contrary to Guidance note 7.2
0066             };
0067 
0068             template <typename T, typename Parameters>
0069             struct base_col_urban_spheroid
0070             {
0071                 par_col_urban<T> 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& par, T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
0076                 {
0077                     const T cosphi = cos(lp_lat);
0078                     const T sinphi = sin(lp_lat);
0079                     const T nu = 1. / sqrt(1 - par.es * sinphi * sinphi);
0080                     const T lam_nu_cosphi = lp_lon * nu * cosphi;
0081                     xy_x = this->m_proj_parm.A * lam_nu_cosphi;
0082                     const T sinphi_m = sin(0.5 * (lp_lat + par.phi0));
0083                     const T rho_m = (1 - par.es) / pow(1 - par.es * sinphi_m * sinphi_m, 1.5);
0084                     const T G = 1 + this->m_proj_parm.h0 / rho_m;
0085                     xy_y = G * this->m_proj_parm.rho0 * ((lp_lat - par.phi0) + this->m_proj_parm.B * lam_nu_cosphi * lam_nu_cosphi);
0086                 }
0087 
0088                 // INVERSE(s_inverse)  spheroid
0089                 // Project coordinates from cartesian (x, y) to geographic (lon, lat)
0090                 inline void inv(Parameters const& par, T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
0091                 {
0092                     lp_lat = par.phi0 + xy_y / this->m_proj_parm.D - this->m_proj_parm.B * (xy_x / this->m_proj_parm.C) * (xy_x / this->m_proj_parm.C);
0093                     const double sinphi = sin(lp_lat);
0094                     const double nu = 1. / sqrt(1 - par.es * sinphi * sinphi);
0095                     lp_lon = xy_x / (this->m_proj_parm.C * nu * cos(lp_lat));
0096 
0097                 }
0098 
0099                 static inline std::string get_name()
0100                 {
0101                     return "col_urban_spheroid";
0102                 }
0103 
0104             };
0105 
0106             // Colombia Urban
0107             template <typename Params, typename Parameters, typename T>
0108             inline void setup(Params const& params, Parameters const& par, par_col_urban<T>& proj_parm)
0109             {
0110                 T h0_unscaled;
0111                 if ( !pj_param_f<srs::spar::h_0>(params, "h_0", srs::dpar::h_0, h0_unscaled) ){
0112                     h0_unscaled = T(0);
0113                 }
0114                 proj_parm.h0 = h0_unscaled / par.a;
0115                 const T sinphi0 = sin(par.phi0);
0116                 const T nu0 = 1. / sqrt(1 - par.es * sinphi0 * sinphi0);
0117                 proj_parm.A = 1 + proj_parm.h0 / nu0;
0118                 proj_parm.rho0 = (1 - par.es) / pow(1 - par.es * sinphi0 * sinphi0, 1.5);
0119                 proj_parm.B = tan(par.phi0) / (2 * proj_parm.rho0 * nu0);
0120                 proj_parm.C = 1 + proj_parm.h0;
0121                 proj_parm.D = proj_parm.rho0 * (1 + proj_parm.h0 / (1 - par.es));
0122             }
0123 
0124     }} // namespace col_urban
0125     #endif // doxygen
0126 
0127     /*!
0128         \brief Colombia Urban
0129         \ingroup projections
0130         \tparam Geographic latlong point type
0131         \tparam Cartesian xy point type
0132         \tparam Parameters parameter type
0133     */
0134     template <typename T, typename Parameters>
0135     struct col_urban_spheroid : public detail::col_urban::base_col_urban_spheroid<T, Parameters>
0136     {
0137         template <typename Params>
0138         inline col_urban_spheroid(Params const& params, Parameters & par)
0139         {
0140             detail::col_urban::setup(params, par, this->m_proj_parm);
0141         }
0142     };
0143 
0144     #ifndef DOXYGEN_NO_DETAIL
0145     namespace detail
0146     {
0147 
0148         // Static projection
0149         BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_col_urban, col_urban_spheroid)
0150 
0151         // Factory entry(s)
0152         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(col_urban_entry, col_urban_spheroid)
0153 
0154         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(col_urban_init)
0155         {
0156             BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(col_urban, col_urban_entry);
0157         }
0158 
0159     } // namespace detail
0160     #endif // doxygen
0161 
0162 } // namespace projections
0163 
0164 }} // namespace boost::geometry
0165 
0166 #endif // BOOST_GEOMETRY_PROJECTIONS_COL_URBAN_HPP