1
#ifndef GGL_PROJECTIONS_LCCA_HPP
2
#define GGL_PROJECTIONS_LCCA_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/projections/impl/base_static.hpp>
41
#include <ggl/projections/impl/base_dynamic.hpp>
42
#include <ggl/projections/impl/projects.hpp>
43
#include <ggl/projections/impl/factory_entry.hpp>
44
#include <ggl/projections/impl/pj_mlfn.hpp>
46
namespace ggl { namespace projection
48
#ifndef DOXYGEN_NO_DETAIL
49
namespace detail { namespace lcca{
50
static const int MAX_ITER = 10;
51
static const double DEL_TOL = 1e-12;
61
inline double /* func to compute dr */
62
fS(double S, double C) {
63
return(S * ( 1. + S * S * C));
65
inline double /* deriv of fs */
66
fSp(double S, double C) {
67
return(1. + 3.* S * S * C);
70
// template class, using CRTP to implement forward/inverse
71
template <typename Geographic, typename Cartesian, typename Parameters>
72
struct base_lcca_ellipsoid : public base_t_fi<base_lcca_ellipsoid<Geographic, Cartesian, Parameters>,
73
Geographic, Cartesian, Parameters>
76
typedef double geographic_type;
77
typedef double cartesian_type;
81
inline base_lcca_ellipsoid(const Parameters& par)
82
: base_t_fi<base_lcca_ellipsoid<Geographic, Cartesian, Parameters>,
83
Geographic, Cartesian, Parameters>(*this, par) {}
85
inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
89
S = pj_mlfn(lp_lat, sin(lp_lat), cos(lp_lat), this->m_proj_parm.en) - this->m_proj_parm.M0;
90
dr = fS(S, this->m_proj_parm.C);
91
r = this->m_proj_parm.r0 - dr;
92
xy_x = this->m_par.k0 * (r * sin( lp_lon *= this->m_proj_parm.l ) );
93
xy_y = this->m_par.k0 * (this->m_proj_parm.r0 - r * cos(lp_lon) );
96
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
98
double theta, dr, S, dif;
101
xy_x /= this->m_par.k0;
102
xy_y /= this->m_par.k0;
103
theta = atan2(xy_x , this->m_proj_parm.r0 - xy_y);
104
dr = xy_y - xy_x * tan(0.5 * theta);
105
lp_lon = theta / this->m_proj_parm.l;
107
for (i = MAX_ITER; i ; --i) {
108
S -= (dif = (fS(S, this->m_proj_parm.C) - dr) / fSp(S, this->m_proj_parm.C));
109
if (fabs(dif) < DEL_TOL) break;
111
if (!i) throw proj_exception();
112
lp_lat = pj_inv_mlfn(S + this->m_proj_parm.M0, this->m_par.es, this->m_proj_parm.en);
116
// Lambert Conformal Conic Alternative
117
template <typename Parameters>
118
void setup_lcca(Parameters& par, par_lcca& proj_parm)
120
double s2p0, N0, R0, tan0, tan20;
121
pj_enfn(par.es, proj_parm.en);
122
if (!pj_param(par.params, "tlat_0").i) throw proj_exception(50);
123
if (par.phi0 == 0.) throw proj_exception(51);
124
proj_parm.l = sin(par.phi0);
125
proj_parm.M0 = pj_mlfn(par.phi0, proj_parm.l, cos(par.phi0), proj_parm.en);
126
s2p0 = proj_parm.l * proj_parm.l;
127
R0 = 1. / (1. - par.es * s2p0);
129
R0 *= par.one_es * N0;
130
tan0 = tan(par.phi0);
132
proj_parm.r0 = N0 / tan0;
133
proj_parm.C = 1. / (6. * R0 * N0);
134
// par.inv = e_inverse;
135
// par.fwd = e_forward;
138
}} // namespace detail::lcca
142
\brief Lambert Conformal Conic Alternative projection
144
\tparam Geographic latlong point type
145
\tparam Cartesian xy point type
146
\tparam Parameters parameter type
147
\par Projection characteristics
153
\image html ex_lcca.gif
155
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
156
struct lcca_ellipsoid : public detail::lcca::base_lcca_ellipsoid<Geographic, Cartesian, Parameters>
158
inline lcca_ellipsoid(const Parameters& par) : detail::lcca::base_lcca_ellipsoid<Geographic, Cartesian, Parameters>(par)
160
detail::lcca::setup_lcca(this->m_par, this->m_proj_parm);
164
#ifndef DOXYGEN_NO_DETAIL
169
template <typename Geographic, typename Cartesian, typename Parameters>
170
class lcca_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
173
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
175
return new base_v_fi<lcca_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
179
template <typename Geographic, typename Cartesian, typename Parameters>
180
inline void lcca_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
182
factory.add_to_factory("lcca", new lcca_entry<Geographic, Cartesian, Parameters>);
185
} // namespace detail
188
}} // namespace ggl::projection
190
#endif // GGL_PROJECTIONS_LCCA_HPP