1
#ifndef GGL_PROJECTIONS_OCEA_HPP
2
#define GGL_PROJECTIONS_OCEA_HPP
4
// Generic Geometry Library - projections (based on PROJ4)
5
// This file is automatically generated. DO NOT EDIT.
7
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
8
// Copyright Bruno Lalande (2008-2009)
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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
18
// Original copyright notice:
20
// Permission is hereby granted, free of charge, to any person obtaining a
21
// copy of this software and associated documentation files (the "Software"),
22
// to deal in the Software without restriction, including without limitation
23
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
24
// and/or sell copies of the Software, and to permit persons to whom the
25
// Software is furnished to do so, subject to the following conditions:
27
// The above copyright notice and this permission notice shall be included
28
// in all copies or substantial portions of the Software.
30
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
31
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
33
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
35
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
36
// DEALINGS IN THE SOFTWARE.
38
#include <boost/math/special_functions/hypot.hpp>
40
#include <ggl/extensions/gis/projections/impl/base_static.hpp>
41
#include <ggl/extensions/gis/projections/impl/base_dynamic.hpp>
42
#include <ggl/extensions/gis/projections/impl/projects.hpp>
43
#include <ggl/extensions/gis/projections/impl/factory_entry.hpp>
45
namespace ggl { namespace projection
47
#ifndef DOXYGEN_NO_DETAIL
48
namespace detail { namespace ocea{
60
// template class, using CRTP to implement forward/inverse
61
template <typename Geographic, typename Cartesian, typename Parameters>
62
struct base_ocea_spheroid : public base_t_fi<base_ocea_spheroid<Geographic, Cartesian, Parameters>,
63
Geographic, Cartesian, Parameters>
66
typedef double geographic_type;
67
typedef double cartesian_type;
71
inline base_ocea_spheroid(const Parameters& par)
72
: base_t_fi<base_ocea_spheroid<Geographic, Cartesian, Parameters>,
73
Geographic, Cartesian, Parameters>(*this, par) {}
75
inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
81
xy_x = atan2((tan(lp_lat) * this->m_proj_parm.cosphi + this->m_proj_parm.sinphi * xy_y) , cos(lp_lon));
84
xy_x = atan((tan(lp_lat) * this->m_proj_parm.cosphi + this->m_proj_parm.sinphi * xy_y) / t);
87
xy_x *= this->m_proj_parm.rtk;
88
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);
91
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
95
xy_y /= this->m_proj_parm.rok;
96
xy_x /= this->m_proj_parm.rtk;
97
t = sqrt(1. - xy_y * xy_y);
98
lp_lat = asin(xy_y * this->m_proj_parm.sinphi + t * this->m_proj_parm.cosphi * (s = sin(xy_x)));
99
lp_lon = atan2(t * this->m_proj_parm.sinphi * s - xy_y * this->m_proj_parm.cosphi,
104
// Oblique Cylindrical Equal Area
105
template <typename Parameters>
106
void setup_ocea(Parameters& par, par_ocea& proj_parm)
108
double phi_0=0.0, phi_1, phi_2, lam_1, lam_2, lonz, alpha;
109
proj_parm.rok = par.a / par.k0;
110
proj_parm.rtk = par.a * par.k0;
111
if ( pj_param(par.params, "talpha").i) {
112
alpha = pj_param(par.params, "ralpha").f;
113
lonz = pj_param(par.params, "rlonc").f;
114
proj_parm.singam = atan(-cos(alpha)/(-sin(phi_0) * sin(alpha))) + lonz;
115
proj_parm.sinphi = asin(cos(phi_0) * sin(alpha));
117
phi_1 = pj_param(par.params, "rlat_1").f;
118
phi_2 = pj_param(par.params, "rlat_2").f;
119
lam_1 = pj_param(par.params, "rlon_1").f;
120
lam_2 = pj_param(par.params, "rlon_2").f;
121
proj_parm.singam = atan2(cos(phi_1) * sin(phi_2) * cos(lam_1) -
122
sin(phi_1) * cos(phi_2) * cos(lam_2),
123
sin(phi_1) * cos(phi_2) * sin(lam_2) -
124
cos(phi_1) * sin(phi_2) * sin(lam_1) );
125
proj_parm.sinphi = atan(-cos(proj_parm.singam - lam_1) / tan(phi_1));
127
par.lam0 = proj_parm.singam + HALFPI;
128
proj_parm.cosphi = cos(proj_parm.sinphi);
129
proj_parm.sinphi = sin(proj_parm.sinphi);
130
proj_parm.cosgam = cos(proj_parm.singam);
131
proj_parm.singam = sin(proj_parm.singam);
132
// par.inv = s_inverse;
133
// par.fwd = s_forward;
137
}} // namespace detail::ocea
141
\brief Oblique Cylindrical Equal Area projection
143
\tparam Geographic latlong point type
144
\tparam Cartesian xy point type
145
\tparam Parameters parameter type
146
\par Projection characteristics
148
- Sph lonc= alpha= or
149
- lat_1= lat_2= lon_1= lon_2=
151
\image html ex_ocea.gif
153
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
154
struct ocea_spheroid : public detail::ocea::base_ocea_spheroid<Geographic, Cartesian, Parameters>
156
inline ocea_spheroid(const Parameters& par) : detail::ocea::base_ocea_spheroid<Geographic, Cartesian, Parameters>(par)
158
detail::ocea::setup_ocea(this->m_par, this->m_proj_parm);
162
#ifndef DOXYGEN_NO_DETAIL
167
template <typename Geographic, typename Cartesian, typename Parameters>
168
class ocea_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
171
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
173
return new base_v_fi<ocea_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
177
template <typename Geographic, typename Cartesian, typename Parameters>
178
inline void ocea_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
180
factory.add_to_factory("ocea", new ocea_entry<Geographic, Cartesian, Parameters>);
183
} // namespace detail
186
}} // namespace ggl::projection
188
#endif // GGL_PROJECTIONS_OCEA_HPP