1 // Boost.Geometry - gis-projections (based on PROJ4)
3 // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands.
5 // This file was modified by Oracle on 2017, 2018, 2019.
6 // Modifications copyright (c) 2017-2019, Oracle and/or its affiliates.
7 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle.
9 // Use, modification and distribution is subject to the Boost Software License,
10 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
11 // http://www.boost.org/LICENSE_1_0.txt)
13 // This file is converted from PROJ4, http://trac.osgeo.org/proj
14 // PROJ4 is originally written by Gerald Evenden (then of the USGS)
15 // PROJ4 is maintained by Frank Warmerdam
16 // PROJ4 is converted to Boost.Geometry by Barend Gehrels
18 // Last updated version of proj: 5.0.0
20 // Original copyright notice:
22 // Permission is hereby granted, free of charge, to any person obtaining a
23 // copy of this software and associated documentation files (the "Software"),
24 // to deal in the Software without restriction, including without limitation
25 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
26 // and/or sell copies of the Software, and to permit persons to whom the
27 // Software is furnished to do so, subject to the following conditions:
29 // The above copyright notice and this permission notice shall be included
30 // in all copies or substantial portions of the Software.
32 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
33 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
35 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
37 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
38 // DEALINGS IN THE SOFTWARE.
40 #ifndef BOOST_GEOMETRY_PROJECTIONS_GSTMERC_HPP
41 #define BOOST_GEOMETRY_PROJECTIONS_GSTMERC_HPP
43 #include <boost/geometry/srs/projections/impl/base_static.hpp>
44 #include <boost/geometry/srs/projections/impl/base_dynamic.hpp>
45 #include <boost/geometry/srs/projections/impl/projects.hpp>
46 #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
47 #include <boost/geometry/srs/projections/impl/pj_phi2.hpp>
48 #include <boost/geometry/srs/projections/impl/pj_tsfn.hpp>
50 namespace boost { namespace geometry
55 #ifndef DOXYGEN_NO_DETAIL
56 namespace detail { namespace gstmerc
70 template <typename T, typename Parameters>
71 struct base_gstmerc_spheroid
73 par_gstmerc<T> m_proj_parm;
75 // FORWARD(s_forward) spheroid
76 // Project coordinates from geographic (lon, lat) to cartesian (x, y)
77 inline void fwd(Parameters const& par, T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
81 L= this->m_proj_parm.n1*lp_lon;
82 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));
83 sinLs1= sin(L)/cosh(Ls);
84 Ls1= log(pj_tsfn(-1.0*asin(sinLs1),0.0,0.0));
85 xy_x= (this->m_proj_parm.XS + this->m_proj_parm.n2*Ls1) * par.ra;
86 xy_y= (this->m_proj_parm.YS + this->m_proj_parm.n2*atan(sinh(Ls)/cos(L))) * par.ra;
89 // INVERSE(s_inverse) spheroid
90 // Project coordinates from cartesian (x, y) to geographic (lon, lat)
91 inline void inv(Parameters const& par, T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
95 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));
96 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);
97 LC= log(pj_tsfn(-1.0*asin(sinC),0.0,0.0));
98 lp_lon= L/this->m_proj_parm.n1;
99 lp_lat= -1.0*pj_phi2(exp((LC-this->m_proj_parm.c)/this->m_proj_parm.n1), par.e);
102 static inline std::string get_name()
104 return "gstmerc_spheroid";
109 // Gauss-Schreiber Transverse Mercator (aka Gauss-Laborde Reunion)
110 template <typename Parameters, typename T>
111 inline void setup_gstmerc(Parameters const& par, par_gstmerc<T>& proj_parm)
113 proj_parm.lamc= par.lam0;
114 proj_parm.n1= sqrt(T(1)+par.es*math::pow(cos(par.phi0),4)/(T(1)-par.es));
115 proj_parm.phic= asin(sin(par.phi0)/proj_parm.n1);
116 proj_parm.c= log(pj_tsfn(-1.0*proj_parm.phic,0.0,0.0))
117 - proj_parm.n1*log(pj_tsfn(-1.0*par.phi0,-1.0*sin(par.phi0),par.e));
118 proj_parm.n2= par.k0*par.a*sqrt(1.0-par.es)/(1.0-par.es*sin(par.phi0)*sin(par.phi0));
119 proj_parm.XS= 0;/* -par.x0 */
120 proj_parm.YS= -1.0*proj_parm.n2*proj_parm.phic;/* -par.y0 */
123 }} // namespace detail::gstmerc
127 \brief Gauss-Schreiber Transverse Mercator (aka Gauss-Laborde Reunion) projection
129 \tparam Geographic latlong point type
130 \tparam Cartesian xy point type
131 \tparam Parameters parameter type
132 \par Projection characteristics
136 \par Projection parameters
137 - lat_0: Latitude of origin
138 - lon_0: Central meridian
141 \image html ex_gstmerc.gif
143 template <typename T, typename Parameters>
144 struct gstmerc_spheroid : public detail::gstmerc::base_gstmerc_spheroid<T, Parameters>
146 template <typename Params>
147 inline gstmerc_spheroid(Params const& , Parameters const& par)
149 detail::gstmerc::setup_gstmerc(par, this->m_proj_parm);
153 #ifndef DOXYGEN_NO_DETAIL
158 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_gstmerc, gstmerc_spheroid)
161 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(gstmerc_entry, gstmerc_spheroid)
163 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(gstmerc_init)
165 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(gstmerc, gstmerc_entry);
168 } // namespace detail
171 } // namespace projections
173 }} // namespace boost::geometry
175 #endif // BOOST_GEOMETRY_PROJECTIONS_GSTMERC_HPP