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

« back to all changes in this revision

Viewing changes to include/ggl/projections/impl/pj_auth.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
// Generic Geometry Library - projections (based on PROJ4)
 
2
// This file is manually converted from PROJ4
 
3
 
 
4
// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
 
5
// Copyright Bruno Lalande 2008, 2009
 
6
// Use, modification and distribution is subject to the Boost Software License,
 
7
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 
8
// http://www.boost.org/LICENSE_1_0.txt)
 
9
 
 
10
// This file is converted from PROJ4, http://trac.osgeo.org/proj
 
11
// PROJ4 is originally written by Gerald Evenden (then of the USGS)
 
12
// PROJ4 is maintained by Frank Warmerdam
 
13
// PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
 
14
 
 
15
// Original copyright notice:
 
16
 
 
17
// Permission is hereby granted, free of charge, to any person obtaining a
 
18
// copy of this software and associated documentation files (the "Software"),
 
19
// to deal in the Software without restriction, including without limitation
 
20
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
 
21
// and/or sell copies of the Software, and to permit persons to whom the
 
22
// Software is furnished to do so, subject to the following conditions:
 
23
 
 
24
// The above copyright notice and this permission notice shall be included
 
25
// in all copies or substantial portions of the Software.
 
26
 
 
27
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 
28
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
29
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 
30
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
31
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 
32
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 
33
// DEALINGS IN THE SOFTWARE.
 
34
 
 
35
#ifndef GGL_PROJECTIONS_IMPL_PJ_AUTH_HPP
 
36
#define GGL_PROJECTIONS_IMPL_PJ_AUTH_HPP
 
37
 
 
38
#include <cassert>
 
39
#include <cmath>
 
40
 
 
41
namespace ggl { namespace projection { namespace detail {
 
42
 
 
43
static const double P00 = .33333333333333333333;
 
44
static const double P01 = .17222222222222222222;
 
45
static const double P02 = .10257936507936507936;
 
46
static const double P10 = .06388888888888888888;
 
47
static const double P11 = .06640211640211640211;
 
48
static const double P20 = .01641501294219154443;
 
49
static const int APA_SIZE = 3;
 
50
 
 
51
/* determine latitude from authalic latitude */
 
52
inline void pj_authset(double es, double* APA)
 
53
{
 
54
    assert(0 != APA);
 
55
 
 
56
    double t = 0;
 
57
 
 
58
    // if (APA = (double *)pj_malloc(APA_SIZE * sizeof(double)))
 
59
    {
 
60
        APA[0] = es * P00;
 
61
        t = es * es;
 
62
        APA[0] += t * P01;
 
63
        APA[1] = t * P10;
 
64
        t *= es;
 
65
        APA[0] += t * P02;
 
66
        APA[1] += t * P11;
 
67
        APA[2] = t * P20;
 
68
    }
 
69
}
 
70
 
 
71
inline double pj_authlat(double beta, const double* APA)
 
72
{
 
73
    assert(0 != APA);
 
74
 
 
75
    const double t = beta + beta;
 
76
 
 
77
    return(beta + APA[0] * std::sin(t) + APA[1] * std::sin(t + t) + APA[2] * std::sin(t + t + t));
 
78
}
 
79
 
 
80
}}} // namespace ggl::projection::impl
 
81
 
 
82
#endif // GGL_PROJECTIONS_IMPL_PJ_AUTH_HPP