~ubuntu-branches/ubuntu/saucy/merkaartor/saucy

« back to all changes in this revision

Viewing changes to include/ggl/projections/proj/gstmerc.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Bernd Zeimetz
  • Date: 2009-09-13 00:52:12 UTC
  • mto: (1.2.7 upstream) (0.1.3 upstream) (3.1.7 sid)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: james.westby@ubuntu.com-20090913005212-pjecal8zxm07x0fj
ImportĀ upstreamĀ versionĀ 0.14+svnfixes~20090912

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef GGL_PROJECTIONS_GSTMERC_HPP
 
2
#define GGL_PROJECTIONS_GSTMERC_HPP
 
3
 
 
4
// Generic Geometry Library - projections (based on PROJ4)
 
5
// This file is automatically generated. DO NOT EDIT.
 
6
 
 
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)
 
12
 
 
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)
 
17
 
 
18
// Original copyright notice:
 
19
 
 
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:
 
26
 
 
27
// The above copyright notice and this permission notice shall be included
 
28
// in all copies or substantial portions of the Software.
 
29
 
 
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.
 
37
 
 
38
#include <boost/math/special_functions/hypot.hpp>
 
39
 
 
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_tsfn.hpp>
 
45
#include <ggl/projections/impl/pj_phi2.hpp>
 
