dotnet/NETGeographicLib/GeodesicLine.cpp
Go to the documentation of this file.
1 
11 #include "stdafx.h"
13 #include "Geodesic.h"
14 #include "GeodesicLine.h"
15 
16 using namespace NETGeographicLib;
17 
18 const char BADALLOC[] = "Failed to allocate memory for a GeographicLib::GeodesicLine";
19 
20 //*****************************************************************************
22 {
23  if ( m_pGeodesicLine != NULL )
24  {
25  delete m_pGeodesicLine;
26  m_pGeodesicLine = NULL;
27  }
28 }
29 
30 //*****************************************************************************
31 GeodesicLine::GeodesicLine( Geodesic^ g, double lat1, double lon1, double azi1,
33 {
34  try
35  {
36  const GeographicLib::Geodesic* pGeodesic =
37  reinterpret_cast<const GeographicLib::Geodesic*>(
38  g->GetUnmanaged()->ToPointer() );
40  lat1, lon1, azi1, static_cast<unsigned>(caps) );
41  }
42  catch ( std::bad_alloc )
43  {
44  throw gcnew GeographicErr( BADALLOC );
45  }
46 }
47 
48 //*****************************************************************************
50 {
51  try
52  {
54  }
55  catch (std::bad_alloc)
56  {
57  throw gcnew GeographicErr(BADALLOC);
58  }
59 }
60 
61 //*****************************************************************************
62 GeodesicLine::GeodesicLine(double lat1, double lon1, double azi1,
64 {
65  try
66  {
68  GeographicLib::Geodesic::WGS84(), lat1, lon1, azi1,
69  static_cast<unsigned>(caps) );
70  }
71  catch ( std::bad_alloc )
72  {
73  throw gcnew GeographicErr( BADALLOC );
74  }
75 }
76 
77 //*****************************************************************************
78 double GeodesicLine::Position(double s12,
79  [System::Runtime::InteropServices::Out] double% lat2,
80  [System::Runtime::InteropServices::Out] double% lon2,
81  [System::Runtime::InteropServices::Out] double% azi2,
82  [System::Runtime::InteropServices::Out] double% m12,
83  [System::Runtime::InteropServices::Out] double% M12,
84  [System::Runtime::InteropServices::Out] double% M21,
85  [System::Runtime::InteropServices::Out] double% S12)
86 {
87  double llat2, llon2, lazi2, lm12, lM12, lM21, lS12;
88  double out = m_pGeodesicLine->Position( s12, llat2, llon2, lazi2, lm12,
89  lM12, lM21, lS12 );
90  lat2 = llat2;
91  lon2 = llon2;
92  azi2 = lazi2;
93  m12 = lm12;
94  M12 = lM12;
95  M21 = lM21;
96  S12 = lS12;
97  return out;
98 }
99 
100 //*****************************************************************************
101 double GeodesicLine::Position(double s12,
102  [System::Runtime::InteropServices::Out] double% lat2,
103  [System::Runtime::InteropServices::Out] double% lon2)
104 {
105  double llat2, llon2;
106  double out = m_pGeodesicLine->Position( s12, llat2, llon2);
107  lat2 = llat2;
108  lon2 = llon2;
109  return out;
110 }
111 
112 //*****************************************************************************
113 double GeodesicLine::Position(double s12,
114  [System::Runtime::InteropServices::Out] double% lat2,
115  [System::Runtime::InteropServices::Out] double% lon2,
116  [System::Runtime::InteropServices::Out] double% azi2)
117 {
118  double llat2, llon2, lazi2;
119  double out = m_pGeodesicLine->Position( s12, llat2, llon2, lazi2 );
120  lat2 = llat2;
121  lon2 = llon2;
122  azi2 = lazi2;
123  return out;
124 }
125 
126 //*****************************************************************************
127 double GeodesicLine::Position(double s12,
128  [System::Runtime::InteropServices::Out] double% lat2,
129  [System::Runtime::InteropServices::Out] double% lon2,
130  [System::Runtime::InteropServices::Out] double% azi2,
131  [System::Runtime::InteropServices::Out] double% m12)
132 {
133  double llat2, llon2, lazi2, lm12;
134  double out = m_pGeodesicLine->Position( s12, llat2, llon2, lazi2,
135  lm12 );
136  lat2 = llat2;
137  lon2 = llon2;
138  azi2 = lazi2;
139  m12 = lm12;
140  return out;
141 }
142 
143 //*****************************************************************************
144 double GeodesicLine::Position(double s12,
145  [System::Runtime::InteropServices::Out] double% lat2,
146  [System::Runtime::InteropServices::Out] double% lon2,
147  [System::Runtime::InteropServices::Out] double% azi2,
148  [System::Runtime::InteropServices::Out] double% M12,
149  [System::Runtime::InteropServices::Out] double% M21)
150 {
151  double llat2, llon2, lazi2, lM12, lM21;
152  double out = m_pGeodesicLine->Position( s12, llat2, llon2, lazi2,
153  lM12, lM21 );
154  lat2 = llat2;
155  lon2 = llon2;
156  azi2 = lazi2;
157  M12 = lM12;
158  M21 = lM21;
159  return out;
160 }
161 
162 //*****************************************************************************
163 double GeodesicLine::Position(double s12,
164  [System::Runtime::InteropServices::Out] double% lat2,
165  [System::Runtime::InteropServices::Out] double% lon2,
166  [System::Runtime::InteropServices::Out] double% azi2,
167  [System::Runtime::InteropServices::Out] double% m12,
168  [System::Runtime::InteropServices::Out] double% M12,
169  [System::Runtime::InteropServices::Out] double% M21)
170 {
171  double llat2, llon2, lazi2, lm12, lM12, lM21;
172  double out = m_pGeodesicLine->Position( s12, llat2, llon2, lazi2, lm12,
173  lM12, lM21 );
174  lat2 = llat2;
175  lon2 = llon2;
176  azi2 = lazi2;
177  m12 = lm12;
178  M12 = lM12;
179  M21 = lM21;
180  return out;
181 }
182 
183 //*****************************************************************************
185  [System::Runtime::InteropServices::Out] double% lat2,
186  [System::Runtime::InteropServices::Out] double% lon2,
187  [System::Runtime::InteropServices::Out] double% azi2,
188  [System::Runtime::InteropServices::Out] double% s12,
189  [System::Runtime::InteropServices::Out] double% m12,
190  [System::Runtime::InteropServices::Out] double% M12,
191  [System::Runtime::InteropServices::Out] double% M21,
192  [System::Runtime::InteropServices::Out] double% S12)
193 {
194  double llat2, llon2, lazi2, ls12, lm12, lM12, lM21, lS12;
195  m_pGeodesicLine->ArcPosition( a12, llat2, llon2, lazi2,
196  ls12, lm12, lM12, lM21, lS12 );
197  lat2 = llat2;
198  lon2 = llon2;
199  azi2 = lazi2;
200  s12 = ls12;
201  m12 = lm12;
202  M12 = lM12;
203  M21 = lM21;
204  S12 = lS12;
205 }
206 
207 //*****************************************************************************
209  [System::Runtime::InteropServices::Out] double% lat2,
210  [System::Runtime::InteropServices::Out] double% lon2)
211 {
212  double llat2, llon2;
213  m_pGeodesicLine->ArcPosition( a12, llat2, llon2 );
214  lat2 = llat2;
215  lon2 = llon2;
216 }
217 
218 //*****************************************************************************
220  [System::Runtime::InteropServices::Out] double% lat2,
221  [System::Runtime::InteropServices::Out] double% lon2,
222  [System::Runtime::InteropServices::Out] double% azi2)
223 {
224  double llat2, llon2, lazi2;
225  m_pGeodesicLine->ArcPosition( a12, llat2, llon2, lazi2 );
226  lat2 = llat2;
227  lon2 = llon2;
228  azi2 = lazi2;
229 }
230 
231 //*****************************************************************************
233  [System::Runtime::InteropServices::Out] double% lat2,
234  [System::Runtime::InteropServices::Out] double% lon2,
235  [System::Runtime::InteropServices::Out] double% azi2,
236  [System::Runtime::InteropServices::Out] double% s12)
237 {
238  double llat2, llon2, lazi2, ls12;
239  m_pGeodesicLine->ArcPosition( a12, llat2, llon2, lazi2, ls12 );
240  lat2 = llat2;
241  lon2 = llon2;
242  azi2 = lazi2;
243  s12 = ls12;
244 }
245 
246 //*****************************************************************************
248  [System::Runtime::InteropServices::Out] double% lat2,
249  [System::Runtime::InteropServices::Out] double% lon2,
250  [System::Runtime::InteropServices::Out] double% azi2,
251  [System::Runtime::InteropServices::Out] double% s12,
252  [System::Runtime::InteropServices::Out] double% m12)
253 {
254  double llat2, llon2, lazi2, ls12, lm12;
255  m_pGeodesicLine->ArcPosition( a12, llat2, llon2, lazi2, ls12, lm12 );
256  lat2 = llat2;
257  lon2 = llon2;
258  azi2 = lazi2;
259  s12 = ls12;
260  m12 = lm12;
261 }
262 
263 //*****************************************************************************
265  [System::Runtime::InteropServices::Out] double% lat2,
266  [System::Runtime::InteropServices::Out] double% lon2,
267  [System::Runtime::InteropServices::Out] double% azi2,
268  [System::Runtime::InteropServices::Out] double% s12,
269  [System::Runtime::InteropServices::Out] double% M12,
270  [System::Runtime::InteropServices::Out] double% M21)
271 {
272  double llat2, llon2, lazi2, ls12, lM12, lM21;
273  m_pGeodesicLine->ArcPosition( a12, llat2, llon2, lazi2,
274  ls12, lM12, lM21 );
275  lat2 = llat2;
276  lon2 = llon2;
277  azi2 = lazi2;
278  s12 = ls12;
279  M12 = lM12;
280  M21 = lM21;
281 }
282 
283 //*****************************************************************************
285  [System::Runtime::InteropServices::Out] double% lat2,
286  [System::Runtime::InteropServices::Out] double% lon2,
287  [System::Runtime::InteropServices::Out] double% azi2,
288  [System::Runtime::InteropServices::Out] double% s12,
289  [System::Runtime::InteropServices::Out] double% m12,
290  [System::Runtime::InteropServices::Out] double% M12,
291  [System::Runtime::InteropServices::Out] double% M21)
292 {
293  double llat2, llon2, lazi2, ls12, lm12, lM12, lM21;
294  m_pGeodesicLine->ArcPosition( a12, llat2, llon2, lazi2,
295  ls12, lm12, lM12, lM21 );
296  lat2 = llat2;
297  lon2 = llon2;
298  azi2 = lazi2;
299  s12 = ls12;
300  m12 = lm12;
301  M12 = lM12;
302  M21 = lM21;
303 }
304 
305 //*****************************************************************************
306 double GeodesicLine::GenPosition(bool arcmode, double s12_a12,
307  GeodesicLine::mask outmask,
308  [System::Runtime::InteropServices::Out] double% lat2,
309  [System::Runtime::InteropServices::Out] double% lon2,
310  [System::Runtime::InteropServices::Out] double% azi2,
311  [System::Runtime::InteropServices::Out] double% s12,
312  [System::Runtime::InteropServices::Out] double% m12,
313  [System::Runtime::InteropServices::Out] double% M12,
314  [System::Runtime::InteropServices::Out] double% M21,
315  [System::Runtime::InteropServices::Out] double% S12)
316 {
317  double llat2, llon2, lazi2, ls12, lm12, lM12, lM21, lS12;
318  double out = m_pGeodesicLine->GenPosition( arcmode, s12_a12,
319  static_cast<unsigned>(outmask),
320  llat2, llon2, lazi2, ls12, lm12, lM12, lM21, lS12 );
321  lat2 = llat2;
322  lon2 = llon2;
323  azi2 = lazi2;
324  s12 = ls12;
325  m12 = lm12;
326  M12 = lM12;
327  M21 = lM21;
328  S12 = lS12;
329  return out;
330 }
331 
332 //*****************************************************************************
334 
335 //*****************************************************************************
337 
338 //*****************************************************************************
339 double GeodesicLine::Azimuth::get() { return m_pGeodesicLine->Azimuth(); }
340 
341 //*****************************************************************************
343 { return m_pGeodesicLine->EquatorialAzimuth(); }
344 
345 //*****************************************************************************
347 { return m_pGeodesicLine->EquatorialArc(); }
348 
349 //*****************************************************************************
351 { return m_pGeodesicLine->MajorRadius(); }
352 
353 //*****************************************************************************
355 { return m_pGeodesicLine->Flattening(); }
356 
357 //*****************************************************************************
359 { return m_pGeodesicLine->Distance(); }
360 
361 //*****************************************************************************
362 double GeodesicLine::Arc::get()
363 { return m_pGeodesicLine->Arc(); }
364 
365 //*****************************************************************************
367 { return static_cast<NETGeographicLib::Mask>(m_pGeodesicLine->Capabilities()); }
368 
369 //*****************************************************************************
371 { return m_pGeodesicLine->Capabilities( static_cast<unsigned>(testcaps) ); }
372 
373 //*****************************************************************************
375 { m_pGeodesicLine->SetDistance(s13); }
376 
377 //*****************************************************************************
378 void GeodesicLine::SetArc(double a13)
379 { m_pGeodesicLine->SetArc(a13); }
380 
381 //*****************************************************************************
382 void GeodesicLine::GenSetDistance(bool arcmode, double s13_a13)
383 { m_pGeodesicLine->GenSetDistance(arcmode, s13_a13); }
384 
385 //*****************************************************************************
386 void GeodesicLine::AzimuthSinCos(double% sazi1, double% cazi1)
387 {
388  double x1, x2;
389  m_pGeodesicLine->Azimuth(x1, x2);
390  sazi1 = x1;
391  cazi1 = x2;
392 }
393 
394 //*****************************************************************************
395 void GeodesicLine::EquatorialAzimuthSinCos(double% sazi0, double% cazi0)
396 {
397  double x1, x2;
399  sazi0 = x1;
400  cazi0 = x2;
401 }
402 
403 //*****************************************************************************
404 double GeodesicLine::GenDistance(bool arcmode)
405 { return m_pGeodesicLine->GenDistance(arcmode); }
void ArcPosition(double a12, [System::Runtime::InteropServices::Out] double% lat2, [System::Runtime::InteropServices::Out] double% lon2, [System::Runtime::InteropServices::Out] double% azi2, [System::Runtime::InteropServices::Out] double% s12, [System::Runtime::InteropServices::Out] double% m12, [System::Runtime::InteropServices::Out] double% M12, [System::Runtime::InteropServices::Out] double% M21, [System::Runtime::InteropServices::Out] double% S12)
Header for GeographicLib::GeodesicLine class.
GeodesicLine(Geodesic^ g, double lat1, double lon1, double azi1, NETGeographicLib::Mask caps)
Math::real Flattening() const
void GenSetDistance(bool arcmode, double s13_a13)
static const Geodesic & WGS84()
Exception class for NETGeographicLib.
std::ofstream out("Result.txt")
Math::real Position(real s12, real &lat2, real &lon2, real &azi2, real &m12, real &M12, real &M21, real &S12) const
Math::real GenDistance(bool arcmode) const
Pose3 x2(Rot3::Ypr(0.0, 0.0, 0.0), l2)
Math::real MajorRadius() const
void EquatorialAzimuthSinCos([System::Runtime::InteropServices::Out] double% sazi0, [System::Runtime::InteropServices::Out] double% cazi0)
Math::real EquatorialArc() const
Header for NETGeographicLib::GeodesicLine class.
void g(const string &key, int i)
Definition: testBTree.cpp:41
unsigned Capabilities() const
Math::real Azimuth() const
Math::real Distance() const
void GenSetDistance(bool arcmode, real s13_a13)
Math::real EquatorialAzimuth() const
.NET wrapper for GeographicLib::GeodesicLine.
Definition: GeodesicLine.h:75
void AzimuthSinCos([System::Runtime::InteropServices::Out] double% sazi1, [System::Runtime::InteropServices::Out] double% cazi1)
.NET wrapper for GeographicLib::Geodesic.
Definition: Geodesic.h:170
#define NULL
Definition: ccolamd.c:609
Math::real Latitude() const
Pose3 x1
Definition: testPose3.cpp:663
double Position(double s12, [System::Runtime::InteropServices::Out] double% lat2, [System::Runtime::InteropServices::Out] double% lon2, [System::Runtime::InteropServices::Out] double% azi2, [System::Runtime::InteropServices::Out] double% m12, [System::Runtime::InteropServices::Out] double% M12, [System::Runtime::InteropServices::Out] double% M21, [System::Runtime::InteropServices::Out] double% S12)
GeographicLib::GeodesicLine * m_pGeodesicLine
Definition: GeodesicLine.h:79
double GenPosition(bool arcmode, double s12_a12, GeodesicLine::mask outmask, [System::Runtime::InteropServices::Out] double% lat2, [System::Runtime::InteropServices::Out] double% lon2, [System::Runtime::InteropServices::Out] double% azi2, [System::Runtime::InteropServices::Out] double% s12, [System::Runtime::InteropServices::Out] double% m12, [System::Runtime::InteropServices::Out] double% M12, [System::Runtime::InteropServices::Out] double% M21, [System::Runtime::InteropServices::Out] double% S12)
void ArcPosition(real a12, real &lat2, real &lon2, real &azi2, real &s12, real &m12, real &M12, real &M21, real &S12) const
Container::iterator get(Container &c, Position position)
Header for NETGeographicLib::Geodesic class.
Math::real GenPosition(bool arcmode, real s12_a12, unsigned outmask, real &lat2, real &lon2, real &azi2, real &s12, real &m12, real &M12, real &M21, real &S12) const
Geodesic calculations
Definition: Geodesic.hpp:172
Math::real Longitude() const


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:18