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(); }
const char Y
Matrix< RealScalar, Dynamic, Dynamic > M
Definition: bench_gemm.cpp:51
Header for NETGeographicLib::NETGeographicLib objects.
static const double lat
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)
Exception class for NETGeographicLib.
Definition: numpy.h:680
void g(const string &key, int i)
Definition: testBTree.cpp:41
.NET wrapper for GeographicLib::Geocentric.
Definition: Geocentric.h:68
Geocentric coordinates
Definition: Geocentric.hpp:67
std::ptrdiff_t IntPtr
Definition: Meta.h:91
#define Z
Definition: icosphere.cpp:21
void Forward(real lat, real lon, real h, real &X, real &Y, real &Z) const
Definition: Geocentric.hpp:132
Header for NETGeographicLib::Geocentric class.
static const Geocentric & WGS84()
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
#define NULL
Definition: ccolamd.c:609
Header for GeographicLib::Geocentric class.
Math::real Flattening() const
Definition: Geocentric.hpp:254
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)
const double h
static const double lon
Math::real MajorRadius() const
Definition: Geocentric.hpp:247
void Reverse(real X, real Y, real Z, real &lat, real &lon, real &h) const
Definition: Geocentric.hpp:194
Container::iterator get(Container &c, Position position)
#define X
Definition: icosphere.cpp:20
const GeographicLib::Geocentric * m_pGeocentric
Definition: Geocentric.h:72
std::ptrdiff_t j
const char BADALLOC[]


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