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.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/AUTHORS +12 -0
  3. data/LICENSE +24 -0
  4. data/ext/geographiclib/Accumulator.cpp +23 -0
  5. data/ext/geographiclib/AlbersEqualArea.cpp +445 -0
  6. data/ext/geographiclib/AzimuthalEquidistant.cpp +41 -0
  7. data/ext/geographiclib/CassiniSoldner.cpp +89 -0
  8. data/ext/geographiclib/CircularEngine.cpp +96 -0
  9. data/ext/geographiclib/DMS.cpp +381 -0
  10. data/ext/geographiclib/Ellipsoid.cpp +125 -0
  11. data/ext/geographiclib/EllipticFunction.cpp +512 -0
  12. data/ext/geographiclib/GARS.cpp +122 -0
  13. data/ext/geographiclib/GeoCoords.cpp +175 -0
  14. data/ext/geographiclib/Geocentric.cpp +172 -0
  15. data/ext/geographiclib/Geodesic.cpp +1908 -0
  16. data/ext/geographiclib/GeodesicExact.cpp +927 -0
  17. data/ext/geographiclib/GeodesicExactC4.cpp +7879 -0
  18. data/ext/geographiclib/GeodesicLine.cpp +321 -0
  19. data/ext/geographiclib/GeodesicLineExact.cpp +289 -0
  20. data/ext/geographiclib/GeographicLib/Accumulator.hpp +184 -0
  21. data/ext/geographiclib/GeographicLib/AlbersEqualArea.hpp +312 -0
  22. data/ext/geographiclib/GeographicLib/AzimuthalEquidistant.hpp +139 -0
  23. data/ext/geographiclib/GeographicLib/CassiniSoldner.hpp +204 -0
  24. data/ext/geographiclib/GeographicLib/CircularEngine.hpp +195 -0
  25. data/ext/geographiclib/GeographicLib/Config.h +12 -0
  26. data/ext/geographiclib/GeographicLib/Constants.hpp +387 -0
  27. data/ext/geographiclib/GeographicLib/DMS.hpp +370 -0
  28. data/ext/geographiclib/GeographicLib/Ellipsoid.hpp +534 -0
  29. data/ext/geographiclib/GeographicLib/EllipticFunction.hpp +692 -0
  30. data/ext/geographiclib/GeographicLib/GARS.hpp +143 -0
  31. data/ext/geographiclib/GeographicLib/GeoCoords.hpp +544 -0
  32. data/ext/geographiclib/GeographicLib/Geocentric.hpp +267 -0
  33. data/ext/geographiclib/GeographicLib/Geodesic.hpp +970 -0
  34. data/ext/geographiclib/GeographicLib/GeodesicExact.hpp +862 -0
  35. data/ext/geographiclib/GeographicLib/GeodesicLine.hpp +701 -0
  36. data/ext/geographiclib/GeographicLib/GeodesicLineExact.hpp +667 -0
  37. data/ext/geographiclib/GeographicLib/Geohash.hpp +180 -0
  38. data/ext/geographiclib/GeographicLib/Geoid.hpp +472 -0
  39. data/ext/geographiclib/GeographicLib/Georef.hpp +160 -0
  40. data/ext/geographiclib/GeographicLib/Gnomonic.hpp +206 -0
  41. data/ext/geographiclib/GeographicLib/GravityCircle.hpp +301 -0
  42. data/ext/geographiclib/GeographicLib/GravityModel.hpp +520 -0
  43. data/ext/geographiclib/GeographicLib/LambertConformalConic.hpp +313 -0
  44. data/ext/geographiclib/GeographicLib/LocalCartesian.hpp +236 -0
  45. data/ext/geographiclib/GeographicLib/MGRS.hpp +355 -0
  46. data/ext/geographiclib/GeographicLib/MagneticCircle.hpp +178 -0
  47. data/ext/geographiclib/GeographicLib/MagneticModel.hpp +347 -0
  48. data/ext/geographiclib/GeographicLib/Math.hpp +920 -0
  49. data/ext/geographiclib/GeographicLib/NormalGravity.hpp +350 -0
  50. data/ext/geographiclib/GeographicLib/OSGB.hpp +249 -0
  51. data/ext/geographiclib/GeographicLib/PolarStereographic.hpp +150 -0
  52. data/ext/geographiclib/GeographicLib/PolygonArea.hpp +288 -0
  53. data/ext/geographiclib/GeographicLib/Rhumb.hpp +589 -0
  54. data/ext/geographiclib/GeographicLib/SphericalEngine.hpp +376 -0
  55. data/ext/geographiclib/GeographicLib/SphericalHarmonic.hpp +354 -0
  56. data/ext/geographiclib/GeographicLib/SphericalHarmonic1.hpp +281 -0
  57. data/ext/geographiclib/GeographicLib/SphericalHarmonic2.hpp +315 -0
  58. data/ext/geographiclib/GeographicLib/TransverseMercator.hpp +196 -0
  59. data/ext/geographiclib/GeographicLib/TransverseMercatorExact.hpp +254 -0
  60. data/ext/geographiclib/GeographicLib/UTMUPS.hpp +421 -0
  61. data/ext/geographiclib/GeographicLib/Utility.hpp +612 -0
  62. data/ext/geographiclib/Geohash.cpp +102 -0
  63. data/ext/geographiclib/Geoid.cpp +509 -0
  64. data/ext/geographiclib/Georef.cpp +135 -0
  65. data/ext/geographiclib/Gnomonic.cpp +85 -0
  66. data/ext/geographiclib/GravityCircle.cpp +129 -0
  67. data/ext/geographiclib/GravityModel.cpp +360 -0
  68. data/ext/geographiclib/LambertConformalConic.cpp +456 -0
  69. data/ext/geographiclib/LocalCartesian.cpp +62 -0
  70. data/ext/geographiclib/MGRS.cpp +461 -0
  71. data/ext/geographiclib/MagneticCircle.cpp +52 -0
  72. data/ext/geographiclib/MagneticModel.cpp +269 -0
  73. data/ext/geographiclib/Math.cpp +63 -0
  74. data/ext/geographiclib/NormalGravity.cpp +262 -0
  75. data/ext/geographiclib/OSGB.cpp +167 -0
  76. data/ext/geographiclib/PolarStereographic.cpp +108 -0
  77. data/ext/geographiclib/PolygonArea.cpp +204 -0
  78. data/ext/geographiclib/Rhumb.cpp +383 -0
  79. data/ext/geographiclib/SphericalEngine.cpp +477 -0
  80. data/ext/geographiclib/TransverseMercator.cpp +603 -0
  81. data/ext/geographiclib/TransverseMercatorExact.cpp +464 -0
  82. data/ext/geographiclib/UTMUPS.cpp +296 -0
  83. data/ext/geographiclib/Utility.cpp +61 -0
  84. data/ext/geographiclib/extconf.rb +3 -0
  85. data/ext/geographiclib/geographiclib.cpp +62 -0
  86. data/lib/geographiclib.rb +20 -0
  87. metadata +140 -0
