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, 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_PJ_INV_HPP
0040 #define BOOST_GEOMETRY_PROJECTIONS_PJ_INV_HPP
0041 
0042 
0043 
0044 #include <boost/geometry/srs/projections/impl/adjlon.hpp>
0045 #include <boost/geometry/core/radian_access.hpp>
0046 #include <boost/geometry/util/math.hpp>
0047 
0048 /* general inverse projection */
0049 
0050 namespace boost { namespace geometry { namespace projections
0051 {
0052 
0053 namespace detail
0054 {
0055 
0056  /* inverse projection entry */
0057 template <typename PRJ, typename LL, typename XY, typename PAR>
0058 inline void pj_inv(PRJ const& prj, PAR const& par, XY const& xy, LL& ll)
0059 {
0060     typedef typename PAR::type calc_t;
0061     static const calc_t EPS = 1.0e-12;
0062 
0063     /* can't do as much preliminary checking as with forward */
0064     /* descale and de-offset */
0065     calc_t lon = 0;
0066     calc_t lat = 0;
0067     calc_t xy_x = 0;
0068     calc_t xy_y = 0;
0069 
0070     if (par.axis[0] == 1)
0071     {
0072         xy_x = (geometry::get<1>(xy) * par.to_meter * par.sign[1] - par.x0) * par.ra;
0073         xy_y = (geometry::get<0>(xy) * par.to_meter * par.sign[0] - par.y0) * par.ra;
0074     } else {
0075         xy_x = (geometry::get<0>(xy) * par.to_meter * par.sign[0] - par.x0) * par.ra;
0076         xy_y = (geometry::get<1>(xy) * par.to_meter * par.sign[1] - par.y0) * par.ra;
0077     }
0078 
0079     prj.inv(par, xy_x, xy_y, lon, lat); /* inverse project */
0080 
0081     lon += par.lam0; /* reduce from del lp.lam */
0082     if (!par.over)
0083         lon = adjlon(lon); /* adjust longitude to CM */
0084     if (par.geoc && geometry::math::abs(geometry::math::abs(lat)-geometry::math::half_pi<calc_t>()) > EPS)
0085         lat = atan(par.one_es * tan(lat));
0086 
0087     geometry::set_from_radian<0>(ll, lon);
0088     geometry::set_from_radian<1>(ll, lat);
0089 }
0090 
0091 } // namespace detail
0092 }}} // namespace boost::geometry::projections
0093 
0094 #endif