dotnet/NETGeographicLib/Geocentric.cpp
Go to the documentation of this file.
1 
11 #include "stdafx.h"
13 #include "Geocentric.h"
14 #include "NETGeographicLib.h"
15 
16 using namespace NETGeographicLib;
17 
18 const char BADALLOC[] = "Unable to allocate memory for a GeographicLib::Geocentric";
19 
20 //*****************************************************************************
22 {
23  if ( m_pGeocentric != NULL )
24  {
25  delete m_pGeocentric;
26  m_pGeocentric = NULL;
27  }
28 }
29 
30 //*****************************************************************************
32 {
33  try
34  {
37  }
38  catch (std::bad_alloc)
39  {
40  throw gcnew GeographicErr( BADALLOC );
41  }
42 }
43 
44 //*****************************************************************************
45 Geocentric::Geocentric(double a, double f)
46 {
47  try
48  {
50  }
51  catch (std::bad_alloc)
52  {
53  throw gcnew GeographicErr( BADALLOC );
54  }
55  catch (std::exception err )
56  {
57  throw gcnew GeographicErr( err.what() );
58  }
59 }
60 
61 //*****************************************************************************
63 {
64  try
65  {
67  }
68  catch (std::bad_alloc)
69  {
70  throw gcnew GeographicErr( BADALLOC );
71  }
72 }
73 
74 //*****************************************************************************
75 void Geocentric::Forward(double lat, double lon, double h,
76  [System::Runtime::InteropServices::Out] double% X,
77  [System::Runtime::InteropServices::Out] double% Y,
78  [System::Runtime::InteropServices::Out] double% Z)
79 {
80  double lX, lY, lZ;
81  m_pGeocentric->Forward( lat, lon, h, lX, lY, lZ);
82  X = lX;
83  Y = lY;
84  Z = lZ;
85 }
86 
87 //*****************************************************************************
88 void Geocentric::Forward(double lat, double lon, double h,
89  [System::Runtime::InteropServices::Out] double% X,
90  [System::Runtime::InteropServices::Out] double% Y,
91  [System::Runtime::InteropServices::Out] double% Z,
92  [System::Runtime::InteropServices::Out] array<double,2>^% M)
93 {
94  double lX, lY, lZ;
95  std::vector<double> lM(9);
96  m_pGeocentric->Forward( lat, lon, h, lX, lY, lZ, lM);
97  X = lX;
98  Y = lY;
99  Z = lZ;
100  M = gcnew array<double,2>( 3, 3 );
101  for ( int i = 0; i < 3; i++ )
102  for ( int j = 0; j < 3; j++ )
103  M[i,j] = lM[3*i+j];
104 }
105 
106 //*****************************************************************************
107 void Geocentric::Reverse(double X, double Y, double Z,
108  [System::Runtime::InteropServices::Out] double% lat,
109  [System::Runtime::InteropServices::Out] double% lon,
110  [System::Runtime::InteropServices::Out] double% h)
111 {
112  double llat, llon, lh;
113  m_pGeocentric->Reverse(X, Y, Z, llat, llon, lh);
114  lat = llat;
115  lon = llon;
116  h = lh;
117 }
118 
119 //*****************************************************************************
120 void Geocentric::Reverse(double X, double Y, double Z,
121  [System::Runtime::InteropServices::Out] double% lat,
122  [System::Runtime::InteropServices::Out] double% lon,
123  [System::Runtime::InteropServices::Out] double% h,
124  [System::Runtime::InteropServices::Out] array<double,2>^% M)
125 {
126  std::vector<double> lM(9);
127  double llat, llon, lh;
128  m_pGeocentric->Reverse(X, Y, Z, llat, llon, lh, lM);
129  lat = llat;
130  lon = llon;
131  h = lh;
132  M = gcnew array<double,2>( 3, 3 );
133  for ( int i = 0; i < 3; i++ )
134  for ( int j = 0; j < 3; j++ )
135  M[i,j] = lM[3*i+j];
136 }
137 
138 //*****************************************************************************
140 {
141  return gcnew System::IntPtr( const_cast<void*>(
142  reinterpret_cast<const void*>(m_pGeocentric) ) );
143 }
144 
145 //*****************************************************************************
147 { return m_pGeocentric->MajorRadius(); }
148 
149 //*****************************************************************************
151 { return m_pGeocentric->Flattening(); }
NETGeographicLib::Geocentric::Reverse
void Reverse(double X, double Y, double Z, [System::Runtime::InteropServices::Out] double% lat, [System::Runtime::InteropServices::Out] double% lon, [System::Runtime::InteropServices::Out] double% h)
Definition: dotnet/NETGeographicLib/Geocentric.cpp:107
NETGeographicLib::Geocentric
.NET wrapper for GeographicLib::Geocentric.
Definition: Geocentric.h:68
gtsam::Y
GaussianFactorGraphValuePair Y
Definition: HybridGaussianProductFactor.cpp:29
GeographicLib::Geocentric::Reverse
void Reverse(real X, real Y, real Z, real &lat, real &lon, real &h) const
Definition: Geocentric.hpp:194
X
#define X
Definition: icosphere.cpp:20
h
const double h
Definition: testSimpleHelicopter.cpp:19
NETGeographicLib::GeographicErr
Exception class for NETGeographicLib.
Definition: NETGeographicLib.h:132
GeographicLib::Geocentric
Geocentric coordinates
Definition: Geocentric.hpp:67
GeographicLib::Geocentric::Forward
void Forward(real lat, real lon, real h, real &X, real &Y, real &Z) const
Definition: Geocentric.hpp:132
Geocentric.hpp
Header for GeographicLib::Geocentric class.
j
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
stdafx.h
NETGeographicLib.h
Header for NETGeographicLib::NETGeographicLib objects.
g
void g(const string &key, int i)
Definition: testBTree.cpp:41
NETGeographicLib::Geocentric::Geocentric
Geocentric()
Definition: dotnet/NETGeographicLib/Geocentric.cpp:31
tree::f
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Definition: testExpression.cpp:218
NETGeographicLib::Geocentric::GetUnmanaged
System::IntPtr GetUnmanaged()
Definition: dotnet/NETGeographicLib/Geocentric.cpp:139
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
array
Definition: numpy.h:821
BADALLOC
const char BADALLOC[]
Definition: dotnet/NETGeographicLib/Geocentric.cpp:18
NETGeographicLib::Geocentric::m_pGeocentric
const GeographicLib::Geocentric * m_pGeocentric
Definition: Geocentric.h:72
lon
static const double lon
Definition: testGeographicLib.cpp:34
NULL
#define NULL
Definition: ccolamd.c:609
Z
#define Z
Definition: icosphere.cpp:21
NETGeographicLib::Geocentric::Forward
void Forward(double lat, double lon, double h, [System::Runtime::InteropServices::Out] double% X, [System::Runtime::InteropServices::Out] double% Y, [System::Runtime::InteropServices::Out] double% Z)
Definition: dotnet/NETGeographicLib/Geocentric.cpp:75
GeographicLib::Geocentric::WGS84
static const Geocentric & WGS84()
Definition: src/Geocentric.cpp:31
get
Container::iterator get(Container &c, Position position)
Definition: stdlist_overload.cpp:29
NETGeographicLib
Definition: Accumulator.h:13
Geocentric.h
Header for NETGeographicLib::Geocentric class.
Eigen::internal::IntPtr
std::ptrdiff_t IntPtr
Definition: Meta.h:91
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
lat
static const double lat
Definition: testGeographicLib.cpp:34
M
Matrix< RealScalar, Dynamic, Dynamic > M
Definition: bench_gemm.cpp:51


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:11:36