@@ -0,0 +1,701 @@
1
+ /**
2
+ * \file GeodesicLine.hpp
3
+ * \brief Header for GeographicLib::GeodesicLine class
4
+ *
5
+ * Copyright (c) Charles Karney (2009-2016) <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_GEODESICLINE_HPP)
11
+ #define GEOGRAPHICLIB_GEODESICLINE_HPP 1
12
+
13
+ #include <GeographicLib/Constants.hpp>
14
+ #include <GeographicLib/Geodesic.hpp>
15
+
16
+ namespace GeographicLib {
17
+
18
+ /**
19
+ * \brief A geodesic line
20
+ *
21
+ * GeodesicLine facilitates the determination of a series of points on a
22
+ * single geodesic. The starting point (\e lat1, \e lon1) and the azimuth \e
23
+ * azi1 are specified in the constructor; alternatively, the Geodesic::Line
24
+ * method can be used to create a GeodesicLine. GeodesicLine.Position
25
+ * returns the location of point 2 a distance \e s12 along the geodesic. In
26
+ * addition, GeodesicLine.ArcPosition gives the position of point 2 an arc
27
+ * length \e a12 along the geodesic.
28
+ *
29
+ * You can register the position of a reference point 3 a distance (arc
30
+ * length), \e s13 (\e a13) along the geodesic with the
31
+ * GeodesicLine.SetDistance (GeodesicLine.SetArc) functions. Points a
32
+ * fractional distance along the line can be found by providing, for example,
33
+ * 0.5 * Distance() as an argument to GeodesicLine.Position. The
34
+ * Geodesic::InverseLine or Geodesic::DirectLine methods return GeodesicLine
35
+ * objects with point 3 set to the point 2 of the corresponding geodesic
36
+ * problem. GeodesicLine objects created with the public constructor or with
37
+ * Geodesic::Line have \e s13 and \e a13 set to NaNs.
38
+ *
39
+ * The default copy constructor and assignment operators work with this
40
+ * class. Similarly, a vector can be used to hold GeodesicLine objects.
41
+ *
42
+ * The calculations are accurate to better than 15 nm (15 nanometers). See
43
+ * Sec. 9 of
44
+ * <a href="http://arxiv.org/abs/1102.1215v1">arXiv:1102.1215v1</a> for
45
+ * details. The algorithms used by this class are based on series expansions
46
+ * using the flattening \e f as a small parameter. These are only accurate
47
+ * for |<i>f</i>| &lt; 0.02; however reasonably accurate results will be
48
+ * obtained for |<i>f</i>| &lt; 0.2. For very eccentric ellipsoids, use
49
+ * GeodesicLineExact instead.
50
+ *
51
+ * The algorithms are described in
52
+ * - C. F. F. Karney,
53
+ * <a href="https://dx.doi.org/10.1007/s00190-012-0578-z">
54
+ * Algorithms for geodesics</a>,
55
+ * J. Geodesy <b>87</b>, 43--55 (2013);
56
+ * DOI: <a href="https://dx.doi.org/10.1007/s00190-012-0578-z">
57
+ * 10.1007/s00190-012-0578-z</a>;
58
+ * addenda: <a href="http://geographiclib.sourceforge.net/geod-addenda.html">
59
+ * geod-addenda.html</a>.
60
+ * .
61
+ * For more information on geodesics see \ref geodesic.
62
+ *
63
+ * Example of use:
64
+ * \include example-GeodesicLine.cpp
65
+ *
66
+ * <a href="GeodSolve.1.html">GeodSolve</a> is a command-line utility
67
+ * providing access to the functionality of Geodesic and GeodesicLine.
68
+ **********************************************************************/
69
+
70
+ class GEOGRAPHICLIB_EXPORT GeodesicLine {
71
+ private:
72
+ typedef Math::real real;
73
+ friend class Geodesic;
74
+ static const int nC1_ = Geodesic::nC1_;
75
+ static const int nC1p_ = Geodesic::nC1p_;
76
+ static const int nC2_ = Geodesic::nC2_;
77
+ static const int nC3_ = Geodesic::nC3_;
78
+ static const int nC4_ = Geodesic::nC4_;
79
+
80
+ real tiny_;
81
+ real _lat1, _lon1, _azi1;
82
+ real _a, _f, _b, _c2, _f1, _salp0, _calp0, _k2,
83
+ _salp1, _calp1, _ssig1, _csig1, _dn1, _stau1, _ctau1, _somg1, _comg1,
84
+ _A1m1, _A2m1, _A3c, _B11, _B21, _B31, _A4, _B41;
85
+ real _a13, _s13;
86
+ // index zero elements of _C1a, _C1pa, _C2a, _C3a are unused
87
+ real _C1a[nC1_ + 1], _C1pa[nC1p_ + 1], _C2a[nC2_ + 1], _C3a[nC3_],
88
+ _C4a[nC4_]; // all the elements of _C4a are used
89
+ unsigned _caps;
90
+
91
+ void LineInit(const Geodesic& g,
92
+ real lat1, real lon1,
93
+ real azi1, real salp1, real calp1,
94
+ unsigned caps);
95
+ GeodesicLine(const Geodesic& g,
96
+ real lat1, real lon1,
97
+ real azi1, real salp1, real calp1,
98
+ unsigned caps, bool arcmode, real s13_a13);
99
+
100
+ enum captype {
101
+ CAP_NONE = Geodesic::CAP_NONE,
102
+ CAP_C1 = Geodesic::CAP_C1,
103
+ CAP_C1p = Geodesic::CAP_C1p,
104
+ CAP_C2 = Geodesic::CAP_C2,
105
+ CAP_C3 = Geodesic::CAP_C3,
106
+ CAP_C4 = Geodesic::CAP_C4,
107
+ CAP_ALL = Geodesic::CAP_ALL,
108
+ CAP_MASK = Geodesic::CAP_MASK,
109
+ OUT_ALL = Geodesic::OUT_ALL,
110
+ OUT_MASK = Geodesic::OUT_MASK,
111
+ };
112
+ public:
113
+
114
+ /**
115
+ * Bit masks for what calculations to do. They signify to the
116
+ * GeodesicLine::GeodesicLine constructor and to Geodesic::Line what
117
+ * capabilities should be included in the GeodesicLine object. This is
118
+ * merely a duplication of Geodesic::mask.
119
+ **********************************************************************/
120
+ enum mask {
121
+ /**
122
+ * No capabilities, no output.
123
+ * @hideinitializer
124
+ **********************************************************************/
125
+ NONE = Geodesic::NONE,
126
+ /**
127
+ * Calculate latitude \e lat2. (It's not necessary to include this as a
128
+ * capability to GeodesicLine because this is included by default.)
129
+ * @hideinitializer
130
+ **********************************************************************/
131
+ LATITUDE = Geodesic::LATITUDE,
132
+ /**
133
+ * Calculate longitude \e lon2.
134
+ * @hideinitializer
135
+ **********************************************************************/
136
+ LONGITUDE = Geodesic::LONGITUDE,
137
+ /**
138
+ * Calculate azimuths \e azi1 and \e azi2. (It's not necessary to
139
+ * include this as a capability to GeodesicLine because this is included
140
+ * by default.)
141
+ * @hideinitializer
142
+ **********************************************************************/
143
+ AZIMUTH = Geodesic::AZIMUTH,
144
+ /**
145
+ * Calculate distance \e s12.
146
+ * @hideinitializer
147
+ **********************************************************************/
148
+ DISTANCE = Geodesic::DISTANCE,
149
+ /**
150
+ * Allow distance \e s12 to be used as input in the direct geodesic
151
+ * problem.
152
+ * @hideinitializer
153
+ **********************************************************************/
154
+ DISTANCE_IN = Geodesic::DISTANCE_IN,
155
+ /**
156
+ * Calculate reduced length \e m12.
157
+ * @hideinitializer
158
+ **********************************************************************/
159
+ REDUCEDLENGTH = Geodesic::REDUCEDLENGTH,
160
+ /**
161
+ * Calculate geodesic scales \e M12 and \e M21.
162
+ * @hideinitializer
163
+ **********************************************************************/
164
+ GEODESICSCALE = Geodesic::GEODESICSCALE,
165
+ /**
166
+ * Calculate area \e S12.
167
+ * @hideinitializer
168
+ **********************************************************************/
169
+ AREA = Geodesic::AREA,
170
+ /**
171
+ * Unroll \e lon2 in the direct calculation.
172
+ * @hideinitializer
173
+ **********************************************************************/
174
+ LONG_UNROLL = Geodesic::LONG_UNROLL,
175
+ /**
176
+ * All capabilities, calculate everything. (LONG_UNROLL is not
177
+ * included in this mask.)
178
+ * @hideinitializer
179
+ **********************************************************************/
180
+ ALL = Geodesic::ALL,
181
+ };
182
+
183
+ /** \name Constructors
184
+ **********************************************************************/
185
+ ///@{
186
+
187
+ /**
188
+ * Constructor for a geodesic line staring at latitude \e lat1, longitude
189
+ * \e lon1, and azimuth \e azi1 (all in degrees).
190
+ *
191
+ * @param[in] g A Geodesic object used to compute the necessary information
192
+ * about the GeodesicLine.
193
+ * @param[in] lat1 latitude of point 1 (degrees).
194
+ * @param[in] lon1 longitude of point 1 (degrees).
195
+ * @param[in] azi1 azimuth at point 1 (degrees).
196
+ * @param[in] caps bitor'ed combination of GeodesicLine::mask values
197
+ * specifying the capabilities the GeodesicLine object should possess,
198
+ * i.e., which quantities can be returned in calls to
199
+ * GeodesicLine::Position.
200
+ *
201
+ * \e lat1 should be in the range [&minus;90&deg;, 90&deg;].
202
+ *
203
+ * The GeodesicLine::mask values are
204
+ * - \e caps |= GeodesicLine::LATITUDE for the latitude \e lat2; this is
205
+ * added automatically;
206
+ * - \e caps |= GeodesicLine::LONGITUDE for the latitude \e lon2;
207
+ * - \e caps |= GeodesicLine::AZIMUTH for the latitude \e azi2; this is
208
+ * added automatically;
209
+ * - \e caps |= GeodesicLine::DISTANCE for the distance \e s12;
210
+ * - \e caps |= GeodesicLine::REDUCEDLENGTH for the reduced length \e m12;
211
+ * - \e caps |= GeodesicLine::GEODESICSCALE for the geodesic scales \e M12
212
+ * and \e M21;
213
+ * - \e caps |= GeodesicLine::AREA for the area \e S12;
214
+ * - \e caps |= GeodesicLine::DISTANCE_IN permits the length of the
215
+ * geodesic to be given in terms of \e s12; without this capability the
216
+ * length can only be specified in terms of arc length;
217
+ * - \e caps |= GeodesicLine::ALL for all of the above.
218
+ * .
219
+ * The default value of \e caps is GeodesicLine::ALL.
220
+ *
221
+ * If the point is at a pole, the azimuth is defined by keeping \e lon1
222
+ * fixed, writing \e lat1 = &plusmn;(90&deg; &minus; &epsilon;), and taking
223
+ * the limit &epsilon; &rarr; 0+.
224
+ **********************************************************************/
225
+ GeodesicLine(const Geodesic& g, real lat1, real lon1, real azi1,
226
+ unsigned caps = ALL);
227
+
228
+ /**
229
+ * A default constructor. If GeodesicLine::Position is called on the
230
+ * resulting object, it returns immediately (without doing any
231
+ * calculations). The object can be set with a call to Geodesic::Line.
232
+ * Use Init() to test whether object is still in this uninitialized state.
233
+ **********************************************************************/
234
+ GeodesicLine() : _caps(0U) {}
235
+ ///@}
236
+
237
+ /** \name Position in terms of distance
238
+ **********************************************************************/
239
+ ///@{
240
+
241
+ /**
242
+ * Compute the position of point 2 which is a distance \e s12 (meters) from
243
+ * point 1.
244
+ *
245
+ * @param[in] s12 distance from point 1 to point 2 (meters); it can be
246
+ * negative.
247
+ * @param[out] lat2 latitude of point 2 (degrees).
248
+ * @param[out] lon2 longitude of point 2 (degrees); requires that the
249
+ * GeodesicLine object was constructed with \e caps |=
250
+ * GeodesicLine::LONGITUDE.
251
+ * @param[out] azi2 (forward) azimuth at point 2 (degrees).
252
+ * @param[out] m12 reduced length of geodesic (meters); requires that the
253
+ * GeodesicLine object was constructed with \e caps |=
254
+ * GeodesicLine::REDUCEDLENGTH.
255
+ * @param[out] M12 geodesic scale of point 2 relative to point 1
256
+ * (dimensionless); requires that the GeodesicLine object was constructed
257
+ * with \e caps |= GeodesicLine::GEODESICSCALE.
258
+ * @param[out] M21 geodesic scale of point 1 relative to point 2
259
+ * (dimensionless); requires that the GeodesicLine object was constructed
260
+ * with \e caps |= GeodesicLine::GEODESICSCALE.
261
+ * @param[out] S12 area under the geodesic (meters<sup>2</sup>); requires
262
+ * that the GeodesicLine object was constructed with \e caps |=
263
+ * GeodesicLine::AREA.
264
+ * @return \e a12 arc length from point 1 to point 2 (degrees).
265
+ *
266
+ * The values of \e lon2 and \e azi2 returned are in the range
267
+ * [&minus;180&deg;, 180&deg;).
268
+ *
269
+ * The GeodesicLine object \e must have been constructed with \e caps |=
270
+ * GeodesicLine::DISTANCE_IN; otherwise Math::NaN() is returned and no
271
+ * parameters are set. Requesting a value which the GeodesicLine object is
272
+ * not capable of computing is not an error; the corresponding argument
273
+ * will not be altered.
274
+ *
275
+ * The following functions are overloaded versions of
276
+ * GeodesicLine::Position which omit some of the output parameters. Note,
277
+ * however, that the arc length is always computed and returned as the
278
+ * function value.
279
+ **********************************************************************/
280
+ Math::real Position(real s12,
281
+ real& lat2, real& lon2, real& azi2,
282
+ real& m12, real& M12, real& M21,
283
+ real& S12) const {
284
+ real t;
285
+ return GenPosition(false, s12,
286
+ LATITUDE | LONGITUDE | AZIMUTH |
287
+ REDUCEDLENGTH | GEODESICSCALE | AREA,
288
+ lat2, lon2, azi2, t, m12, M12, M21, S12);
289
+ }
290
+
291
+ /**
292
+ * See the documentation for GeodesicLine::Position.
293
+ **********************************************************************/
294
+ Math::real Position(real s12, real& lat2, real& lon2) const {
295
+ real t;
296
+ return GenPosition(false, s12,
297
+ LATITUDE | LONGITUDE,
298
+ lat2, lon2, t, t, t, t, t, t);
299
+ }
300
+
301
+ /**
302
+ * See the documentation for GeodesicLine::Position.
303
+ **********************************************************************/
304
+ Math::real Position(real s12, real& lat2, real& lon2,
305
+ real& azi2) const {
306
+ real t;
307
+ return GenPosition(false, s12,
308
+ LATITUDE | LONGITUDE | AZIMUTH,
309
+ lat2, lon2, azi2, t, t, t, t, t);
310
+ }
311
+
312
+ /**
313
+ * See the documentation for GeodesicLine::Position.
314
+ **********************************************************************/
315
+ Math::real Position(real s12, real& lat2, real& lon2,
316
+ real& azi2, real& m12) const {
317
+ real t;
318
+ return GenPosition(false, s12,
319
+ LATITUDE | LONGITUDE |
320
+ AZIMUTH | REDUCEDLENGTH,
321
+ lat2, lon2, azi2, t, m12, t, t, t);
322
+ }
323
+
324
+ /**
325
+ * See the documentation for GeodesicLine::Position.
326
+ **********************************************************************/
327
+ Math::real Position(real s12, real& lat2, real& lon2,
328
+ real& azi2, real& M12, real& M21)
329
+ const {
330
+ real t;
331
+ return GenPosition(false, s12,
332
+ LATITUDE | LONGITUDE |
333
+ AZIMUTH | GEODESICSCALE,
334
+ lat2, lon2, azi2, t, t, M12, M21, t);
335
+ }
336
+
337
+ /**
338
+ * See the documentation for GeodesicLine::Position.
339
+ **********************************************************************/
340
+ Math::real Position(real s12,
341
+ real& lat2, real& lon2, real& azi2,
342
+ real& m12, real& M12, real& M21)
343
+ const {
344
+ real t;
345
+ return GenPosition(false, s12,
346
+ LATITUDE | LONGITUDE | AZIMUTH |
347
+ REDUCEDLENGTH | GEODESICSCALE,
348
+ lat2, lon2, azi2, t, m12, M12, M21, t);
349
+ }
350
+ ///@}
351
+
352
+ /** \name Position in terms of arc length
353
+ **********************************************************************/
354
+ ///@{
355
+
356
+ /**
357
+ * Compute the position of point 2 which is an arc length \e a12 (degrees)
358
+ * from point 1.
359
+ *
360
+ * @param[in] a12 arc length from point 1 to point 2 (degrees); it can
361
+ * be negative.
362
+ * @param[out] lat2 latitude of point 2 (degrees).
363
+ * @param[out] lon2 longitude of point 2 (degrees); requires that the
364
+ * GeodesicLine object was constructed with \e caps |=
365
+ * GeodesicLine::LONGITUDE.
366
+ * @param[out] azi2 (forward) azimuth at point 2 (degrees).
367
+ * @param[out] s12 distance from point 1 to point 2 (meters); requires
368
+ * that the GeodesicLine object was constructed with \e caps |=
369
+ * GeodesicLine::DISTANCE.
370
+ * @param[out] m12 reduced length of geodesic (meters); requires that the
371
+ * GeodesicLine object was constructed with \e caps |=
372
+ * GeodesicLine::REDUCEDLENGTH.
373
+ * @param[out] M12 geodesic scale of point 2 relative to point 1
374
+ * (dimensionless); requires that the GeodesicLine object was constructed
375
+ * with \e caps |= GeodesicLine::GEODESICSCALE.
376
+ * @param[out] M21 geodesic scale of point 1 relative to point 2
377
+ * (dimensionless); requires that the GeodesicLine object was constructed
378
+ * with \e caps |= GeodesicLine::GEODESICSCALE.
379
+ * @param[out] S12 area under the geodesic (meters<sup>2</sup>); requires
380
+ * that the GeodesicLine object was constructed with \e caps |=
381
+ * GeodesicLine::AREA.
382
+ *
383
+ * The values of \e lon2 and \e azi2 returned are in the range
384
+ * [&minus;180&deg;, 180&deg;).
385
+ *
386
+ * Requesting a value which the GeodesicLine object is not capable of
387
+ * computing is not an error; the corresponding argument will not be
388
+ * altered.
389
+ *
390
+ * The following functions are overloaded versions of
391
+ * GeodesicLine::ArcPosition which omit some of the output parameters.
392
+ **********************************************************************/
393
+ void ArcPosition(real a12, real& lat2, real& lon2, real& azi2,
394
+ real& s12, real& m12, real& M12, real& M21,
395
+ real& S12) const {
396
+ GenPosition(true, a12,
397
+ LATITUDE | LONGITUDE | AZIMUTH | DISTANCE |
398
+ REDUCEDLENGTH | GEODESICSCALE | AREA,
399
+ lat2, lon2, azi2, s12, m12, M12, M21, S12);
400
+ }
401
+
402
+ /**
403
+ * See the documentation for GeodesicLine::ArcPosition.
404
+ **********************************************************************/
405
+ void ArcPosition(real a12, real& lat2, real& lon2)
406
+ const {
407
+ real t;
408
+ GenPosition(true, a12,
409
+ LATITUDE | LONGITUDE,
410
+ lat2, lon2, t, t, t, t, t, t);
411
+ }
412
+
413
+ /**
414
+ * See the documentation for GeodesicLine::ArcPosition.
415
+ **********************************************************************/
416
+ void ArcPosition(real a12,
417
+ real& lat2, real& lon2, real& azi2)
418
+ const {
419
+ real t;
420
+ GenPosition(true, a12,
421
+ LATITUDE | LONGITUDE | AZIMUTH,
422
+ lat2, lon2, azi2, t, t, t, t, t);
423
+ }
424
+
425
+ /**
426
+ * See the documentation for GeodesicLine::ArcPosition.
427
+ **********************************************************************/
428
+ void ArcPosition(real a12, real& lat2, real& lon2, real& azi2,
429
+ real& s12) const {
430
+ real t;
431
+ GenPosition(true, a12,
432
+ LATITUDE | LONGITUDE | AZIMUTH | DISTANCE,
433
+ lat2, lon2, azi2, s12, t, t, t, t);
434
+ }
435
+
436
+ /**
437
+ * See the documentation for GeodesicLine::ArcPosition.
438
+ **********************************************************************/
439
+ void ArcPosition(real a12, real& lat2, real& lon2, real& azi2,
440
+ real& s12, real& m12) const {
441
+ real t;
442
+ GenPosition(true, a12,
443
+ LATITUDE | LONGITUDE | AZIMUTH |
444
+ DISTANCE | REDUCEDLENGTH,
445
+ lat2, lon2, azi2, s12, m12, t, t, t);
446
+ }
447
+
448
+ /**
449
+ * See the documentation for GeodesicLine::ArcPosition.
450
+ **********************************************************************/
451
+ void ArcPosition(real a12, real& lat2, real& lon2, real& azi2,
452
+ real& s12, real& M12, real& M21)
453
+ const {
454
+ real t;
455
+ GenPosition(true, a12,
456
+ LATITUDE | LONGITUDE | AZIMUTH |
457
+ DISTANCE | GEODESICSCALE,
458
+ lat2, lon2, azi2, s12, t, M12, M21, t);
459
+ }
460
+
461
+ /**
462
+ * See the documentation for GeodesicLine::ArcPosition.
463
+ **********************************************************************/
464
+ void ArcPosition(real a12, real& lat2, real& lon2, real& azi2,
465
+ real& s12, real& m12, real& M12, real& M21)
466
+ const {
467
+ real t;
468
+ GenPosition(true, a12,
469
+ LATITUDE | LONGITUDE | AZIMUTH |
470
+ DISTANCE | REDUCEDLENGTH | GEODESICSCALE,
471
+ lat2, lon2, azi2, s12, m12, M12, M21, t);
472
+ }
473
+ ///@}
474
+
475
+ /** \name The general position function.
476
+ **********************************************************************/
477
+ ///@{
478
+
479
+ /**
480
+ * The general position function. GeodesicLine::Position and
481
+ * GeodesicLine::ArcPosition are defined in terms of this function.
482
+ *
483
+ * @param[in] arcmode boolean flag determining the meaning of the second
484
+ * parameter; if \e arcmode is false, then the GeodesicLine object must
485
+ * have been constructed with \e caps |= GeodesicLine::DISTANCE_IN.
486
+ * @param[in] s12_a12 if \e arcmode is false, this is the distance between
487
+ * point 1 and point 2 (meters); otherwise it is the arc length between
488
+ * point 1 and point 2 (degrees); it can be negative.
489
+ * @param[in] outmask a bitor'ed combination of GeodesicLine::mask values
490
+ * specifying which of the following parameters should be set.
491
+ * @param[out] lat2 latitude of point 2 (degrees).
492
+ * @param[out] lon2 longitude of point 2 (degrees); requires that the
493
+ * GeodesicLine object was constructed with \e caps |=
494
+ * GeodesicLine::LONGITUDE.
495
+ * @param[out] azi2 (forward) azimuth at point 2 (degrees).
496
+ * @param[out] s12 distance from point 1 to point 2 (meters); requires
497
+ * that the GeodesicLine object was constructed with \e caps |=
498
+ * GeodesicLine::DISTANCE.
499
+ * @param[out] m12 reduced length of geodesic (meters); requires that the
500
+ * GeodesicLine object was constructed with \e caps |=
501
+ * GeodesicLine::REDUCEDLENGTH.
502
+ * @param[out] M12 geodesic scale of point 2 relative to point 1
503
+ * (dimensionless); requires that the GeodesicLine object was constructed
504
+ * with \e caps |= GeodesicLine::GEODESICSCALE.
505
+ * @param[out] M21 geodesic scale of point 1 relative to point 2
506
+ * (dimensionless); requires that the GeodesicLine object was constructed
507
+ * with \e caps |= GeodesicLine::GEODESICSCALE.
508
+ * @param[out] S12 area under the geodesic (meters<sup>2</sup>); requires
509
+ * that the GeodesicLine object was constructed with \e caps |=
510
+ * GeodesicLine::AREA.
511
+ * @return \e a12 arc length from point 1 to point 2 (degrees).
512
+ *
513
+ * The GeodesicLine::mask values possible for \e outmask are
514
+ * - \e outmask |= GeodesicLine::LATITUDE for the latitude \e lat2;
515
+ * - \e outmask |= GeodesicLine::LONGITUDE for the latitude \e lon2;
516
+ * - \e outmask |= GeodesicLine::AZIMUTH for the latitude \e azi2;
517
+ * - \e outmask |= GeodesicLine::DISTANCE for the distance \e s12;
518
+ * - \e outmask |= GeodesicLine::REDUCEDLENGTH for the reduced length \e
519
+ * m12;
520
+ * - \e outmask |= GeodesicLine::GEODESICSCALE for the geodesic scales \e
521
+ * M12 and \e M21;
522
+ * - \e outmask |= GeodesicLine::AREA for the area \e S12;
523
+ * - \e outmask |= GeodesicLine::ALL for all of the above;
524
+ * - \e outmask |= GeodesicLine::LONG_UNROLL to unroll \e lon2 instead of
525
+ * reducing it into the range [&minus;180&deg;, 180&deg;).
526
+ * .
527
+ * Requesting a value which the GeodesicLine object is not capable of
528
+ * computing is not an error; the corresponding argument will not be
529
+ * altered. Note, however, that the arc length is always computed and
530
+ * returned as the function value.
531
+ *
532
+ * With the GeodesicLine::LONG_UNROLL bit set, the quantity \e lon2 &minus;
533
+ * \e lon1 indicates how many times and in what sense the geodesic
534
+ * encircles the ellipsoid.
535
+ **********************************************************************/
536
+ Math::real GenPosition(bool arcmode, real s12_a12, unsigned outmask,
537
+ real& lat2, real& lon2, real& azi2,
538
+ real& s12, real& m12, real& M12, real& M21,
539
+ real& S12) const;
540
+ ///@}
541
+
542
+ /** \name Setting point 3
543
+ **********************************************************************/
544
+ ///@{
545
+
546
+ /**
547
+ * Specify position of point 3 in terms of distance.
548
+ *
549
+ * @param[in] s13 the distance from point 1 to point 3 (meters); it
550
+ * can be negative.
551
+ *
552
+ * This is only useful if the GeodesicLine object has been constructed
553
+ * with \e caps |= GeodesicLine::DISTANCE_IN.
554
+ **********************************************************************/
555
+ void SetDistance(real s13);
556
+
557
+ /**
558
+ * Specify position of point 3 in terms of arc length.
559
+ *
560
+ * @param[in] a13 the arc length from point 1 to point 3 (degrees); it
561
+ * can be negative.
562
+ *
563
+ * The distance \e s13 is only set if the GeodesicLine object has been
564
+ * constructed with \e caps |= GeodesicLine::DISTANCE.
565
+ **********************************************************************/
566
+ void SetArc(real a13);
567
+
568
+ /**
569
+ * Specify position of point 3 in terms of either distance or arc length.
570
+ *
571
+ * @param[in] arcmode boolean flag determining the meaning of the second
572
+ * parameter; if \e arcmode is false, then the GeodesicLine object must
573
+ * have been constructed with \e caps |= GeodesicLine::DISTANCE_IN.
574
+ * @param[in] s13_a13 if \e arcmode is false, this is the distance from
575
+ * point 1 to point 3 (meters); otherwise it is the arc length from
576
+ * point 1 to point 3 (degrees); it can be negative.
577
+ **********************************************************************/
578
+ void GenSetDistance(bool arcmode, real s13_a13);
579
+ ///@}
580
+
581
+ /** \name Inspector functions
582
+ **********************************************************************/
583
+ ///@{
584
+
585
+ /**
586
+ * @return true if the object has been initialized.
587
+ **********************************************************************/
588
+ bool Init() const { return _caps != 0U; }
589
+
590
+ /**
591
+ * @return \e lat1 the latitude of point 1 (degrees).
592
+ **********************************************************************/
593
+ Math::real Latitude() const
594
+ { return Init() ? _lat1 : Math::NaN(); }
595
+
596
+ /**
597
+ * @return \e lon1 the longitude of point 1 (degrees).
598
+ **********************************************************************/
599
+ Math::real Longitude() const
600
+ { return Init() ? _lon1 : Math::NaN(); }
601
+
602
+ /**
603
+ * @return \e azi1 the azimuth (degrees) of the geodesic line at point 1.
604
+ **********************************************************************/
605
+ Math::real Azimuth() const
606
+ { return Init() ? _azi1 : Math::NaN(); }
607
+
608
+ /**
609
+ * The sine and cosine of \e azi1.
610
+ *
611
+ * @param[out] sazi1 the sine of \e azi1.
612
+ * @param[out] cazi1 the cosine of \e azi1.
613
+ **********************************************************************/
614
+ void Azimuth(real& sazi1, real& cazi1) const
615
+ { if (Init()) { sazi1 = _salp1; cazi1 = _calp1; } }
616
+
617
+ /**
618
+ * @return \e azi0 the azimuth (degrees) of the geodesic line as it crosses
619
+ * the equator in a northward direction.
620
+ *
621
+ * The result lies in [&minus;90&deg;, 90&deg;].
622
+ **********************************************************************/
623
+ Math::real EquatorialAzimuth() const
624
+ { return Init() ? Math::atan2d(_salp0, _calp0) : Math::NaN(); }
625
+
626
+ /**
627
+ * The sine and cosine of \e azi0.
628
+ *
629
+ * @param[out] sazi0 the sine of \e azi0.
630
+ * @param[out] cazi0 the cosine of \e azi0.
631
+ **********************************************************************/
632
+ void EquatorialAzimuth(real& sazi0, real& cazi0) const
633
+ { if (Init()) { sazi0 = _salp0; cazi0 = _calp0; } }
634
+
635
+ /**
636
+ * @return \e a1 the arc length (degrees) between the northward equatorial
637
+ * crossing and point 1.
638
+ *
639
+ * The result lies in (&minus;180&deg;, 180&deg;].
640
+ **********************************************************************/
641
+ Math::real EquatorialArc() const {
642
+ return Init() ? Math::atan2d(_ssig1, _csig1) : Math::NaN();
643
+ }
644
+
645
+ /**
646
+ * @return \e a the equatorial radius of the ellipsoid (meters). This is
647
+ * the value inherited from the Geodesic object used in the constructor.
648
+ **********************************************************************/
649
+ Math::real MajorRadius() const
650
+ { return Init() ? _a : Math::NaN(); }
651
+
652
+ /**
653
+ * @return \e f the flattening of the ellipsoid. This is the value
654
+ * inherited from the Geodesic object used in the constructor.
655
+ **********************************************************************/
656
+ Math::real Flattening() const
657
+ { return Init() ? _f : Math::NaN(); }
658
+
659
+ /**
660
+ * @return \e caps the computational capabilities that this object was
661
+ * constructed with. LATITUDE and AZIMUTH are always included.
662
+ **********************************************************************/
663
+ unsigned Capabilities() const { return _caps; }
664
+
665
+ /**
666
+ * Test what capabilities are available.
667
+ *
668
+ * @param[in] testcaps a set of bitor'ed GeodesicLine::mask values.
669
+ * @return true if the GeodesicLine object has all these capabilities.
670
+ **********************************************************************/
671
+ bool Capabilities(unsigned testcaps) const {
672
+ testcaps &= OUT_ALL;
673
+ return (_caps & testcaps) == testcaps;
674
+ }
675
+
676
+ /**
677
+ * The distance or arc length to point 3.
678
+ *
679
+ * @param[in] arcmode boolean flag determining the meaning of returned
680
+ * value.
681
+ * @return \e s13 if \e arcmode is false; \e a13 if \e arcmode is true.
682
+ **********************************************************************/
683
+ Math::real GenDistance(bool arcmode) const
684
+ { return Init() ? (arcmode ? _a13 : _s13) : Math::NaN(); }
685
+
686
+ /**
687
+ * @return \e s13, the distance to point 3 (meters).
688
+ **********************************************************************/
689
+ Math::real Distance() const { return GenDistance(false); }
690
+
691
+ /**
692
+ * @return \e a13, the arc length to point 3 (degrees).
693
+ **********************************************************************/
694
+ Math::real Arc() const { return GenDistance(true); }
695
+ ///@}
696
+
697
+ };
698
+
699
+ } // namespace GeographicLib
700
+
701
+ #endif // GEOGRAPHICLIB_GEODESICLINE_HPP