1 #ifndef BOOST_GEOMETRY_PROJECTIONS_OCEA_HPP
2 #define BOOST_GEOMETRY_PROJECTIONS_OCEA_HPP
4 // Boost.Geometry - extensions-gis-projections (based on PROJ4)
5 // This file is automatically generated. DO NOT EDIT.
7 // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands.
9 // This file was modified by Oracle on 2017.
10 // Modifications copyright (c) 2017, Oracle and/or its affiliates.
11 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle.
13 // Use, modification and distribution is subject to the Boost Software License,
14 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
15 // http://www.boost.org/LICENSE_1_0.txt)
17 // This file is converted from PROJ4, http://trac.osgeo.org/proj
18 // PROJ4 is originally written by Gerald Evenden (then of the USGS)
19 // PROJ4 is maintained by Frank Warmerdam
20 // PROJ4 is converted to Boost.Geometry by Barend Gehrels
22 // Last updated version of proj: 4.9.1
24 // Original copyright notice:
26 // Permission is hereby granted, free of charge, to any person obtaining a
27 // copy of this software and associated documentation files (the "Software"),
28 // to deal in the Software without restriction, including without limitation
29 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
30 // and/or sell copies of the Software, and to permit persons to whom the
31 // Software is furnished to do so, subject to the following conditions:
33 // The above copyright notice and this permission notice shall be included
34 // in all copies or substantial portions of the Software.
36 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
37 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
38 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
39 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
40 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
41 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
42 // DEALINGS IN THE SOFTWARE.
44 #include <boost/geometry/util/math.hpp>
46 #include <boost/geometry/srs/projections/impl/base_static.hpp>
47 #include <boost/geometry/srs/projections/impl/base_dynamic.hpp>
48 #include <boost/geometry/srs/projections/impl/projects.hpp>
49 #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
51 namespace boost { namespace geometry
54 namespace srs { namespace par4
58 }} //namespace srs::par4
62 #ifndef DOXYGEN_NO_DETAIL
63 namespace detail { namespace ocea
76 // template class, using CRTP to implement forward/inverse
77 template <typename CalculationType, typename Parameters>
78 struct base_ocea_spheroid : public base_t_fi<base_ocea_spheroid<CalculationType, Parameters>,
79 CalculationType, Parameters>
82 typedef CalculationType geographic_type;
83 typedef CalculationType cartesian_type;
85 par_ocea<CalculationType> m_proj_parm;
87 inline base_ocea_spheroid(const Parameters& par)
88 : base_t_fi<base_ocea_spheroid<CalculationType, Parameters>,
89 CalculationType, Parameters>(*this, par) {}
91 // FORWARD(s_forward) spheroid
92 // Project coordinates from geographic (lon, lat) to cartesian (x, y)
93 inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
95 static const CalculationType ONEPI = detail::ONEPI<CalculationType>();
101 xy_x = atan2((tan(lp_lat) * this->m_proj_parm.cosphi + this->m_proj_parm.sinphi * xy_y) , cos(lp_lon));
104 xy_x = atan((tan(lp_lat) * this->m_proj_parm.cosphi + this->m_proj_parm.sinphi * xy_y) / t);
107 xy_x *= this->m_proj_parm.rtk;
108 xy_y = this->m_proj_parm.rok * (this->m_proj_parm.sinphi * sin(lp_lat) - this->m_proj_parm.cosphi * cos(lp_lat) * xy_y);
111 // INVERSE(s_inverse) spheroid
112 // Project coordinates from cartesian (x, y) to geographic (lon, lat)
113 inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
115 CalculationType t, s;
117 xy_y /= this->m_proj_parm.rok;
118 xy_x /= this->m_proj_parm.rtk;
119 t = sqrt(1. - xy_y * xy_y);
120 lp_lat = asin(xy_y * this->m_proj_parm.sinphi + t * this->m_proj_parm.cosphi * (s = sin(xy_x)));
121 lp_lon = atan2(t * this->m_proj_parm.sinphi * s - xy_y * this->m_proj_parm.cosphi,
125 static inline std::string get_name()
127 return "ocea_spheroid";
132 // Oblique Cylindrical Equal Area
133 template <typename Parameters, typename T>
134 inline void setup_ocea(Parameters& par, par_ocea<T>& proj_parm)
136 static const T HALFPI = detail::HALFPI<T>();
138 T phi_0=0.0, phi_1, phi_2, lam_1, lam_2, lonz, alpha;
140 proj_parm.rok = 1. / par.k0;
141 proj_parm.rtk = par.k0;
142 if ( pj_param(par.params, "talpha").i) {
143 alpha = pj_param(par.params, "ralpha").f;
144 lonz = pj_param(par.params, "rlonc").f;
145 proj_parm.singam = atan(-cos(alpha)/(-sin(phi_0) * sin(alpha))) + lonz;
146 proj_parm.sinphi = asin(cos(phi_0) * sin(alpha));
148 phi_1 = pj_param(par.params, "rlat_1").f;
149 phi_2 = pj_param(par.params, "rlat_2").f;
150 lam_1 = pj_param(par.params, "rlon_1").f;
151 lam_2 = pj_param(par.params, "rlon_2").f;
152 proj_parm.singam = atan2(cos(phi_1) * sin(phi_2) * cos(lam_1) -
153 sin(phi_1) * cos(phi_2) * cos(lam_2),
154 sin(phi_1) * cos(phi_2) * sin(lam_2) -
155 cos(phi_1) * sin(phi_2) * sin(lam_1) );
156 if (lam_1 == -HALFPI)
157 proj_parm.singam = -proj_parm.singam;
158 proj_parm.sinphi = atan(-cos(proj_parm.singam - lam_1) / tan(phi_1));
160 par.lam0 = proj_parm.singam + HALFPI;
161 proj_parm.cosphi = cos(proj_parm.sinphi);
162 proj_parm.sinphi = sin(proj_parm.sinphi);
163 proj_parm.cosgam = cos(proj_parm.singam);
164 proj_parm.singam = sin(proj_parm.singam);
168 }} // namespace detail::ocea
172 \brief Oblique Cylindrical Equal Area projection
174 \tparam Geographic latlong point type
175 \tparam Cartesian xy point type
176 \tparam Parameters parameter type
177 \par Projection characteristics
180 \par Projection parameters
181 - lonc: Longitude (only used if alpha (or gamma) is specified) (degrees)
182 - alpha: Alpha (degrees)
183 - lat_1: Latitude of first standard parallel (degrees)
184 - lat_2: Latitude of second standard parallel (degrees)
188 \image html ex_ocea.gif
190 template <typename CalculationType, typename Parameters>
191 struct ocea_spheroid : public detail::ocea::base_ocea_spheroid<CalculationType, Parameters>
193 inline ocea_spheroid(const Parameters& par) : detail::ocea::base_ocea_spheroid<CalculationType, Parameters>(par)
195 detail::ocea::setup_ocea(this->m_par, this->m_proj_parm);
199 #ifndef DOXYGEN_NO_DETAIL
204 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::ocea, ocea_spheroid, ocea_spheroid)
207 template <typename CalculationType, typename Parameters>
208 class ocea_entry : public detail::factory_entry<CalculationType, Parameters>
211 virtual base_v<CalculationType, Parameters>* create_new(const Parameters& par) const
213 return new base_v_fi<ocea_spheroid<CalculationType, Parameters>, CalculationType, Parameters>(par);
217 template <typename CalculationType, typename Parameters>
218 inline void ocea_init(detail::base_factory<CalculationType, Parameters>& factory)
220 factory.add_to_factory("ocea", new ocea_entry<CalculationType, Parameters>);
223 } // namespace detail
226 } // namespace projections
228 }} // namespace boost::geometry
230 #endif // BOOST_GEOMETRY_PROJECTIONS_OCEA_HPP