dotnet/NETGeographicLib/MagneticModel.cpp
Go to the documentation of this file.
1 
11 #include "stdafx.h"
13 #include "MagneticModel.h"
15 #include "MagneticCircle.h"
16 #include "Geocentric.h"
17 #include "NETGeographicLib.h"
18 
19 using namespace NETGeographicLib;
20 
21 const char BADALLOC[] = "Failed to allocate memory for a GeographicLib::MagneticModel";
22 
23 //*****************************************************************************
25 {
26  if ( m_pMagneticModel != NULL )
27  {
28  delete m_pMagneticModel;
29  m_pMagneticModel = NULL;
30  }
31 }
32 
33 //*****************************************************************************
35  System::String^ path,
36  Geocentric^ earth)
37 {
38  if ( name == nullptr ) throw gcnew GeographicErr("name cannot be a null pointer.");
39  if ( path == nullptr ) throw gcnew GeographicErr("path cannot be a null pointer.");
40  if ( earth == nullptr ) throw gcnew GeographicErr("earth cannot be a null pointer.");
41 
42  try
43  {
44  const GeographicLib::Geocentric* pGeocentric =
45  reinterpret_cast<const GeographicLib::Geocentric*>(
46  earth->GetUnmanaged()->ToPointer() );
47 
51  *pGeocentric );
52  }
53  catch ( std::bad_alloc )
54  {
55  throw gcnew GeographicErr( BADALLOC );
56  }
57  catch (const std::exception& err )
58  {
59  throw gcnew GeographicErr( err.what() );
60  }
61 }
62 
63 //*****************************************************************************
65  System::String^ path)
66 {
67  if ( name == nullptr ) throw gcnew GeographicErr("name cannot be a null pointer.");
68  if ( path == nullptr ) throw gcnew GeographicErr("path cannot be a null pointer.");
69 
70  try
71  {
76  }
77  catch ( std::bad_alloc )
78  {
79  throw gcnew GeographicErr( BADALLOC );
80  }
81  catch (const std::exception& err )
82  {
83  throw gcnew GeographicErr( err.what() );
84  }
85 }
86 
87 //*****************************************************************************
88 void MagneticModel::Field(double t, double lat, double lon, double h,
89  [System::Runtime::InteropServices::Out] double% Bx,
90  [System::Runtime::InteropServices::Out] double% By,
91  [System::Runtime::InteropServices::Out] double% Bz)
92 {
93  double lx, ly, lz;
94  m_pMagneticModel->operator()( t, lat, lon, h, lx, ly, lz );
95  Bx = lx;
96  By = ly;
97  Bz = lz;
98 }
99 
100 //*****************************************************************************
101 void MagneticModel::Field(double t, double lat, double lon, double h,
102  [System::Runtime::InteropServices::Out] double% Bx,
103  [System::Runtime::InteropServices::Out] double% By,
104  [System::Runtime::InteropServices::Out] double% Bz,
105  [System::Runtime::InteropServices::Out] double% Bxt,
106  [System::Runtime::InteropServices::Out] double% Byt,
107  [System::Runtime::InteropServices::Out] double% Bzt)
108 {
109  double lx, ly, lz, lxt, lyt, lzt;
110  m_pMagneticModel->operator()( t, lat, lon, h, lx, ly, lz, lxt, lyt, lzt );
111  Bx = lx;
112  By = ly;
113  Bz = lz;
114  Bxt = lxt;
115  Byt = lyt;
116  Bzt = lzt;
117 }
118 
119 //*****************************************************************************
120 MagneticCircle^ MagneticModel::Circle(double t, double lat, double h)
121 {
122  try
123  {
124  return gcnew MagneticCircle( m_pMagneticModel->Circle( t, lat, h ) );
125  }
126  catch ( std::bad_alloc )
127  {
128  throw gcnew GeographicErr("Failed to allocate memory for a MagneticCircle in MagneticModel::Circle");
129  }
130 }
131 
132 //*****************************************************************************
133 void MagneticModel::FieldComponents(double Bx, double By, double Bz,
134  [System::Runtime::InteropServices::Out] double% H,
135  [System::Runtime::InteropServices::Out] double% F,
136  [System::Runtime::InteropServices::Out] double% D,
137  [System::Runtime::InteropServices::Out] double% I)
138 {
139  double lh, lf, ld, li;
140  GeographicLib::MagneticModel::FieldComponents(Bx, By, Bz, lh, lf, ld, li);
141  H = lh;
142  F = lf;
143  D = ld;
144  I = li;
145 }
146 
147 //*****************************************************************************
148 void MagneticModel::FieldComponents(double Bx, double By, double Bz,
149  double Bxt, double Byt, double Bzt,
150  [System::Runtime::InteropServices::Out] double% H,
151  [System::Runtime::InteropServices::Out] double% F,
152  [System::Runtime::InteropServices::Out] double% D,
153  [System::Runtime::InteropServices::Out] double% I,
154  [System::Runtime::InteropServices::Out] double% Ht,
155  [System::Runtime::InteropServices::Out] double% Ft,
156  [System::Runtime::InteropServices::Out] double% Dt,
157  [System::Runtime::InteropServices::Out] double% It)
158 {
159  double lh, lf, ld, li, lht, lft, ldt, lit;
160  GeographicLib::MagneticModel::FieldComponents(Bx, By, Bz, Bxt, Byt, Bzt,
161  lh, lf, ld, li, lht, lft, ldt, lit);
162  H = lh;
163  F = lf;
164  D = ld;
165  I = li;
166  Ht = lht;
167  Ft = lft;
168  Dt = ldt;
169  It = lit;
170 }
171 
172 //*****************************************************************************
173 System::String^ MagneticModel::Description::get()
174 {
175  return StringConvert::UnmanagedToManaged( m_pMagneticModel->Description() );
176 }
177 
178 //*****************************************************************************
179 System::String^ MagneticModel::DateTime::get()
180 {
181  return StringConvert::UnmanagedToManaged( m_pMagneticModel->DateTime() );
182 }
183 
184 //*****************************************************************************
185 System::String^ MagneticModel::MagneticFile::get()
186 {
187  return StringConvert::UnmanagedToManaged( m_pMagneticModel->MagneticFile() );
188 }
189 
190 //*****************************************************************************
192 {
193  return StringConvert::UnmanagedToManaged( m_pMagneticModel->MagneticModelName() );
194 }
195 
196 //*****************************************************************************
198 {
199  return StringConvert::UnmanagedToManaged( m_pMagneticModel->MagneticModelDirectory() );
200 }
201 
202 //*****************************************************************************
204 {
206 }
207 
208 //*****************************************************************************
210 {
212 }
213 
214 //*****************************************************************************
216 { return m_pMagneticModel->MinHeight(); }
217 
218 //*****************************************************************************
220 { return m_pMagneticModel->MaxHeight(); }
221 
222 //*****************************************************************************
223 double MagneticModel::MinTime::get() { return m_pMagneticModel->MinTime(); }
224 
225 //*****************************************************************************
226 double MagneticModel::MaxTime::get() { return m_pMagneticModel->MaxTime(); }
227 
228 //*****************************************************************************
230 { return m_pMagneticModel->MajorRadius(); }
231 
232 //*****************************************************************************
234 { return m_pMagneticModel->Flattening(); }
H
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 y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set set xzeroaxis lt lw set x2zeroaxis lt lw set yzeroaxis lt lw set y2zeroaxis lt lw set tics in set ticslevel set tics set mxtics default set mytics default set mx2tics default set my2tics default set xtics border mirror norotate autofreq set ytics border mirror norotate autofreq set ztics border nomirror norotate autofreq set nox2tics set noy2tics set timestamp bottom norotate set rrange[*:*] noreverse nowriteback set trange[*:*] noreverse nowriteback set urange[*:*] noreverse nowriteback set vrange[*:*] noreverse nowriteback set xlabel matrix size set x2label set timefmt d m y n H
Definition: gnuplot_common_settings.hh:74
name
Annotation for function names.
Definition: attr.h:51
NETGeographicLib::Geocentric
.NET wrapper for GeographicLib::Geocentric.
Definition: Geocentric.h:68
MagneticModel.hpp
Header for GeographicLib::MagneticModel class.
D
MatrixXcd D
Definition: EigenSolver_EigenSolver_MatrixType.cpp:14
NETGeographicLib::MagneticModel::FieldComponents
static void FieldComponents(double Bx, double By, double Bz, [System::Runtime::InteropServices::Out] double% H, [System::Runtime::InteropServices::Out] double% F, [System::Runtime::InteropServices::Out] double% D, [System::Runtime::InteropServices::Out] double% I)
Definition: dotnet/NETGeographicLib/MagneticModel.cpp:133
MagneticCircle.h
Header for NETGeographicLib::MagneticCircle class.
NETGeographicLib::MagneticModel::DefaultMagneticPath
static System::String DefaultMagneticPath()
Definition: dotnet/NETGeographicLib/MagneticModel.cpp:203
GeographicLib::MagneticModel
Model of the earth's magnetic field.
Definition: MagneticModel.hpp:69
h
const double h
Definition: testSimpleHelicopter.cpp:19
NETGeographicLib::GeographicErr
Exception class for NETGeographicLib.
Definition: NETGeographicLib.h:132
NETGeographicLib::StringConvert::UnmanagedToManaged
static System::String UnmanagedToManaged(const std::string &s)
Definition: NETGeographicLib.h:153
GeographicLib::Geocentric
Geocentric coordinates
Definition: Geocentric.hpp:67
GeographicLib::MagneticModel::DefaultMagneticName
static std::string DefaultMagneticName()
Definition: src/MagneticModel.cpp:261
I
#define I
Definition: main.h:112
NETGeographicLib::MagneticModel::m_pMagneticModel
const GeographicLib::MagneticModel * m_pMagneticModel
Definition: MagneticModel.h:67
NETGeographicLib::MagneticModel::MagneticModel
MagneticModel(System::String^ name, System::String^ path, Geocentric^ earth)
Definition: dotnet/NETGeographicLib/MagneticModel.cpp:34
stdafx.h
NETGeographicLib::MagneticModel
.NET wrapper for GeographicLib::MagneticModel.
Definition: MagneticModel.h:63
GeographicLib::MagneticModel::FieldComponents
static void FieldComponents(real Bx, real By, real Bz, real &H, real &F, real &D, real &I)
Definition: MagneticModel.hpp:202
gtsam::symbol_shorthand::F
Key F(std::uint64_t j)
Definition: inference/Symbol.h:153
NETGeographicLib.h
Header for NETGeographicLib::NETGeographicLib objects.
matlab_wrap.path
path
Definition: matlab_wrap.py:66
NETGeographicLib::Geocentric::GetUnmanaged
System::IntPtr GetUnmanaged()
Definition: dotnet/NETGeographicLib/Geocentric.cpp:139
MagneticCircle.hpp
Header for GeographicLib::MagneticCircle class.
NETGeographicLib::MagneticCircle
.NET wrapper for GeographicLib::MagneticCircle.
Definition: MagneticCircle.h:41
BADALLOC
const char BADALLOC[]
Definition: dotnet/NETGeographicLib/MagneticModel.cpp:21
GeographicLib::MagneticModel::Circle
MagneticCircle Circle(real t, real lat, real h) const
Definition: src/MagneticModel.cpp:212
lon
static const double lon
Definition: testGeographicLib.cpp:34
NULL
#define NULL
Definition: ccolamd.c:609
align_3::t
Point2 t(10, 10)
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
NETGeographicLib::MagneticModel::Field
void Field(double t, double lat, double lon, double h, [System::Runtime::InteropServices::Out] double% Bx, [System::Runtime::InteropServices::Out] double% By, [System::Runtime::InteropServices::Out] double% Bz)
Definition: dotnet/NETGeographicLib/MagneticModel.cpp:88
Geocentric.h
Header for NETGeographicLib::Geocentric class.
MagneticModel.h
Header for NETGeographicLib::MagneticModel class.
NETGeographicLib::MagneticModel::DefaultMagneticName
static System::String DefaultMagneticName()
Definition: dotnet/NETGeographicLib/MagneticModel.cpp:209
NETGeographicLib::StringConvert::ManagedToUnmanaged
static std::string ManagedToUnmanaged(System::String^ s)
Definition: NETGeographicLib.cpp:20
GeographicLib::MagneticModel::DefaultMagneticPath
static std::string DefaultMagneticPath()
Definition: src/MagneticModel.cpp:248
NETGeographicLib::MagneticModel::Circle
MagneticCircle Circle(double t, double lat, double h)
Definition: dotnet/NETGeographicLib/MagneticModel.cpp:120
lat
static const double lat
Definition: testGeographicLib.cpp:34


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