Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 // This file is manually converted from PROJ4
0003 
0004 // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
0005 
0006 // This file was modified by Oracle on 2017, 2018, 2019.
0007 // Modifications copyright (c) 2017-2019, Oracle and/or its affiliates.
0008 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0009 
0010 // Use, modification and distribution is subject to the Boost Software License,
0011 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0012 // http://www.boost.org/LICENSE_1_0.txt)
0013 
0014 // This file is converted from PROJ4, http://trac.osgeo.org/proj
0015 // PROJ4 is originally written by Gerald Evenden (then of the USGS)
0016 // PROJ4 is maintained by Frank Warmerdam
0017 // PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
0018 
0019 // Original copyright notice:
0020 
0021 // Permission is hereby granted, free of charge, to any person obtaining a
0022 // copy of this software and associated documentation files (the "Software"),
0023 // to deal in the Software without restriction, including without limitation
0024 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
0025 // and/or sell copies of the Software, and to permit persons to whom the
0026 // Software is furnished to do so, subject to the following conditions:
0027 
0028 // The above copyright notice and this permission notice shall be included
0029 // in all copies or substantial portions of the Software.
0030 
0031 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
0032 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0033 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
0034 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
0035 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
0036 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
0037 // DEALINGS IN THE SOFTWARE.
0038 
0039 #ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_FWD_HPP
0040 #define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_FWD_HPP
0041 
0042 #include <boost/geometry/core/radian_access.hpp>
0043 #include <boost/geometry/util/math.hpp>
0044 
0045 #include <boost/geometry/srs/projections/impl/adjlon.hpp>
0046 #include <boost/geometry/srs/projections/impl/projects.hpp>
0047 
0048 #include <boost/math/constants/constants.hpp>
0049 
0050 /* general forward projection */
0051 
0052 namespace boost { namespace geometry { namespace projections {
0053 
0054 namespace detail {
0055 
0056 /* forward projection entry */
0057 template <typename Prj, typename LL, typename XY, typename P>
0058 inline void pj_fwd(Prj const& prj, P const& par, LL const& ll, XY& xy)
0059 {
0060     typedef typename P::type calc_t;
0061     static const calc_t EPS = 1.0e-12;
0062 
0063     using namespace detail;
0064 
0065     calc_t lp_lon = geometry::get_as_radian<0>(ll);
0066     calc_t lp_lat = geometry::get_as_radian<1>(ll);
0067     calc_t const t = geometry::math::abs(lp_lat) - geometry::math::half_pi<calc_t>();
0068 
0069     /* check for forward and latitude or longitude overange */
0070     if (t > EPS || geometry::math::abs(lp_lon) > 10.)
0071     {
0072         BOOST_THROW_EXCEPTION( projection_exception(error_lat_or_lon_exceed_limit) );
0073     }
0074 
0075     if (geometry::math::abs(t) <= EPS)
0076     {
0077         lp_lat = lp_lat < 0. ? -geometry::math::half_pi<calc_t>() : geometry::math::half_pi<calc_t>();
0078     }
0079     else if (par.geoc)
0080     {
0081         lp_lat = atan(par.rone_es * tan(lp_lat));
0082     }
0083 
0084     lp_lon -= par.lam0;    /* compute del lp.lam */
0085     if (! par.over)
0086     {
0087         lp_lon = adjlon(lp_lon); /* post_forward del longitude */
0088     }
0089 
0090     calc_t x = 0;
0091     calc_t y = 0;
0092 
0093     prj.fwd(par, lp_lon, lp_lat, x, y);
0094 
0095     if (par.axis[0] == 0)
0096     {
0097         geometry::set<0>(xy, par.sign[0] * par.fr_meter * (par.a * x + par.x0));
0098         geometry::set<1>(xy, par.sign[1] * par.fr_meter * (par.a * y + par.y0));
0099     } else {
0100         geometry::set<1>(xy, par.sign[1] * par.fr_meter * (par.a * x + par.x0));
0101         geometry::set<0>(xy, par.sign[0] * par.fr_meter * (par.a * y + par.y0));
0102     }
0103 }
0104 
0105 } // namespace detail
0106 }}} // namespace boost::geometry::projections
0107 
0108 #endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_FWD_HPP