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,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* \file Georef.hpp
|
|
3
|
+
* \brief Header for GeographicLib::Georef class
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Charles Karney (2015) <charles@karney.com> and licensed under
|
|
6
|
+
* the MIT/X11 License. For more information, see
|
|
7
|
+
* http://geographiclib.sourceforge.net/
|
|
8
|
+
**********************************************************************/
|
|
9
|
+
|
|
10
|
+
#if !defined(GEOGRAPHICLIB_GEOREF_HPP)
|
|
11
|
+
#define GEOGRAPHICLIB_GEOREF_HPP 1
|
|
12
|
+
|
|
13
|
+
#include <GeographicLib/Constants.hpp>
|
|
14
|
+
|
|
15
|
+
#if defined(_MSC_VER)
|
|
16
|
+
// Squelch warnings about dll vs string
|
|
17
|
+
# pragma warning (push)
|
|
18
|
+
# pragma warning (disable: 4251)
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
namespace GeographicLib {
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* \brief Conversions for the World Geographic Reference System (georef)
|
|
25
|
+
*
|
|
26
|
+
* The World Geographic Reference System is described in
|
|
27
|
+
* - https://en.wikipedia.org/wiki/Georef
|
|
28
|
+
* - http://earth-info.nga.mil/GandG/coordsys/grids/georef.pdf
|
|
29
|
+
* .
|
|
30
|
+
* It provides a compact string representation of a geographic area
|
|
31
|
+
* (expressed as latitude and longitude). The classes GARS and Geohash
|
|
32
|
+
* implement similar compact representations.
|
|
33
|
+
*
|
|
34
|
+
* Example of use:
|
|
35
|
+
* \include example-Georef.cpp
|
|
36
|
+
**********************************************************************/
|
|
37
|
+
|
|
38
|
+
class GEOGRAPHICLIB_EXPORT Georef {
|
|
39
|
+
private:
|
|
40
|
+
typedef Math::real real;
|
|
41
|
+
static const std::string digits_;
|
|
42
|
+
static const std::string lontile_;
|
|
43
|
+
static const std::string lattile_;
|
|
44
|
+
static const std::string degrees_;
|
|
45
|
+
enum {
|
|
46
|
+
tile_ = 15, // The size of tile in degrees
|
|
47
|
+
lonorig_ = -180, // Origin for longitude
|
|
48
|
+
latorig_ = -90, // Origin for latitude
|
|
49
|
+
base_ = 10, // Base for minutes
|
|
50
|
+
baselen_ = 4,
|
|
51
|
+
maxprec_ = 11, // approximately equivalent to MGRS class
|
|
52
|
+
maxlen_ = baselen_ + 2 * maxprec_,
|
|
53
|
+
};
|
|
54
|
+
Georef(); // Disable constructor
|
|
55
|
+
|
|
56
|
+
public:
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Convert from geographic coordinates to georef.
|
|
60
|
+
*
|
|
61
|
+
* @param[in] lat latitude of point (degrees).
|
|
62
|
+
* @param[in] lon longitude of point (degrees).
|
|
63
|
+
* @param[in] prec the precision of the resulting georef.
|
|
64
|
+
* @param[out] georef the georef string.
|
|
65
|
+
* @exception GeographicErr if \e lat is not in [−90°,
|
|
66
|
+
* 90°].
|
|
67
|
+
* @exception std::bad_alloc if memory for \e georef can't be allocated.
|
|
68
|
+
*
|
|
69
|
+
* \e prec specifies the precision of \e georef as follows:
|
|
70
|
+
* - \e prec = −1 (min), 15°
|
|
71
|
+
* - \e prec = 0, 1°
|
|
72
|
+
* - \e prec = 1, converted to \e prec = 2
|
|
73
|
+
* - \e prec = 2, 1'
|
|
74
|
+
* - \e prec = 3, 0.1'
|
|
75
|
+
* - \e prec = 4, 0.01'
|
|
76
|
+
* - \e prec = 5, 0.001'
|
|
77
|
+
* - …
|
|
78
|
+
* - \e prec = 11 (max), 10<sup>−9</sup>'
|
|
79
|
+
*
|
|
80
|
+
* If \e lat or \e lon is NaN, then \e georef is set to "INVALID".
|
|
81
|
+
**********************************************************************/
|
|
82
|
+
static void Forward(real lat, real lon, int prec, std::string& georef);
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Convert from Georef to geographic coordinates.
|
|
86
|
+
*
|
|
87
|
+
* @param[in] georef the Georef.
|
|
88
|
+
* @param[out] lat latitude of point (degrees).
|
|
89
|
+
* @param[out] lon longitude of point (degrees).
|
|
90
|
+
* @param[out] prec the precision of \e georef.
|
|
91
|
+
* @param[in] centerp if true (the default) return the center
|
|
92
|
+
* \e georef, otherwise return the south-west corner.
|
|
93
|
+
* @exception GeographicErr if \e georef is illegal.
|
|
94
|
+
*
|
|
95
|
+
* The case of the letters in \e georef is ignored. \e prec is in the
|
|
96
|
+
* range [−1, 11] and gives the precision of \e georef as follows:
|
|
97
|
+
* - \e prec = −1 (min), 15°
|
|
98
|
+
* - \e prec = 0, 1°
|
|
99
|
+
* - \e prec = 1, not returned
|
|
100
|
+
* - \e prec = 2, 1'
|
|
101
|
+
* - \e prec = 3, 0.1'
|
|
102
|
+
* - \e prec = 4, 0.01'
|
|
103
|
+
* - \e prec = 5, 0.001'
|
|
104
|
+
* - …
|
|
105
|
+
* - \e prec = 11 (max), 10<sup>−9</sup>'
|
|
106
|
+
*
|
|
107
|
+
* If the first 3 characters of \e georef are "INV", then \e lat and \e lon
|
|
108
|
+
* are set to NaN and \e prec is unchanged.
|
|
109
|
+
**********************************************************************/
|
|
110
|
+
static void Reverse(const std::string& georef, real& lat, real& lon,
|
|
111
|
+
int& prec, bool centerp = true);
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The angular resolution of a Georef.
|
|
115
|
+
*
|
|
116
|
+
* @param[in] prec the precision of the Georef.
|
|
117
|
+
* @return the latitude-longitude resolution (degrees).
|
|
118
|
+
*
|
|
119
|
+
* Internally, \e prec is first put in the range [−1, 11].
|
|
120
|
+
**********************************************************************/
|
|
121
|
+
static Math::real Resolution(int prec) {
|
|
122
|
+
if (prec < 1)
|
|
123
|
+
return real(prec < 0 ? 15 : 1);
|
|
124
|
+
else {
|
|
125
|
+
using std::pow;
|
|
126
|
+
// Treat prec = 1 as 2.
|
|
127
|
+
prec = (std::max)(2, (std::min)(int(maxprec_), prec));
|
|
128
|
+
return 1/(60 * pow(real(base_), prec - 2));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* The Georef precision required to meet a given geographic resolution.
|
|
134
|
+
*
|
|
135
|
+
* @param[in] res the minimum of resolution in latitude and longitude
|
|
136
|
+
* (degrees).
|
|
137
|
+
* @return Georef precision.
|
|
138
|
+
*
|
|
139
|
+
* The returned length is in the range [0, 11].
|
|
140
|
+
**********************************************************************/
|
|
141
|
+
static int Precision(real res) {
|
|
142
|
+
using std::abs; res = abs(res);
|
|
143
|
+
for (int prec = 0; prec < maxprec_; ++prec) {
|
|
144
|
+
if (prec == 1)
|
|
145
|
+
continue;
|
|
146
|
+
if (Resolution(prec) <= res)
|
|
147
|
+
return prec;
|
|
148
|
+
}
|
|
149
|
+
return maxprec_;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
} // namespace GeographicLib
|
|
155
|
+
|
|
156
|
+
#if defined(_MSC_VER)
|
|
157
|
+
# pragma warning (pop)
|
|
158
|
+
#endif
|
|
159
|
+
|
|
160
|
+
#endif // GEOGRAPHICLIB_GEOREF_HPP
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* \file Gnomonic.hpp
|
|
3
|
+
* \brief Header for GeographicLib::Gnomonic 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_GNOMONIC_HPP)
|
|
11
|
+
#define GEOGRAPHICLIB_GNOMONIC_HPP 1
|
|
12
|
+
|
|
13
|
+
#include <GeographicLib/Geodesic.hpp>
|
|
14
|
+
#include <GeographicLib/GeodesicLine.hpp>
|
|
15
|
+
#include <GeographicLib/Constants.hpp>
|
|
16
|
+
|
|
17
|
+
namespace GeographicLib {
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* \brief %Gnomonic projection
|
|
21
|
+
*
|
|
22
|
+
* %Gnomonic projection centered at an arbitrary position \e C on the
|
|
23
|
+
* ellipsoid. This projection is derived in Section 8 of
|
|
24
|
+
* - C. F. F. Karney,
|
|
25
|
+
* <a href="https://dx.doi.org/10.1007/s00190-012-0578-z">
|
|
26
|
+
* Algorithms for geodesics</a>,
|
|
27
|
+
* J. Geodesy <b>87</b>, 43--55 (2013);
|
|
28
|
+
* DOI: <a href="https://dx.doi.org/10.1007/s00190-012-0578-z">
|
|
29
|
+
* 10.1007/s00190-012-0578-z</a>;
|
|
30
|
+
* addenda: <a href="http://geographiclib.sourceforge.net/geod-addenda.html">
|
|
31
|
+
* geod-addenda.html</a>.
|
|
32
|
+
* .
|
|
33
|
+
* The projection of \e P is defined as follows: compute the geodesic line
|
|
34
|
+
* from \e C to \e P; compute the reduced length \e m12, geodesic scale \e
|
|
35
|
+
* M12, and ρ = <i>m12</i>/\e M12; finally \e x = ρ sin \e azi1; \e
|
|
36
|
+
* y = ρ cos \e azi1, where \e azi1 is the azimuth of the geodesic at \e
|
|
37
|
+
* C. The Gnomonic::Forward and Gnomonic::Reverse methods also return the
|
|
38
|
+
* azimuth \e azi of the geodesic at \e P and reciprocal scale \e rk in the
|
|
39
|
+
* azimuthal direction. The scale in the radial direction if
|
|
40
|
+
* 1/<i>rk</i><sup>2</sup>.
|
|
41
|
+
*
|
|
42
|
+
* For a sphere, ρ is reduces to \e a tan(<i>s12</i>/<i>a</i>), where \e
|
|
43
|
+
* s12 is the length of the geodesic from \e C to \e P, and the gnomonic
|
|
44
|
+
* projection has the property that all geodesics appear as straight lines.
|
|
45
|
+
* For an ellipsoid, this property holds only for geodesics interesting the
|
|
46
|
+
* centers. However geodesic segments close to the center are approximately
|
|
47
|
+
* straight.
|
|
48
|
+
*
|
|
49
|
+
* Consider a geodesic segment of length \e l. Let \e T be the point on the
|
|
50
|
+
* geodesic (extended if necessary) closest to \e C the center of the
|
|
51
|
+
* projection and \e t be the distance \e CT. To lowest order, the maximum
|
|
52
|
+
* deviation (as a true distance) of the corresponding gnomonic line segment
|
|
53
|
+
* (i.e., with the same end points) from the geodesic is<br>
|
|
54
|
+
* <br>
|
|
55
|
+
* (<i>K</i>(<i>T</i>) - <i>K</i>(<i>C</i>))
|
|
56
|
+
* <i>l</i><sup>2</sup> \e t / 32.<br>
|
|
57
|
+
* <br>
|
|
58
|
+
* where \e K is the Gaussian curvature.
|
|
59
|
+
*
|
|
60
|
+
* This result applies for any surface. For an ellipsoid of revolution,
|
|
61
|
+
* consider all geodesics whose end points are within a distance \e r of \e
|
|
62
|
+
* C. For a given \e r, the deviation is maximum when the latitude of \e C
|
|
63
|
+
* is 45°, when endpoints are a distance \e r away, and when their
|
|
64
|
+
* azimuths from the center are ± 45° or ± 135°.
|
|
65
|
+
* To lowest order in \e r and the flattening \e f, the deviation is \e f
|
|
66
|
+
* (<i>r</i>/2<i>a</i>)<sup>3</sup> \e r.
|
|
67
|
+
*
|
|
68
|
+
* The conversions all take place using a Geodesic object (by default
|
|
69
|
+
* Geodesic::WGS84()). For more information on geodesics see \ref geodesic.
|
|
70
|
+
*
|
|
71
|
+
* <b>CAUTION:</b> The definition of this projection for a sphere is
|
|
72
|
+
* standard. However, there is no standard for how it should be extended to
|
|
73
|
+
* an ellipsoid. The choices are:
|
|
74
|
+
* - Declare that the projection is undefined for an ellipsoid.
|
|
75
|
+
* - Project to a tangent plane from the center of the ellipsoid. This
|
|
76
|
+
* causes great ellipses to appear as straight lines in the projection;
|
|
77
|
+
* i.e., it generalizes the spherical great circle to a great ellipse.
|
|
78
|
+
* This was proposed by independently by Bowring and Williams in 1997.
|
|
79
|
+
* - Project to the conformal sphere with the constant of integration chosen
|
|
80
|
+
* so that the values of the latitude match for the center point and
|
|
81
|
+
* perform a central projection onto the plane tangent to the conformal
|
|
82
|
+
* sphere at the center point. This causes normal sections through the
|
|
83
|
+
* center point to appear as straight lines in the projection; i.e., it
|
|
84
|
+
* generalizes the spherical great circle to a normal section. This was
|
|
85
|
+
* proposed by I. G. Letoval'tsev, Generalization of the gnomonic
|
|
86
|
+
* projection for a spheroid and the principal geodetic problems involved
|
|
87
|
+
* in the alignment of surface routes, Geodesy and Aerophotography (5),
|
|
88
|
+
* 271--274 (1963).
|
|
89
|
+
* - The projection given here. This causes geodesics close to the center
|
|
90
|
+
* point to appear as straight lines in the projection; i.e., it
|
|
91
|
+
* generalizes the spherical great circle to a geodesic.
|
|
92
|
+
*
|
|
93
|
+
* Example of use:
|
|
94
|
+
* \include example-Gnomonic.cpp
|
|
95
|
+
*
|
|
96
|
+
* <a href="GeodesicProj.1.html">GeodesicProj</a> is a command-line utility
|
|
97
|
+
* providing access to the functionality of AzimuthalEquidistant, Gnomonic,
|
|
98
|
+
* and CassiniSoldner.
|
|
99
|
+
**********************************************************************/
|
|
100
|
+
|
|
101
|
+
class GEOGRAPHICLIB_EXPORT Gnomonic {
|
|
102
|
+
private:
|
|
103
|
+
typedef Math::real real;
|
|
104
|
+
real eps0_, eps_;
|
|
105
|
+
Geodesic _earth;
|
|
106
|
+
real _a, _f;
|
|
107
|
+
static const int numit_ = 10;
|
|
108
|
+
public:
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Constructor for Gnomonic.
|
|
112
|
+
*
|
|
113
|
+
* @param[in] earth the Geodesic object to use for geodesic calculations.
|
|
114
|
+
* By default this uses the WGS84 ellipsoid.
|
|
115
|
+
**********************************************************************/
|
|
116
|
+
explicit Gnomonic(const Geodesic& earth = Geodesic::WGS84());
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Forward projection, from geographic to gnomonic.
|
|
120
|
+
*
|
|
121
|
+
* @param[in] lat0 latitude of center point of projection (degrees).
|
|
122
|
+
* @param[in] lon0 longitude of center point of projection (degrees).
|
|
123
|
+
* @param[in] lat latitude of point (degrees).
|
|
124
|
+
* @param[in] lon longitude of point (degrees).
|
|
125
|
+
* @param[out] x easting of point (meters).
|
|
126
|
+
* @param[out] y northing of point (meters).
|
|
127
|
+
* @param[out] azi azimuth of geodesic at point (degrees).
|
|
128
|
+
* @param[out] rk reciprocal of azimuthal scale at point.
|
|
129
|
+
*
|
|
130
|
+
* \e lat0 and \e lat should be in the range [−90°, 90°].
|
|
131
|
+
* The scale of the projection is 1/<i>rk</i><sup>2</sup> in the "radial"
|
|
132
|
+
* direction, \e azi clockwise from true north, and is 1/\e rk in the
|
|
133
|
+
* direction perpendicular to this. If the point lies "over the horizon",
|
|
134
|
+
* i.e., if \e rk ≤ 0, then NaNs are returned for \e x and \e y (the
|
|
135
|
+
* correct values are returned for \e azi and \e rk). A call to Forward
|
|
136
|
+
* followed by a call to Reverse will return the original (\e lat, \e lon)
|
|
137
|
+
* (to within roundoff) provided the point in not over the horizon.
|
|
138
|
+
**********************************************************************/
|
|
139
|
+
void Forward(real lat0, real lon0, real lat, real lon,
|
|
140
|
+
real& x, real& y, real& azi, real& rk) const;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Reverse projection, from gnomonic to geographic.
|
|
144
|
+
*
|
|
145
|
+
* @param[in] lat0 latitude of center point of projection (degrees).
|
|
146
|
+
* @param[in] lon0 longitude of center point of projection (degrees).
|
|
147
|
+
* @param[in] x easting of point (meters).
|
|
148
|
+
* @param[in] y northing of point (meters).
|
|
149
|
+
* @param[out] lat latitude of point (degrees).
|
|
150
|
+
* @param[out] lon longitude of point (degrees).
|
|
151
|
+
* @param[out] azi azimuth of geodesic at point (degrees).
|
|
152
|
+
* @param[out] rk reciprocal of azimuthal scale at point.
|
|
153
|
+
*
|
|
154
|
+
* \e lat0 should be in the range [−90°, 90°]. \e lat will
|
|
155
|
+
* be in the range [−90°, 90°] and \e lon will be in the
|
|
156
|
+
* range [−180°, 180°). The scale of the projection is
|
|
157
|
+
* 1/<i>rk</i><sup>2</sup> in the "radial" direction, \e azi clockwise from
|
|
158
|
+
* true north, and is 1/\e rk in the direction perpendicular to this. Even
|
|
159
|
+
* though all inputs should return a valid \e lat and \e lon, it's possible
|
|
160
|
+
* that the procedure fails to converge for very large \e x or \e y; in
|
|
161
|
+
* this case NaNs are returned for all the output arguments. A call to
|
|
162
|
+
* Reverse followed by a call to Forward will return the original (\e x, \e
|
|
163
|
+
* y) (to roundoff).
|
|
164
|
+
**********************************************************************/
|
|
165
|
+
void Reverse(real lat0, real lon0, real x, real y,
|
|
166
|
+
real& lat, real& lon, real& azi, real& rk) const;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Gnomonic::Forward without returning the azimuth and scale.
|
|
170
|
+
**********************************************************************/
|
|
171
|
+
void Forward(real lat0, real lon0, real lat, real lon,
|
|
172
|
+
real& x, real& y) const {
|
|
173
|
+
real azi, rk;
|
|
174
|
+
Forward(lat0, lon0, lat, lon, x, y, azi, rk);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Gnomonic::Reverse without returning the azimuth and scale.
|
|
179
|
+
**********************************************************************/
|
|
180
|
+
void Reverse(real lat0, real lon0, real x, real y,
|
|
181
|
+
real& lat, real& lon) const {
|
|
182
|
+
real azi, rk;
|
|
183
|
+
Reverse(lat0, lon0, x, y, lat, lon, azi, rk);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** \name Inspector functions
|
|
187
|
+
**********************************************************************/
|
|
188
|
+
///@{
|
|
189
|
+
/**
|
|
190
|
+
* @return \e a the equatorial radius of the ellipsoid (meters). This is
|
|
191
|
+
* the value inherited from the Geodesic object used in the constructor.
|
|
192
|
+
**********************************************************************/
|
|
193
|
+
Math::real MajorRadius() const { return _earth.MajorRadius(); }
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* @return \e f the flattening of the ellipsoid. This is the value
|
|
197
|
+
* inherited from the Geodesic object used in the constructor.
|
|
198
|
+
**********************************************************************/
|
|
199
|
+
Math::real Flattening() const { return _earth.Flattening(); }
|
|
200
|
+
///@}
|
|
201
|
+
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
} // namespace GeographicLib
|
|
205
|
+
|
|
206
|
+
#endif // GEOGRAPHICLIB_GNOMONIC_HPP
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* \file GravityCircle.hpp
|
|
3
|
+
* \brief Header for GeographicLib::GravityCircle class
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Charles Karney (2011-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_GRAVITYCIRCLE_HPP)
|
|
11
|
+
#define GEOGRAPHICLIB_GRAVITYCIRCLE_HPP 1
|
|
12
|
+
|
|
13
|
+
#include <vector>
|
|
14
|
+
#include <GeographicLib/Constants.hpp>
|
|
15
|
+
#include <GeographicLib/CircularEngine.hpp>
|
|
16
|
+
#include <GeographicLib/GravityModel.hpp>
|
|
17
|
+
|
|
18
|
+
namespace GeographicLib {
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* \brief Gravity on a circle of latitude
|
|
22
|
+
*
|
|
23
|
+
* Evaluate the earth's gravity field on a circle of constant height and
|
|
24
|
+
* latitude. This uses a CircularEngine to pre-evaluate the inner sum of the
|
|
25
|
+
* spherical harmonic sum, allowing the values of the field at several
|
|
26
|
+
* different longitudes to be evaluated rapidly.
|
|
27
|
+
*
|
|
28
|
+
* Use GravityModel::Circle to create a GravityCircle object. (The
|
|
29
|
+
* constructor for this class is private.)
|
|
30
|
+
*
|
|
31
|
+
* See \ref gravityparallel for an example of using GravityCircle (together
|
|
32
|
+
* with OpenMP) to speed up the computation of geoid heights.
|
|
33
|
+
*
|
|
34
|
+
* Example of use:
|
|
35
|
+
* \include example-GravityCircle.cpp
|
|
36
|
+
*
|
|
37
|
+
* <a href="Gravity.1.html">Gravity</a> is a command-line utility providing
|
|
38
|
+
* access to the functionality of GravityModel and GravityCircle.
|
|
39
|
+
**********************************************************************/
|
|
40
|
+
|
|
41
|
+
class GEOGRAPHICLIB_EXPORT GravityCircle {
|
|
42
|
+
private:
|
|
43
|
+
typedef Math::real real;
|
|
44
|
+
enum mask {
|
|
45
|
+
NONE = GravityModel::NONE,
|
|
46
|
+
GRAVITY = GravityModel::GRAVITY,
|
|
47
|
+
DISTURBANCE = GravityModel::DISTURBANCE,
|
|
48
|
+
DISTURBING_POTENTIAL = GravityModel::DISTURBING_POTENTIAL,
|
|
49
|
+
GEOID_HEIGHT = GravityModel::GEOID_HEIGHT,
|
|
50
|
+
SPHERICAL_ANOMALY = GravityModel::SPHERICAL_ANOMALY,
|
|
51
|
+
ALL = GravityModel::ALL,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
unsigned _caps;
|
|
55
|
+
real _a, _f, _lat, _h, _Z, _Px, _invR, _cpsi, _spsi,
|
|
56
|
+
_cphi, _sphi, _amodel, _GMmodel, _dzonal0,
|
|
57
|
+
_corrmult, _gamma0, _gamma, _frot;
|
|
58
|
+
CircularEngine _gravitational, _disturbing, _correction;
|
|
59
|
+
|
|
60
|
+
GravityCircle(mask caps, real a, real f, real lat, real h,
|
|
61
|
+
real Z, real P, real cphi, real sphi,
|
|
62
|
+
real amodel, real GMmodel, real dzonal0, real corrmult,
|
|
63
|
+
real gamma0, real gamma, real frot,
|
|
64
|
+
const CircularEngine& gravitational,
|
|
65
|
+
const CircularEngine& disturbing,
|
|
66
|
+
const CircularEngine& correction)
|
|
67
|
+
: _caps(caps)
|
|
68
|
+
, _a(a)
|
|
69
|
+
, _f(f)
|
|
70
|
+
, _lat(Math::LatFix(lat))
|
|
71
|
+
, _h(h)
|
|
72
|
+
, _Z(Z)
|
|
73
|
+
, _Px(P)
|
|
74
|
+
, _invR(1 / Math::hypot(_Px, _Z))
|
|
75
|
+
, _cpsi(_Px * _invR)
|
|
76
|
+
, _spsi(_Z * _invR)
|
|
77
|
+
, _cphi(cphi)
|
|
78
|
+
, _sphi(sphi)
|
|
79
|
+
, _amodel(amodel)
|
|
80
|
+
, _GMmodel(GMmodel)
|
|
81
|
+
, _dzonal0(dzonal0)
|
|
82
|
+
, _corrmult(corrmult)
|
|
83
|
+
, _gamma0(gamma0)
|
|
84
|
+
, _gamma(gamma)
|
|
85
|
+
, _frot(frot)
|
|
86
|
+
, _gravitational(gravitational)
|
|
87
|
+
, _disturbing(disturbing)
|
|
88
|
+
, _correction(correction)
|
|
89
|
+
{}
|
|
90
|
+
|
|
91
|
+
friend class GravityModel; // GravityModel calls the private constructor
|
|
92
|
+
Math::real W(real slam, real clam,
|
|
93
|
+
real& gX, real& gY, real& gZ) const;
|
|
94
|
+
Math::real V(real slam, real clam,
|
|
95
|
+
real& gX, real& gY, real& gZ) const;
|
|
96
|
+
Math::real InternalT(real slam, real clam,
|
|
97
|
+
real& deltaX, real& deltaY, real& deltaZ,
|
|
98
|
+
bool gradp, bool correct) const;
|
|
99
|
+
public:
|
|
100
|
+
/**
|
|
101
|
+
* A default constructor for the normal gravity. This sets up an
|
|
102
|
+
* uninitialized object which can be later replaced by the
|
|
103
|
+
* GravityModel::Circle.
|
|
104
|
+
**********************************************************************/
|
|
105
|
+
GravityCircle() : _a(-1) {}
|
|
106
|
+
|
|
107
|
+
/** \name Compute the gravitational field
|
|
108
|
+
**********************************************************************/
|
|
109
|
+
///@{
|
|
110
|
+
/**
|
|
111
|
+
* Evaluate the gravity.
|
|
112
|
+
*
|
|
113
|
+
* @param[in] lon the geographic longitude (degrees).
|
|
114
|
+
* @param[out] gx the easterly component of the acceleration
|
|
115
|
+
* (m s<sup>−2</sup>).
|
|
116
|
+
* @param[out] gy the northerly component of the acceleration
|
|
117
|
+
* (m s<sup>−2</sup>).
|
|
118
|
+
* @param[out] gz the upward component of the acceleration
|
|
119
|
+
* (m s<sup>−2</sup>); this is usually negative.
|
|
120
|
+
* @return \e W the sum of the gravitational and centrifugal potentials.
|
|
121
|
+
*
|
|
122
|
+
* The function includes the effects of the earth's rotation.
|
|
123
|
+
**********************************************************************/
|
|
124
|
+
Math::real Gravity(real lon, real& gx, real& gy, real& gz) const;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Evaluate the gravity disturbance vector.
|
|
128
|
+
*
|
|
129
|
+
* @param[in] lon the geographic longitude (degrees).
|
|
130
|
+
* @param[out] deltax the easterly component of the disturbance vector
|
|
131
|
+
* (m s<sup>−2</sup>).
|
|
132
|
+
* @param[out] deltay the northerly component of the disturbance vector
|
|
133
|
+
* (m s<sup>−2</sup>).
|
|
134
|
+
* @param[out] deltaz the upward component of the disturbance vector
|
|
135
|
+
* (m s<sup>−2</sup>).
|
|
136
|
+
* @return \e T the corresponding disturbing potential.
|
|
137
|
+
**********************************************************************/
|
|
138
|
+
Math::real Disturbance(real lon, real& deltax, real& deltay, real& deltaz)
|
|
139
|
+
const;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Evaluate the geoid height.
|
|
143
|
+
*
|
|
144
|
+
* @param[in] lon the geographic longitude (degrees).
|
|
145
|
+
* @return \e N the height of the geoid above the reference ellipsoid
|
|
146
|
+
* (meters).
|
|
147
|
+
*
|
|
148
|
+
* Some approximations are made in computing the geoid height so that the
|
|
149
|
+
* results of the NGA codes are reproduced accurately. Details are given
|
|
150
|
+
* in \ref gravitygeoid.
|
|
151
|
+
**********************************************************************/
|
|
152
|
+
Math::real GeoidHeight(real lon) const;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Evaluate the components of the gravity anomaly vector using the
|
|
156
|
+
* spherical approximation.
|
|
157
|
+
*
|
|
158
|
+
* @param[in] lon the geographic longitude (degrees).
|
|
159
|
+
* @param[out] Dg01 the gravity anomaly (m s<sup>−2</sup>).
|
|
160
|
+
* @param[out] xi the northerly component of the deflection of the vertical
|
|
161
|
+
* (degrees).
|
|
162
|
+
* @param[out] eta the easterly component of the deflection of the vertical
|
|
163
|
+
* (degrees).
|
|
164
|
+
*
|
|
165
|
+
* The spherical approximation (see Heiskanen and Moritz, Sec 2-14) is used
|
|
166
|
+
* so that the results of the NGA codes are reproduced accurately.
|
|
167
|
+
* approximations used here. Details are given in \ref gravitygeoid.
|
|
168
|
+
**********************************************************************/
|
|
169
|
+
void SphericalAnomaly(real lon, real& Dg01, real& xi, real& eta)
|
|
170
|
+
const;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Evaluate the components of the acceleration due to gravity and the
|
|
174
|
+
* centrifugal acceleration in geocentric coordinates.
|
|
175
|
+
*
|
|
176
|
+
* @param[in] lon the geographic longitude (degrees).
|
|
177
|
+
* @param[out] gX the \e X component of the acceleration
|
|
178
|
+
* (m s<sup>−2</sup>).
|
|
179
|
+
* @param[out] gY the \e Y component of the acceleration
|
|
180
|
+
* (m s<sup>−2</sup>).
|
|
181
|
+
* @param[out] gZ the \e Z component of the acceleration
|
|
182
|
+
* (m s<sup>−2</sup>).
|
|
183
|
+
* @return \e W = \e V + Φ the sum of the gravitational and
|
|
184
|
+
* centrifugal potentials (m<sup>2</sup> s<sup>−2</sup>).
|
|
185
|
+
**********************************************************************/
|
|
186
|
+
Math::real W(real lon, real& gX, real& gY, real& gZ) const {
|
|
187
|
+
real slam, clam;
|
|
188
|
+
Math::sincosd(lon, slam, clam);
|
|
189
|
+
return W(slam, clam, gX, gY, gZ);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Evaluate the components of the acceleration due to gravity in geocentric
|
|
194
|
+
* coordinates.
|
|
195
|
+
*
|
|
196
|
+
* @param[in] lon the geographic longitude (degrees).
|
|
197
|
+
* @param[out] GX the \e X component of the acceleration
|
|
198
|
+
* (m s<sup>−2</sup>).
|
|
199
|
+
* @param[out] GY the \e Y component of the acceleration
|
|
200
|
+
* (m s<sup>−2</sup>).
|
|
201
|
+
* @param[out] GZ the \e Z component of the acceleration
|
|
202
|
+
* (m s<sup>−2</sup>).
|
|
203
|
+
* @return \e V = \e W - Φ the gravitational potential
|
|
204
|
+
* (m<sup>2</sup> s<sup>−2</sup>).
|
|
205
|
+
**********************************************************************/
|
|
206
|
+
Math::real V(real lon, real& GX, real& GY, real& GZ) const {
|
|
207
|
+
real slam, clam;
|
|
208
|
+
Math::sincosd(lon, slam, clam);
|
|
209
|
+
return V(slam, clam, GX, GY, GZ);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Evaluate the components of the gravity disturbance in geocentric
|
|
214
|
+
* coordinates.
|
|
215
|
+
*
|
|
216
|
+
* @param[in] lon the geographic longitude (degrees).
|
|
217
|
+
* @param[out] deltaX the \e X component of the gravity disturbance
|
|
218
|
+
* (m s<sup>−2</sup>).
|
|
219
|
+
* @param[out] deltaY the \e Y component of the gravity disturbance
|
|
220
|
+
* (m s<sup>−2</sup>).
|
|
221
|
+
* @param[out] deltaZ the \e Z component of the gravity disturbance
|
|
222
|
+
* (m s<sup>−2</sup>).
|
|
223
|
+
* @return \e T = \e W - \e U the disturbing potential (also called the
|
|
224
|
+
* anomalous potential) (m<sup>2</sup> s<sup>−2</sup>).
|
|
225
|
+
**********************************************************************/
|
|
226
|
+
Math::real T(real lon, real& deltaX, real& deltaY, real& deltaZ)
|
|
227
|
+
const {
|
|
228
|
+
real slam, clam;
|
|
229
|
+
Math::sincosd(lon, slam, clam);
|
|
230
|
+
return InternalT(slam, clam, deltaX, deltaY, deltaZ, true, true);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Evaluate disturbing potential in geocentric coordinates.
|
|
235
|
+
*
|
|
236
|
+
* @param[in] lon the geographic longitude (degrees).
|
|
237
|
+
* @return \e T = \e W - \e U the disturbing potential (also called the
|
|
238
|
+
* anomalous potential) (m<sup>2</sup> s<sup>−2</sup>).
|
|
239
|
+
**********************************************************************/
|
|
240
|
+
Math::real T(real lon) const {
|
|
241
|
+
real slam, clam, dummy;
|
|
242
|
+
Math::sincosd(lon, slam, clam);
|
|
243
|
+
return InternalT(slam, clam, dummy, dummy, dummy, false, true);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
///@}
|
|
247
|
+
|
|
248
|
+
/** \name Inspector functions
|
|
249
|
+
**********************************************************************/
|
|
250
|
+
///@{
|
|
251
|
+
/**
|
|
252
|
+
* @return true if the object has been initialized.
|
|
253
|
+
**********************************************************************/
|
|
254
|
+
bool Init() const { return _a > 0; }
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* @return \e a the equatorial radius of the ellipsoid (meters). This is
|
|
258
|
+
* the value inherited from the GravityModel object used in the
|
|
259
|
+
* constructor.
|
|
260
|
+
**********************************************************************/
|
|
261
|
+
Math::real MajorRadius() const
|
|
262
|
+
{ return Init() ? _a : Math::NaN(); }
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* @return \e f the flattening of the ellipsoid. This is the value
|
|
266
|
+
* inherited from the GravityModel object used in the constructor.
|
|
267
|
+
**********************************************************************/
|
|
268
|
+
Math::real Flattening() const
|
|
269
|
+
{ return Init() ? _f : Math::NaN(); }
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* @return the latitude of the circle (degrees).
|
|
273
|
+
**********************************************************************/
|
|
274
|
+
Math::real Latitude() const
|
|
275
|
+
{ return Init() ? _lat : Math::NaN(); }
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* @return the height of the circle (meters).
|
|
279
|
+
**********************************************************************/
|
|
280
|
+
Math::real Height() const
|
|
281
|
+
{ return Init() ? _h : Math::NaN(); }
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* @return \e caps the computational capabilities that this object was
|
|
285
|
+
* constructed with.
|
|
286
|
+
**********************************************************************/
|
|
287
|
+
unsigned Capabilities() const { return _caps; }
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* @param[in] testcaps a set of bitor'ed GravityModel::mask values.
|
|
291
|
+
* @return true if the GravityCircle object has all these capabilities.
|
|
292
|
+
**********************************************************************/
|
|
293
|
+
bool Capabilities(unsigned testcaps) const {
|
|
294
|
+
return (_caps & testcaps) == testcaps;
|
|
295
|
+
}
|
|
296
|
+
///@}
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
} // namespace GeographicLib
|
|
300
|
+
|
|
301
|
+
#endif // GEOGRAPHICLIB_GRAVITYCIRCLE_HPP
|