dotnet/NETGeographicLib/LocalCartesian.cpp
Go to the documentation of this file.
1 
11 #include "stdafx.h"
13 #include "LocalCartesian.h"
14 #include "Geocentric.h"
15 #include "NETGeographicLib.h"
16 
17 using namespace NETGeographicLib;
18 
19 const char BADALLOC[] = "Failed to allocate memory for a GeographicLib::LocalCartesian";
20 
21 //*****************************************************************************
23 {
24  if ( m_pLocalCartesian != NULL )
25  {
26  delete m_pLocalCartesian;
27  m_pLocalCartesian = NULL;
28  }
29 }
30 
31 //*****************************************************************************
32 LocalCartesian::LocalCartesian(double lat0, double lon0, double h0,
33  Geocentric^ earth )
34 {
35  try
36  {
37  const GeographicLib::Geocentric* pGeocentric =
38  reinterpret_cast<const GeographicLib::Geocentric*>(
39  earth->GetUnmanaged()->ToPointer() );
41  }
42  catch ( std::bad_alloc )
43  {
44  throw gcnew GeographicErr( BADALLOC );
45  }
46 }
47 
48 //*****************************************************************************
49 LocalCartesian::LocalCartesian(double lat0, double lon0, double h0 )
50 {
51  try
52  {
55  }
56  catch ( std::bad_alloc )
57  {
58  throw gcnew GeographicErr( BADALLOC );
59  }
60 }
61 
62 //*****************************************************************************
64 {
65  try
66  {
67  const GeographicLib::Geocentric* pGeocentric =
68  reinterpret_cast<const GeographicLib::Geocentric*>(
69  earth->GetUnmanaged()->ToPointer() );
71  }
72  catch ( std::bad_alloc )
73  {
74  throw gcnew GeographicErr( BADALLOC );
75  }
76 }
77 
78 //*****************************************************************************
80 {
81  try
82  {
85  }
86  catch ( std::bad_alloc )
87  {
88  throw gcnew GeographicErr( BADALLOC );
89  }
90 }
91 
92 //*****************************************************************************
93 void LocalCartesian::Reset(double lat0, double lon0, double h0 )
94 {
96 }
97 
98 //*****************************************************************************
99 void LocalCartesian::Forward(double lat, double lon, double h,
100  [System::Runtime::InteropServices::Out] double% x,
101  [System::Runtime::InteropServices::Out] double% y,
102  [System::Runtime::InteropServices::Out] double% z)
103 {
104  double lx, ly, lz;
105  m_pLocalCartesian->Forward( lat, lon, h, lx, ly, lz );
106  x = lx;
107  y = ly;
108  z = lz;
109 }
110 
111 //*****************************************************************************
112 void LocalCartesian::Forward(double lat, double lon, double h,
113  [System::Runtime::InteropServices::Out] double% x,
114  [System::Runtime::InteropServices::Out] double% y,
115  [System::Runtime::InteropServices::Out] double% z,
116  [System::Runtime::InteropServices::Out] array<double,2>^% M)
117 {
118  double lx, ly, lz;
119  std::vector<double> lM(9);
120  m_pLocalCartesian->Forward( lat, lon, h, lx, ly, lz, lM );
121  x = lx;
122  y = ly;
123  z = lz;
124  M = gcnew array<double,2>(3,3);
125  for ( int i = 0; i < 3; i++ )
126  for ( int j = 0; j < 3; j++ )
127  M[i,j] = lM[3*i+j];
128 }
129 
130 //*****************************************************************************
131 void LocalCartesian::Reverse(double x, double y, double z,
132  [System::Runtime::InteropServices::Out] double% lat,
133  [System::Runtime::InteropServices::Out] double% lon,
134  [System::Runtime::InteropServices::Out] double% h)
135 {
136  double llat, llon, lh;
137  m_pLocalCartesian->Reverse( x, y, z, llat, llon, lh );
138  lat = llat;
139  lon = llon;
140  h = lh;
141 }
142 
143 //*****************************************************************************
144 void LocalCartesian::Reverse(double x, double y, double z,
145  [System::Runtime::InteropServices::Out] double% lat,
146  [System::Runtime::InteropServices::Out] double% lon,
147  [System::Runtime::InteropServices::Out] double% h,
148  [System::Runtime::InteropServices::Out] array<double,2>^% M)
149 {
150  double llat, llon, lh;
151  std::vector<double> lM(9);
152  m_pLocalCartesian->Reverse( x, y, z, llat, llon, lh, lM );
153  lat = llat;
154  lon = llon;
155  h = lh;
156  M = gcnew array<double,2>(3,3);
157  for ( int i = 0; i < 3; i++ )
158  for ( int j = 0; j < 3; j++ )
159  M[i,j] = lM[3*i+j];
160 }
161 
162 //*****************************************************************************
164 { return m_pLocalCartesian->LatitudeOrigin(); }
165 
166 //*****************************************************************************
168 { return m_pLocalCartesian->LongitudeOrigin(); }
169 
170 //*****************************************************************************
172 { return m_pLocalCartesian->HeightOrigin(); }
173 
174 //*****************************************************************************
176 { return m_pLocalCartesian->MajorRadius(); }
177 
178 //*****************************************************************************
180 { return m_pLocalCartesian->Flattening(); }
NETGeographicLib::Geocentric
.NET wrapper for GeographicLib::Geocentric.
Definition: Geocentric.h:68
example::h0
const double h0
Definition: testGPSFactor.cpp:41
NETGeographicLib::LocalCartesian::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/LocalCartesian.cpp:131
GeographicLib::LocalCartesian::Forward
void Forward(real lat, real lon, real h, real &x, real &y, real &z) const
Definition: LocalCartesian.hpp:104
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
NETGeographicLib::LocalCartesian
.NET wrapper for GeographicLib::LocalCartesian.
Definition: LocalCartesian.h:48
NETGeographicLib::LocalCartesian::LocalCartesian
LocalCartesian()
Definition: dotnet/NETGeographicLib/LocalCartesian.cpp:79
LocalCartesian.h
Header for NETGeographicLib::LocalCartesian class.
h
const double h
Definition: testSimpleHelicopter.cpp:19
NETGeographicLib::LocalCartesian::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/LocalCartesian.cpp:99
NETGeographicLib::GeographicErr
Exception class for NETGeographicLib.
Definition: NETGeographicLib.h:132
GeographicLib::LocalCartesian::Reset
void Reset(real lat0, real lon0, real h0=0)
Definition: src/LocalCartesian.cpp:16
BADALLOC
const char BADALLOC[]
Definition: dotnet/NETGeographicLib/LocalCartesian.cpp:19
GeographicLib::Geocentric
Geocentric coordinates
Definition: Geocentric.hpp:67
example::lat0
const double lat0
Definition: testGPSFactor.cpp:41
j
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
example::lon0
const double lon0
Definition: testGPSFactor.cpp:41
GeographicLib::LocalCartesian::Reverse
void Reverse(real x, real y, real z, real &lat, real &lon, real &h) const
Definition: LocalCartesian.hpp:159
stdafx.h
pybind_wrapper_test_script.z
z
Definition: pybind_wrapper_test_script.py:61
NETGeographicLib.h
Header for NETGeographicLib::NETGeographicLib objects.
y
Scalar * y
Definition: level1_cplx_impl.h:124
NETGeographicLib::Geocentric::GetUnmanaged
System::IntPtr GetUnmanaged()
Definition: dotnet/NETGeographicLib/Geocentric.cpp:139
array
Definition: numpy.h:821
NETGeographicLib::LocalCartesian::Reset
void Reset(double lat0, double lon0, double h0)
Definition: dotnet/NETGeographicLib/LocalCartesian.cpp:93
LocalCartesian.hpp
Header for GeographicLib::LocalCartesian class.
GeographicLib::LocalCartesian
Local cartesian coordinates.
Definition: LocalCartesian.hpp:38
lon
static const double lon
Definition: testGeographicLib.cpp:34
NULL
#define NULL
Definition: ccolamd.c:609
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.
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
lat
static const double lat
Definition: testGeographicLib.cpp:34
NETGeographicLib::LocalCartesian::m_pLocalCartesian
GeographicLib::LocalCartesian * m_pLocalCartesian
Definition: LocalCartesian.h:52
M
Matrix< RealScalar, Dynamic, Dynamic > M
Definition: bench_gemm.cpp:51


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:43