00001 #pragma once 00002 /** 00003 * \file NETGeographicLib/Rhumb.h 00004 * \brief Header for NETGeographicLib::Rhumb and NETGeographicLib::RhumbLine classes 00005 * 00006 * NETGeographicLib is copyright (c) Scott Heiman (2013) 00007 * GeographicLib is Copyright (c) Charles Karney (2010-2012) 00008 * <charles@karney.com> and licensed under the MIT/X11 License. 00009 * For more information, see 00010 * http://geographiclib.sourceforge.net/ 00011 **********************************************************************/ 00012 00013 namespace NETGeographicLib { 00014 00015 ref class RhumbLine; 00016 00017 /** 00018 * \brief .NET wrapper for GeographicLib::Rhumb. 00019 * 00020 * This class allows .NET applications to access GeographicLib::Rhumb. 00021 * 00022 * Solve of the direct and inverse rhumb problems. 00023 * 00024 * The path of constant azimuth between two points on a ellipsoid at (\e 00025 * lat1, \e lon1) and (\e lat2, \e lon2) is called the rhumb line (also 00026 * called the loxodrome). Its length is \e s12 and its azimuth is \e azi12 00027 * and \e azi2. (The azimuth is the heading measured clockwise from north.) 00028 * 00029 * Given \e lat1, \e lon1, \e azi12, and \e s12, we can determine \e lat2, 00030 * and \e lon2. This is the \e direct rhumb problem and its solution is 00031 * given by the function Rhumb::Direct. 00032 * 00033 * Given \e lat1, \e lon1, \e lat2, and \e lon2, we can determine \e azi12 00034 * and \e s12. This is the \e inverse rhumb problem, whose solution is 00035 * given by Rhumb::Inverse. This finds the shortest such rhumb line, i.e., 00036 * the one that wraps no more than half way around the earth . 00037 * 00038 * Note that rhumb lines may be appreciably longer (up to 50%) than the 00039 * corresponding Geodesic. For example the distance between London Heathrow 00040 * and Tokyo Narita via the rhumb line is 11400 km which is 18% longer than 00041 * the geodesic distance 9600 km. 00042 * 00043 * For more information on rhumb lines see \ref rhumb. 00044 * 00045 * C# Example: 00046 * \include example-Rhumb.cs 00047 * Managed C++ Example: 00048 * \include example-Rhumb.cpp 00049 * Visual Basic Example: 00050 * \include example-Rhumb.vb 00051 * 00052 * <B>INTERFACE DIFFERENCES:</B><BR> 00053 * The MajorRadius and Flattening functions are implemented as properties. 00054 **********************************************************************/ 00055 00056 public ref class Rhumb { 00057 private: 00058 // pointer to the unmanaged Rhumb object 00059 GeographicLib::Rhumb* m_pRhumb; 00060 00061 // The finalizer destroys m_pRhumb when this object is destroyed. 00062 !Rhumb(void); 00063 public: 00064 00065 /** 00066 * Constructor for a ellipsoid with 00067 * 00068 * @param[in] a equatorial radius (meters). 00069 * @param[in] f flattening of ellipsoid. Setting \e f = 0 gives a sphere. 00070 * Negative \e f gives a prolate ellipsoid. If \e f > 1, set 00071 * flattening to 1/\e f. 00072 * @param[in] exact if true (the default) use an addition theorem for 00073 * elliptic integrals to compute divided differences; otherwise use 00074 * series expansion (accurate for |<i>f</i>| < 0.01). 00075 * @exception GeographicErr if \e a or (1 − \e f) \e a is not 00076 * positive. 00077 * 00078 * See \ref rhumb, for a detailed description of the \e exact parameter. 00079 **********************************************************************/ 00080 Rhumb(double a, double f, bool exact); 00081 00082 /** 00083 * \brief The destructor calls the finalizer. 00084 **********************************************************************/ 00085 ~Rhumb() { this->!Rhumb(); } 00086 00087 /** 00088 * Solve the direct rhumb problem. 00089 * 00090 * @param[in] lat1 latitude of point 1 (degrees). 00091 * @param[in] lon1 longitude of point 1 (degrees). 00092 * @param[in] azi12 azimuth of the rhumb line (degrees). 00093 * @param[in] s12 distance between point 1 and point 2 (meters); it can be 00094 * negative. 00095 * @param[out] lat2 latitude of point 2 (degrees). 00096 * @param[out] lon2 longitude of point 2 (degrees). 00097 * 00098 * \e lat1 should be in the range [−90°, 90°]; \e lon1 and \e 00099 * azi1 should be in the range [−540°, 540°). The values of 00100 * \e lon2 and \e azi2 returned are in the range [−180°, 00101 * 180°). 00102 * 00103 * If point 1 is a pole, the cosine of its latitude is taken to be 00104 * 1/ε<sup>2</sup> (where ε is 2<sup>-52</sup>). This 00105 * position, which is extremely close to the actual pole, allows the 00106 * calculation to be carried out in finite terms. If \e s12 is large 00107 * enough that the rhumb line crosses a pole, the longitude of point 2 00108 * is indeterminate (a NaN is returned for \e lon2). 00109 **********************************************************************/ 00110 void Direct(double lat1, double lon1, double azi12, double s12, 00111 [System::Runtime::InteropServices::Out] double% lat2, 00112 [System::Runtime::InteropServices::Out] double% lon2); 00113 00114 /** 00115 * Solve the inverse rhumb problem. 00116 * 00117 * @param[in] lat1 latitude of point 1 (degrees). 00118 * @param[in] lon1 longitude of point 1 (degrees). 00119 * @param[in] lat2 latitude of point 2 (degrees). 00120 * @param[in] lon2 longitude of point 2 (degrees). 00121 * @param[out] s12 rhumb distance between point 1 and point 2 (meters). 00122 * @param[out] azi12 azimuth of the rhumb line (degrees). 00123 * 00124 * The shortest rhumb line is found. \e lat1 and \e lat2 should be in the 00125 * range [−90°, 90°]; \e lon1 and \e lon2 should be in the 00126 * range [−540°, 540°). The value of \e azi12 returned is in 00127 * the range [−180°, 180°). 00128 * 00129 * If either point is a pole, the cosine of its latitude is taken to be 00130 * 1/ε<sup>2</sup> (where ε is 2<sup>-52</sup>). This 00131 * position, which is extremely close to the actual pole, allows the 00132 * calculation to be carried out in finite terms. 00133 **********************************************************************/ 00134 void Inverse(double lat1, double lon1, double lat2, double lon2, 00135 [System::Runtime::InteropServices::Out] double% s12, 00136 [System::Runtime::InteropServices::Out] double% azi12); 00137 00138 /** 00139 * Set up to compute several points on a single rhumb line. 00140 * 00141 * @param[in] lat1 latitude of point 1 (degrees). 00142 * @param[in] lon1 longitude of point 1 (degrees). 00143 * @param[in] azi12 azimuth of the rhumb line (degrees). 00144 * @return a RhumbLine object. 00145 * 00146 * \e lat1 should be in the range [−90°, 90°]; \e lon1 and \e 00147 * azi12 should be in the range [−540°, 540°). 00148 * 00149 * If point 1 is a pole, the cosine of its latitude is taken to be 00150 * 1/ε<sup>2</sup> (where ε is 2<sup>-52</sup>). This 00151 * position, which is extremely close to the actual pole, allows the 00152 * calculation to be carried out in finite terms. 00153 **********************************************************************/ 00154 RhumbLine^ Line(double lat1, double lon1, double azi12); 00155 00156 /** \name Inspector functions. 00157 **********************************************************************/ 00158 ///@{ 00159 00160 /** 00161 * @return the equatorial radius of the ellipsoid (meters). This is 00162 * the value used in the constructor. 00163 **********************************************************************/ 00164 property double MajorRadius { double get(); } 00165 00166 /** 00167 * @return f the flattening of the ellipsoid. This is the 00168 * value used in the constructor. 00169 **********************************************************************/ 00170 property double Flattening { double get(); } 00171 00172 /** 00173 * A global instantiation of Rhumb with the parameters for the WGS84 00174 * ellipsoid. 00175 **********************************************************************/ 00176 static Rhumb^ WGS84(); 00177 }; 00178 00179 /** 00180 * \brief .NET wrapper for GeographicLib::RhumbLine. 00181 * 00182 * This class allows .NET applications to access GeographicLib::RhumbLine. 00183 * 00184 * Find a sequence of points on a single rhumb line. 00185 * 00186 * RhumbLine facilitates the determination of a series of points on a single 00187 * rhumb line. The starting point (\e lat1, \e lon1) and the azimuth \e 00188 * azi12 are specified in the call to Rhumb::Line which returns a RhumbLine 00189 * object. RhumbLine.Position returns the location of point 2 a distance \e 00190 * s12 along the rhumb line. 00191 00192 * There is no public constructor for this class. (Use Rhumb::Line to create 00193 * an instance.) The Rhumb object used to create a RhumbLine must stay in 00194 * scope as long as the RhumbLine. 00195 * 00196 **********************************************************************/ 00197 00198 public ref class RhumbLine { 00199 private: 00200 // pointer to the unmanaged RhumbLine object. 00201 GeographicLib::RhumbLine* m_pRhumbLine; 00202 00203 // The finalizer destroys m_pRhumbLine when this object is destroyed. 00204 !RhumbLine(void); 00205 public: 00206 /** 00207 * \brief Constructor. 00208 * 00209 * For internal use only. Developers should not call this constructor 00210 * directly. Use the Rhumb::Line function to create RhumbLine objects. 00211 **********************************************************************/ 00212 RhumbLine( GeographicLib::RhumbLine* pRhumbLine ); 00213 00214 /** 00215 * \brief The destructor calls the finalizer. 00216 **********************************************************************/ 00217 ~RhumbLine() { this->!RhumbLine(); } 00218 00219 /** 00220 * Compute the position of point 2 which is a distance \e s12 (meters) from 00221 * point 1. 00222 * 00223 * @param[in] s12 distance between point 1 and point 2 (meters); it can be 00224 * negative. 00225 * @param[out] lat2 latitude of point 2 (degrees). 00226 * @param[out] lon2 longitude of point 2 (degrees). 00227 * 00228 * The values of \e lon2 and \e azi2 returned are in the range 00229 * [−180°, 180°). 00230 * 00231 * If \e s12 is large enough that the rhumb line crosses a pole, the 00232 * longitude of point 2 is indeterminate (a NaN is returned for \e lon2). 00233 **********************************************************************/ 00234 void Position(double s12, 00235 [System::Runtime::InteropServices::Out] double% lat2, 00236 [System::Runtime::InteropServices::Out] double% lon2); 00237 00238 /** \name Inspector functions 00239 **********************************************************************/ 00240 ///@{ 00241 00242 /** 00243 * @return the latitude of point 1 (degrees). 00244 **********************************************************************/ 00245 property double Latitude { double get(); } 00246 00247 /** 00248 * @return the longitude of point 1 (degrees). 00249 **********************************************************************/ 00250 property double Longitude { double get(); } 00251 00252 /** 00253 * @return the azimuth of the rhumb line (degrees). 00254 **********************************************************************/ 00255 property double Azimuth { double get(); } 00256 00257 /** 00258 * @return the equatorial radius of the ellipsoid (meters). This is 00259 * the value inherited from the Rhumb object used in the constructor. 00260 **********************************************************************/ 00261 property double MajorRadius { double get(); } 00262 00263 /** 00264 * @return the flattening of the ellipsoid. This is the value 00265 * inherited from the Rhumb object used in the constructor. 00266 **********************************************************************/ 00267 property double Flattening { double get(); } 00268 }; 00269 00270 } // namespace NETGeographicLib