NETGeographicLib  1.50.1
NETGeographicLib.h
Go to the documentation of this file.
1 #pragma once
2 /**
3  * \file NETGeographicLib/NETGeographicLib.h
4  * \brief Header for NETGeographicLib::NETGeographicLib objects
5  *
6  * NETGeographicLib is copyright (c) Scott Heiman (2013)
7  * GeographicLib is Copyright (c) Charles Karney (2010-2012)
8  * <charles@karney.com> and licensed under the MIT/X11 License.
9  * For more information, see
10  * https://geographiclib.sourceforge.io/
11  **********************************************************************/
12 #include <string>
13 
14 using namespace System;
15 
16 namespace NETGeographicLib
17 {
18  enum class captype {
19  CAP_NONE = 0U,
20  CAP_C1 = 1U<<0,
21  CAP_C1p = 1U<<1,
22  CAP_C2 = 1U<<2,
23  CAP_C3 = 1U<<3,
24  CAP_C4 = 1U<<4,
25  CAP_ALL = 0x1FU,
26  CAP_MASK = CAP_ALL,
27  OUT_ALL = 0x7F80U,
28  OUT_MASK = 0xFF80U,
29  };
30 
31  /**
32  * Bit masks for what calculations to do. These masks do double duty.
33  * They signify to the GeodesicLine::GeodesicLine constructor and to
34  * Geodesic::Line what capabilities should be included in the GeodesicLine
35  * object. They also specify which results to return in the general
36  * routines Geodesic::GenDirect and Geodesic::GenInverse routines.
37  **********************************************************************/
38  public enum class Mask {
39  /**
40  * No capabilities, no output.
41  * @hideinitializer
42  **********************************************************************/
43  NONE = 0U,
44  /**
45  * Calculate latitude \e lat2. (It's not necessary to include this as a
46  * capability to GeodesicLine because this is included by default.)
47  * @hideinitializer
48  **********************************************************************/
49  LATITUDE = 1U<<7 | unsigned(captype::CAP_NONE),
50  /**
51  * Calculate longitude \e lon2.
52  * @hideinitializer
53  **********************************************************************/
54  LONGITUDE = 1U<<8 | unsigned(captype::CAP_C3),
55  /**
56  * Calculate azimuths \e azi1 and \e azi2. (It's not necessary to
57  * include this as a capability to GeodesicLine because this is included
58  * by default.)
59  * @hideinitializer
60  **********************************************************************/
61  AZIMUTH = 1U<<9 | unsigned(captype::CAP_NONE),
62  /**
63  * Calculate distance \e s12.
64  * @hideinitializer
65  **********************************************************************/
66  DISTANCE = 1U<<10 | unsigned(captype::CAP_C1),
67  /**
68  * Allow distance \e s12 to be used as input in the direct geodesic
69  * problem.
70  * @hideinitializer
71  **********************************************************************/
72  DISTANCE_IN = 1U<<11 | unsigned(captype::CAP_C1) |
73  unsigned(captype::CAP_C1p),
74  /**
75  * Calculate reduced length \e m12.
76  * @hideinitializer
77  **********************************************************************/
78  REDUCEDLENGTH = 1U<<12 | unsigned(captype::CAP_C1) |
79  unsigned(captype::CAP_C2),
80  /**
81  * Calculate geodesic scales \e M12 and \e M21.
82  * @hideinitializer
83  **********************************************************************/
84  GEODESICSCALE = 1U<<13 | unsigned(captype::CAP_C1) |
85  unsigned(captype::CAP_C2),
86  /**
87  * Calculate area \e S12.
88  * @hideinitializer
89  **********************************************************************/
90  AREA = 1U<<14 | unsigned(captype::CAP_C4),
91  /**
92  * Do not wrap the \e lon2 in the direct calculation.
93  * @hideinitializer
94  **********************************************************************/
95  LONG_UNROLL = 1U<<15,
96  /**
97  * All capabilities, calculate everything.
98  * @hideinitializer
99  **********************************************************************/
100  ALL = unsigned(captype::OUT_ALL) | unsigned(captype::CAP_ALL),
101  };
102 
103  /**
104  * @brief The version information.
105  **********************************************************************/
106  public ref class VersionInfo
107  {
108  private:
109  VersionInfo() {}
110  public:
111  /**
112  * @return The version string.
113  *******************************************************************/
114  static System::String^ GetString();
115  /**
116  * @return The major version.
117  *******************************************************************/
118  static int MajorVersion();
119  /**
120  * @return The minor version.
121  *******************************************************************/
122  static int MinorVersion();
123  /**
124  * @return The patch number.
125  *******************************************************************/
126  static int Patch();
127  };
128 
129  /**
130  * @brief Exception class for NETGeographicLib
131  **********************************************************************/
132  public ref class GeographicErr : public System::Exception
133  {
134  public:
135  /**
136  * @brief Creates an exception using an unmanaged string.
137  * @param[in] msg The error string.
138  ******************************************************************/
139  GeographicErr( const char* msg ) :
140  System::Exception( gcnew System::String( msg ) ) {}
141  /**
142  * @brief Creates an exception using a managed string.
143  * @param[in] msg The error string.
144  ******************************************************************/
145  GeographicErr( System::String^ msg ) : System::Exception( msg ) {}
146  };
147 
148  ref class StringConvert
149  {
151  public:
152  static std::string ManagedToUnmanaged( System::String^ s );
153  static System::String^ UnmanagedToManaged( const std::string& s )
154  { return gcnew System::String( s.c_str() ); }
155  };
156 
157  /**
158  * @brief Physical constants
159  *
160  * References:<br>
161  * http://www.orekit.org/static/apidocs/org/orekit/utils/Constants.html<br>
162  * A COMPENDIUM OF EARTH CONSTANTS RELEVANT TO AUSTRALIAN GEODETIC SCIENCE<br>
163  * http://espace.library.curtin.edu.au/R?func=dbin-jump-full&local_base=gen01-era02&object_id=146669
164  **********************************************************************/
165  public ref class Constants
166  {
167  private:
168  Constants() {}
169  public:
170 
171  /**
172  * @brief WGS72 Parameters
173  **********************************************************************/
174  ref class WGS72
175  {
176  private:
177  WGS72() {}
178  // The equatorial radius in meters.
179  static const double m_EquatorialRadius = 6378135.0;
180  // The flattening of the ellipsoid
181  static const double m_Flattening = 1.0 / 298.26;
182  // The gravitational constant in meters<sup>3</sup>/second<sup>2</sup>.
183  static const double m_GravitationalConstant = 3.986008e+14;
184  // The spin rate of the Earth in radians/second.
185  static const double m_EarthRate = 7.292115147e-5;
186  // dynamical form factor
187  static const double m_J2 = 1.0826158e-3;
188  public:
189  //! The equatorial radius in meters.
190  static property double EquatorialRadius { double get() { return m_EquatorialRadius; } }
191  //! The flattening of the ellipsoid
192  static property double Flattening { double get() { return m_Flattening; } }
193  //! The gravitational constant in meters<sup>3</sup>/second<sup>2</sup>.
194  static property double GravitationalConstant { double get() { return m_GravitationalConstant; } }
195  //! The spin rate of the Earth in radians/second.
196  static property double EarthRate { double get() { return m_EarthRate; } }
197  //! The dynamical form factor (J2).
198  static property double J2 { double get() { return m_J2; } }
199  };
200 
201  /**
202  * @brief WGS84 Parameters
203  **********************************************************************/
204  ref class WGS84
205  {
206  private:
207  WGS84() {}
208  // The equatorial radius in meters.
209  static const double m_EquatorialRadius = 6378137.0;
210  // The flattening of the ellipsoid
211  static const double m_Flattening = 1.0 / 298.257223563;
212  // The gravitational constant in meters<sup>3</sup>/second<sup>2</sup>.
213  // I have also seen references that set this value to 3.986004418e+14.
214  // The following value is used to maintain consistency with GeographicLib.
215  static const double m_GravitationalConstant = 3.986005e+14;
216  // The spin rate of the Earth in radians/second.
217  static const double m_EarthRate = 7.292115e-5;
218  // dynamical form factor
219  static const double m_J2 = 1.08263e-3;
220  public:
221  //! The equatorial radius in meters.
222  static property double EquatorialRadius { double get() { return m_EquatorialRadius; } }
223  //! The flattening of the ellipsoid
224  static property double Flattening { double get() { return m_Flattening; } }
225  //! The gravitational constant in meters<sup>3</sup>/second<sup>2</sup>.
226  static property double GravitationalConstant { double get() { return m_GravitationalConstant; } }
227  //! The spin rate of the Earth in radians/second.
228  static property double EarthRate { double get() { return m_EarthRate; } }
229  //! The dynamical form factor (J2).
230  static property double J2 { double get() { return m_J2; } }
231  };
232 
233  /**
234  * @brief GRS80 Parameters
235  **********************************************************************/
236  ref class GRS80
237  {
238  private:
239  GRS80() {}
240  // The equatorial radius in meters.
241  static const double m_EquatorialRadius = 6378137.0;
242  // The flattening of the ellipsoid
243  static const double m_Flattening = 1.0 / 298.257222100882711;
244  // The gravitational constant in meters<sup>3</sup>/second<sup>2</sup>.
245  static const double m_GravitationalConstant = 3.986005e+14;
246  // The spin rate of the Earth in radians/second.
247  static const double m_EarthRate = 7.292115e-5;
248  // dynamical form factor
249  static const double m_J2 = 1.08263e-3;
250  public:
251  //! The equatorial radius in meters.
252  static property double EquatorialRadius { double get() { return m_EquatorialRadius; } }
253  //! The flattening of the ellipsoid
254  static property double Flattening { double get() { return m_Flattening; } }
255  //! The gravitational constant in meters<sup>3</sup>/second<sup>2</sup>.
256  static property double GravitationalConstant { double get() { return m_GravitationalConstant; } }
257  //! The spin rate of the Earth in radians/second.
258  static property double EarthRate { double get() { return m_EarthRate; } }
259  //! The dynamical form factor (J2).
260  static property double J2 { double get() { return m_J2; } }
261  };
262  };
263 
264  /**
265  * @brief Utility library.
266  *
267  * This class only exposes the GeographicLib::Utility::fractionalyear
268  * function.
269  **********************************************************************/
270  public ref class Utility
271  {
272  private:
273  // hide the constructor since all members of this class are static
274  Utility() {}
275  public:
276  /**
277  * Convert a string representing a date to a fractional year.
278  *
279  * @param[in] s the string to be converted.
280  * @exception GeographicErr if \e s can't be interpreted as a date.
281  * @return the fractional year.
282  *
283  * The string is first read as an ordinary number (e.g., 2010 or 2012.5);
284  * if this is successful, the value is returned. Otherwise the string
285  * should be of the form yyyy-mm or yyyy-mm-dd and this is converted to a
286  * number with 2010-01-01 giving 2010.0 and 2012-07-03 giving 2012.5.
287  **********************************************************************/
288  static double FractionalYear( System::String^ s );
289  };
290 } // namespace NETGeographicLib
NETGeographicLib::Mask::DISTANCE
NETGeographicLib::captype::CAP_C2
NETGeographicLib::Constants::WGS84
WGS84 Parameters.
Definition: NETGeographicLib.h:204
NETGeographicLib::Mask::LONG_UNROLL
NETGeographicLib::StringConvert::StringConvert
StringConvert()
Definition: NETGeographicLib.h:150
NETGeographicLib::StringConvert
Definition: NETGeographicLib.h:148
NETGeographicLib::VersionInfo
The version information.
Definition: NETGeographicLib.h:106
NETGeographicLib::captype::CAP_C1p
NETGeographicLib::captype::CAP_C1
NETGeographicLib::GeographicErr
Exception class for NETGeographicLib.
Definition: NETGeographicLib.h:132
NETGeographicLib::Mask::AREA
NETGeographicLib::Constants::WGS72
WGS72 Parameters.
Definition: NETGeographicLib.h:174
NETGeographicLib::Mask::NONE
NETGeographicLib::Utility
Utility library.
Definition: NETGeographicLib.h:270
NETGeographicLib::captype::OUT_ALL
NETGeographicLib::captype::CAP_C4
NETGeographicLib::captype
captype
Definition: NETGeographicLib.h:18
NETGeographicLib::captype::CAP_MASK
NETGeographicLib::GeographicErr::GeographicErr
GeographicErr(System::String^ msg)
Creates an exception using a managed string.
Definition: NETGeographicLib.h:145
NETGeographicLib::Mask::ALL
NETGeographicLib::Mask::AZIMUTH
NETGeographicLib::StringConvert::UnmanagedToManaged
static System::String ^ UnmanagedToManaged(const std::string &s)
Definition: NETGeographicLib.h:153
NETGeographicLib::captype::CAP_C3
NETGeographicLib::captype::CAP_ALL
NETGeographicLib::Mask::LONGITUDE
NETGeographicLib::captype::CAP_NONE
NETGeographicLib::Mask
Mask
Definition: NETGeographicLib.h:38
NETGeographicLib::Mask::REDUCEDLENGTH
NETGeographicLib::Constants
Physical constants.
Definition: NETGeographicLib.h:165
NETGeographicLib::Mask::DISTANCE_IN
NETGeographicLib::Mask::GEODESICSCALE
NETGeographicLib::captype::OUT_MASK
NETGeographicLib::GeographicErr::GeographicErr
GeographicErr(const char *msg)
Creates an exception using an unmanaged string.
Definition: NETGeographicLib.h:139
NETGeographicLib::Mask::LATITUDE
NETGeographicLib::Constants::GRS80
GRS80 Parameters.
Definition: NETGeographicLib.h:236
NETGeographicLib
Definition: Accumulator.h:13