1 /**
2  * \file NETGeographicLib/Ellipsoid.cpp
3  * \brief Implementation for NETGeographicLib::Ellipsoid class
4  *
5  * NETGeographicLib is copyright (c) Scott Heiman (2013)
6  * GeographicLib is Copyright (c) Charles Karney (2010-2012)
7  * <charles@karney.com> and licensed under the MIT/X11 License.
8  * For more information, see
9  * https://geographiclib.sourceforge.io/
10  **********************************************************************/
11 #include "stdafx.h"
12 #include "GeographicLib/Ellipsoid.hpp"
13 #include "Ellipsoid.h"
14 #include "NETGeographicLib.h"
15 
16 using namespace NETGeographicLib;
17 
18 const char BADALLOC[] = "Failed to allocate memory for a GeographicLib::Ellipsoid";
19 
20 //*****************************************************************************
21 Ellipsoid::!Ellipsoid(void)
22 {
23     if ( m_pEllipsoid != NULL )
24     {
25         delete m_pEllipsoid;
26         m_pEllipsoid = NULL;
27     }
28 }
29 
30 //*****************************************************************************
Ellipsoid()31 Ellipsoid::Ellipsoid()
32 {
33     try
34     {
35         m_pEllipsoid = new GeographicLib::Ellipsoid( GeographicLib::Ellipsoid::WGS84() );
36     }
37     catch ( std::bad_alloc )
38     {
39         throw gcnew GeographicErr( BADALLOC );
40     }
41 }
42 
43 //*****************************************************************************
Ellipsoid(double a,double f)44 Ellipsoid::Ellipsoid(double a, double f)
45 {
46     try
47     {
48         m_pEllipsoid = new GeographicLib::Ellipsoid( a, f );
49     }
50     catch ( std::bad_alloc err )
51     {
52         throw gcnew GeographicErr( BADALLOC );
53     }
54     catch ( const std::exception& err )
55     {
56         throw gcnew GeographicErr( err.what() );
57     }
58 }
59 
60 //*****************************************************************************
ParametricLatitude(double phi)61 double Ellipsoid::ParametricLatitude(double phi)
62 {
63     return m_pEllipsoid->ParametricLatitude( phi );
64 }
65 
66 //*****************************************************************************
InverseParametricLatitude(double beta)67 double Ellipsoid::InverseParametricLatitude(double beta)
68 {
69     return m_pEllipsoid->InverseParametricLatitude( beta );
70 }
71 
72 //*****************************************************************************
GeocentricLatitude(double phi)73 double Ellipsoid::GeocentricLatitude(double phi)
74 {
75     return m_pEllipsoid->GeocentricLatitude( phi );
76 }
77 
78 //*****************************************************************************
InverseGeocentricLatitude(double theta)79 double Ellipsoid::InverseGeocentricLatitude(double theta)
80 {
81     return m_pEllipsoid->InverseGeocentricLatitude( theta );
82 }
83 
84 //*****************************************************************************
RectifyingLatitude(double phi)85 double Ellipsoid::RectifyingLatitude(double phi)
86 {
87     return m_pEllipsoid->RectifyingLatitude( phi );
88 }
89 
90 //*****************************************************************************
InverseRectifyingLatitude(double mu)91 double Ellipsoid::InverseRectifyingLatitude(double mu)
92 {
93     return m_pEllipsoid->InverseRectifyingLatitude( mu );
94 }
95 
96 //*****************************************************************************
AuthalicLatitude(double phi)97 double Ellipsoid::AuthalicLatitude(double phi)
98 {
99     return m_pEllipsoid->AuthalicLatitude( phi );
100 }
101 
102 //*****************************************************************************
InverseAuthalicLatitude(double xi)103 double Ellipsoid::InverseAuthalicLatitude(double xi)
104 {
105     return m_pEllipsoid->InverseAuthalicLatitude( xi );
106 }
107 
108 //*****************************************************************************
ConformalLatitude(double phi)109 double Ellipsoid::ConformalLatitude(double phi)
110 {
111     return m_pEllipsoid->ConformalLatitude( phi );
112 }
113 
114 //*****************************************************************************
InverseConformalLatitude(double chi)115 double Ellipsoid::InverseConformalLatitude(double chi)
116 {
117     return m_pEllipsoid->InverseConformalLatitude( chi );
118 }
119 
120 //*****************************************************************************
IsometricLatitude(double phi)121 double Ellipsoid::IsometricLatitude(double phi)
122 {
123     return m_pEllipsoid->IsometricLatitude( phi );
124 }
125 
126 //*****************************************************************************
InverseIsometricLatitude(double psi)127 double Ellipsoid::InverseIsometricLatitude(double psi)
128 {
129     return m_pEllipsoid->InverseIsometricLatitude( psi );
130 }
131 
132 //*****************************************************************************
CircleRadius(double phi)133 double Ellipsoid::CircleRadius(double phi)
134 {
135     return m_pEllipsoid->CircleRadius( phi );
136 }
137 
138 //*****************************************************************************
CircleHeight(double phi)139 double Ellipsoid::CircleHeight(double phi)
140 {
141     return m_pEllipsoid->CircleHeight( phi );
142 }
143 
144 //*****************************************************************************
MeridianDistance(double phi)145 double Ellipsoid::MeridianDistance(double phi)
146 {
147     return m_pEllipsoid->MeridianDistance( phi );
148 }
149 
150 //*****************************************************************************
MeridionalCurvatureRadius(double phi)151 double Ellipsoid::MeridionalCurvatureRadius(double phi)
152 {
153     return m_pEllipsoid->MeridionalCurvatureRadius( phi );
154 }
155 
156 //*****************************************************************************
TransverseCurvatureRadius(double phi)157 double Ellipsoid::TransverseCurvatureRadius(double phi)
158 {
159     return m_pEllipsoid->TransverseCurvatureRadius( phi );
160 }
161 
162 //*****************************************************************************
NormalCurvatureRadius(double phi,double azi)163 double Ellipsoid::NormalCurvatureRadius(double phi, double azi)
164 {
165     return m_pEllipsoid->NormalCurvatureRadius( phi, azi );
166 }
167 
168 //*****************************************************************************
SecondFlatteningToFlattening(double fp)169 double Ellipsoid::SecondFlatteningToFlattening(double fp)
170 {
171     return GeographicLib::Ellipsoid::SecondFlatteningToFlattening( fp );
172 }
173 
174 //*****************************************************************************
FlatteningToSecondFlattening(double f)175 double Ellipsoid::FlatteningToSecondFlattening(double f)
176 {
177     return GeographicLib::Ellipsoid::FlatteningToSecondFlattening( f );
178 }
179 
180 //*****************************************************************************
ThirdFlatteningToFlattening(double n)181 double Ellipsoid::ThirdFlatteningToFlattening(double n)
182 {
183     return GeographicLib::Ellipsoid::ThirdFlatteningToFlattening( n );
184 }
185 
186 //*****************************************************************************
FlatteningToThirdFlattening(double f)187 double Ellipsoid::FlatteningToThirdFlattening(double f)
188 {
189     return GeographicLib::Ellipsoid::FlatteningToThirdFlattening( f );
190 }
191 
192 //*****************************************************************************
EccentricitySqToFlattening(double e2)193 double Ellipsoid::EccentricitySqToFlattening(double e2)
194 {
195     return GeographicLib::Ellipsoid::EccentricitySqToFlattening( e2 );
196 }
197 
198 //*****************************************************************************
FlatteningToEccentricitySq(double f)199 double Ellipsoid::FlatteningToEccentricitySq(double f)
200 {
201     return GeographicLib::Ellipsoid::FlatteningToEccentricitySq( f );
202 }
203 
204 //*****************************************************************************
SecondEccentricitySqToFlattening(double ep2)205 double Ellipsoid::SecondEccentricitySqToFlattening(double ep2)
206 {
207     return GeographicLib::Ellipsoid::SecondEccentricitySqToFlattening( ep2 );
208 }
209 
210 //*****************************************************************************
FlatteningToSecondEccentricitySq(double f)211 double Ellipsoid::FlatteningToSecondEccentricitySq(double f)
212 {
213     return GeographicLib::Ellipsoid::FlatteningToSecondEccentricitySq( f );
214 }
215 
216 //*****************************************************************************
ThirdEccentricitySqToFlattening(double epp2)217 double Ellipsoid::ThirdEccentricitySqToFlattening(double epp2)
218 {
219     return GeographicLib::Ellipsoid::ThirdEccentricitySqToFlattening( epp2 );
220 }
221 
222 //*****************************************************************************
FlatteningToThirdEccentricitySq(double f)223 double Ellipsoid::FlatteningToThirdEccentricitySq(double f)
224 {
225     return GeographicLib::Ellipsoid::FlatteningToThirdEccentricitySq( f );
226 }
227 
228 //*****************************************************************************
get()229 double Ellipsoid::EquatorialRadius::get()
230 { return m_pEllipsoid->EquatorialRadius(); }
231 
232 //*****************************************************************************
get()233 double Ellipsoid::MinorRadius::get()
234 { return m_pEllipsoid->MinorRadius(); }
235 
236 //*****************************************************************************
get()237 double Ellipsoid::QuarterMeridian::get()
238 { return m_pEllipsoid->QuarterMeridian(); }
239 
240 //*****************************************************************************
get()241 double Ellipsoid::Area::get()
242 { return m_pEllipsoid->Area(); }
243 
244 //*****************************************************************************
get()245 double Ellipsoid::Volume::get()
246 { return m_pEllipsoid->Volume(); }
247 
248 //*****************************************************************************
get()249 double Ellipsoid::Flattening::get()
250 { return m_pEllipsoid->Flattening(); }
251 
252 //*****************************************************************************
get()253 double Ellipsoid::SecondFlattening::get()
254 { return m_pEllipsoid->SecondFlattening(); }
255 
256 //*****************************************************************************
get()257 double Ellipsoid::ThirdFlattening::get()
258 { return m_pEllipsoid->ThirdFlattening(); }
259 
260 //*****************************************************************************
get()261 double Ellipsoid::EccentricitySq::get()
262 { return m_pEllipsoid->EccentricitySq(); }
263 
264 //*****************************************************************************
get()265 double Ellipsoid::SecondEccentricitySq::get()
266 { return m_pEllipsoid->SecondEccentricitySq(); }
267 
268 //*****************************************************************************
get()269 double Ellipsoid::ThirdEccentricitySq::get()
270 { return m_pEllipsoid->ThirdEccentricitySq(); }
271