geographiclib 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/AUTHORS +12 -0
- data/LICENSE +24 -0
- data/ext/geographiclib/Accumulator.cpp +23 -0
- data/ext/geographiclib/AlbersEqualArea.cpp +445 -0
- data/ext/geographiclib/AzimuthalEquidistant.cpp +41 -0
- data/ext/geographiclib/CassiniSoldner.cpp +89 -0
- data/ext/geographiclib/CircularEngine.cpp +96 -0
- data/ext/geographiclib/DMS.cpp +381 -0
- data/ext/geographiclib/Ellipsoid.cpp +125 -0
- data/ext/geographiclib/EllipticFunction.cpp +512 -0
- data/ext/geographiclib/GARS.cpp +122 -0
- data/ext/geographiclib/GeoCoords.cpp +175 -0
- data/ext/geographiclib/Geocentric.cpp +172 -0
- data/ext/geographiclib/Geodesic.cpp +1908 -0
- data/ext/geographiclib/GeodesicExact.cpp +927 -0
- data/ext/geographiclib/GeodesicExactC4.cpp +7879 -0
- data/ext/geographiclib/GeodesicLine.cpp +321 -0
- data/ext/geographiclib/GeodesicLineExact.cpp +289 -0
- data/ext/geographiclib/GeographicLib/Accumulator.hpp +184 -0
- data/ext/geographiclib/GeographicLib/AlbersEqualArea.hpp +312 -0
- data/ext/geographiclib/GeographicLib/AzimuthalEquidistant.hpp +139 -0
- data/ext/geographiclib/GeographicLib/CassiniSoldner.hpp +204 -0
- data/ext/geographiclib/GeographicLib/CircularEngine.hpp +195 -0
- data/ext/geographiclib/GeographicLib/Config.h +12 -0
- data/ext/geographiclib/GeographicLib/Constants.hpp +387 -0
- data/ext/geographiclib/GeographicLib/DMS.hpp +370 -0
- data/ext/geographiclib/GeographicLib/Ellipsoid.hpp +534 -0
- data/ext/geographiclib/GeographicLib/EllipticFunction.hpp +692 -0
- data/ext/geographiclib/GeographicLib/GARS.hpp +143 -0
- data/ext/geographiclib/GeographicLib/GeoCoords.hpp +544 -0
- data/ext/geographiclib/GeographicLib/Geocentric.hpp +267 -0
- data/ext/geographiclib/GeographicLib/Geodesic.hpp +970 -0
- data/ext/geographiclib/GeographicLib/GeodesicExact.hpp +862 -0
- data/ext/geographiclib/GeographicLib/GeodesicLine.hpp +701 -0
- data/ext/geographiclib/GeographicLib/GeodesicLineExact.hpp +667 -0
- data/ext/geographiclib/GeographicLib/Geohash.hpp +180 -0
- data/ext/geographiclib/GeographicLib/Geoid.hpp +472 -0
- data/ext/geographiclib/GeographicLib/Georef.hpp +160 -0
- data/ext/geographiclib/GeographicLib/Gnomonic.hpp +206 -0
- data/ext/geographiclib/GeographicLib/GravityCircle.hpp +301 -0
- data/ext/geographiclib/GeographicLib/GravityModel.hpp +520 -0
- data/ext/geographiclib/GeographicLib/LambertConformalConic.hpp +313 -0
- data/ext/geographiclib/GeographicLib/LocalCartesian.hpp +236 -0
- data/ext/geographiclib/GeographicLib/MGRS.hpp +355 -0
- data/ext/geographiclib/GeographicLib/MagneticCircle.hpp +178 -0
- data/ext/geographiclib/GeographicLib/MagneticModel.hpp +347 -0
- data/ext/geographiclib/GeographicLib/Math.hpp +920 -0
- data/ext/geographiclib/GeographicLib/NormalGravity.hpp +350 -0
- data/ext/geographiclib/GeographicLib/OSGB.hpp +249 -0
- data/ext/geographiclib/GeographicLib/PolarStereographic.hpp +150 -0
- data/ext/geographiclib/GeographicLib/PolygonArea.hpp +288 -0
- data/ext/geographiclib/GeographicLib/Rhumb.hpp +589 -0
- data/ext/geographiclib/GeographicLib/SphericalEngine.hpp +376 -0
- data/ext/geographiclib/GeographicLib/SphericalHarmonic.hpp +354 -0
- data/ext/geographiclib/GeographicLib/SphericalHarmonic1.hpp +281 -0
- data/ext/geographiclib/GeographicLib/SphericalHarmonic2.hpp +315 -0
- data/ext/geographiclib/GeographicLib/TransverseMercator.hpp +196 -0
- data/ext/geographiclib/GeographicLib/TransverseMercatorExact.hpp +254 -0
- data/ext/geographiclib/GeographicLib/UTMUPS.hpp +421 -0
- data/ext/geographiclib/GeographicLib/Utility.hpp +612 -0
- data/ext/geographiclib/Geohash.cpp +102 -0
- data/ext/geographiclib/Geoid.cpp +509 -0
- data/ext/geographiclib/Georef.cpp +135 -0
- data/ext/geographiclib/Gnomonic.cpp +85 -0
- data/ext/geographiclib/GravityCircle.cpp +129 -0
- data/ext/geographiclib/GravityModel.cpp +360 -0
- data/ext/geographiclib/LambertConformalConic.cpp +456 -0
- data/ext/geographiclib/LocalCartesian.cpp +62 -0
- data/ext/geographiclib/MGRS.cpp +461 -0
- data/ext/geographiclib/MagneticCircle.cpp +52 -0
- data/ext/geographiclib/MagneticModel.cpp +269 -0
- data/ext/geographiclib/Math.cpp +63 -0
- data/ext/geographiclib/NormalGravity.cpp +262 -0
- data/ext/geographiclib/OSGB.cpp +167 -0
- data/ext/geographiclib/PolarStereographic.cpp +108 -0
- data/ext/geographiclib/PolygonArea.cpp +204 -0
- data/ext/geographiclib/Rhumb.cpp +383 -0
- data/ext/geographiclib/SphericalEngine.cpp +477 -0
- data/ext/geographiclib/TransverseMercator.cpp +603 -0
- data/ext/geographiclib/TransverseMercatorExact.cpp +464 -0
- data/ext/geographiclib/UTMUPS.cpp +296 -0
- data/ext/geographiclib/Utility.cpp +61 -0
- data/ext/geographiclib/extconf.rb +3 -0
- data/ext/geographiclib/geographiclib.cpp +62 -0
- data/lib/geographiclib.rb +20 -0
- metadata +140 -0
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* \file NormalGravity.hpp
|
|
3
|
+
* \brief Header for GeographicLib::NormalGravity class
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Charles Karney (2011-2014) <charles@karney.com> and licensed
|
|
6
|
+
* under the MIT/X11 License. For more information, see
|
|
7
|
+
* http://geographiclib.sourceforge.net/
|
|
8
|
+
**********************************************************************/
|
|
9
|
+
|
|
10
|
+
#if !defined(GEOGRAPHICLIB_NORMALGRAVITY_HPP)
|
|
11
|
+
#define GEOGRAPHICLIB_NORMALGRAVITY_HPP 1
|
|
12
|
+
|
|
13
|
+
#include <GeographicLib/Constants.hpp>
|
|
14
|
+
#include <GeographicLib/Geocentric.hpp>
|
|
15
|
+
|
|
16
|
+
namespace GeographicLib {
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* \brief The normal gravity of the earth
|
|
20
|
+
*
|
|
21
|
+
* "Normal" gravity refers to an idealization of the earth which is modeled
|
|
22
|
+
* as an rotating ellipsoid. The eccentricity of the ellipsoid, the rotation
|
|
23
|
+
* speed, and the distribution of mass within the ellipsoid are such that the
|
|
24
|
+
* surface of the ellipsoid is a surface of constant potential (gravitational
|
|
25
|
+
* plus centrifugal). The acceleration due to gravity is therefore
|
|
26
|
+
* perpendicular to the surface of the ellipsoid.
|
|
27
|
+
*
|
|
28
|
+
* There is a closed solution to this problem which is implemented here.
|
|
29
|
+
* Series "approximations" are only used to evaluate certain combinations of
|
|
30
|
+
* elementary functions where use of the closed expression results in a loss
|
|
31
|
+
* of accuracy for small arguments due to cancellation of the two leading
|
|
32
|
+
* terms. However these series include sufficient terms to give full machine
|
|
33
|
+
* precision.
|
|
34
|
+
*
|
|
35
|
+
* Definitions:
|
|
36
|
+
* - <i>V</i><sub>0</sub>, the gravitational contribution to the normal
|
|
37
|
+
* potential;
|
|
38
|
+
* - Φ, the rotational contribution to the normal potential;
|
|
39
|
+
* - \e U = <i>V</i><sub>0</sub> + Φ, the total
|
|
40
|
+
* potential;
|
|
41
|
+
* - <b>Γ</b> = ∇<i>V</i><sub>0</sub>, the acceleration due to
|
|
42
|
+
* mass of the earth;
|
|
43
|
+
* - <b>f</b> = ∇Φ, the centrifugal acceleration;
|
|
44
|
+
* - <b>γ</b> = ∇\e U = <b>Γ</b> + <b>f</b>, the normal
|
|
45
|
+
* acceleration;
|
|
46
|
+
* - \e X, \e Y, \e Z, geocentric coordinates;
|
|
47
|
+
* - \e x, \e y, \e z, local cartesian coordinates used to denote the east,
|
|
48
|
+
* north and up directions.
|
|
49
|
+
*
|
|
50
|
+
* References:
|
|
51
|
+
* - W. A. Heiskanen and H. Moritz, Physical Geodesy (Freeman, San
|
|
52
|
+
* Francisco, 1967), Secs. 1-19, 2-7, 2-8 (2-9, 2-10), 6-2 (6-3).
|
|
53
|
+
* - H. Moritz, Geodetic Reference System 1980, J. Geodesy 54(3), 395-405
|
|
54
|
+
* (1980) https://dx.doi.org/10.1007/BF02521480
|
|
55
|
+
*
|
|
56
|
+
* Example of use:
|
|
57
|
+
* \include example-NormalGravity.cpp
|
|
58
|
+
**********************************************************************/
|
|
59
|
+
|
|
60
|
+
class GEOGRAPHICLIB_EXPORT NormalGravity {
|
|
61
|
+
private:
|
|
62
|
+
static const int maxit_ = 10;
|
|
63
|
+
typedef Math::real real;
|
|
64
|
+
friend class GravityModel;
|
|
65
|
+
real _a, _GM, _omega, _f, _J2, _omega2, _aomega2;
|
|
66
|
+
real _e2, _ep2, _b, _E, _U0, _gammae, _gammap, _q0, _m, _k, _fstar;
|
|
67
|
+
Geocentric _earth;
|
|
68
|
+
// (atan(y)-(y-y^3/3))/y^5 (y = sqrt(x)) = 1/5-y/7+y^2/9-y^3/11...
|
|
69
|
+
static real atan5(real x);
|
|
70
|
+
// (atan(y)-(y-y^3/3+y^5/5))/y^7 (y = sqrt(x)) = -1/7+x/9-x^2/11+x^3/13...
|
|
71
|
+
static real atan7(real x);
|
|
72
|
+
static real qf(real ep2);
|
|
73
|
+
static real dq(real ep2);
|
|
74
|
+
static real qpf(real ep2);
|
|
75
|
+
real Jn(int n) const;
|
|
76
|
+
public:
|
|
77
|
+
|
|
78
|
+
/** \name Setting up the normal gravity
|
|
79
|
+
**********************************************************************/
|
|
80
|
+
///@{
|
|
81
|
+
/**
|
|
82
|
+
* Constructor for the normal gravity.
|
|
83
|
+
*
|
|
84
|
+
* @param[in] a equatorial radius (meters).
|
|
85
|
+
* @param[in] GM mass constant of the ellipsoid
|
|
86
|
+
* (meters<sup>3</sup>/seconds<sup>2</sup>); this is the product of \e G
|
|
87
|
+
* the gravitational constant and \e M the mass of the earth (usually
|
|
88
|
+
* including the mass of the earth's atmosphere).
|
|
89
|
+
* @param[in] omega the angular velocity (rad s<sup>−1</sup>).
|
|
90
|
+
* @param[in] f the flattening of the ellipsoid.
|
|
91
|
+
* @param[in] J2 the dynamical form factor.
|
|
92
|
+
* @exception if \e a is not positive or the other constants are
|
|
93
|
+
* inconsistent (see below).
|
|
94
|
+
*
|
|
95
|
+
* If \e omega is non-zero, then exactly one of \e f and \e J2 should be
|
|
96
|
+
* positive and this will be used to define the ellipsoid. The shape of
|
|
97
|
+
* the ellipsoid can be given in one of two ways:
|
|
98
|
+
* - geometrically, the ellipsoid is defined by the flattening \e f = (\e a
|
|
99
|
+
* − \e b) / \e a, where \e a and \e b are the equatorial radius
|
|
100
|
+
* and the polar semi-axis.
|
|
101
|
+
* - physically, the ellipsoid is defined by the dynamical form factor
|
|
102
|
+
* <i>J</i><sub>2</sub> = (\e C − \e A) / <i>Ma</i><sup>2</sup>,
|
|
103
|
+
* where \e A and \e C are the equatorial and polar moments of inertia
|
|
104
|
+
* and \e M is the mass of the earth.
|
|
105
|
+
* .
|
|
106
|
+
* If \e omega, \e f, and \e J2 are all zero, then the ellipsoid becomes a
|
|
107
|
+
* sphere.
|
|
108
|
+
**********************************************************************/
|
|
109
|
+
NormalGravity(real a, real GM, real omega, real f, real J2);
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* A default constructor for the normal gravity. This sets up an
|
|
113
|
+
* uninitialized object and is used by GravityModel which constructs this
|
|
114
|
+
* object before it has read in the parameters for the reference ellipsoid.
|
|
115
|
+
**********************************************************************/
|
|
116
|
+
NormalGravity() : _a(-1) {}
|
|
117
|
+
///@}
|
|
118
|
+
|
|
119
|
+
/** \name Compute the gravity
|
|
120
|
+
**********************************************************************/
|
|
121
|
+
///@{
|
|
122
|
+
/**
|
|
123
|
+
* Evaluate the gravity on the surface of the ellipsoid.
|
|
124
|
+
*
|
|
125
|
+
* @param[in] lat the geographic latitude (degrees).
|
|
126
|
+
* @return γ the acceleration due to gravity, positive downwards
|
|
127
|
+
* (m s<sup>−2</sup>).
|
|
128
|
+
*
|
|
129
|
+
* Due to the axial symmetry of the ellipsoid, the result is independent of
|
|
130
|
+
* the value of the longitude. This acceleration is perpendicular to the
|
|
131
|
+
* surface of the ellipsoid. It includes the effects of the earth's
|
|
132
|
+
* rotation.
|
|
133
|
+
**********************************************************************/
|
|
134
|
+
Math::real SurfaceGravity(real lat) const;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Evaluate the gravity at an arbitrary point above (or below) the
|
|
138
|
+
* ellipsoid.
|
|
139
|
+
*
|
|
140
|
+
* @param[in] lat the geographic latitude (degrees).
|
|
141
|
+
* @param[in] h the height above the ellipsoid (meters).
|
|
142
|
+
* @param[out] gammay the northerly component of the acceleration
|
|
143
|
+
* (m s<sup>−2</sup>).
|
|
144
|
+
* @param[out] gammaz the upward component of the acceleration
|
|
145
|
+
* (m s<sup>−2</sup>); this is usually negative.
|
|
146
|
+
* @return \e U the corresponding normal potential.
|
|
147
|
+
*
|
|
148
|
+
* Due to the axial symmetry of the ellipsoid, the result is independent of
|
|
149
|
+
* the value of the longitude and the easterly component of the
|
|
150
|
+
* acceleration vanishes, \e gammax = 0. The function includes the effects
|
|
151
|
+
* of the earth's rotation. When \e h = 0, this function gives \e gammay =
|
|
152
|
+
* 0 and the returned value matches that of NormalGravity::SurfaceGravity.
|
|
153
|
+
**********************************************************************/
|
|
154
|
+
Math::real Gravity(real lat, real h, real& gammay, real& gammaz)
|
|
155
|
+
const;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Evaluate the components of the acceleration due to gravity and the
|
|
159
|
+
* centrifugal acceleration in geocentric coordinates.
|
|
160
|
+
*
|
|
161
|
+
* @param[in] X geocentric coordinate of point (meters).
|
|
162
|
+
* @param[in] Y geocentric coordinate of point (meters).
|
|
163
|
+
* @param[in] Z geocentric coordinate of point (meters).
|
|
164
|
+
* @param[out] gammaX the \e X component of the acceleration
|
|
165
|
+
* (m s<sup>−2</sup>).
|
|
166
|
+
* @param[out] gammaY the \e Y component of the acceleration
|
|
167
|
+
* (m s<sup>−2</sup>).
|
|
168
|
+
* @param[out] gammaZ the \e Z component of the acceleration
|
|
169
|
+
* (m s<sup>−2</sup>).
|
|
170
|
+
* @return \e U = <i>V</i><sub>0</sub> + Φ the sum of the
|
|
171
|
+
* gravitational and centrifugal potentials
|
|
172
|
+
* (m<sup>2</sup> s<sup>−2</sup>).
|
|
173
|
+
*
|
|
174
|
+
* The acceleration given by <b>γ</b> = ∇\e U =
|
|
175
|
+
* ∇<i>V</i><sub>0</sub> + ∇Φ = <b>Γ</b> + <b>f</b>.
|
|
176
|
+
**********************************************************************/
|
|
177
|
+
Math::real U(real X, real Y, real Z,
|
|
178
|
+
real& gammaX, real& gammaY, real& gammaZ) const;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Evaluate the components of the acceleration due to gravity alone in
|
|
182
|
+
* geocentric coordinates.
|
|
183
|
+
*
|
|
184
|
+
* @param[in] X geocentric coordinate of point (meters).
|
|
185
|
+
* @param[in] Y geocentric coordinate of point (meters).
|
|
186
|
+
* @param[in] Z geocentric coordinate of point (meters).
|
|
187
|
+
* @param[out] GammaX the \e X component of the acceleration due to gravity
|
|
188
|
+
* (m s<sup>−2</sup>).
|
|
189
|
+
* @param[out] GammaY the \e Y component of the acceleration due to gravity
|
|
190
|
+
* (m s<sup>−2</sup>).
|
|
191
|
+
* @param[out] GammaZ the \e Z component of the acceleration due to gravity
|
|
192
|
+
* (m s<sup>−2</sup>).
|
|
193
|
+
* @return <i>V</i><sub>0</sub> the gravitational potential
|
|
194
|
+
* (m<sup>2</sup> s<sup>−2</sup>).
|
|
195
|
+
*
|
|
196
|
+
* This function excludes the centrifugal acceleration and is appropriate
|
|
197
|
+
* to use for space applications. In terrestrial applications, the
|
|
198
|
+
* function NormalGravity::U (which includes this effect) should usually be
|
|
199
|
+
* used.
|
|
200
|
+
**********************************************************************/
|
|
201
|
+
Math::real V0(real X, real Y, real Z,
|
|
202
|
+
real& GammaX, real& GammaY, real& GammaZ) const;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Evaluate the centrifugal acceleration in geocentric coordinates.
|
|
206
|
+
*
|
|
207
|
+
* @param[in] X geocentric coordinate of point (meters).
|
|
208
|
+
* @param[in] Y geocentric coordinate of point (meters).
|
|
209
|
+
* @param[out] fX the \e X component of the centrifugal acceleration
|
|
210
|
+
* (m s<sup>−2</sup>).
|
|
211
|
+
* @param[out] fY the \e Y component of the centrifugal acceleration
|
|
212
|
+
* (m s<sup>−2</sup>).
|
|
213
|
+
* @return Φ the centrifugal potential (m<sup>2</sup>
|
|
214
|
+
* s<sup>−2</sup>).
|
|
215
|
+
*
|
|
216
|
+
* Φ is independent of \e Z, thus \e fZ = 0. This function
|
|
217
|
+
* NormalGravity::U sums the results of NormalGravity::V0 and
|
|
218
|
+
* NormalGravity::Phi.
|
|
219
|
+
**********************************************************************/
|
|
220
|
+
Math::real Phi(real X, real Y, real& fX, real& fY) const;
|
|
221
|
+
///@}
|
|
222
|
+
|
|
223
|
+
/** \name Inspector functions
|
|
224
|
+
**********************************************************************/
|
|
225
|
+
///@{
|
|
226
|
+
/**
|
|
227
|
+
* @return true if the object has been initialized.
|
|
228
|
+
**********************************************************************/
|
|
229
|
+
bool Init() const { return _a > 0; }
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* @return \e a the equatorial radius of the ellipsoid (meters). This is
|
|
233
|
+
* the value used in the constructor.
|
|
234
|
+
**********************************************************************/
|
|
235
|
+
Math::real MajorRadius() const
|
|
236
|
+
{ return Init() ? _a : Math::NaN(); }
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* @return \e GM the mass constant of the ellipsoid
|
|
240
|
+
* (m<sup>3</sup> s<sup>−2</sup>). This is the value used in the
|
|
241
|
+
* constructor.
|
|
242
|
+
**********************************************************************/
|
|
243
|
+
Math::real MassConstant() const
|
|
244
|
+
{ return Init() ? _GM : Math::NaN(); }
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* @return <i>J</i><sub><i>n</i></sub> the dynamical form factors of the
|
|
248
|
+
* ellipsoid.
|
|
249
|
+
*
|
|
250
|
+
* If \e n = 2 (the default), this is the value of <i>J</i><sub>2</sub>
|
|
251
|
+
* used in the constructor. Otherwise it is the zonal coefficient of the
|
|
252
|
+
* Legendre harmonic sum of the normal gravitational potential. Note that
|
|
253
|
+
* <i>J</i><sub><i>n</i></sub> = 0 if \e n is odd. In most gravity
|
|
254
|
+
* applications, fully normalized Legendre functions are used and the
|
|
255
|
+
* corresponding coefficient is <i>C</i><sub><i>n</i>0</sub> =
|
|
256
|
+
* −<i>J</i><sub><i>n</i></sub> / sqrt(2 \e n + 1).
|
|
257
|
+
**********************************************************************/
|
|
258
|
+
Math::real DynamicalFormFactor(int n = 2) const
|
|
259
|
+
{ return Init() ? ( n == 2 ? _J2 : Jn(n)) : Math::NaN(); }
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* @return ω the angular velocity of the ellipsoid (rad
|
|
263
|
+
* s<sup>−1</sup>). This is the value used in the constructor.
|
|
264
|
+
**********************************************************************/
|
|
265
|
+
Math::real AngularVelocity() const
|
|
266
|
+
{ return Init() ? _omega : Math::NaN(); }
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* @return <i>f</i> the flattening of the ellipsoid (\e a − \e b)/\e
|
|
270
|
+
* a.
|
|
271
|
+
**********************************************************************/
|
|
272
|
+
Math::real Flattening() const
|
|
273
|
+
{ return Init() ? _f : Math::NaN(); }
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* @return γ<sub>e</sub> the normal gravity at equator (m
|
|
277
|
+
* s<sup>−2</sup>).
|
|
278
|
+
**********************************************************************/
|
|
279
|
+
Math::real EquatorialGravity() const
|
|
280
|
+
{ return Init() ? _gammae : Math::NaN(); }
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* @return γ<sub>p</sub> the normal gravity at poles (m
|
|
284
|
+
* s<sup>−2</sup>).
|
|
285
|
+
**********************************************************************/
|
|
286
|
+
Math::real PolarGravity() const
|
|
287
|
+
{ return Init() ? _gammap : Math::NaN(); }
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* @return <i>f*</i> the gravity flattening (γ<sub>p</sub> −
|
|
291
|
+
* γ<sub>e</sub>) / γ<sub>e</sub>.
|
|
292
|
+
**********************************************************************/
|
|
293
|
+
Math::real GravityFlattening() const
|
|
294
|
+
{ return Init() ? _fstar : Math::NaN(); }
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* @return <i>U</i><sub>0</sub> the constant normal potential for the
|
|
298
|
+
* surface of the ellipsoid (m<sup>2</sup> s<sup>−2</sup>).
|
|
299
|
+
**********************************************************************/
|
|
300
|
+
Math::real SurfacePotential() const
|
|
301
|
+
{ return Init() ? _U0 : Math::NaN(); }
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* @return the Geocentric object used by this instance.
|
|
305
|
+
**********************************************************************/
|
|
306
|
+
const Geocentric& Earth() const { return _earth; }
|
|
307
|
+
///@}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* A global instantiation of NormalGravity for the WGS84 ellipsoid.
|
|
311
|
+
**********************************************************************/
|
|
312
|
+
static const NormalGravity& WGS84();
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* A global instantiation of NormalGravity for the GRS80 ellipsoid.
|
|
316
|
+
**********************************************************************/
|
|
317
|
+
static const NormalGravity& GRS80();
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Compute the flattening from the dynamical form factor.
|
|
321
|
+
*
|
|
322
|
+
* @param[in] a equatorial radius (meters).
|
|
323
|
+
* @param[in] GM mass constant of the ellipsoid
|
|
324
|
+
* (meters<sup>3</sup>/seconds<sup>2</sup>); this is the product of \e G
|
|
325
|
+
* the gravitational constant and \e M the mass of the earth (usually
|
|
326
|
+
* including the mass of the earth's atmosphere).
|
|
327
|
+
* @param[in] omega the angular velocity (rad s<sup>−1</sup>).
|
|
328
|
+
* @param[in] J2 the dynamical form factor.
|
|
329
|
+
* @return \e f the flattening of the ellipsoid.
|
|
330
|
+
**********************************************************************/
|
|
331
|
+
static Math::real J2ToFlattening(real a, real GM, real omega, real J2);
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Compute the dynamical form factor from the flattening.
|
|
335
|
+
*
|
|
336
|
+
* @param[in] a equatorial radius (meters).
|
|
337
|
+
* @param[in] GM mass constant of the ellipsoid
|
|
338
|
+
* (meters<sup>3</sup>/seconds<sup>2</sup>); this is the product of \e G
|
|
339
|
+
* the gravitational constant and \e M the mass of the earth (usually
|
|
340
|
+
* including the mass of the earth's atmosphere).
|
|
341
|
+
* @param[in] omega the angular velocity (rad s<sup>−1</sup>).
|
|
342
|
+
* @param[in] f the flattening of the ellipsoid.
|
|
343
|
+
* @return \e J2 the dynamical form factor.
|
|
344
|
+
**********************************************************************/
|
|
345
|
+
static Math::real FlatteningToJ2(real a, real GM, real omega, real f);
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
} // namespace GeographicLib
|
|
349
|
+
|
|
350
|
+
#endif // GEOGRAPHICLIB_NORMALGRAVITY_HPP
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* \file OSGB.hpp
|
|
3
|
+
* \brief Header for GeographicLib::OSGB class
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Charles Karney (2010-2015) <charles@karney.com> and licensed
|
|
6
|
+
* under the MIT/X11 License. For more information, see
|
|
7
|
+
* http://geographiclib.sourceforge.net/
|
|
8
|
+
**********************************************************************/
|
|
9
|
+
|
|
10
|
+
#if !defined(GEOGRAPHICLIB_OSGB_HPP)
|
|
11
|
+
#define GEOGRAPHICLIB_OSGB_HPP 1
|
|
12
|
+
|
|
13
|
+
#include <GeographicLib/Constants.hpp>
|
|
14
|
+
#include <GeographicLib/TransverseMercator.hpp>
|
|
15
|
+
|
|
16
|
+
#if defined(_MSC_VER)
|
|
17
|
+
// Squelch warnings about dll vs string
|
|
18
|
+
# pragma warning (push)
|
|
19
|
+
# pragma warning (disable: 4251)
|
|
20
|
+
#endif
|
|
21
|
+
|
|
22
|
+
namespace GeographicLib {
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* \brief Ordnance Survey grid system for Great Britain
|
|
26
|
+
*
|
|
27
|
+
* The class implements the coordinate system used by the Ordnance Survey for
|
|
28
|
+
* maps of Great Britain and conversions to the grid reference system.
|
|
29
|
+
*
|
|
30
|
+
* See
|
|
31
|
+
* - <a href="http://www.ordnancesurvey.co.uk/docs/support/guide-coordinate-systems-great-britain.pdf">
|
|
32
|
+
* A guide to coordinate systems in Great Britain</a>
|
|
33
|
+
* - <a href="http://www.ordnancesurvey.co.uk/docs/support/national-grid.pdf">
|
|
34
|
+
* Guide to the National Grid</a>
|
|
35
|
+
*
|
|
36
|
+
* \b WARNING: the latitudes and longitudes for the Ordnance Survey grid
|
|
37
|
+
* system do not use the WGS84 datum. Do not use the values returned by this
|
|
38
|
+
* class in the UTMUPS, MGRS, or Geoid classes without first converting the
|
|
39
|
+
* datum (and vice versa).
|
|
40
|
+
*
|
|
41
|
+
* Example of use:
|
|
42
|
+
* \include example-OSGB.cpp
|
|
43
|
+
**********************************************************************/
|
|
44
|
+
class GEOGRAPHICLIB_EXPORT OSGB {
|
|
45
|
+
private:
|
|
46
|
+
typedef Math::real real;
|
|
47
|
+
static const std::string letters_;
|
|
48
|
+
static const std::string digits_;
|
|
49
|
+
static const TransverseMercator& OSGBTM();
|
|
50
|
+
enum {
|
|
51
|
+
base_ = 10,
|
|
52
|
+
tile_ = 100000,
|
|
53
|
+
tilelevel_ = 5,
|
|
54
|
+
tilegrid_ = 5,
|
|
55
|
+
tileoffx_ = 2 * tilegrid_,
|
|
56
|
+
tileoffy_ = 1 * tilegrid_,
|
|
57
|
+
minx_ = - tileoffx_ * tile_,
|
|
58
|
+
miny_ = - tileoffy_ * tile_,
|
|
59
|
+
maxx_ = (tilegrid_*tilegrid_ - tileoffx_) * tile_,
|
|
60
|
+
maxy_ = (tilegrid_*tilegrid_ - tileoffy_) * tile_,
|
|
61
|
+
// Maximum precision is um
|
|
62
|
+
maxprec_ = 5 + 6,
|
|
63
|
+
};
|
|
64
|
+
static real computenorthoffset();
|
|
65
|
+
static void CheckCoords(real x, real y);
|
|
66
|
+
OSGB(); // Disable constructor
|
|
67
|
+
public:
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Forward projection, from geographic to OSGB coordinates.
|
|
71
|
+
*
|
|
72
|
+
* @param[in] lat latitude of point (degrees).
|
|
73
|
+
* @param[in] lon longitude of point (degrees).
|
|
74
|
+
* @param[out] x easting of point (meters).
|
|
75
|
+
* @param[out] y northing of point (meters).
|
|
76
|
+
* @param[out] gamma meridian convergence at point (degrees).
|
|
77
|
+
* @param[out] k scale of projection at point.
|
|
78
|
+
*
|
|
79
|
+
* \e lat should be in the range [−90°, 90°].
|
|
80
|
+
**********************************************************************/
|
|
81
|
+
static void Forward(real lat, real lon,
|
|
82
|
+
real& x, real& y, real& gamma, real& k) {
|
|
83
|
+
OSGBTM().Forward(OriginLongitude(), lat, lon, x, y, gamma, k);
|
|
84
|
+
x += FalseEasting();
|
|
85
|
+
y += computenorthoffset();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Reverse projection, from OSGB coordinates to geographic.
|
|
90
|
+
*
|
|
91
|
+
* @param[in] x easting of point (meters).
|
|
92
|
+
* @param[in] y northing of point (meters).
|
|
93
|
+
* @param[out] lat latitude of point (degrees).
|
|
94
|
+
* @param[out] lon longitude of point (degrees).
|
|
95
|
+
* @param[out] gamma meridian convergence at point (degrees).
|
|
96
|
+
* @param[out] k scale of projection at point.
|
|
97
|
+
*
|
|
98
|
+
* The value of \e lon returned is in the range [−180°,
|
|
99
|
+
* 180°).
|
|
100
|
+
**********************************************************************/
|
|
101
|
+
|
|
102
|
+
static void Reverse(real x, real y,
|
|
103
|
+
real& lat, real& lon, real& gamma, real& k) {
|
|
104
|
+
x -= FalseEasting();
|
|
105
|
+
y -= computenorthoffset();
|
|
106
|
+
OSGBTM().Reverse(OriginLongitude(), x, y, lat, lon, gamma, k);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* OSGB::Forward without returning the convergence and scale.
|
|
111
|
+
**********************************************************************/
|
|
112
|
+
static void Forward(real lat, real lon, real& x, real& y) {
|
|
113
|
+
real gamma, k;
|
|
114
|
+
Forward(lat, lon, x, y, gamma, k);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* OSGB::Reverse without returning the convergence and scale.
|
|
119
|
+
**********************************************************************/
|
|
120
|
+
static void Reverse(real x, real y, real& lat, real& lon) {
|
|
121
|
+
real gamma, k;
|
|
122
|
+
Reverse(x, y, lat, lon, gamma, k);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Convert OSGB coordinates to a grid reference.
|
|
127
|
+
*
|
|
128
|
+
* @param[in] x easting of point (meters).
|
|
129
|
+
* @param[in] y northing of point (meters).
|
|
130
|
+
* @param[in] prec precision relative to 100 km.
|
|
131
|
+
* @param[out] gridref National Grid reference.
|
|
132
|
+
* @exception GeographicErr if \e prec, \e x, or \e y is outside its
|
|
133
|
+
* allowed range.
|
|
134
|
+
* @exception std::bad_alloc if the memory for \e gridref can't be
|
|
135
|
+
* allocatied.
|
|
136
|
+
*
|
|
137
|
+
* \e prec specifies the precision of the grid reference string as follows:
|
|
138
|
+
* - prec = 0 (min), 100km
|
|
139
|
+
* - prec = 1, 10km
|
|
140
|
+
* - prec = 2, 1km
|
|
141
|
+
* - prec = 3, 100m
|
|
142
|
+
* - prec = 4, 10m
|
|
143
|
+
* - prec = 5, 1m
|
|
144
|
+
* - prec = 6, 0.1m
|
|
145
|
+
* - prec = 11 (max), 1μm
|
|
146
|
+
*
|
|
147
|
+
* The easting must be in the range [−1000 km, 1500 km) and the
|
|
148
|
+
* northing must be in the range [−500 km, 2000 km). These bounds
|
|
149
|
+
* are consistent with rules for the letter designations for the grid
|
|
150
|
+
* system.
|
|
151
|
+
*
|
|
152
|
+
* If \e x or \e y is NaN, the returned grid reference is "INVALID".
|
|
153
|
+
**********************************************************************/
|
|
154
|
+
static void GridReference(real x, real y, int prec, std::string& gridref);
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Convert OSGB coordinates to a grid reference.
|
|
158
|
+
*
|
|
159
|
+
* @param[in] gridref National Grid reference.
|
|
160
|
+
* @param[out] x easting of point (meters).
|
|
161
|
+
* @param[out] y northing of point (meters).
|
|
162
|
+
* @param[out] prec precision relative to 100 km.
|
|
163
|
+
* @param[in] centerp if true (default), return center of the grid square,
|
|
164
|
+
* else return SW (lower left) corner.
|
|
165
|
+
* @exception GeographicErr if \e gridref is illegal.
|
|
166
|
+
*
|
|
167
|
+
* The grid reference must be of the form: two letters (not including I)
|
|
168
|
+
* followed by an even number of digits (up to 22).
|
|
169
|
+
*
|
|
170
|
+
* If the first 2 characters of \e gridref are "IN", then \e x and \e y are
|
|
171
|
+
* set to NaN and \e prec is set to −2.
|
|
172
|
+
**********************************************************************/
|
|
173
|
+
static void GridReference(const std::string& gridref,
|
|
174
|
+
real& x, real& y, int& prec,
|
|
175
|
+
bool centerp = true);
|
|
176
|
+
|
|
177
|
+
/** \name Inspector functions
|
|
178
|
+
**********************************************************************/
|
|
179
|
+
///@{
|
|
180
|
+
/**
|
|
181
|
+
* @return \e a the equatorial radius of the Airy 1830 ellipsoid (meters).
|
|
182
|
+
*
|
|
183
|
+
* This is 20923713 ft converted to meters using the rule 1 ft =
|
|
184
|
+
* 10<sup>9.48401603−10</sup> m. The Airy 1830 value is returned
|
|
185
|
+
* because the OSGB projection is based on this ellipsoid. The conversion
|
|
186
|
+
* factor from feet to meters is the one used for the 1936 retriangulation
|
|
187
|
+
* of Britain; see Section A.1 (p. 37) of <i>A guide to coordinate systems
|
|
188
|
+
* in Great Britain</i>, v2.2 (Dec. 2013).
|
|
189
|
+
**********************************************************************/
|
|
190
|
+
static Math::real MajorRadius() {
|
|
191
|
+
// result is about 6377563.3960320664406 m
|
|
192
|
+
using std::pow;
|
|
193
|
+
return pow(real(10), real(48401603 - 100000000) / 100000000)
|
|
194
|
+
* 20923713;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* @return \e f the inverse flattening of the Airy 1830 ellipsoid.
|
|
199
|
+
*
|
|
200
|
+
* For the Airy 1830 ellipsoid, \e a = 20923713 ft and \e b = 20853810 ft;
|
|
201
|
+
* thus the flattening = (20923713 − 20853810)/20923713 =
|
|
202
|
+
* 7767/2324857 = 1/299.32496459... (The Airy 1830 value is returned
|
|
203
|
+
* because the OSGB projection is based on this ellipsoid.)
|
|
204
|
+
**********************************************************************/
|
|
205
|
+
static Math::real Flattening()
|
|
206
|
+
{ return real(20923713 - 20853810) / 20923713; }
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* @return \e k0 central scale for the OSGB projection (0.9996012717...).
|
|
210
|
+
*
|
|
211
|
+
* C. J. Mugnier, Grids & Datums, PE&RS, Oct. 2003, states that
|
|
212
|
+
* this is defined as 10<sup>9.9998268−10</sup>.
|
|
213
|
+
**********************************************************************/
|
|
214
|
+
static Math::real CentralScale() {
|
|
215
|
+
using std::pow;
|
|
216
|
+
return pow(real(10), real(9998268 - 10000000) / 10000000);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* @return latitude of the origin for the OSGB projection (49 degrees).
|
|
221
|
+
**********************************************************************/
|
|
222
|
+
static Math::real OriginLatitude() { return real(49); }
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* @return longitude of the origin for the OSGB projection (−2
|
|
226
|
+
* degrees).
|
|
227
|
+
**********************************************************************/
|
|
228
|
+
static Math::real OriginLongitude() { return real(-2); }
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* @return false northing the OSGB projection (−100000 meters).
|
|
232
|
+
**********************************************************************/
|
|
233
|
+
static Math::real FalseNorthing() { return real(-100000); }
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* @return false easting the OSGB projection (400000 meters).
|
|
237
|
+
**********************************************************************/
|
|
238
|
+
static Math::real FalseEasting() { return real(400000); }
|
|
239
|
+
///@}
|
|
240
|
+
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
} // namespace GeographicLib
|
|
244
|
+
|
|
245
|
+
#if defined(_MSC_VER)
|
|
246
|
+
# pragma warning (pop)
|
|
247
|
+
#endif
|
|
248
|
+
|
|
249
|
+
#endif // GEOGRAPHICLIB_OSGB_HPP
|