46
 
 
47
namespace ggl { namespace projection
 
48
{
 
49
    #ifndef DOXYGEN_NO_DETAIL
 
50
    namespace detail { namespace gstmerc{ 
 
51
 
 
52
            struct par_gstmerc
 
53
            {
 
54
                double lamc;
 
55
                double phic;
 
56
                double c;
 
57
                double n1;
 
58
                double n2;
 
59
                double XS;
 
60
                double YS;
 
61
            };
 
62
            
 
63
 
 
64
            // template class, using CRTP to implement forward/inverse
 
65
            template <typename Geographic, typename Cartesian, typename Parameters>
 
66
            struct base_gstmerc_spheroid : public base_t_fi<base_gstmerc_spheroid<Geographic, Cartesian, Parameters>,
 
67
                     Geographic, Cartesian, Parameters>
 
68
            {
 
69
 
 
70
                 typedef double geographic_type;
 
71
                 typedef double cartesian_type;
 
72
 
 
73
                par_gstmerc m_proj_parm;
 
74
 
 
75
                inline base_gstmerc_spheroid(const Parameters& par)
 
76
                    : base_t_fi<base_gstmerc_spheroid<Geographic, Cartesian, Parameters>,
 
77
                     Geographic, Cartesian, Parameters>(*this, par) {}
 
78
 
 
79
                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
 
80
                {
 
81
                        double L, Ls, sinLs1, Ls1;
 
82
                        L= this->m_proj_parm.n1*lp_lon;
 
83
                    Ls= this->m_proj_parm.c+this->m_proj_parm.n1*log(pj_tsfn(-1.0*lp_lat,-1.0*sin(lp_lat),this->m_par.e));
 
84
                    sinLs1= sin(L)/cosh(Ls);
 
85
                    Ls1= log(pj_tsfn(-1.0*asin(sinLs1),0.0,0.0));
 
86
                    xy_x= (this->m_proj_parm.XS + this->m_proj_parm.n2*Ls1)*this->m_par.ra;
 
87
                    xy_y= (this->m_proj_parm.YS + this->m_proj_parm.n2*atan(sinh(Ls)/cos(L)))*this->m_par.ra;
 
88
                }
 
89
 
 
90
                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
 
91
                {
 
92
                        double L, LC, sinC;
 
93
                        L= atan(sinh((xy_x - this->m_proj_parm.XS)*this->m_par.a/this->m_proj_parm.n2)/cos((xy_y - this->m_proj_parm.YS)*this->m_par.a/this->m_proj_parm.n2));
 
94
                    sinC= sin((xy_y - this->m_proj_parm.YS)*this->m_par.a/this->m_proj_parm.n2)/cosh((xy_x - this->m_proj_parm.XS)*this->m_par.a/this->m_proj_parm.n2);
 
95
                    LC= log(pj_tsfn(-1.0*asin(sinC),0.0,0.0));
 
96
                    lp_lon= L/this->m_proj_parm.n1;
 
97
                    lp_lat= -1.0*pj_phi2(exp((LC-this->m_proj_parm.c)/this->m_proj_parm.n1),this->m_par.e);
 
98
                }
 
99
            };
 
100
 
 
101
            // Gauss-Schreiber Transverse Mercator (aka Gauss-Laborde Reunion)
 
102
            template <typename Parameters>
 
103
            void setup_gstmerc(Parameters& par, par_gstmerc& proj_parm)
 
104
            {
 
105
                proj_parm.n1= sqrt(1.0+par.es*pow(cos(par.phi0),4.0)/(1.0-par.es));
 
106
                proj_parm.phic= asin(sin(par.phi0)/proj_parm.n1);
 
107
                proj_parm.c=       log(pj_tsfn(-1.0*proj_parm.phic,0.0,0.0))
 
108
                     -proj_parm.n1*log(pj_tsfn(-1.0*par.phi0,-1.0*sin(par.phi0),par.e));
 
109
                proj_parm.n2= par.k0*par.a*sqrt(1.0-par.es)/(1.0-par.es*sin(par.phi0)*sin(par.phi0));
 
110
                proj_parm.XS= 0;
 
111
                proj_parm.YS= -1.0*proj_parm.n2*proj_parm.phic;
 
112
                // par.inv= s_inverse;
 
113
                // par.fwd= s_forward;
 
114
            }
 
115
 
 
116
        }} // namespace detail::gstmerc
 
117
    #endif // doxygen 
 
118
 
 
119
    /*!
 
120
        \brief Gauss-Schreiber Transverse Mercator (aka Gauss-Laborde Reunion) projection
 
121
        \ingroup projections
 
122
        \tparam Geographic latlong point type
 
123
        \tparam Cartesian xy point type
 
124
        \tparam Parameters parameter type
 
125
        \par Projection characteristics
 
126
         - Cylindrical
 
127
         - Spheroid
 
128
         - Ellipsoid
 
129
         - lat_0= lon_0= k_0=
 
130
        \par Example
 
131
        \image html ex_gstmerc.gif
 
132
    */
 
133
    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
 
134
    struct gstmerc_spheroid : public detail::gstmerc::base_gstmerc_spheroid<Geographic, Cartesian, Parameters>
 
135
    {
 
136
        inline gstmerc_spheroid(const Parameters& par) : detail::gstmerc::base_gstmerc_spheroid<Geographic, Cartesian, Parameters>(par)
 
137
        {
 
138
            detail::gstmerc::setup_gstmerc(this->m_par, this->m_proj_parm);
 
139
        }
 
140
    };
 
141
 
 
142
    #ifndef DOXYGEN_NO_DETAIL
 
143
    namespace detail
 
144
    {
 
145
 
 
146
        // Factory entry(s)
 
147
        template <typename Geographic, typename Cartesian, typename Parameters>
 
148
        class gstmerc_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
 
149
        {
 
150
            public :
 
151
                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
 
152
                {
 
153
                    return new base_v_fi<gstmerc_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
 
154
                }
 
155
        };
 
156
 
 
157
        template <typename Geographic, typename Cartesian, typename Parameters>
 
158
        inline void gstmerc_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
 
159
        {
 
160
            factory.add_to_factory("gstmerc", new gstmerc_entry<Geographic, Cartesian, Parameters>);
 
161
        }
 
162
 
 
163
    } // namespace detail 
 
164
    #endif // doxygen
 
165
 
 
166
}} // namespace ggl::projection
 
167
 
 
168
#endif // GGL_PROJECTIONS_GSTMERC_HPP
 
169